Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3304614rwb; Mon, 5 Sep 2022 09:21:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wwv7JOV4MGFzmLYJXbNmY04bPAdzCYtORQtYOtf+T1Z4DOsrT35euU2jM8x1ChDvXPm4J X-Received: by 2002:a05:6a00:24c2:b0:52e:7181:a8a0 with SMTP id d2-20020a056a0024c200b0052e7181a8a0mr50929018pfv.57.1662394905170; Mon, 05 Sep 2022 09:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662394905; cv=none; d=google.com; s=arc-20160816; b=xdaOBk8i/sGcmYGNxNRkPb4F3hK6cMwtdoVvuvr4arH+ZYLBEP/kOU0uT+5OSHZgL2 FYHpgZtNuoM+5qmjdFckh9OaHHyb5qPQ/h7uMX8GVnkubPZ5hATZglpOdUBm+2Rz8rbv ldFgqkahmg7it/3+Yp1ciJGMKJ+R+hhmgoah/wrMLJcia8pErTkehLTr1761b9y0fVNc /FB/+knjnX3mp9vUXc/AsHoSFX+Trz2i+UBLFtrnY5grKY5MohJIhO3M31/DEjv0Nm5w 7W64s+VqaCqopOE+PzCfNwDWsiTKleFCdPAKFGfQkRr+xc0yeBo2FaMe5uTE/675hk5F K8rQ== 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=0PWeM+E11fkoVMwue07w1fF1IbEgIRYHE8D1vGf/xINXYpExBjNzuvaS547vtcsYoS FOxG/mXw+KuffZt3WbSMyhPQxG0Xolrxx1BhDZOsgWPhSYQdbeSUq0JlswFw24rRBtyc vVQNvf5NWHIVjI+1z5Ib0141xs4ChVUCcZw5f3gkFAOSDINrspZ3yCbuDoLOUujzBod4 e9K2ro8dyrvDkO5P7/pycN0eQdaY/mO53Q/QQxt6dMcDVWbwFgqJq0ZIOYwMZ2aSXa74 Ng2HsFc51q+mL7y02guQNx3iPB6AApj0qUQOzhoX+RR/aGyhwHBSx/IA1XBVC7kb9IzP 2l+g== 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 e20-20020a656794000000b0041d7e887487si12132153pgr.695.2022.09.05.09.21.33; Mon, 05 Sep 2022 09:21:45 -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 S238912AbiIEP05 (ORCPT + 99 others); Mon, 5 Sep 2022 11:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238909AbiIEPZy (ORCPT ); Mon, 5 Sep 2022 11:25:54 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45DB72AE01; Mon, 5 Sep 2022 08:25:53 -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 1C35AED1; Mon, 5 Sep 2022 08:25:59 -0700 (PDT) Received: from entos-ampere-02.shanghai.arm.com (unknown [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 25C553F534; Mon, 5 Sep 2022 08:25:45 -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 v5 7/8] apei/ghes: Use unrcu_pointer for cmpxchg Date: Mon, 5 Sep 2022 15:24:38 +0000 Message-Id: <20220905152439.77770-8-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905152439.77770-1-justin.he@arm.com> References: <20220905152439.77770-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