Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp494691ybg; Wed, 10 Jun 2020 06:17:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywNGTbIWxIBGUswdD7B6qkioKeh5sS6UfSq2aH58t5enbv0CZfcgFljzqXYGdRXeRnjaU8 X-Received: by 2002:a17:906:3013:: with SMTP id 19mr3248484ejz.303.1591795059101; Wed, 10 Jun 2020 06:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591795059; cv=none; d=google.com; s=arc-20160816; b=KZat29wuPtJ8o/40lLQ2SUkOj6SrbqV48O12Vup301+MdXxhuPcbGvWiOrC5IC9NiP qOmQ8ea+pu2wLR2TRcEXGOlaDrQcDAnkvXHRuEJ5HlacI5Va6dz9y5NyEfjHaqIj1mPL UPeCUaylV02T+Kq+wwAGBo+OCUkv10uHAIwBfwUcyyUz2qUosbHi2J5wT8OJF9/VmB7R EHpN9DIpZPlrzEwzREXIY692zufkTp53BKdW8Q7W6xYRcDZQRJJ/j2eAMCWUNEpPhCe5 RuXKd2OtQLtTwEZDLa1bVYPkq/laL/nmZIoHxyU8hMaMWZGWKt3CZjtg9OdEyZCYH/Ve gP+A== 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; bh=XUQy6n4qoUzzPCsfeZDUMu456CKi5GiXpX8yRnfAKTs=; b=KU5UKOT5z0mzIG0/nUspm6QVLWghXu1CZeOkki8UcfQL8FZAD7qB3I3qrNYZzR8QgS F51PU0bKlqW4ZIF0bQh+XE7uT8HT7kgMq0BqHowK6vLYkVP4fGn+wPedkkF2Xw2nMqAd gthUh5VGT09f7hEbCy5t6ee+ytmpoN//sQEeFySX83mMpYDo4gM+6kLw9CuZuHFgUNQK i1kuSVuB6CiX1IcZKBaSZZLqi3dB87sso2WQ6LjZmflMjpNzmud2SUhp1WdWjrF5sdaW yp1j7RjlshSnK+Eqd2ar1GMEd5xfHZfjlfGbIJAodnZT9lXe6boZDEJT+99V/Z626oC5 xJgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EtcXatLa; 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 cm27si11773340edb.248.2020.06.10.06.17.14; Wed, 10 Jun 2020 06:17: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=@kernel.org header.s=default header.b=EtcXatLa; 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 S1729239AbgFJNMp (ORCPT + 99 others); Wed, 10 Jun 2020 09:12:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:50062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729120AbgFJNMm (ORCPT ); Wed, 10 Jun 2020 09:12:42 -0400 Received: from localhost (lfbn-ncy-1-1025-94.w92-138.abo.wanadoo.fr [92.138.0.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A320206F4; Wed, 10 Jun 2020 13:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591794762; bh=ccKcrDJ9vgY+vczOxvBZN8klM3S/Ibm9bitAkG+Tg1I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EtcXatLaGES4NGAyOj2p9rtVKe3kKZWB8ifao71wky3x/aWfeFYl/jvEEB7mjBIVx BgL9X+EyM/SRPK0QB0n5bPb2LbliG5mvtiBbecz3K5PsqfPd8kEKdsXOy/EFLglyQc 8kLQaX2eDfl+Xw/NXJoKH+B2Bhj6v6EGYYfhvH2Q= Date: Wed, 10 Jun 2020 15:12:39 +0200 From: Frederic Weisbecker To: "Paul E. McKenney" Cc: Joel Fernandes , LKML , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Josh Triplett Subject: Re: [PATCH 01/10] rcu: Directly lock rdp->nocb_lock on nocb code entrypoints Message-ID: <20200610131238.GA26639@lenoir> References: <20200513164714.22557-1-frederic@kernel.org> <20200513164714.22557-2-frederic@kernel.org> <20200520122949.GB16672@google.com> <20200522175739.GM2869@paulmck-ThinkPad-P72> <20200604114121.GA26398@lenoir> <20200604163655.GC29598@paulmck-ThinkPad-P72> <20200608125715.GA30920@lenoir> <20200609180227.GR4455@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200609180227.GR4455@paulmck-ThinkPad-P72> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 09, 2020 at 11:02:27AM -0700, Paul E. McKenney wrote: > > > > And anyway we still want to unconditionally lock on many places, > > > > regardless of the offloaded state. I don't know how we could have > > > > a magic helper do the unconditional lock on some places and the > > > > conditional on others. > > > > > > I was assuming (perhaps incorrectly) that an intermediate phase between > > > not-offloaded and offloaded would take care of all of those cases. > > > > Perhaps partly but I fear that won't be enough. > > One approach is to rely on RCU read-side critical sections surrounding > the lock acquisition and to stay in the intermediate phase until a grace > period completes, preferably call_rcu() instead of synchronize_rcu(). > > This of course means refusing to do a transition if the CPU is still > in the intermediate state from a prior transition. That sounds good. But using synchronize_rcu() would be far easier. We need to keep the hotplug and rcu barrier locked during the transition. > > Also I've been thinking that rcu_nocb_lock() should meet any of these > > requirements: > > > > * hotplug is locked > > * rcu barrier is locked > > * rnp is locked > > > > Because checking the offloaded state (when nocb isn't locked yet) of > > an rdp without any of the above locks held is racy. And that should > > be easy to check and prevent from copy-pasta accidents. > > > > What do you think? > > An RCU read-side critical section might be simpler. Ok I think I can manage that. Thanks.