From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 8AE4826AE4 for ; Thu, 18 Sep 2025 06:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758175799; cv=none; b=jp50wRDklv9JKMcgIauMuOK+paa8vhYqmvaZVTfoSGWUjR1hTCCDNY7R2IEgoqYd4PMjKYf4p+1dMRtoiXZdSwVU0qufZbVs9PFsHsNB+IM8wV95HfOQNGIwX2a08mB5FhDZGgEwEkVpjhSTtfAlvw/tJvzITZIFFp1dAs3si/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758175799; c=relaxed/simple; bh=NIMy5R5nf6DdV1ze7QsimyipASntB/qjfHYgCld51pQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mWoFtJH8VhUU7pWx77VlF89Sx1WUS1CQh92yGGDQlEG1cToY8LsIBDUyVCJZQSPhXGasGP4zus//2ooDPl2SgpZUf0Kmnf1yWUDEwoA77b6lGbGNlqNfr0KSwf6fu6Ef+zMx81DtmuQOBmK8ROzYhxlBBXM/4ksyt4P+9/T6qgs= 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=IUONQkMG; arc=none smtp.client-ip=95.215.58.170 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="IUONQkMG" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1758175794; 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=eD/67DPnwyKX2mcMSIG5+0/Vo6T967tR+VuwRVClzo8=; b=IUONQkMGOOhs30d9Bkveol1Z+vg7FaxoIzsBm/KSn72kXjD98ghgIjMRzdfaPkigzox263 yCcFkdDTtTHLHqBSzqzrWCXDAafLq2yZlvBuHDj9lRLhfL2Et3WMkGKDfnFPT3KuZt7EZl P9o2lo11O6cQHKK/TBb51OhZaQT3Pd0= Date: Thu, 18 Sep 2025 14:09:08 +0800 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net-next v3 1/3] rculist: Add __hlist_nulls_replace_rcu() and hlist_nulls_replace_init_rcu() To: Kuniyuki Iwashima Cc: edumazet@google.com, kerneljasonxing@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, Xuanqiang Luo References: <20250916103054.719584-1-xuanqiang.luo@linux.dev> <20250916103054.719584-2-xuanqiang.luo@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: luoxuanqiang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 2025/9/17 12:43, Kuniyuki Iwashima 写道: > On Tue, Sep 16, 2025 at 9:27 PM Kuniyuki Iwashima wrote: >> On Tue, Sep 16, 2025 at 8:27 PM luoxuanqiang wrote: >>> >>> 在 2025/9/17 02:58, Kuniyuki Iwashima 写道: >>>> On Tue, Sep 16, 2025 at 3:31 AM wrote: >>>>> From: Xuanqiang Luo >>>>> >>>>> Add two functions to atomically replace RCU-protected hlist_nulls entries. >>>>> >>>>> Signed-off-by: Xuanqiang Luo >>>>> --- >>>>> include/linux/rculist_nulls.h | 61 +++++++++++++++++++++++++++++++++++ >>>>> 1 file changed, 61 insertions(+) >>>>> >>>>> diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h >>>>> index 89186c499dd4..8ed604f65a3e 100644 >>>>> --- a/include/linux/rculist_nulls.h >>>>> +++ b/include/linux/rculist_nulls.h >>>>> @@ -152,6 +152,67 @@ static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n) >>>>> n->next = (struct hlist_nulls_node *)NULLS_MARKER(NULL); >>>>> } >>>>> >>>>> +/** >>>>> + * __hlist_nulls_replace_rcu - replace an old entry by a new one >>>>> + * @old: the element to be replaced >>>>> + * @new: the new element to insert >>>>> + * >>>>> + * Description: >>>>> + * Replace the old entry with the new one in a RCU-protected hlist_nulls, while >>>>> + * permitting racing traversals. >>>>> + * >>>>> + * The caller must take whatever precautions are necessary (such as holding >>>>> + * appropriate locks) to avoid racing with another list-mutation primitive, such >>>>> + * as hlist_nulls_add_head_rcu() or hlist_nulls_del_rcu(), running on this same >>>>> + * list. However, it is perfectly legal to run concurrently with the _rcu >>>>> + * list-traversal primitives, such as hlist_nulls_for_each_entry_rcu(). >>>>> + */ >>>>> +static inline void __hlist_nulls_replace_rcu(struct hlist_nulls_node *old, >>>>> + struct hlist_nulls_node *new) >>>>> +{ >>>>> + struct hlist_nulls_node *next = old->next; >>>>> + >>>>> + new->next = next; >>> Do we need to use WRITE_ONCE() here, as mentioned in efd04f8a8b45 >>> ("rcu: Use WRITE_ONCE() for assignments to ->next for rculist_nulls")? >>> I am more inclined to think that it is necessary. >> Good point, then WRITE_ONCE() makes sense. > and it would be nice to have such reasoning in the commit > message as we were able to learn from efd04f8a8b45. Okay, I'll add an explanation in the next version. Really appreciate you confirming this!