Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4902174rwb; Wed, 17 Aug 2022 07:53:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qi5FGheEmoJdgH/N7fXdHC/Nm3iXGCZaI7vdSzHFm1w15DmfgclTtlXOnEjl8YKfGeC4G X-Received: by 2002:aa7:cb92:0:b0:443:98d6:20da with SMTP id r18-20020aa7cb92000000b0044398d620damr15748328edt.399.1660748035756; Wed, 17 Aug 2022 07:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660748035; cv=none; d=google.com; s=arc-20160816; b=MAOMYDVog5ZYl8JtbfeFub46EjPb1jaDO8IjiCKjai/I2O0tgy7skHKvuuJflfhxMW BHYs8TSLm3F9IPv634G5MnNxzbvZN1yxXS45/zKkBMX2tiqG22ummcZpgox2vULv4beV MJpQyedwtUB7DHeR3Qma1uGpq9vBCGn97DOlpPx4Zctsm4mODDJ0tM/WGBL8LuoAVUqA I8R1xAzmwOWq/UNICrC94eg5091bpTqJzeT5QFVoqabIKW1qiswyK8GSxdCgf9XQUukX j4fvcYqzuQor5JfWctKDBnpu1HtnFX6MOm2mcJ5pOZWuiVTCeQh+cAf7dth7dcpIbHci YLIQ== 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=9mHJpzm7z8DXJUQYDUzbOwMqU3LXK/UA1FlwX6pQyeg=; b=Y7cr5teQ080Badit6TecKxjypjSFs1UGahl+wlaOt+EyUqPR34W7O/rNn3g9Nxrykn e4upH6PuCOs4FWl75PMpoOyi9DrRCM/kyU3E7S+DTLMp6ae1dCzlLNEokfqW/K2lAgAZ NuFJ9zrcH57xyaLw9NekNqDCKClGW2oPA4oUHXVFVae+nYRdal0PXiP3X4xr3+e96xtA 3FUL2ikf7dYVPylBpOGHHdNXM0BstyMS+6OCLp5UXT3H1bJBO6YBuKbG97N/8jm2Tu1y GbLe3ssaheJuS42y0TbWLGYfb9LRBuiVFYMe7JuWIDqtMiV3hRi+GYy06QzUFwRqMVlD uwlg== 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 z10-20020a17090655ca00b00730ab71fb4esi11508943ejp.561.2022.08.17.07.53.28; Wed, 17 Aug 2022 07:53:55 -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 S240189AbiHQOgd (ORCPT + 99 others); Wed, 17 Aug 2022 10:36:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240242AbiHQOgG (ORCPT ); Wed, 17 Aug 2022 10:36:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B85DD9AFB8; Wed, 17 Aug 2022 07:35:59 -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 C11C415DB; Wed, 17 Aug 2022 07:35:59 -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 B50A63F70D; Wed, 17 Aug 2022 07:35:52 -0700 (PDT) From: Jia He To: Ard Biesheuvel , Len Brown , James Morse , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam Cc: 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, toshi.kani@hpe.com, nd@arm.com, Jia He , kernel test robot Subject: [PATCH v2 6/7] apei/ghes: Use unrcu_pointer for cmpxchg Date: Wed, 17 Aug 2022 14:34:57 +0000 Message-Id: <20220817143458.335938-7-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220817143458.335938-1-justin.he@arm.com> References: <20220817143458.335938-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 9272d963b57d..92ae58f4f7bb 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -144,7 +144,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; @@ -834,8 +834,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)))) { if (slot_cache) call_rcu(&slot_cache->rcu, ghes_estatus_cache_rcu_free); } else -- 2.25.1