From patchwork Tue Mar 14 09:06:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 69404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1648264wrd; Tue, 14 Mar 2023 02:16:53 -0700 (PDT) X-Google-Smtp-Source: AK7set8rdtz+Sz+arjWVBoOsH2E/wxy9sZHlQWZtnAX24KckxT/i6paXJpm+9zMPuT+mATMpFJci X-Received: by 2002:a17:902:cecb:b0:19a:6acc:1de2 with SMTP id d11-20020a170902cecb00b0019a6acc1de2mr43056625plg.35.1678785413019; Tue, 14 Mar 2023 02:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678785412; cv=none; d=google.com; s=arc-20160816; b=xAQP+OnUHf4UasD21b/gsZsAc1Xm/HBT/aUV8n0R4vVtkSwWo9qsR81A4byGmOPsKd S7IqN/SggsclIJX3upAP3HOb+fVbuu9LyHWjvdZ4UPMAG7pre4nDpm+cvL9T4oCKhLaG cEKFGm5t7hTOiaRv0ps+dYbJcpzsaf2bmQxuCXBd9Fh2JifDeb4MSfS+VhIo0unK9GAo DahX3+Tx5LTTJzcBNr1sJRrV6xNplrbOTpMJlJsBpQt3jxOpz5V4SE3XRb+l9wMUgRje BCFVjZNwqADSVCUvAREQwvGiCHl2ODXt5U/fj2QjZe3IFgPcy5RUKaodu/gUJcLFE+zw g4tQ== 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 :message-id:date:subject:cc:to:from; bh=1iBAV0ner6+LdIzA6bn1G7Qcu5OZq8ZGYjPUO1VSCk4=; b=swZjPuW7t6Icn4jnEEbNdLJU9WqFc+/4Jg9OYNgSge4D9enGjl/gC5WPBe8rf/jypW 0hIg3UFl45BOLOSUqTC+PX79io6giwwewcLIipTG6KiD5EhplIuIzHJoLld4ZjWdSY3z GlJPcGBEGzyjO+a0Otk8p4t5kxgBL52X8s3tf6IVqJMejcoPVWkBnON5mOx0Y0+sHfvJ cLlimVWSWtzucCtzrkgR2tSZj/2pMO6lCsfC5vjBFQN7mo4zjxhm6hTOcLZE0dKjXjM/ 5eAV2Qtds8uD9ZKXAyiu5uPDptkbxfCAvwKfY1L2aBx5nR2SLsJ9Q5Gh4AEjCbZbbUC4 ZFbw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a1709026b4100b001870a181f24si2087525plt.222.2023.03.14.02.16.40; Tue, 14 Mar 2023 02:16:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbjCNJHl (ORCPT + 99 others); Tue, 14 Mar 2023 05:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbjCNJHj (ORCPT ); Tue, 14 Mar 2023 05:07:39 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456452915E; Tue, 14 Mar 2023 02:07:38 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PbSN525JLz4f3mVc; Tue, 14 Mar 2023 17:07:33 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDX0R9VORBk1nWZEw--.18813S4; Tue, 14 Mar 2023 17:07:35 +0800 (CST) From: Ye Bin To: djwong@kernel.org, linux-xfs@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ye Bin Subject: [PATCH] xfs: fix possible assert failed in xfs_fs_put_super() when do cpu offline Date: Tue, 14 Mar 2023 17:06:49 +0800 Message-Id: <20230314090649.326642-1-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDX0R9VORBk1nWZEw--.18813S4 X-Coremail-Antispam: 1UD129KBjvJXoWxZr4kAr4fGr45Ww4rZr4UXFb_yoW5GrWDpr ZxCr4UGr4kAr9rAw43Ar4DtFy8Xa1DAFW5Cw1xJFy2yFn8Gw1Yv34IkFW7JFy7Wr4fXr12 qry5X3yIg3s5taUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUgKb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCj c4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4 CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1x MIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJV Cq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBI daVFxhVjvjDU0xZFpf9x07UE-erUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760334093021935875?= X-GMAIL-MSGID: =?utf-8?q?1760334093021935875?= From: Ye Bin There's a issue when do cpu offline test: CPU: 48 PID: 1168152 Comm: umount Kdump: loaded Tainted: G L pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--) pc : assfail+0x8c/0xb4 lr : assfail+0x38/0xb4 sp : ffffa00033ce7c40 x29: ffffa00033ce7c40 x28: ffffa00014794f30 x27: ffffa00014f6ca20 x26: 1fffe0120b2e2030 x25: ffff009059710188 x24: ffff00886c0a4650 x23: 1fffe0110d8148ca x22: ffff009059710180 x21: ffffa00015155680 x20: ffff00886c0a4000 x19: 0000000000000001 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000007 x14: 1fffe00304cef265 x13: ffff00182642b200 x12: ffff8012d37757bf x11: 1fffe012d37757be x10: ffff8012d37757be x9 : ffffa00010603a0c x8 : 0000000041b58ab3 x7 : ffff94000679cf44 x6 : 00000000ffffffc0 x5 : 0000000000000021 x4 : 00000000ffffffca x3 : 1ffff40002a27ee1 x2 : 0000000000000004 x1 : 0000000000000000 x0 : ffffa0001513f000 Call trace: assfail+0x8c/0xb4 xfs_destroy_percpu_counters+0x98/0xa4 xfs_fs_put_super+0x1a0/0x2a4 generic_shutdown_super+0x104/0x2c0 kill_block_super+0x8c/0xf4 deactivate_locked_super+0xa4/0x164 deactivate_super+0xb0/0xdc cleanup_mnt+0x29c/0x3ec __cleanup_mnt+0x1c/0x30 task_work_run+0xe0/0x200 do_notify_resume+0x244/0x320 work_pending+0xc/0xa0 We analyzed the data in vmcore is correct. But triggered above issue. As f689054aace2 ("percpu_counter: add percpu_counter_sum_all interface") commit describes there is a small race window between the online CPUs traversal of percpu_counter_sum and the CPU offline callback. This means percpu_counter_sum() may return incorrect result during cpu offline. To solve above issue use percpu_counter_sum_all() interface to make sure result is correct to prevent false triggering of assertions. Signed-off-by: Ye Bin --- fs/xfs/xfs_super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 2479b5cbd75e..c0ce66f966ee 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1076,7 +1076,7 @@ xfs_destroy_percpu_counters( percpu_counter_destroy(&mp->m_ifree); percpu_counter_destroy(&mp->m_fdblocks); ASSERT(xfs_is_shutdown(mp) || - percpu_counter_sum(&mp->m_delalloc_blks) == 0); + percpu_counter_sum_all(&mp->m_delalloc_blks) == 0); percpu_counter_destroy(&mp->m_delalloc_blks); percpu_counter_destroy(&mp->m_frextents); }