Re: [PATCH] checkpatch: Warn about data_race() without comment

From: Marco Elver
Date: Thu Apr 16 2020 - 05:27:59 EST


On Wed, 1 Apr 2020 at 17:19, Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> On Wed, 2020-04-01 at 12:17 +0200, Marco Elver wrote:
> > Warn about applications of data_race() without a comment, to encourage
> > documenting the reasoning behind why it was deemed safe.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -5833,6 +5833,14 @@ sub process {
> > }
> > }
> >
> > +# check for data_race without a comment.
> > + if ($line =~ /\bdata_race\s*\(/) {
> > + if (!ctx_has_comment($first_line, $linenr)) {
> > + WARN("DATA_RACE",
> > + "data_race without comment\n" . $herecurr);
> > + }
> > + }
> > +
> > # check for smp_read_barrier_depends and read_barrier_depends
> > if (!$file && $line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
> > WARN("READ_BARRIER_DEPENDS",

Do we still want to do this? Which tree can pick this up? Or was there
anything left that we missed?

> Sensible enough but it looks like ctx_has_comment should
> be updated to allow c99 comments too, but that should be
> a separate change from this patch.

AFAIK the C99 comment patch is in -mm now.

> Otherwise, this style emits a message:
>
> WARNING: data_race without comment
> #135: FILE: kernel/rcu/tasks.h:135:
> + int i = data_race(rtp->gp_state); // Let KCSAN detect update races
>

Thanks,
-- Marco