From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23B38C04A95 for ; Thu, 29 Sep 2022 02:39:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234877AbiI2CjR (ORCPT ); Wed, 28 Sep 2022 22:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234784AbiI2Cie (ORCPT ); Wed, 28 Sep 2022 22:38:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC293125DA6; Wed, 28 Sep 2022 19:38:32 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8394D1480; Wed, 28 Sep 2022 19:38:38 -0700 (PDT) Received: from entos-ampere-02.shanghai.arm.com (entos-ampere-02.shanghai.arm.com [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2A9463F73B; Wed, 28 Sep 2022 19:38:24 -0700 (PDT) From: Jia He To: Len Brown , James Morse , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: Ard Biesheuvel , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, devel@acpica.org, "Rafael J . Wysocki" , Shuai Xue , Jarkko Sakkinen , linux-efi@vger.kernel.org, nd@arm.com, Jia He , kernel test robot Subject: [PATCH v7 7/8] apei/ghes: Use unrcu_pointer for cmpxchg Date: Thu, 29 Sep 2022 02:37:25 +0000 Message-Id: <20220929023726.73727-8-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929023726.73727-1-justin.he@arm.com> References: <20220929023726.73727-1-justin.he@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ghes_estatus_caches should be add rcu annotation to avoid sparse warnings. drivers/acpi/apei/ghes.c:733:25: sparse: sparse: incompatible types in comparison expression (different address spaces): drivers/acpi/apei/ghes.c:733:25: sparse: struct ghes_estatus_cache [noderef] __rcu * drivers/acpi/apei/ghes.c:733:25: sparse: struct ghes_estatus_cache * drivers/acpi/apei/ghes.c:813:25: sparse: sparse: incompatible types in comparison expression (different address spaces): drivers/acpi/apei/ghes.c:813:25: sparse: struct ghes_estatus_cache [noderef] __rcu * drivers/acpi/apei/ghes.c:813:25: sparse: struct ghes_estatus_cache * unrcu_pointer is to strip the __rcu in cmpxchg. Reported-by: kernel test robot Signed-off-by: Jia He --- drivers/acpi/apei/ghes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 11a503f2260d..803e9d9867ca 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -151,7 +151,7 @@ struct ghes_vendor_record_entry { static struct gen_pool *ghes_estatus_pool; static unsigned long ghes_estatus_pool_size_request; -static struct ghes_estatus_cache *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE]; +static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE]; static atomic_t ghes_estatus_cache_alloced; static int ghes_panic_timeout __read_mostly = 30; @@ -841,8 +841,9 @@ static void ghes_estatus_cache_add( } /* new_cache must be put into array after its contents are written */ smp_wmb(); - if (slot != -1 && cmpxchg(ghes_estatus_caches + slot, - slot_cache, new_cache) == slot_cache) { + if (slot != -1 && unrcu_pointer(cmpxchg(ghes_estatus_caches + slot, + RCU_INITIALIZER(slot_cache), + RCU_INITIALIZER(new_cache))) == slot_cache) { if (slot_cache) call_rcu(&slot_cache->rcu, ghes_estatus_cache_rcu_free); } else -- 2.25.1