Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Aug 2021 17:58:41 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Andrew Gallatin <gallatin@FreeBSD.org>, src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: 09066b98663d - main - ktls: Use the new PNOLOCK flag
Message-ID:  <c9584533ca172253d3243276b8216127facd5a7a.camel@freebsd.org>
In-Reply-To: <202108052251.175MpwTC090873@gitrepo.freebsd.org>
References:  <202108052251.175MpwTC090873@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 2021-08-05 at 22:51 +0000, Andrew Gallatin wrote:
> The branch main has been updated by gallatin:
> 
> URL:
> https://cgit.FreeBSD.org/src/commit/?id=09066b98663d92f4d129bab25105805adf0abaf7
> 
> commit 09066b98663d92f4d129bab25105805adf0abaf7
> Author:     Andrew Gallatin <gallatin@FreeBSD.org>
> AuthorDate: 2021-08-05 21:19:12 +0000
> Commit:     Andrew Gallatin <gallatin@FreeBSD.org>
> CommitDate: 2021-08-05 21:19:12 +0000
> 
>     ktls: Use the new PNOLOCK flag
>     
>     Use the new PNOLOCK flag to tsleep() to indicate that
>     we are managing potential races, and don't need to
>     sleep with a lock, or have a backstop timeout.
>     
>     Reviewed by: jhb
>     Sponsored by: Netflix
> ---
>  sys/kern/uipc_ktls.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c
> index 47815c266667..1cc1f2e8b8c4 100644
> --- a/sys/kern/uipc_ktls.c
> +++ b/sys/kern/uipc_ktls.c
> @@ -2240,7 +2240,7 @@ ktls_alloc_thread(void *ctx)
>         nbufs = 0;
>         for (;;) {
>                 atomic_store_int(&sc->running, 0);
> -               tsleep_sbt(sc, PZERO, "waiting for work", SBT_MAX,
> SBT_1S, 0);
> +               tsleep(sc, PZERO | PNOLOCK, "-",  0);
>                 atomic_store_int(&sc->running, 1);
>                 sc->wakeups++;
>                 if (nbufs != ktls_max_alloc) {

I especially like this solution, it documents explicitly what you're
doing and why.  (Earlier I was considering mumbling something about
"there should be a comment to say a sleep-forever is known safe here".)

-- Ian





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c9584533ca172253d3243276b8216127facd5a7a.camel>