From: David Laight <david.laight.linux@gmail.com>
To: Amery Hung <ameryhung@gmail.com>
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
alexei.starovoitov@gmail.com, andrii@kernel.org,
daniel@iogearbox.net, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v1 1/1] bpf: Annotate rqspinlock lock acquiring functions with __must_check
Date: Thu, 20 Nov 2025 21:27:13 +0000 [thread overview]
Message-ID: <20251120212713.240fa185@pumpkin> (raw)
In-Reply-To: <CAMB2axPqr6bw-MgH-QqSRz+1LOuByytOwHj8KWQc-4cG8ykz7g@mail.gmail.com>
On Thu, 20 Nov 2025 12:12:12 -0800
Amery Hung <ameryhung@gmail.com> wrote:
> On Tue, Nov 18, 2025 at 2:42 AM David Laight
> <david.laight.linux@gmail.com> wrote:
> >
> > On Tue, 18 Nov 2025 05:16:50 -0500
> > Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
> >
> > > On Mon, 17 Nov 2025 at 14:15, Amery Hung <ameryhung@gmail.com> wrote:
> > > >
> > > > Locking a resilient queued spinlock can fail when deadlock or timeout
> > > > happen. Mark the lock acquring functions with __must_check to make sure
> > > > callers always handle the returned error.
> > > >
> > > > Suggested-by: Andrii Nakryiko <andrii@kernel.org>
> > > > Signed-off-by: Amery Hung <ameryhung@gmail.com>
> > > > ---
> > >
> > > Looks like it's working :)
> > > I would just explicitly ignore with (void) cast the locktorture case.
> >
> > I'm not sure that works - I usually have to try a lot harder to ignore
> > a '__must_check' result.
>
> Thanks for the heads up.
>
> Indeed, gcc still complains about it even casting the return to (void)
> while clang does not.
>
> I have to silence the warning by:
>
> #pragma GCC diagnostic push
> #pragma GCC diagnostic ignored "-Wunused-result"
> raw_res_spin_lock(&rqspinlock);
> #pragma GCC diagnostic pop
I think the simpler:
if (raw_res_spin_lock(&rqspinlock)) {};
also works.
But I'm sure I've resorted to crap like:
x += foo() ? 0 : 0;
and/or:
x += foo() == IMPOSSIBLE_VALUE;
and/or wrapping the call in a static inline function.
It is all a right PITA when you are doing read/write on a pipe
that is being used for events.
At least no one has put a 'must_check' on fprintf() (yet).
Code that looks at the return value is usually broken!
(hint: you need to call fflush() and then check ferror().)
David
>
> Thanks!
> Amery
>
> >
> > David
next prev parent reply other threads:[~2025-11-20 21:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 19:15 [PATCH bpf-next v1 1/1] bpf: Annotate rqspinlock lock acquiring functions with __must_check Amery Hung
2025-11-18 10:11 ` kernel test robot
2025-11-18 10:12 ` kernel test robot
2025-11-18 10:16 ` Kumar Kartikeya Dwivedi
2025-11-18 10:42 ` David Laight
2025-11-20 20:12 ` Amery Hung
2025-11-20 21:27 ` David Laight [this message]
2025-11-25 23:34 ` Andrii Nakryiko
2025-11-26 21:52 ` Amery Hung
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=20251120212713.240fa185@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=memxor@gmail.com \
--cc=netdev@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.