Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1698972ybt; Thu, 18 Jun 2020 15:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxOvQKC7o9Gitk2JRQ9gIAD6HJP3XrqBVmYRvmFmZxecsJ7zomzIBfC/vBXlR71vSeJmst X-Received: by 2002:a50:934e:: with SMTP id n14mr379326eda.88.1592518419176; Thu, 18 Jun 2020 15:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592518419; cv=none; d=google.com; s=arc-20160816; b=s5PeCMAldbe7UFR0ydPp40mkFN07MI5uAl8ua3UopKa1TlNu8XGtf2ucF+xK1bPLL3 05Kk+nQpUCjzrJuz2nbpS/ZpczsYrq2xvd7BZmyQeuS/Pa636qrdnQEU5rCWjA7P2sRR 6STR4FotlscMBTrxD/EdC9oakxKE5E6DDmpMleC4GiiitDhn1X1DgVQWMTGWL+ULFPuj AEzEYoD60gvTMdJCPiHvbOU2gYeOjyRF9OXPlRegg8qyeVtmA+vjw3NgOEGHzY5YaS1a +f9hJsBc9InsR+ohBoIMsQY5L7hwv9nS75eWAq6HbS+dEkYEHSONY20U/F0H2zL9Xit5 VD7g== 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=gMOtZLcID+RRbq+QbVzKX+Sw9GzEGaMQc8XZ1xKu5m8=; b=BkqM2LEg2EmWU59EU6/vGyPVZe9xgw3mGD3VAMOHP3IV7nmnCSN/5dKW9vqaVql0m/ 2XXzNcGKi+T2x62qCBBI5tji+wBhEGVxHBafyMnItipgpcKNZ2t7dcxk4LpKQCtIufMw I2dK6/itE+Q54OCh4UDZNCwTpnmGKCi03zSDJoeVrgM38iKnJ8mTVMsFd1o4BYbaUQPe kRXiKQDoFhixM4PHStubP1YULaAMI4MphgCMQzrkodsOiuaCdkg32Jt9Y64l/dDl+45B F/oUXNlSZ3Tazo9k1Ngq6LQGfQzaPtPyUAlFlBdMqD76z/sK3+Owb8gFayBHfYuJRQOh 8jcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=RDc8PBr8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn16si3102429ejc.427.2020.06.18.15.12.55; Thu, 18 Jun 2020 15:13:39 -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=@joelfernandes.org header.s=google header.b=RDc8PBr8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730936AbgFRUaH (ORCPT + 99 others); Thu, 18 Jun 2020 16:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729847AbgFRUaG (ORCPT ); Thu, 18 Jun 2020 16:30:06 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F86DC0613EE for ; Thu, 18 Jun 2020 13:30:06 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id n11so6925338qkn.8 for ; Thu, 18 Jun 2020 13:30:06 -0700 (PDT) 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=gMOtZLcID+RRbq+QbVzKX+Sw9GzEGaMQc8XZ1xKu5m8=; b=RDc8PBr85lcjVAicltmfcfy4dzfexCk/dEiGFvqbM8lScWjY1PkBHl6o4/PY8wgxcB ToIPTtkxdMT5FTrFrESjJb4ugVU0nqz/g2iczQzFDJvRCCnkvM1x9V1NEa97zCQJZANT d1tQkqFlCcKx5WaxCSHtW4Dag3Mv3IL4nzxWs= 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=gMOtZLcID+RRbq+QbVzKX+Sw9GzEGaMQc8XZ1xKu5m8=; b=K4XmQW1ICNfzBw77BAhQWYYvFDdN+5gERWco87HhpXkSNWPBDIWjQrJON9DNI6LOeu DOwjVAzLE9Z6C2JqfEcyVc0NuNiokl7RlsE3vcmtT19T6gLKSOl0iK8F/pFkqBWzjDj5 IvsIkvdklz3FpRpvmQo6LmN1pVMdcP6Br7KrJBUfLZO3fUkjziVvwVPFbOloUtEyDVo9 qwLL97C5zhIH/Yly2vtkjnaH20M3FCaYhEFfWIRM5HZ1TVKcaqES4AQ4BcEtIpSoojWS g9PnfFVUN6EDbNOeky2L/El4yKoNENFfa3WmtIpw7gzeAzLlxgM7AAl+EivIqAyb+iEq gntw== X-Gm-Message-State: AOAM533fKf74g4yJIYu24mujoh6bW746wlkATux8ljgtlIXsiE0WKUy/ dli4Mw0SBlYzPsOes7B8HFFWLeIW0x0= X-Received: by 2002:ae9:e10f:: with SMTP id g15mr205435qkm.285.1592512204709; Thu, 18 Jun 2020 13:30:04 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id v3sm4027503qkh.130.2020.06.18.13.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 13:30:04 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , urezki@gmail.com, Davidlohr Bueso , Ingo Molnar , Josh Triplett , Lai Jiangshan , Marco Elver , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: [PATCH 1/7] rcu/segcblist: Prevent useless GP start if no CBs to accelerate Date: Thu, 18 Jun 2020 16:29:49 -0400 Message-Id: <20200618202955.4024-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.27.0.111.gc72c7da667-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 rcu_segcblist_accelerate() returns true if a GP is to be started/requested and false if not. During tracing, I found that it is asking that GPs be requested The exact flow seems to be something like: 1. Callbacks are queued on CPU A - into the NEXT list. 2. softirq runs on CPU A, accelerate all CBs from NEXT->WAIT and request a GP X. 3. GP thread wakes up on another CPU, starts the GP X and requests QS from CPU A. 4. CPU A's softirq runs again presumably because of #3. 5. CPU A's softirq now does acceleration again, this time no CBs are accelerated since last attempt, but it still requests GP X+1 which could be useless. The fix is, prevent the useless GP start if we detect no CBs are there to accelerate. With this, we have the following improvement in short runs of rcutorture (5 seconds each): +----+-------------------+-------------------+ | # | Number of GPs | Number of Wakeups | +====+=========+=========+=========+=========+ | 1 | With | Without | With | Without | +----+---------+---------+---------+---------+ | 2 | 75 | 89 | 113 | 119 | +----+---------+---------+---------+---------+ | 3 | 62 | 91 | 105 | 123 | +----+---------+---------+---------+---------+ | 4 | 60 | 79 | 98 | 110 | +----+---------+---------+---------+---------+ | 5 | 63 | 79 | 99 | 112 | +----+---------+---------+---------+---------+ | 6 | 57 | 89 | 96 | 123 | +----+---------+---------+---------+---------+ | 7 | 64 | 85 | 97 | 118 | +----+---------+---------+---------+---------+ | 8 | 58 | 83 | 98 | 113 | +----+---------+---------+---------+---------+ | 9 | 57 | 77 | 89 | 104 | +----+---------+---------+---------+---------+ | 10 | 66 | 82 | 98 | 119 | +----+---------+---------+---------+---------+ | 11 | 52 | 82 | 83 | 117 | +----+---------+---------+---------+---------+ Cc: urezki@gmail.com Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/rcu_segcblist.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c index 9a0f66133b4b3..4782cf17bf4f9 100644 --- a/kernel/rcu/rcu_segcblist.c +++ b/kernel/rcu/rcu_segcblist.c @@ -475,8 +475,15 @@ bool rcu_segcblist_accelerate(struct rcu_segcblist *rsclp, unsigned long seq) * Also advance to the oldest segment of callbacks whose * ->gp_seq[] completion is at or after that passed in via "seq", * skipping any empty segments. + * + * Note that "i" is the youngest segment of the list after which + * any older segments than "i" would not be mutated or assigned + * GPs. For example, if i == WAIT_TAIL, then neither WAIT_TAIL, + * nor DONE_TAIL will be touched. Only CBs in NEXT_TAIL will be + * merged with NEXT_READY_TAIL and the GP numbers of both of + * them would be updated. */ - if (++i >= RCU_NEXT_TAIL) + if (rcu_segcblist_restempty(rsclp, i) || ++i >= RCU_NEXT_TAIL) return false; /* -- 2.27.0.111.gc72c7da667-goog