scripts: Make checkpatch.pl warn on expedited RCU grace periods
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 2 Jul 2015 18:55:40 +0000 (11:55 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 22 Jul 2015 22:27:42 +0000 (15:27 -0700)
The synchronize_rcu_expedited() and synchronize_sched_expedited()
expedited-grace-period primitives induce OS jitter, which can degrade
real-time response.  This commit therefore adds a checkpatch.pl warning
on any patch adding them.

Note that this patch does not warn on synchronize_srcu_expedited()
because it does not induce OS jitter, courtesy of its otherwise
much-maligned read-side memory barriers.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
scripts/checkpatch.pl

index 90e1edc8dd42fbfba3c31d03214f99d4e3c361b4..976e7117edfbb4040fb93517fca4fb43c2283c5f 100755 (executable)
@@ -5011,6 +5011,7 @@ sub process {
                                     "memory barrier without comment\n" . $herecurr);
                        }
                }
+
 # check for waitqueue_active without a comment.
                if ($line =~ /\bwaitqueue_active\s*\(/) {
                        if (!ctx_has_comment($first_line, $linenr)) {
@@ -5018,6 +5019,24 @@ sub process {
                                     "waitqueue_active without comment\n" . $herecurr);
                        }
                }
+
+# Check for expedited grace periods that interrupt non-idle non-nohz
+# online CPUs.  These expedited can therefore degrade real-time response
+# if used carelessly, and should be avoided where not absolutely
+# needed.  It is always OK to use synchronize_rcu_expedited() and
+# synchronize_sched_expedited() at boot time (before real-time applications
+# start) and in error situations where real-time response is compromised in
+# any case.  Note that synchronize_srcu_expedited() does -not- interrupt
+# other CPUs, so don't warn on uses of synchronize_srcu_expedited().
+# Of course, nothing comes for free, and srcu_read_lock() and
+# srcu_read_unlock() do contain full memory barriers in payment for
+# synchronize_srcu_expedited() non-interruption properties.
+               if ($line =~ /\b(synchronize_rcu_expedited|synchronize_sched_expedited)\(/) {
+                       WARN("EXPEDITED_RCU_GRACE_PERIOD",
+                            "expedited RCU grace periods should be avoided where they can degrade real-time response\n" . $herecurr);
+
+               }
+
 # check of hardware specific defines
                if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
                        CHK("ARCH_DEFINES",