Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4384262imu; Sat, 19 Jan 2019 08:16:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN5LTM/MP3GynnrNcESk63NU1F0jogELUWx5Yoff5sFEpcgcjzNG9f0PvErw8ilUt93CyiYt X-Received: by 2002:a17:902:2a66:: with SMTP id i93mr23030338plb.113.1547914593935; Sat, 19 Jan 2019 08:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547914593; cv=none; d=google.com; s=arc-20160816; b=mGBtgMSQ3J62vjXq1nrRPCKsv03cCwSuOwiSlaIgfel1AvmPBZdMtQ2Ofa1CQR8z8+ IvbHQ2tMeZ4+BulsX4y+ux0hxP+6avoJTZ5iwx4JbYlFQJ1J1Ra5wdhPY7T9BUF7gh7x GuZgkzj3kM66sxXADi/uVitnc9g7xVYAUpW9RaUwqa6rOglTS/3nz1GmjK6WM2jO/xBb ff8u0qcp0OAOnEVTx6R70DgYFjqsxsec6Abr3SNW3y9KAqaF8sgep3rM/35n2mCFDrp2 iZiAdLnxQVfK5IbS9neht1KvacdrBaANlbphDlCTmeOyYttC7VkTgQE4GTkgqKYMbkkV +LcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=e6yMb6PRHmeFDBnmK1UMXlNWyico8bLjeKf61ZSNHSU=; b=pRcsoVFyEYcdVu+QSN3BsLOLgZVtP4v3Rs/dY2GtHpmpfg2mnZwT35KUw1PECTC+it +Q3XJVhyAAVDIzpi+WFnG5gzPaA7HIIzTm0kxlpNegDa2gk8R/qvVC5usIFIpX53lnoQ hFnh8DNn1YLoUhfz4GTC1IYKU6Pn6YBx+aOCsfsabZNNicOV3Men6P8VjfvkBQRpa/Qv SAAgwN76Ka83pt7En7OwNNVZua46WEnbxN9TvjxhCq984iIFHHJmLpeW+J32qlUxFZT9 inSs3MyLdi2wEU+z5TZX2wm35l6YoEcXGZpmJ/TfL28g23xOF1EAETKEntQFDfeWvxRN jAGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=QaGNlyED; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u9si1483542plk.61.2019.01.19.08.16.15; Sat, 19 Jan 2019 08:16:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=QaGNlyED; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728580AbfASQO7 (ORCPT + 99 others); Sat, 19 Jan 2019 11:14:59 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:33534 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728438AbfASQO7 (ORCPT ); Sat, 19 Jan 2019 11:14:59 -0500 Received: by mail-qt1-f194.google.com with SMTP id l11so18709712qtp.0 for ; Sat, 19 Jan 2019 08:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e6yMb6PRHmeFDBnmK1UMXlNWyico8bLjeKf61ZSNHSU=; b=QaGNlyEDLCO3RK5ybtRJ/2ez07NsZyJIa1NB7+Cz/fZZzHXhfQeaVoMUmfb3o3fchu NTcqgK0tn03mvjCMauWGhE+rk1ENFenVDCFm0j6Z92NXQDXy9AJACWxXnuPYPXgABEKL tt1FR0PG7Rj9ilaeVtFG/IAlvy216UhS4LPYk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e6yMb6PRHmeFDBnmK1UMXlNWyico8bLjeKf61ZSNHSU=; b=YIcsna4Vs46fCIXMk/yPGhARGYpir5eo4abY/qHLyN2OYt+VkgloqadG8m+zXIJaui SggUk8SLqEx2BWvrm3JkYJXOlGi9HF1GsRIMxOLJ56nGw6Y4VCS3gmBhw60VFkgKNUBf 1Us2au9x3KnLdbYKQxIkz89qNlcy/QzUCIYv50kdpMCOfqQm01GgK6Z1oj8egxk7g4NY 8qFlVUgI3SRla+bhti/1aoCwox50iaapyK6Lo1C3Bjq2Bek18J2Nn7ECLzjhYrdiUfgD 1maRCinY7/dx50hBJMZfu3iZtWy1PyvtOLq0vpoTTD6NPdpac0kKe+HXee7YuMJG+Mf6 ApHQ== X-Gm-Message-State: AJcUukdibeqoHhrqSDSV8+PrGnUrlb+wHaC61ztd2sXmJQY0W5cx0v2r wQmsfH+sBCoXIiOMTtaAasjRwiMbEcU= X-Received: by 2002:ac8:7353:: with SMTP id q19mr20125197qtp.265.1547914497548; Sat, 19 Jan 2019 08:14:57 -0800 (PST) Received: from joelaf.cam.corp.google.com ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id u50sm70960256qta.23.2019.01.19.08.14.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jan 2019 08:14:56 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , Steven Rostedt Subject: [RFC] rcu: Avoid unnecessary softirq when system is idle Date: Sat, 19 Jan 2019 11:14:18 -0500 Message-Id: <20190119161418.231042-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When there are no callbacks pending on an idle system, I noticed that RCU softirq is continuously firing. During this the cpu_no_qs is set to false, and core_needs_qs is set to true indefinitely. This causes rcu_process_callbacks to be repeatedly called, even though the node corresponding to the CPU has that CPU's mask bit cleared and the system is idle. I believe the race is when such mask clearing is done during idle CPU scan of the quiescent state forcing stage in the kthread instead of the softirq. Since the rnp mask is cleared, but the flags on the CPU's rdp are not cleared, the CPU thinks it still needs to report to core RCU. Cure this by clearing the core_needs_qs flag when the CPU detects that its node is already updated which will avoid the unwanted softirq raises to the benefit of real-time systems. Test: Ran rcutorture for various tree RCU configs. Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/tree.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 9180158756d2..96ad80c76b15 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2273,6 +2273,7 @@ rcu_report_qs_rdp(int cpu, struct rcu_data *rdp) } mask = rdp->grpmask; if ((rnp->qsmask & mask) == 0) { + rdp->core_needs_qs = false; raw_spin_unlock_irqrestore_rcu_node(rnp, flags); } else { rdp->core_needs_qs = false; -- 2.20.1.321.g9e740568ce-goog