All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: clang-built-linux <clang-built-linux@googlegroups.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Marco Elver <elver@google.com>
Subject: Thread-safety annotations for irq/rcu/atomic contexts
Date: Mon, 26 Jun 2023 19:21:34 +0200	[thread overview]
Message-ID: <CACT4Y+bif9Wek-g10F5y0aLbH=JbCcqryi2nOUAFxGFo0O2B9A@mail.gmail.com> (raw)

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?

             reply	other threads:[~2023-06-26 17:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 17:21 Dmitry Vyukov [this message]
2023-06-26 17:24 ` Thread-safety annotations for irq/rcu/atomic contexts Nick Desaulniers

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='CACT4Y+bif9Wek-g10F5y0aLbH=JbCcqryi2nOUAFxGFo0O2B9A@mail.gmail.com' \
    --to=dvyukov@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=elver@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /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.