mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Thread-safety annotations for irq/rcu/atomic contexts
@ 2023-06-26 17:21 Dmitry Vyukov
  2023-06-26 17:24 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Vyukov @ 2023-06-26 17:21 UTC (permalink / raw)
  To: clang-built-linux, Lukas Bulwahn; +Cc: LKML, Marco Elver

Hi,

Previous Lukas' attempt to apply clang thread-safety annotations to the kernel:
https://clangbuiltlinux.github.io/CBL-meetup-2020-slides/lukas/tsa.pdf

I am thinking if the annotations can be used to check for functions
that must/must not be called from irq/atomic/rcu_read/etc contexts.
Namely, we create global fake locks that denote these contexts, then
annotate spin_lock_irqsave/irqrestore/etc as taking releasing these
locks, and finally annotate functions are requiring/excluding these
contexts:

void foo() require(irq_context);
void bar() exclude(irq_context);
void baz() require(rcu_read_context);

This may help to catch "suspicious RCU usage", "scheduling while
atomic" and similar bug types statically. I suspect it may also be
simpler (?) to do rather than annotating all normal locks.

Does it make any sense?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Thread-safety annotations for irq/rcu/atomic contexts
  2023-06-26 17:21 Thread-safety annotations for irq/rcu/atomic contexts Dmitry Vyukov
@ 2023-06-26 17:24 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2023-06-26 17:24 UTC (permalink / raw)
  To: Dmitry Vyukov; +Cc: Lukas Bulwahn, LKML, Marco Elver, clang-built-linux

(minus old ML, plus new ML)

On Mon, Jun 26, 2023 at 10:21 AM 'Dmitry Vyukov' via Clang Built Linux
<clang-built-linux@googlegroups.com> wrote:
>
> Hi,
>
> Previous Lukas' attempt to apply clang thread-safety annotations to the kernel:
> https://clangbuiltlinux.github.io/CBL-meetup-2020-slides/lukas/tsa.pdf
>
> I am thinking if the annotations can be used to check for functions
> that must/must not be called from irq/atomic/rcu_read/etc contexts.
> Namely, we create global fake locks that denote these contexts, then
> annotate spin_lock_irqsave/irqrestore/etc as taking releasing these
> locks, and finally annotate functions are requiring/excluding these
> contexts:
>
> void foo() require(irq_context);
> void bar() exclude(irq_context);
> void baz() require(rcu_read_context);
>
> This may help to catch "suspicious RCU usage", "scheduling while
> atomic" and similar bug types statically. I suspect it may also be
> simpler (?) to do rather than annotating all normal locks.
>
> Does it make any sense?
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/CACT4Y%2Bbif9Wek-g10F5y0aLbH%3DJbCcqryi2nOUAFxGFo0O2B9A%40mail.gmail.com.



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-26 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 17:21 Thread-safety annotations for irq/rcu/atomic contexts Dmitry Vyukov
2023-06-26 17:24 ` Nick Desaulniers

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®