Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3139460lqt; Tue, 23 Apr 2024 11:19:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMUHxB3so9dVp1meHRcY5cvo9W3ZDPU0kbdwWAs8bbTHhUesGLdLC0ZIN81B2DVYbLxkxjxnG7OR/cek4ET+lNrHaNh8SWLUcOcsaqbQ== X-Google-Smtp-Source: AGHT+IFGVvMml4HsTmN05SBxUTGq23wtaWZI7BF71n3Bu4h+LZqkq2wJpz98osxW2VSgD6gdMQFB X-Received: by 2002:a05:6870:8616:b0:22e:1514:8077 with SMTP id h22-20020a056870861600b0022e15148077mr60090oal.43.1713896396029; Tue, 23 Apr 2024 11:19:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713896396; cv=pass; d=google.com; s=arc-20160816; b=uq9wEWFKovMopcQx3ui1iR7k1t+li1VHLFyuBBI1FVAqZZ7AvcFKCx553tBneZyU4r 2+NoDCRCoYjq9WZO4UBDpPito0tp4OvrV0sz90HMD0rSy9b3EyU40TTBMquPVzI6yMnx Asx2sjcKTRHAlhKJ5r3k6kbGVimRWX296zRezmnMNQNi0gL1XqPSF4r9zLG8NMknkQgC 5pAvnwKamYa+DeyUl+Zt7dPZRR0uljnHM12yuwzuArT9v4ynTjiBVcsyrUJI6PEzSqVT Mj5MKPOWL2pRfeEUNf1XgL7KXnxuy2p2UiF2XMv3JqmacHwS9lkW3WbjDBf/kkbbhRfA JMPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=1o4Xoxam1hucE10zqLFgiDlF1FTTCxVt5NXIsVs9D4Y=; fh=EkipNViYbUdDweWtu4DC+SStNJDRtUwHJQcj36PH3EI=; b=cuALvO7fDkQSvWyxi9fdl9WcqUgGYairaY1yGe9MYXwY5yStH/EOmQirz5zrxKx2g6 AnSR5sFV+IziBM2Z4FN93oEw541mfTXX2kGwIAzyC2fmrcTg+lRA6V0Yygzu2vYCOUl3 wGxyyIPYN2iBLtY1Cb6EoulyFWiU5FNalJJatcB5pO3MReUBSnonO8wQLq6z/MeZ5v7+ XBNoUQnhxl1H1PPUoEhcJXIsbNppvWPv40Fjp/ctcGQFmJoM3brCVtJxuSay4ewpVLrG hD0lvqFHz/u6evyDzkcb7OlKSBwtHfbH5LUqoY9DkEjOCtXi0MVRY/lc/unN403uaU0Q NlaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=kH2vBiAo; arc=pass (i=1 spf=pass spfdomain=joelfernandes.org dkim=pass dkdomain=joelfernandes.org); spf=pass (google.com: domain of linux-kernel+bounces-155738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155738-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w12-20020ac87e8c000000b0043a0360e3a6si1258719qtj.178.2024.04.23.11.19.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 11:19:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=kH2vBiAo; arc=pass (i=1 spf=pass spfdomain=joelfernandes.org dkim=pass dkdomain=joelfernandes.org); spf=pass (google.com: domain of linux-kernel+bounces-155738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155738-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AA3CA1C222EA for ; Tue, 23 Apr 2024 18:19:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B151B13E89B; Tue, 23 Apr 2024 18:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="kH2vBiAo" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEA4313D8BA for ; Tue, 23 Apr 2024 18:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713896391; cv=none; b=f5r8dHnMJ8LlJ20KqvSLpdzOvVXgIn1UCGlul2KvcF5Quj2Pptsw4tSMSee3MGBsUvtX1ObijprobRSxgndq6rLS8gXmWVn82Cp42pb4hEWI8gfwOdfbEy3mSpiCAXA7uxhzzOSHzszBpsaeG+TntsBozlu+A02WoFSa/ZSHkng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713896391; c=relaxed/simple; bh=oVSimOQFOxbjRp8F5hqap+KnKU7S2Ifth8z3iypX9Io=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=beWHM9rJJARN2MShUWcvn4YRzifZr6ClRDe/xdLsg2Im2/DRFpZ905PHyCIMfVS/8DHBZBvUvTYp7A95vIwZVj0jNhy1x3KFmDsTzas1qT7zyt5r0H1Oq/+fe558IjU+ip3Oiu4p1f68kG8Qq5tHP5ehXCbQrf28xqJ4JjYFFKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org; spf=pass smtp.mailfrom=joelfernandes.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b=kH2vBiAo; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joelfernandes.org Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2db6f5977e1so79894181fa.2 for ; Tue, 23 Apr 2024 11:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1713896388; x=1714501188; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1o4Xoxam1hucE10zqLFgiDlF1FTTCxVt5NXIsVs9D4Y=; b=kH2vBiAoYU4I4a48nQMOxkXSNcaplP9TKYcmePi0pFFTRWn+ClHS7k5hpv6TGZBW4R jd1bcvwh46gheYUW3HMzyIItZTxijysKjdvTZxA+gYFcvisXd6cgRKS/8xdAoOAoH0Rj sFe/Fwuec3Q28btGnEBJrqeNYo+L72qfXZDXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713896388; x=1714501188; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1o4Xoxam1hucE10zqLFgiDlF1FTTCxVt5NXIsVs9D4Y=; b=bqV8rjFMLw4/TT+1q0gxN1W6z6q9DqfJwWYe2zm52grX4MbbB5Mnr0hhVDs2mODPbX P1gqh1iOF8ySPym1m5HpJK2cj1KXooT60yPtXMHrTE5WTnwQdtIv7RRP/W8aq7GXKzMP u6V5ZEMr5rjGL2xxVXOyFOw9Xi9j2UUAaNq5+NTBt7i2eXXUNKex3Z2uvITfhkuckgjI nEJTPVKjbbdg5tpOnp2LKZ+cSlFZQKDvV4lmqe4/QR5zgm/RvGKnbTxqckUKY3pkSU3r YxTegcmIt5Zk7BK1/mICQG9Ln4W0EA2lClt7KG07L9lk49BLq3bzsd432CGYJ76qqzot e9Zw== X-Gm-Message-State: AOJu0Yyon6eAWSOErcS1N9fgLnFZOAURu25KsXiTsOkqqNTSAxRhEes1 kKIMugaOsybdxA06EJ1av0voQbBmS0q0J2MfRIDjWBzZqzVvsY5Je3Afi0WIqAbkMxEW8Mvuwxm ybK77Rq2/QQXPWlafbbaFtcFJuTkgHQoXFlqOIA== X-Received: by 2002:a2e:868e:0:b0:2d7:10a1:481e with SMTP id l14-20020a2e868e000000b002d710a1481emr31854lji.31.1713896387696; Tue, 23 Apr 2024 11:19:47 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240407090558.3395-1-jiangshanlai@gmail.com> <20240407090558.3395-10-jiangshanlai@gmail.com> In-Reply-To: <20240407090558.3395-10-jiangshanlai@gmail.com> From: Joel Fernandes Date: Tue, 23 Apr 2024 14:19:34 -0400 Message-ID: Subject: Re: [PATCH V2 09/11] rcu: Implement PCPU_RCU_PREEMPT_COUNT framework To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, x86@kernel.org, Lai Jiangshan , "Paul E. McKenney" , Peter Zijlstra , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Zqiang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Apr 7, 2024 at 5:04=E2=80=AFAM Lai Jiangshan wrote: > > From: Lai Jiangshan > > When the arch code provides HAVE_PCPU_RCU_PREEMPT_COUNT and the > corresponding functions, rcu core uses the functions to implement > rcu_preempt_depth(), special bits, switching and so on. > > Cc: "Paul E. McKenney" > Cc: Peter Zijlstra > Cc: Frederic Weisbecker > Signed-off-by: Lai Jiangshan > --- > include/linux/rcupdate.h | 33 +++++++++++++++++++++++++++++++++ > kernel/rcu/Kconfig | 8 ++++++++ > kernel/rcu/rcu.h | 4 ++++ > kernel/rcu/tree_plugin.h | 8 ++++++++ > 4 files changed, 53 insertions(+) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 328667ae8086..e3e5ce44c7dc 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -70,6 +70,8 @@ static inline bool same_state_synchronize_rcu(unsigned = long oldstate1, unsigned > > void rcu_read_unlock_special(void); > > +#ifndef CONFIG_PCPU_RCU_PREEMPT_COUNT > + > void __rcu_read_lock(void); > void __rcu_read_unlock(void); > > @@ -81,6 +83,37 @@ void __rcu_read_unlock(void); > */ > #define rcu_preempt_depth() READ_ONCE(current->rcu_read_lock_nesting) > #define rcu_preempt_depth_set(val) WRITE_ONCE(current->rcu_read_lock_nes= ting, (val)) > +#define pcpu_rcu_preempt_special_set() do { } while (0) > +#define pcpu_rcu_preempt_special_clear() do { } while (0) > + > +#else /* #ifndef CONFIG_PCPU_RCU_PREEMPT_COUNT */ > + > +#include > + > +static __always_inline void __rcu_read_lock(void) > +{ > + pcpu_rcu_preempt_count_add(1); > + barrier(); > +} > + > +static __always_inline void __rcu_read_unlock(void) > +{ > + barrier(); > + if (unlikely(pcpu_rcu_preempt_count_dec_and_test())) > + pcpu_rcu_read_unlock_special(); > +} Previous code had comments about the barrier(); , can you add back those comments? Also there was a compiler barrier in the body of the if() as well? For reference: void __rcu_read_unlock(void) { struct task_struct *t =3D current; barrier(); // critical section before exit code. if (rcu_preempt_read_exit() =3D=3D 0) { barrier(); // critical-section exit before .s check. if (unlikely(READ_ONCE(t->rcu_read_unlock_special.s))) rcu_read_unlock_special(t); }