Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1476543rwb; Wed, 28 Sep 2022 20:00:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78e5DkoizNPxcUfIdgFhC5xmN/bDsDuCFH/1XEVNFh0INytrB0DCMi+xxGG9IxioIIxaf8 X-Received: by 2002:a05:6402:34d0:b0:458:a4a:6dd0 with SMTP id w16-20020a05640234d000b004580a4a6dd0mr1076440edc.297.1664420428009; Wed, 28 Sep 2022 20:00:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664420428; cv=none; d=google.com; s=arc-20160816; b=Vdj2ASe31RiMvaUeFJZMjQU+m8cCVesoecB3mwI3dYn3Euyd+tJOliK+c1Oj/X332C ti20F3IsXoIkrfI8f3V8DH7b9hAHEq1kgEX054i2HlYUUb0DQebnUSxmSpfOi2Z49JJS ztWQEPgJelVyZosdvIKdNNzm92qa8poRpIP/Y4hnvViY8rjZlNMCGpOcEgqKhyysz5Y5 r7GPm3rgoTTJDmYLkOEFCkRYJNPWavarYPp6QlUpqR8L0+fRv+7u9xoL0NL8hDYtvC2k nIGgPJ1b8f4MeQC6W0p1SN1LgGOYfqMI6YpvD68ipT/KTeLe446ANuaJV/pcQqr6GoeY PAAw== 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=ZHUCezWFquleysbysB3iWDIqJA3y3EcH7wDsRrS+vj8=; b=VhIDKqgGsiYXc1O5upiPJtO86N/upX1lykFZmonc/kRGNNUOx+QS6+PeOOYXcpOx0S rOYu//Y5w92RBdRDu1PJ92Nb2SpxP4IATdATj9VbGO1CGLfddUIgTs4IhSnxXQ9XcNw9 CY8CYGfEETKeUFQK2jGjxTxMKaX2ebyo0lR9zYHSMmg7gNWZVNH20dBfhmjPrwySlUV6 9TEyR5i2V0qB1P9ha7KhCx+7++rF4rIfQ3BwdPjk2x3TglT/6OGFem3f8PXhATx652Tx pPBhfuCcdvEafJJryv7cAq5L0pSF/C5tqWxYKiOsqBVIhLvFrj7CBFwl+cse4UizY5SN TAgA== 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 g10-20020a1709065d0a00b0077b21283d09si7415943ejt.349.2022.09.28.20.00.02; Wed, 28 Sep 2022 20:00:28 -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 S234761AbiI2CjT (ORCPT + 99 others); Wed, 28 Sep 2022 22:39:19 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 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