Commit c67ee3d6 authored by Joel Fernandes (Google)'s avatar Joel Fernandes (Google) Committed by Chromeos LUCI
Browse files

BACKPORT: FROMGIT: rcu: Make call_rcu() lazy to save power

Implement timer-based RCU callback batching (also known as lazy
callbacks). With this we save about 5-10% of power consumed due
to RCU requests that happen when system is lightly loaded or idle.

By default, all async callbacks (queued via call_rcu) are marked
lazy. An alternate API call_rcu_flush() is provided for the few users,
for example synchronize_rcu(), that need the old behavior.

The batch is flushed whenever a certain amount of time has passed, or
the batch on a particular CPU grows too big. Also memory pressure will
flush it in a future patch.

To handle several corner cases automagically (such as rcu_barrier() and
hotplug), we re-use bypass lists which were originally introduced to
address lock contention, to handle lazy CBs as well. The bypass list
length has the lazy CB length included in it. A separate lazy CB length
counter is also introduced to keep track of the number of lazy CBs.

(cherry picked from commit 65d030d037b06fc01b1670a9a0662b5d85ceb850
 https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git

 rcu/next)

(
Backport:
	Several adjustments as WAKE_BYPASS is missing and tree_plugin.h is
	moved in upstream to tree_nocb.h.
	Also, rcu_nocb_need_deferred_wakeup needs a level field so as
	to not wake rcuog from the rcu_pending and idle path.
)

BUG=b:222463781
TEST=powerIdle lab tests.

TODO: Split out the "too big or too long" bypass flush wake up out of
this patch as it is different upstream:
In upstream it is "rcu: Fix late wakeup when flush of bypass cblist
happens".

Suggested-by: default avatarPaul McKenney <paulmck@kernel.org>
Acked-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: default avatarJoel Fernandes <joelaf@google.com>
Signed-off-by: default avatarParshuram Sangle <parshuram.sangle@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3965071


Reviewed-by: default avatarRoss Zwisler <zwisler@google.com>
Change-Id: Ibd34b5a02a87c88d36c546fad39f185acbc6093a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4069540
parent 3f5d14a1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment