Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp456480ybl; Wed, 11 Dec 2019 22:28:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwtGdp/nCUM1tEwtTzFHUYRbezbEaryKEg8hu5yywmvyW3xoPWRrhpws+8tIkVwih00RsWM X-Received: by 2002:a05:6830:1e7c:: with SMTP id m28mr6561624otr.131.1576132125240; Wed, 11 Dec 2019 22:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576132125; cv=none; d=google.com; s=arc-20160816; b=0YzPTiT0MkeTcz19qeAGlibWrx3Yya6D3yV2k3t/9HwV5u2W/sSz0SEMg1bJqd7ETk jAsTj0o/T6HX6HbIOAjlyS4BMzSSSjGjhKhI8fp38SulgymR0HgJBwrNqDF1gtRrC/ku OIkbjUtFnjhd8uKa+Ng8e3l9kSXIhZ8SjZ6CeL3bCkvcS30EUIBzmIlKn6bpBjGQRELs QKLe3r5+C9NxqZwJQjBo3bwyqW1llfTjpwzWwd6PcSN/dWs0EjuaEOShk8c1c4zrx4uO hskutv3gClnFntTsToxRHf/niRLaIRPwZ6JKfNn9lcorLvseOBYbKskhttHg246gJlzz 3BoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=H7RR71RtDt7+IpLTYZKyaaj71OUDVuUVoz6XnIREVGE=; b=OdhjHrnaRQhLscuK8v3UZhLah4DnFsMILi4/A4UspARxtVKVKI4uv8UM2RBLXpP2tC Aptg1dsbDq6AZO7gJ00245o7sNjlqnvz/KhJiIesc7n5y/SJgeD0SzObvxOeDx3jFWKz 2siErVeaNNLomTcKcMMQ0DhZFpeW7SJC2rEw8nljsOPyQ8YWFZICKzMDGf13li0Xz2oi Vk2lP5LglgEiI2m+6OomWf3lRohHAXu8d1pBVfiIn9KsJ2mfaUno2wc2Z+6I7xss6bhq TZEibQlCxCCdbMgDdu9GrSWi6FOpBu+KdUDn+uUfNhaT9rcgm2Jqa0ILwqimmamLwajC gXmw== ARC-Authentication-Results: i=1; mx.google.com; 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 t142si2609382oih.242.2019.12.11.22.28.32; Wed, 11 Dec 2019 22:28:45 -0800 (PST) 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; 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 S1727954AbfLLG2E (ORCPT + 99 others); Thu, 12 Dec 2019 01:28:04 -0500 Received: from mail.windriver.com ([147.11.1.11]:33403 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727592AbfLLG2E (ORCPT ); Thu, 12 Dec 2019 01:28:04 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id xBC6RfSb021450 (version=TLSv1 cipher=AES256-SHA bits=256 verify=FAIL); Wed, 11 Dec 2019 22:27:41 -0800 (PST) Received: from [128.224.155.90] (128.224.155.90) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.468.0; Wed, 11 Dec 2019 22:27:40 -0800 Subject: Re: [tipc-discussion] [PATCH net/tipc] Replace rcu_swap_protected() with rcu_replace_pointer() To: CC: Tuong Lien Tong , , , , , , , References: <20191210033146.GA32522@paulmck-ThinkPad-P72> <0e565b68-ece1-5ae6-bb5d-710163fb8893@windriver.com> <20191210223825.GS2889@paulmck-ThinkPad-P72> <54112a30-de24-f6b2-b02e-05bc7d567c57@windriver.com> <707801d5afc6$cac68190$605384b0$@dektech.com.au> <20191211184609.GI2889@paulmck-ThinkPad-P72> From: Ying Xue Message-ID: <58df887e-cfb5-37fd-6c06-d5f98449edd5@windriver.com> Date: Thu, 12 Dec 2019 14:14:20 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191211184609.GI2889@paulmck-ThinkPad-P72> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [128.224.155.90] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/12/19 2:46 AM, Paul E. McKenney wrote: > On Wed, Dec 11, 2019 at 12:42:00PM +0800, Ying Xue wrote: >> On 12/11/19 10:00 AM, Tuong Lien Tong wrote: >>>> >>>> /* Move passive key if any */ >>>> if (key.passive) { >>>> - tipc_aead_rcu_swap(rx->aead[key.passive], tmp2, &rx->lock); >>>> + tmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, >>> &rx->lock); >>> The 3rd parameter should be the lockdep condition checking instead of the >>> spinlock's pointer i.e. "lockdep_is_held(&rx->lock)"? >>> That's why I'd prefer to use the 'tipc_aead_rcu_swap ()' macro, which is >>> clear & concise at least for the context here. It might be re-used later as >>> well... >>> >> >> Right. The 3rd parameter of rcu_replace_pointer() should be >> "lockdep_is_held(&rx->lock)" instead of "&rx->lock". > > Like this? Yes, I think it's better to set the 3rd parameter of rcu_replace_pointer() with "lockdep_is_held(&rx->lock)". > > Thanx, Paul > > ------------------------------------------------------------------------ > > commit 575bb4ba1b22383656760feb3d122e11656ccdfd > Author: Paul E. McKenney > Date: Mon Dec 9 19:13:45 2019 -0800 > > net/tipc: Replace rcu_swap_protected() with rcu_replace_pointer() > > This commit replaces the use of rcu_swap_protected() with the more > intuitively appealing rcu_replace_pointer() as a step towards removing > rcu_swap_protected(). > > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/ > Reported-by: Linus Torvalds > Reported-by: kbuild test robot > Signed-off-by: Paul E. McKenney > [ paulmck: Updated based on Ying Xue and Tuong Lien Tong feedback. ] > Cc: Jon Maloy > Cc: Ying Xue > Cc: "David S. Miller" > Cc: > Cc: > > diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c > index 990a872..c8c47fc 100644 > --- a/net/tipc/crypto.c > +++ b/net/tipc/crypto.c > @@ -257,9 +257,6 @@ static char *tipc_key_change_dump(struct tipc_key old, struct tipc_key new, > #define tipc_aead_rcu_ptr(rcu_ptr, lock) \ > rcu_dereference_protected((rcu_ptr), lockdep_is_held(lock)) > > -#define tipc_aead_rcu_swap(rcu_ptr, ptr, lock) \ > - rcu_swap_protected((rcu_ptr), (ptr), lockdep_is_held(lock)) > - > #define tipc_aead_rcu_replace(rcu_ptr, ptr, lock) \ > do { \ > typeof(rcu_ptr) __tmp = rcu_dereference_protected((rcu_ptr), \ > @@ -1189,7 +1186,7 @@ static bool tipc_crypto_key_try_align(struct tipc_crypto *rx, u8 new_pending) > > /* Move passive key if any */ > if (key.passive) { > - tipc_aead_rcu_swap(rx->aead[key.passive], tmp2, &rx->lock); > + tmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, lockdep_is_held(&rx->lock)); > x = (key.passive - key.pending + new_pending) % KEY_MAX; > new_passive = (x <= 0) ? x + KEY_MAX : x; > } >