From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C33B30649F for ; Wed, 15 Oct 2025 08:41:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760517672; cv=none; b=t1bd5XjnSr/lCuRmViFBcxdkkedNPeZdkijSNBBPqLnw6A0Qo5zzowWuxu58Rlt3fKA/kBmZ3k08R0J55FpzP4Rq7/+M93rorBR9iiytPmDQ96TzRShi/lTPmHjj7+dvonjTo5rW4wpm812Skk/Om4gl6llWG8BRKkENUgl/QmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760517672; c=relaxed/simple; bh=f6hvt/NkFdxn6Xx1792HgfmUP0Dn5MOAPtACW0y82Ic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dXOQ2BeNnv8oSa3ie/inkH8zhaahD6vptcpXACYeuLYVCBiAYqirYlo8HvemlfLncNi5Txnlr/qhm0pGNIjpWtA3AWPKpRxI9LvjK/+OXYJ0OZTSuEzOmPl82Ef1PqGZ+gGfnH8Mu03MTMKOwuntqfEgvnIN4php1O0dXUbUE8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lactOngR; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lactOngR" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1760517665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0VSjbHQDh1+KgRk8wHE69Ht5wW5omcZP6fXsOpT7LvU=; b=lactOngR0mxUFc31b0rRqonkdWF9lUr/ALYGH20EDawQY1vG2NicmD4EN1klJa/rpZHl9h sGEHIf29iB3GfkwFz7RyP9Jru6Lls81qN6qefJSGBzCIpHvbGsGS/YarYMzg+ylIC1qYrT IEvX/Pss8uE2T7X6SqgH5PjbHmI1Qvg= From: Menglong Dong To: Menglong Dong , Alexei Starovoitov Cc: Alexei Starovoitov , "Paul E. McKenney" , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jakub Sitnicki , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , jiang.biao@linux.dev, bpf , LKML , Network Development Subject: Re: [PATCH bpf-next 1/4] rcu: factor out migrate_enable_rcu and migrate_disable_rcu Date: Wed, 15 Oct 2025 16:40:43 +0800 Message-ID: <2239372.irdbgypaU6@7950hx> In-Reply-To: References: <20251014112640.261770-1-dongml2@chinatelecom.cn> <20251014112640.261770-2-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Migadu-Flow: FLOW_OUT On 2025/10/14 22:59, Alexei Starovoitov wrote: > On Tue, Oct 14, 2025 at 4:27=E2=80=AFAM Menglong Dong wrote: > > > > Factor out migrate_enable_rcu/migrate_disable_rcu from > > rcu_read_lock_dont_migrate/rcu_read_unlock_migrate. > > > > These functions will be used in the following patches. > > > > It's a little weird to define them in rcupdate.h. Maybe we should move > > them to sched.h? > > > > Signed-off-by: Menglong Dong > > --- > > include/linux/rcupdate.h | 20 +++++++++++++++++--- > > 1 file changed, 17 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > > index c5b30054cd01..43626ccc07e2 100644 > > --- a/include/linux/rcupdate.h > > +++ b/include/linux/rcupdate.h > > @@ -988,18 +988,32 @@ static inline notrace void rcu_read_unlock_sched_= notrace(void) > > preempt_enable_notrace(); > > } > > > > -static __always_inline void rcu_read_lock_dont_migrate(void) > > +/* This can only be used with rcu_read_lock held */ > > +static inline void migrate_enable_rcu(void) > > +{ > > + WARN_ON_ONCE(!rcu_read_lock_held()); > > + if (IS_ENABLED(CONFIG_PREEMPT_RCU)) > > + migrate_enable(); > > +} > > + > > +/* This can only be used with rcu_read_lock held */ > > +static inline void migrate_disable_rcu(void) > > { > > + WARN_ON_ONCE(!rcu_read_lock_held()); > > if (IS_ENABLED(CONFIG_PREEMPT_RCU)) > > migrate_disable(); > > +} > > + > > +static __always_inline void rcu_read_lock_dont_migrate(void) > > +{ > > rcu_read_lock(); > > + migrate_disable_rcu(); > > } > > > > static inline void rcu_read_unlock_migrate(void) > > { > > + migrate_enable_rcu(); > > rcu_read_unlock(); > > - if (IS_ENABLED(CONFIG_PREEMPT_RCU)) > > - migrate_enable(); > > } >=20 > Sorry. I don't like any of it. It obfuscates the code > without adding any benefits. It has a slight performance improving for some BPF type, such as SK_SKB, SK_MSG. Hmm, after we make migrate_disable() inline, the performance improving here is extremely slight. And you are right, it do obfuscate the code :/ Thanks! Menglong Dong >=20 > pw-bot: cr >=20 >=20