From nobody Wed Sep 17 03:35:44 2025 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 19CD7C4167B for ; Mon, 26 Dec 2022 10:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231874AbiLZKd1 (ORCPT ); Mon, 26 Dec 2022 05:33:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLZKdX (ORCPT ); Mon, 26 Dec 2022 05:33:23 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B35586161 for ; Mon, 26 Dec 2022 02:33:21 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NgYz03ZqSz4f3p0c for ; Mon, 26 Dec 2022 18:33:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgBH_rFreKlj6SMxAg--.54373S6; Mon, 26 Dec 2022 18:33:19 +0800 (CST) From: Hou Tao To: linux-cachefs@redhat.com Cc: David Howells , Jeff Layton , linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, Jingbo Xu , houtao1@huawei.com Subject: [PATCH v2 2/2] fscache: Add the missing smp_mb__after_atomic() before wake_up_bit() Date: Mon, 26 Dec 2022 18:33:09 +0800 Message-Id: <20221226103309.953112-3-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20221226103309.953112-1-houtao@huaweicloud.com> References: <20221226103309.953112-1-houtao@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRAN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uYvjxU2GYLDUUUU X-CM-SenderInfo: xkrx3t3r6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hou Tao fscache_create_volume_work() uses wake_up_bit() to wake up the processes which are waiting for the completion of volume creation. According to comments in wake_up_bit() and waitqueue_active(), an extra smp_mb() is needed to guarantee the memory order between FSCACHE_VOLUME_CREATING flag and waitqueue_active() before invoking wake_up_bit(). Considering clear_bit_unlock() before wake_up_bit() is an atomic operation, use smp_mb__after_atomic() instead of smp_mb() to provide such guarantee. Signed-off-by: Hou Tao --- fs/fscache/volume.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c index fc3dd3bc851d..734d17f404e7 100644 --- a/fs/fscache/volume.c +++ b/fs/fscache/volume.c @@ -281,6 +281,11 @@ static void fscache_create_volume_work(struct work_str= uct *work) fscache_access_acquire_volume_end); =20 clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags); + /* + * Paired with barrier in wait_on_bit(). Check wake_up_bit() and + * waitqueue_active() for details. + */ + smp_mb__after_atomic(); wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING); fscache_put_volume(volume, fscache_volume_put_create_work); } --=20 2.29.2