Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5357891rwn; Mon, 12 Sep 2022 07:59:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR4MEEC1ueswqFAV6ZCvApNwAheN1YQRGPtjj6wRWXKhDuUtALyTcYHRtSybN9Rg++qmsx7Y X-Received: by 2002:aa7:c44b:0:b0:44e:e6aa:1558 with SMTP id n11-20020aa7c44b000000b0044ee6aa1558mr23142754edr.263.1662994747665; Mon, 12 Sep 2022 07:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662994747; cv=none; d=google.com; s=arc-20160816; b=c36nPMka34qRSh/KeX5zJNuN9WCrbHnKOX79lIDM/Rkzxr0M7enE7wChA9+HC8VCml jiaNDecqh49O2qlPjHjM0JNZ/t3KGvQqZ3PSbPB+1JsYibB7qGP6uT2UwrkxpayU+isX LydHCvDi8GEZo/oQakfpDgHqOyRo6yvDxtiKuqGbDYdE+GPAZPXf9CW/A2MHGQx8HpJN k5JyO68CTxNlOH8Z7oa1T4DkLClZ+cDy2pAUc/EF/Dw/m3s0ABY0k31OW4J7BX4ztBA4 yV/Wxp4TbmslG3iFE4GSbNvefQIgsRd6PrjFG95mGOtR834cjn1fPLeQQq/1MIOMUkE7 WU4Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=//KhcB414qaJElzmOccJitXWV0XYN7vZWY1a7dDJmC4=; b=ZKK6zzeoCtiYSMM/xgxd0yoDJmuHo1nO/1rRIqDNuzgMF1pzhgHKvru0BgZxTjzUdk tw5qMrNDVhmy+/SQeYoawmwkkezHHSebqMCxbEIqY1XgNHhU/yLENi3RLw2glxjVX2q8 ArfBem2kde2Lo0EzQbl2pzOedL1Qkz34wGbXS/CfwU5/QumG3JYBCoRL5A79IkBlj7OF etVGh3apRMceJl3SRuAOl94ft6Hu/qQ5B5lT1F3OoSpZA6ROmbT8nJdvGbxo9E0z+awu hNVQbKV6Xs5Q94SPB2egbsUUbskSpFAcZCFVzzIN5CdOFZcawv1vL/EtPJ/C0V5w3L3s rrRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb17-20020a1709071c9100b00779dcbe3ac8si7117652ejc.8.2022.09.12.07.58.41; Mon, 12 Sep 2022 07:59:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbiILOmp (ORCPT + 99 others); Mon, 12 Sep 2022 10:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbiILOmI (ORCPT ); Mon, 12 Sep 2022 10:42:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F9653A15C; Mon, 12 Sep 2022 07:41:58 -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 8AF21113E; Mon, 12 Sep 2022 07:42:03 -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 75B6F3F73D; Mon, 12 Sep 2022 07:41:50 -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 v6 7/8] apei/ghes: Use unrcu_pointer for cmpxchg Date: Mon, 12 Sep 2022 14:40:04 +0000 Message-Id: <20220912144005.212624-8-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912144005.212624-1-justin.he@arm.com> References: <20220912144005.212624-1-justin.he@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 4af269b22bd4..c0b09addb96f 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -153,7 +153,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; @@ -843,8 +843,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