From: Peng Fan <peng.fan@oss.nxp.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Chuck Lever <cel@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] SUNRPC: use assign_bit() where applicable
Date: Tue, 22 Sep 2026 08:53:43 +0800 [thread overview]
Message-ID: <arHRl5JvLVEBoSLk@shlinux89> (raw)
In-Reply-To: <ddab3a7be440dcd860b254bcd2dc213c1a3cc538.camel@kernel.org>
On Mon, Sep 21, 2026 at 09:46:05AM -0400, Jeff Layton wrote:
>On Mon, 2026-09-21 at 08:51 +0800, Peng Fan wrote:
>> On Sun, Sep 20, 2026 at 01:22:00PM -0400, Chuck Lever wrote:
>> >
>> >
>> > On Sat, Sep 19, 2026, at 10:27 PM, Peng Fan (OSS) wrote:
>> > > From: Peng Fan <peng.fan@nxp.com>
>> > >
>> > > Convert open-coded if/else with set_bit/clear_bit the assign_bit API.
>> >
>> > The above sentence explains the same thing that the diff body shows me,
>> > so it does not add value.
>> >
>> > But I don't have any context here: why is this being done? Is there some
>> > kind of tree-wide clean-up underway so that a new feature can be added,
>> > or is this patch just a one-off change?
>>
>> It is just a one-off change. I don't group other patches to use assign_bit()
>> into a large patchset, just separate patches.
>>
>> Free to drop if it does not make sense to you.
>>
>>
>
>I think the problem is that you haven't explained the benefit of using
>assign_bit() here. It's now 2 lines instead of 4, but that doesn't seem
>like a substantive change. Does this create better assembly or
>something?
>
>Without a clear benefit, this seems like pointless churn.
commit 5259401ef8f4b ("bitops: let the compiler optimize {__,}assign_bit()")
may give some information:
"
Atomic assign_bit() is less affected due to its nature, but let's
convert it to a macro as well to keep the code consistent and not
leave a place for possible suboptimal codegen. Moreover, with certain
kernel configuration it actually gives some saves (x86):
do_ip_setsockopt 4154 4099 -55
"
I did not do such build test to compare vmlinux size.
If you need me to do a image comparation w/o this patch, I could setup a build
to see whether there are size reduction for the functions that this patch
touched and update commit log in V2. Or we just drop this patch. Both fine
to me.
Thanks
Peng
>
>> > Including a URL that points to an explainer, or making this patch part
>> > of a series would help orient reviewers.
>> >
>> >
>> > > Done with Coccinelle semantic patch:
>> > > // set_bit -> clear_bit => assign_bit
>> > >
>> > > @@
>> > > expression cond, bit, addr;
>> > > @@
>> > >
>> > > -if (cond)
>> > > - set_bit(bit, addr);
>> > > -else
>> > > - clear_bit(bit, addr);
>> > > +assign_bit(bit, addr, cond);
>> > >
>> > > @@
>> > > expression cond, bit, addr;
>> > > @@
>> > >
>> > > -if (cond)
>> > > - clear_bit(bit, addr);
>> > > -else
>> > > - set_bit(bit, addr);
>> > > +assign_bit(bit, addr, !cond);
>> > >
>> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> > > ---
>> > > net/sunrpc/svcsock.c | 18 ++++++------------
>> > > 1 file changed, 6 insertions(+), 12 deletions(-)
>> > >
>> > > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
>> > > index ef7ac080fcd3..d7fa0d1de3ef 100644
>> > > --- a/net/sunrpc/svcsock.c
>> > > +++ b/net/sunrpc/svcsock.c
>> > > @@ -352,10 +352,8 @@ static void svc_sock_setbufsize(struct svc_sock
>> > > *svsk, unsigned int nreqs)
>> > >
>> > > static void svc_sock_secure_port(struct svc_rqst *rqstp)
>> > > {
>> > > - if (svc_port_is_privileged(svc_addr(rqstp)))
>> > > - set_bit(RQ_SECURE, &rqstp->rq_flags);
>> > > - else
>> > > - clear_bit(RQ_SECURE, &rqstp->rq_flags);
>> > > + assign_bit(RQ_SECURE, &rqstp->rq_flags,
>> > > + svc_port_is_privileged(svc_addr(rqstp)));
>> > > }
>> > >
>> > > /*
>> > > @@ -941,10 +939,8 @@ static struct svc_xprt *svc_tcp_accept(struct
>> > > svc_xprt *xprt)
>> > > slen = offsetof(struct sockaddr, sa_data);
>> > > svc_xprt_set_local(&newsvsk->sk_xprt, sin, slen);
>> > >
>> > > - if (sock_is_loopback(newsock->sk))
>> > > - set_bit(XPT_LOCAL, &newsvsk->sk_xprt.xpt_flags);
>> > > - else
>> > > - clear_bit(XPT_LOCAL, &newsvsk->sk_xprt.xpt_flags);
>> > > + assign_bit(XPT_LOCAL, &newsvsk->sk_xprt.xpt_flags,
>> > > + sock_is_loopback(newsock->sk));
>> > > if (serv->sv_stats)
>> > > serv->sv_stats->nettcpconn++;
>> > >
>> > > @@ -1290,10 +1286,8 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
>> > >
>> > > rqstp->rq_xprt_ctxt = NULL;
>> > > rqstp->rq_prot = IPPROTO_TCP;
>> > > - if (test_bit(XPT_LOCAL, &svsk->sk_xprt.xpt_flags))
>> > > - set_bit(RQ_LOCAL, &rqstp->rq_flags);
>> > > - else
>> > > - clear_bit(RQ_LOCAL, &rqstp->rq_flags);
>> > > + assign_bit(RQ_LOCAL, &rqstp->rq_flags,
>> > > + test_bit(XPT_LOCAL, &svsk->sk_xprt.xpt_flags));
>> > >
>> > > /* Completing one message stops ->read_sock with whatever
>> > > * follows still queued, and no path from here re-arms XPT_DATA.
>> > > --
>> > > 2.51.0
>> >
>> > --
>> > Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)
>> >
>> >
>
>--
>Jeff Layton <jlayton@kernel.org>
>
>
next prev parent reply other threads:[~2026-09-22 0:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 2:27 Peng Fan (OSS)
2026-09-20 17:22 ` Chuck Lever
2026-09-21 0:51 ` Peng Fan
2026-09-21 13:24 ` Chuck Lever
2026-09-21 13:46 ` Jeff Layton
2026-09-22 0:53 ` Peng Fan [this message]
2026-09-22 15:50 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arHRl5JvLVEBoSLk@shlinux89 \
--to=peng.fan@oss.nxp.com \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=cel@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jlayton@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=netdev@vger.kernel.org \
--cc=okorniev@redhat.com \
--cc=pabeni@redhat.com \
--cc=peng.fan@nxp.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®