Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1278846pxb; Sun, 12 Sep 2021 13:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4TvZ55ADIBlnlWk3gdDwtvQLD32c/WMTTKSys2zWFLhq/otOQ9Ae/QFeB1WZ6gatEMwcR X-Received: by 2002:a02:6d17:: with SMTP id m23mr6646127jac.63.1631479388464; Sun, 12 Sep 2021 13:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631479388; cv=none; d=google.com; s=arc-20160816; b=YOGzMmDCbxnDa+kxQ+1wSgqVYADzau8ro0Fnm0umpErq9VOQCAyJhAcVe3OF9W2bUL QbmdGv306MDsGVYN1MLrgwM3XEraSI5F5zDk3j8ImH8YvIHZ5x4FNpjDx0hnmaBOlFrj KqfICrjyF+Q3NXpfL2EFqMVYoDrOBWq15PHmmnSWprGRrNTnqobwrJbs/kntsZXTyh0+ +PXm10T2w0AE0/rS6DnCyEeDYZ0GlMKMiRfmlI25sO7GUlnn2lDTKu+Hvj2dO5FwocGi tz0v4uCjboIsJixheoUBjWqLiKAEMH2JOcRjr3JpTJbjU+ZLPlf+ya5lXpuTjLIQugtU bWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ow1HoVLX+9HoNdnX4/sLVCN3K6sWaqzs/vefkU1HZMg=; b=LW7SXIxHjWySQB4Q2HYHVi1rH4MnglSvFsLEZikHh5WZwRdAawIbX6dDlGFpHZvVq2 i0VTneLTzfbsFQYtkGgjyfkWDPCjRJTdF9tHrunu7GpaVDz2wqv9iRCPyplFUky2eMIX SPA3pvrg2xccUbP0zo1sGQCW9ko9vgFHtux+8UctDtToKHXvvN+uBwEpSAeGjgylweTB K4qjQM3jkrXJky5vs8uQwz4GVbBnZZvFaDId9UfiFB9ZxK/IVqlmnf6mGoOtpc2GpozH cpK6uOdNFIAbs7p6r44m7dDl+aiWJOCxsa+rRDJAR3WpREZOyLPl+VEpRj5vDRWV0YVj wn+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="JeX/eVDg"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si5748230jav.64.2021.09.12.13.42.57; Sun, 12 Sep 2021 13:43:08 -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=@gmail.com header.s=20210112 header.b="JeX/eVDg"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236247AbhILUnd (ORCPT + 99 others); Sun, 12 Sep 2021 16:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231560AbhILUnc (ORCPT ); Sun, 12 Sep 2021 16:43:32 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E11C061574; Sun, 12 Sep 2021 13:42:17 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id u16so11395238wrn.5; Sun, 12 Sep 2021 13:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ow1HoVLX+9HoNdnX4/sLVCN3K6sWaqzs/vefkU1HZMg=; b=JeX/eVDgXgXbXR2dFxLq73meQq6/0AyQLg+gujPwrPLDbdlcO9JdnZPPwfcnx7FgxU /scjLibLCTHIKgW+L230CWtTCFS6x+eyMckmZWz0YqXe/3JMXBQ4jPKphpgEB92Lzqty 3d6JOYtWJwRRQgAM8CV6QpGNHXXhGbpa1S2BNJLUTnwY3n/d+Zi263ew76S6fGdQzFu0 8Fd/otQ7l2GIXmRHRlvOJe6aB/g740Ok+Oy+dUfGvh/1LeloWI9N71jDPShjjVKGYrmS ZsUhDXb7S4svOHAeGPcEHgVVIxwmvfZ1/ck7EVhNlHuMUZ/Jk4QQjZmCogzgQ7EDjK6L pB+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ow1HoVLX+9HoNdnX4/sLVCN3K6sWaqzs/vefkU1HZMg=; b=vLo6IoYCegHWJJ/nrEihpLQBbz/9INeE8FICbGu9BvbNfQ1XZFwWbLVbr7+HVk0PMq +1t1ugNMTcPaHnymcPj8n4gtJuOfegZp0NoWu989i4+WZj71gtPpixmc9FN9AqwVOfee YGh/ZJhcuxkz1suU5IYQyfSVO74Ffk3IHwpCuw8+KVKDnUhmX/J7/6NzhC/imSvQEaVi 77o9wOUe25MoAV8mP6dmflw0J4PhJqZcodHF0pdZWnCjVGOaM0zBEB939BSjWR71ryQM eKWfZ3D3TX16Nzhxti2IKMtJcUUMqA/qxoL1jO+E+ZwaleCcLLNebAKbkpkJRnlyzihJ aGCQ== X-Gm-Message-State: AOAM530ekU78e4SVDLguhpPMkR3nMCOaoqqbw/TSYoLSYX3RDnX+hyLX vcP9OezObkpXes2M+sqIB08= X-Received: by 2002:adf:b781:: with SMTP id s1mr9027170wre.165.1631479336100; Sun, 12 Sep 2021 13:42:16 -0700 (PDT) Received: from ubuntu.localdomain (bbcs-125-202.pub.wingo.ch. [144.2.125.202]) by smtp.gmail.com with ESMTPSA id z2sm5103151wma.45.2021.09.12.13.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Sep 2021 13:42:15 -0700 (PDT) From: Chun-Hung Tseng To: paulmck@kernel.org Cc: josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, joel@joelfernandes.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Chun-Hung Tseng , Jim Huang Subject: [PATCH] rcu: replace _________p1 with __UNIQUE_ID(rcu) Date: Mon, 13 Sep 2021 04:41:31 +0800 Message-Id: <20210912204131.93206-1-henrybear327@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit replaced _________p1 with __UNIQUE_ID(rcu), which generates unique variable names during compilation. Necessary modifications due to the changes in the RCU macros have also been reflected in this commit. The same idea is used for the min/max macros (commit 589a978 and commit e9092d0), which aims to reduce variable shadowing issues caused by hard coded variable names. Signed-off-by: Jim Huang Signed-off-by: Chun-Hung Tseng --- include/linux/rcupdate.h | 44 +++++++++++++++++++++++----------------- include/linux/srcu.h | 3 ++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 434d12fe2d4f..a5ab20822040 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -370,39 +370,41 @@ static inline void rcu_preempt_sleep_check(void) { } * Converts @p from an __rcu pointer to a __kernel pointer. * This allows an __rcu pointer to be used with xchg() and friends. */ -#define unrcu_pointer(p) \ +#define __unrcu_pointer(p, local) \ ({ \ - typeof(*p) *_________p1 = (typeof(*p) *__force)(p); \ + typeof(*p) *local = (typeof(*p) *__force)(p); \ rcu_check_sparse(p, __rcu); \ - ((typeof(*p) __force __kernel *)(_________p1)); \ + ((typeof(*p) __force __kernel *)(local)); \ }) +#define unrcu_pointer(p) __unrcu_pointer(p, __UNIQUE_ID(rcu)) -#define __rcu_access_pointer(p, space) \ +#define __rcu_access_pointer(p, local, space) \ ({ \ - typeof(*p) *_________p1 = (typeof(*p) *__force)READ_ONCE(p); \ + typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ rcu_check_sparse(p, space); \ - ((typeof(*p) __force __kernel *)(_________p1)); \ + ((typeof(*p) __force __kernel *)(local)); \ }) -#define __rcu_dereference_check(p, c, space) \ +#define __rcu_dereference_check(p, local, c, space) \ ({ \ /* Dependency order vs. p above. */ \ - typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \ + typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \ rcu_check_sparse(p, space); \ - ((typeof(*p) __force __kernel *)(________p1)); \ + ((typeof(*p) __force __kernel *)(local)); \ }) -#define __rcu_dereference_protected(p, c, space) \ +#define __rcu_dereference_protected(p, local, c, space) \ ({ \ RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_protected() usage"); \ rcu_check_sparse(p, space); \ ((typeof(*p) __force __kernel *)(p)); \ }) -#define rcu_dereference_raw(p) \ +#define __rcu_dereference_raw(p, local) \ ({ \ /* Dependency order vs. p above. */ \ - typeof(p) ________p1 = READ_ONCE(p); \ - ((typeof(*p) __force __kernel *)(________p1)); \ + typeof(p) local = READ_ONCE(p); \ + ((typeof(*p) __force __kernel *)(local)); \ }) +#define rcu_dereference_raw(p) __rcu_dereference_raw(p, __UNIQUE_ID(rcu)) /** * RCU_INITIALIZER() - statically initialize an RCU-protected global variable @@ -489,7 +491,7 @@ do { \ * when tearing down multi-linked structures after a grace period * has elapsed. */ -#define rcu_access_pointer(p) __rcu_access_pointer((p), __rcu) +#define rcu_access_pointer(p) __rcu_access_pointer((p), __UNIQUE_ID(rcu), __rcu) /** * rcu_dereference_check() - rcu_dereference with debug checking @@ -525,7 +527,8 @@ do { \ * annotated as __rcu. */ #define rcu_dereference_check(p, c) \ - __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu) + __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + (c) || rcu_read_lock_held(), __rcu) /** * rcu_dereference_bh_check() - rcu_dereference_bh with debug checking @@ -540,7 +543,8 @@ do { \ * rcu_read_lock() but also rcu_read_lock_bh() into account. */ #define rcu_dereference_bh_check(p, c) \ - __rcu_dereference_check((p), (c) || rcu_read_lock_bh_held(), __rcu) + __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + (c) || rcu_read_lock_bh_held(), __rcu) /** * rcu_dereference_sched_check() - rcu_dereference_sched with debug checking @@ -555,7 +559,8 @@ do { \ * only rcu_read_lock() but also rcu_read_lock_sched() into account. */ #define rcu_dereference_sched_check(p, c) \ - __rcu_dereference_check((p), (c) || rcu_read_lock_sched_held(), \ + __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + (c) || rcu_read_lock_sched_held(), \ __rcu) /* @@ -565,7 +570,8 @@ do { \ * The no-tracing version of rcu_dereference_raw() must not call * rcu_read_lock_held(). */ -#define rcu_dereference_raw_check(p) __rcu_dereference_check((p), 1, __rcu) +#define rcu_dereference_raw_check(p) \ + __rcu_dereference_check((p), __UNIQUE_ID(rcu), 1, __rcu) /** * rcu_dereference_protected() - fetch RCU pointer when updates prevented @@ -584,7 +590,7 @@ do { \ * but very ugly failures. */ #define rcu_dereference_protected(p, c) \ - __rcu_dereference_protected((p), (c), __rcu) + __rcu_dereference_protected((p), __UNIQUE_ID(rcu), (c), __rcu) /** diff --git a/include/linux/srcu.h b/include/linux/srcu.h index e6011a9975af..01226e4d960a 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -117,7 +117,8 @@ static inline int srcu_read_lock_held(const struct srcu_struct *ssp) * lockdep_is_held() calls. */ #define srcu_dereference_check(p, ssp, c) \ - __rcu_dereference_check((p), (c) || srcu_read_lock_held(ssp), __rcu) + __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + (c) || srcu_read_lock_held(ssp), __rcu) /** * srcu_dereference - fetch SRCU-protected pointer for later dereferencing -- 2.25.1