Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1110912imm; Mon, 21 May 2018 21:43:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo3tsJDtxylXCBorlNEfpjTZ+0mQ50GKGQ8ygergEayGXJXdCUpWEKmjk4j6h2Rd9TX+teQ X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr23727145plb.42.1526964236643; Mon, 21 May 2018 21:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526964236; cv=none; d=google.com; s=arc-20160816; b=ODK+Hs/zuOADpXKvuhfSKtYAALnYW/j3NflfcH9hCMcSgovKoJbu8NgmmOE6oiREiW x23jpfz9x2NnoHhp9VeXW8A8D38mQrttRW7jNsBVpNjadCMxoeYYTeD8LRqV3490CRx/ X/yDoO0tk0F1ymGJRnbCBcWXzv14dzDsXcdTKLIuytAj4/QHBlL3keeqWesnJFphlQMY Nc935cNN6AdLA+AdJaLZ1Szevzl8pXDbWUK0OY6vuwh758fIxgj4WQY3EHp8BIF8a4aU TIhkS6b+iDEO+9CgegwWmq8vcK3LCOqSb0z/lSrmcACwJ7VnjyLrPBv/e1P4BfryHVwH +v9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=oS/OiEezo2f7/TTGwvZJ64oCTiYeW7mCzjm+dA782Xo=; b=lhXPML5hCoWe/t2vPF26nIey9WYappD+5osunkYstf1FxiJYoLCQjIUt01imPB5eY8 6nuWkoBgfLSyh/ylIj1ipF2peu6KJgRNqpa3sKEJvr9aNEsq4OCKbuWgvPXhuOmYXTr2 SPzky3qY6Zi8b8rLzizT0oBMX5Dp1TtPd6tfLkPyDwPhx5IjieLSCN9Jo9Q/+tNUN/ew zPg/usAfgrXmBBGaKYJqoczySfaJ/DZrGvYjqqBamuYZEU5UmR+uFXDAdb2nGCOwCsNd QbKcsxzyAtg7xPQHWMTI0K31JDfjkplrJE4OiIAzOx5Q0sFHagK/IpIha8k4YWtwB02E 7Erw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=vdPl8ugK; 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 j131-v6si6277030pgc.606.2018.05.21.21.43.40; Mon, 21 May 2018 21:43:56 -0700 (PDT) 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=vdPl8ugK; 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 S1751301AbeEVEn3 (ORCPT + 99 others); Tue, 22 May 2018 00:43:29 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33724 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751205AbeEVEn2 (ORCPT ); Tue, 22 May 2018 00:43:28 -0400 Received: by mail-pf0-f193.google.com with SMTP id a20-v6so8137939pfo.0 for ; Mon, 21 May 2018 21:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oS/OiEezo2f7/TTGwvZJ64oCTiYeW7mCzjm+dA782Xo=; b=vdPl8ugKjB+OU9h8AErnypFglgg7FPfi7ZaggKcSOUSxUOshjgJEkp7RFBH7BIr7Zm pcc0KzpF3lPUK/NwNSYzMzPxq4jBtEvRKUFF9ydbnKY7X96EEWaSnbAh1ZmH4AUZ0pax u4/wB132lsGZM/SdWdcmmoMIRJoF+jrQBBTYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oS/OiEezo2f7/TTGwvZJ64oCTiYeW7mCzjm+dA782Xo=; b=H/tQc7Pgt9LdWRXbVpoXEKPkTU2dEErScp0z7dc7sxBTdldTYYa5mo6kQVY90jU6ur 6W7iA9gpJZHCUO/a9sVztDiaF4rWsjmBCntBu3YdMj4cS7AB0BW2ZBeXfRECOqHNp1Dj 9RrFY8hAHtjpx7D0kHnTUOPwctZmgFK1aUtUh1NUQzeiyBVsWd2PT3fUF44FTZ5+ddxF rao6E0XlIdVWUkVoJjwUDvZsCtGL6gxaimTFBiObFN7AQTULOyrYpQQzhANnomK28E3t mvIdc2Dv8hpfQyVQS30JJzOJ/gVU7Z1i8AOo5RZ4O7fF+66kVqCAXxucvsPxaioNKzKP Aucg== X-Gm-Message-State: ALKqPwfMoYdpUlkfl/8ilTLOvmJkFg43m2whnz7FT2u24dUwC22fjnD1 o99QKK5j7nJDGx/rpQAyOee2kA== X-Received: by 2002:aa7:80c6:: with SMTP id a6-v6mr22574077pfn.120.1526964208320; Mon, 21 May 2018 21:43:28 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id c21-v6sm29769441pfb.116.2018.05.21.21.43.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 21:43:27 -0700 (PDT) Date: Mon, 21 May 2018 21:43:27 -0700 From: Joel Fernandes To: "Paul E. McKenney" Cc: Joel Fernandes , linux-kernel@vger.kernel.org, Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , byungchul.park@lge.com, kernel-team@android.com Subject: Re: [PATCH v3 4/4] rcu: Unlock non-start node only after accessing its gp_seq_needed Message-ID: <20180522044327.GF40541@joelaf.mtv.corp.google.com> References: <20180521044220.123933-1-joel@joelfernandes.org> <20180521044220.123933-5-joel@joelfernandes.org> <20180521232537.GJ3803@linux.vnet.ibm.com> <20180522000734.GD40541@joelaf.mtv.corp.google.com> <20180522002823.GP3803@linux.vnet.ibm.com> <20180522041651.GA18405@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180522041651.GA18405@linux.vnet.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 21, 2018 at 09:16:51PM -0700, Paul E. McKenney wrote: > On Mon, May 21, 2018 at 05:28:23PM -0700, Paul E. McKenney wrote: > > On Mon, May 21, 2018 at 05:07:34PM -0700, Joel Fernandes wrote: > > > On Mon, May 21, 2018 at 04:25:38PM -0700, Paul E. McKenney wrote: > > > > On Sun, May 20, 2018 at 09:42:20PM -0700, Joel Fernandes wrote: > > > > > We acquire gp_seq_needed locklessly. To be safe, lets do the unlocking > > > > > after the access. > > > > > > > > Actually, no, we hold rnp_start's ->lock throughout. And this CPU (or in > > > > the case of no-CBs CPUs, this task) is in charge of rdp->gp_seq_needed, > > > > so nothing else is accessing it. Or at least that is the intent. ;-) > > > > > > I was talking about protecting the internal node's rnp->gp_seq_needed, not > > > the rnp_start's gp_seq_needed. > > > > Ah, good point, I missed the "if" condition. This can be argued to work, > > sort of, given that we still hold the leaf rcu_node structure's lock, > > so that there is a limit to how far grace periods can advance. > > > > But the code would of course be much cleaner with your change. > > > > > We are protecting them in the loop: > > > > > > like this: > > > for(...) > > > if (rnp != rnp_start) > > > raw_spin_lock_rcu_node(rnp); > > > [...] > > > // access rnp->gp_seq and rnp->gp_seq_needed > > > [...] > > > if (rnp != rnp_start) > > > raw_spin_unlock_rcu_node(rnp); > > > > > > But we don't need to do such protection in unlock_out ? I'm sorry if I'm > > > missing something, but I'm wondering if rnp->gp_seq_needed of an internal > > > node can be accessed locklessly, then why can't that be done also in the > > > funnel locking loop - after all we are holding the rnp_start's lock through > > > out right? > > > > I was focused on the updates, and missed the rnp->gp_seq_req access in the > > "if" statement. The current code does sort of work, but only assuming > > that the compiler doesn't tear the load, and so your change would help. > > Could you please resend with your other two updated patches? It depends > > on one of the earlier patches, so does not apply cleanly as-is. I could > > hand-apply it, but that sounds like a good way to make your updated > > series fail to apply. ;-) > > > > But could you also make the commit log explicitly call out the "if" > > condition as being the offending access? > > Never mind, me being stupid. I need to apply this change to the original > commit "rcu: Make rcu_nocb_wait_gp() check if GP already requested", which > I have done with this attribution: > > [ paulmck: Move lock release past "if" as suggested by Joel Fernandes. ] > > I have rebased my stack on top of the updated commit. Cool, makes sense. I am assuming this means I don't have to resend this patch, if I do let me know :) Either way, once you push your updated tree to kernel.org, I'll double check to make sure the change is in :) thanks, good night, - Joel