On Fri, Jan 6, 2023 at 3:59 PM Kevin Traynor <ktray...@redhat.com> wrote:
>
> xnanosleep forces the thread into quiesce state in anticipation that
> it will be sleeping for a considerable time and that the thread may
> need to quiesce before the sleep is finished.
>
> In some cases, a very short sleep may be requested and in that case
> the overhead of going to into quiesce state may be unnecessary.
>
> To allow for those cases add a xnanosleep_no_quiesce() variant.
>
> Suggested-by: Ilya Maximets <i.maxim...@ovn.org>
> Signed-off-by: Kevin Traynor <ktray...@redhat.com>
> ---
>  lib/util.c | 19 +++++++++++++++----
>  lib/util.h |  1 +
>  2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/lib/util.c b/lib/util.c
> index 1195c7982..0daf06e8f 100644
> --- a/lib/util.c
> +++ b/lib/util.c
> @@ -2372,9 +2372,7 @@ xsleep(unsigned int seconds)
>  }
>
> -/* High resolution sleep. */
> -void
> -xnanosleep(uint64_t nanoseconds)
> +static void
> +__xnanosleep(uint64_t nanoseconds)
>  {

According to coding style:
"Do not use names that begin with _. If you need a name for “internal
use only”, use __ as a suffix instead of a prefix."

So it should be xnanosleep__.


> -    ovsrcu_quiesce_start();
>  #ifndef _WIN32
>      int retval;
> @@ -2404,7 +2402,20 @@ xnanosleep(uint64_t nanoseconds)
>      }
>  #endif
> +}
> +
> +/* High resolution sleep with thread quiesce. */
> +void
> +xnanosleep(uint64_t nanoseconds) {

And I think { should be on next line.



> +    ovsrcu_quiesce_start();
> +    __xnanosleep(nanoseconds);
>      ovsrcu_quiesce_end();
>  }
>
> +/* High resolution sleep without thread quiesce. */
> +void
> +xnanosleep_no_quiesce(uint64_t nanoseconds) {

Idem.


> +    __xnanosleep(nanoseconds);
> +}
> +
>  /* Determine whether standard output is a tty or not. This is useful to 
> decide
>   * whether to use color output or not when --color option for utilities is 
> set
> diff --git a/lib/util.h b/lib/util.h
> index 9ff84b3dc..f35f33021 100644
> --- a/lib/util.h
> +++ b/lib/util.h
> @@ -594,4 +594,5 @@ ovs_u128_is_superset(ovs_u128 super, ovs_u128 sub)
>  void xsleep(unsigned int seconds);
>  void xnanosleep(uint64_t nanoseconds);
> +void xnanosleep_no_quiesce(uint64_t nanoseconds);
>
>  bool is_stdout_a_tty(void);

With this fixed,
Reviewed-by: David Marchand <david.march...@redhat.com>


-- 
David Marchand

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to