Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3175505ybt; Mon, 22 Jun 2020 17:25:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/55c7GHs3IJeefgl0VjDxGAYIkK+yIARRIZQwxjUvC0wb829PrJFv7vpKJn5JhuVKLCxi X-Received: by 2002:a50:8425:: with SMTP id 34mr19819895edp.314.1592871950551; Mon, 22 Jun 2020 17:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592871950; cv=none; d=google.com; s=arc-20160816; b=PWU4XXXmjYxpSowabHp1YZlSkkW8CX7SNad+E/E/EgZ/+/7TlGtWsvGn42j3cGo7g5 KA6o2DAXGKNpauaezXvo2GbpqVLnj5e/gf0P78E06qnhM50UR1PL/7N4S9RxtiEzA7O6 uy2rfeM8zSuufT7xHxWinjzJCv382R7zYUv6pt02fkWPvCv2y8WKGzRTIyHh/ccBuajm E19mitNT6PGEoeqIyTEZYuJ9s/QHFl4Z9OmZGRmKZY/PUHIriTNcx5UnhAvR7iHuwaCV eLwjrLkU3TeP432SZDkgSKshSbgHu2rwBHu+hHwgUMTmh+V67SRXpkKuW6CZOxo0Trv5 PPag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Mh7HBOWgWzFMQapwkC3ck0N7sqcDjG4vdmZPPZtrrpw=; b=YFwNj+YgPoIMwNoxgx94xPhSNkV/ydaAvU29IsGcGRHCLnVMaxxDMKP2xld43CrNGE WW6fhbYs52FP0TgUasKJ8SrcPUVExsRh+NB1RcWem+8WsKppLwGniSJ9+FE1V/RLrLxw q+mqTDLw2ZdwlDRyrWUQu+fAFNbng8VEj6Nj2cENPh7p2bcvbJjkvXAK6hG+BIyF70Ly 10zc5T6Yhz/WGMMToWomM3u1ujzidcSK1v39C/udizXVEaQgpDJ3Q99AVAWG7xsULjcF HZdtQdEOs9H0EZoxQA91RDwvvyKOvqG5dFQladXicuFpPKg2tdQGEdtTfOC45oQOPNRh rMog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pbhDz2xq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si5148471edx.522.2020.06.22.17.25.28; Mon, 22 Jun 2020 17:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pbhDz2xq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731755AbgFWAWx (ORCPT + 99 others); Mon, 22 Jun 2020 20:22:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731533AbgFWAVw (ORCPT ); Mon, 22 Jun 2020 20:21:52 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6A0C20888; Tue, 23 Jun 2020 00:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592871711; bh=ScFiFOeg4wutJUeONEdB3g/vj6kgdvyBYrim7fkHdkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbhDz2xqOOd90aeR/wpemEW9o39zIOk7ijmiFK4X0GlmwVKMv/R0atkEG8DBpreww vB8Kxq0FgJ2lx3jrZmooTVFytZOWq+VNTPVtQVEVCrZtu13+Ckq689+wBfkZvGiiKK 5nh7nfH0ZUYUflF1S7BcJZ+zRN29BGMRmxLr4tzk= From: paulmck@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, Frederic Weisbecker , stable@kernel.org, "Paul E . McKenney" Subject: [PATCH tip/core/rcu 13/26] tick/nohz: Narrow down noise while setting current task's tick dependency Date: Mon, 22 Jun 2020 17:21:34 -0700 Message-Id: <20200623002147.25750-13-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200623002128.GA25456@paulmck-ThinkPad-P72> References: <20200623002128.GA25456@paulmck-ThinkPad-P72> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frederic Weisbecker Setting a tick dependency on any task, including the case where a task sets that dependency on itself, triggers an IPI to all CPUs. That is of course suboptimal but it had previously not been an issue because it was only used by POSIX CPU timers on nohz_full, which apparently never occurs in latency-sensitive workloads in production. (Or users of such systems are suffering in silence on the one hand or venting their ire on the wrong people on the other.) But RCU now sets a task tick dependency on the current task in order to fix stall issues that can occur during RCU callback processing. Thus, RCU callback processing triggers frequent system-wide IPIs from nohz_full CPUs. This is quite counter-productive, after all, avoiding IPIs is what nohz_full is supposed to be all about. This commit therefore optimizes tasks' self-setting of a task tick dependency by using tick_nohz_full_kick() to avoid the system-wide IPI. Instead, only the execution of the one task is disturbed, which is acceptable given that this disturbance is well down into the noise compared to the degree to which the RCU callback processing itself disturbs execution. Fixes: 6a949b7af82d (rcu: Force on tick when invoking lots of callbacks) Reported-by: Matt Fleming Signed-off-by: Frederic Weisbecker Cc: stable@kernel.org Cc: Paul E. McKenney Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Ingo Molnar Signed-off-by: Paul E. McKenney --- kernel/time/tick-sched.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 3e2dc9b..f0199a4 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -351,16 +351,24 @@ void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) EXPORT_SYMBOL_GPL(tick_nohz_dep_clear_cpu); /* - * Set a per-task tick dependency. Posix CPU timers need this in order to elapse - * per task timers. + * Set a per-task tick dependency. RCU need this. Also posix CPU timers + * in order to elapse per task timers. */ void tick_nohz_dep_set_task(struct task_struct *tsk, enum tick_dep_bits bit) { - /* - * We could optimize this with just kicking the target running the task - * if that noise matters for nohz full users. - */ - tick_nohz_dep_set_all(&tsk->tick_dep_mask, bit); + if (!atomic_fetch_or(BIT(bit), &tsk->tick_dep_mask)) { + if (tsk == current) { + preempt_disable(); + tick_nohz_full_kick(); + preempt_enable(); + } else { + /* + * Some future tick_nohz_full_kick_task() + * should optimize this. + */ + tick_nohz_full_kick_all(); + } + } } EXPORT_SYMBOL_GPL(tick_nohz_dep_set_task); -- 2.9.5