Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2463543rdb; Tue, 12 Sep 2023 02:41:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3U8rdWKrKyk3OKUsCUFrszpKmNt3WU086g8BsShVkJl0tOpDgOl/GLJT/gUh1jUXY/SvW X-Received: by 2002:a05:6808:d4:b0:3a7:b47a:9fb with SMTP id t20-20020a05680800d400b003a7b47a09fbmr11470970oic.46.1694511692241; Tue, 12 Sep 2023 02:41:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694511692; cv=pass; d=google.com; s=arc-20160816; b=pR3hgMVE5MsaKWC/CxLj0qqy/KjHqGqMvdzTVEU4uz86Qvvk9Z+CBeod9zbZ+6QH6n jwSs3JJfsnu6k+titS+9mWRPKHE4ku/0x59B/d9QEFQRRV6s7jTFhGSvuizJ+wx9HTWN WPwoSwogUZSEqxJcP0nBsmQ7y0O4yq4Szlc/80WNet627rhl87EpmCvg0AJhIsgR53WU DBi0SHH4TT69UVkj5ZSO4fA9DMTcnqMNYQ/ZTeY4lXDAfIqDFbCtD7Nhvs79Uq+7q+++ ai4N+zBz/7HIiYy2+3MVjdc+wVhkipm4czdjxWp5kKyc3LVwdm1Zq3wS0smPKOXK94Cl nmVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:references:cc:to:from:content-language:subject :user-agent:date:message-id:dkim-signature; bh=QSt9M3Lx9ELnykLY4hPhekC2XnMJZbCE7nsKpZmTlww=; fh=i+A9/SmgdLr1ivN4OGQCJxUKOSNOzQjO7MNr46eUFmY=; b=M9vkjAsNOuR2+Kjgb0mYqvvtUroNZAceueQ5R0bPr6i6Sy+t0Lfw1UXqFs4BAZ6aBw uQi8QRwZPZXiozVDeZVE+z50NFWcoba5SfiCRj2QxdO+kDUxJibn2ftLuFGN8tXFheeK 3jZLy54Od08oWPwvwmh9j+IeHG//i2vAyBBNo1kD7ZGMncG3N7AA+eJT/2ksdvxbEjr+ l+lFHX/EzacnCD5ZYIf+Rl0XcHq3v/UTmn7XjGiy8+OWVk80XQnB7KRK1LJekfKhHwU/ Czm2Tk2+aqb3mjr9xkaT4ekkOcYZT6O80uiO+rLx6oH5f0X6SOUdYidCFA+LurUaf8nQ rYfA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b="R1TrxI/u"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g191-20020a636bc8000000b00564c513ead5si953694pgc.445.2023.09.12.02.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 02:41:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b="R1TrxI/u"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6D88780FF2A8; Tue, 12 Sep 2023 00:22:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbjILHV5 (ORCPT + 99 others); Tue, 12 Sep 2023 03:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231550AbjILHV4 (ORCPT ); Tue, 12 Sep 2023 03:21:56 -0400 Received: from MW2PR02CU002.outbound.protection.outlook.com (mail-westus2azolkn19013052.outbound.protection.outlook.com [52.103.10.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92300E78; Tue, 12 Sep 2023 00:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6U/v+sZMPC9Ik6lQ0bbfPLOknRPqwkFiLNXU11ANZ+QSz8bp4VHZqCXjFw0YjpUhfzJZ4Y+zq028eHIX8/MutdDqFcYRQntRs8q4YzJqZAjC8joVRu44RW7XXl/W+EM/u3PamxT7IgOy0GwgZtyt0oayVbWVPldw/Nd+55lvPYQU0GRZ/Y4EGcLHkjAmvZPoaJ3a0LmN+BW6N3rUj9Kv1xusn1jrYeFAUJUJrJs36GoJ25siIA345/zA7GIF8cVaGaJ8ThR7hmjEJ0aXzhnBMYGMt2AUhImLwkR9WIrnkJ+NSsZ//PCYS1IPflVieGHVy5uVCxZIZfhwe0CeQ0vEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QSt9M3Lx9ELnykLY4hPhekC2XnMJZbCE7nsKpZmTlww=; b=GGUZ4H/zW+BFq3AabenzXZ09MXu1fCtFeNeAHa46yp9IxwcOLK42G3wIPDEpkebRYmi2Wtn9oktk+d1DHusLbqxFHFLJ6CKMTVzJc3vpjXsJf1hjEtGbJIc2Fnc5fCRCmUIqLtRYYq17lZc6FrPN2/TYfafB/0Mon6PmjhRX6WfXOsnC0iFHsNUbPrQt+cvqPmaKj4nNYu7hlYGRvbHlQfGdwr7dUY4AmndnFM1gVFfYBHUQ6EtN0PyvQEKtK+D+WMsRpez1fXPCwBzoE2JR0nI9nxl7dfv8rjC995UTIPYsnjco/9T2vbak1sAT0S/d3y5dAWjv3GRdgJGMJaY9ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QSt9M3Lx9ELnykLY4hPhekC2XnMJZbCE7nsKpZmTlww=; b=R1TrxI/uDRc1GHFj2a+jWdu00+bnAoooQaAJxxsOziJMkCbK2E2cohHf5Sahuf/BJr/wn5Oh2BDWBzg5Cg8hSfLEHQFebYG5gKUROoBH4XgK3kQEWNQOPQMewfZMLe3SKfVggKPWM2M7EU2BDhH/8xGcfrM1WZRufnBFbhxy4Y5vHDQOYo77ROVI8KBxg2ybdTa+kLjjWb27MssvaF21Wwif1JLo5EixmUk7Fqg0ATcCc0tZ9eZV9EJ0arCzd1kNzmkQFroDnesagZ8XILw0dBHHJ42L+Q/y4iDk5eJwI2qNNvAmQcOwP/TT1KHyRRCzV2zTFKO2UyaBDAYxkRC1qw== Received: from CY8PR05MB9378.namprd05.prod.outlook.com (2603:10b6:930:91::8) by SJ0PR05MB7627.namprd05.prod.outlook.com (2603:10b6:a03:2c8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Tue, 12 Sep 2023 07:21:50 +0000 Received: from CY8PR05MB9378.namprd05.prod.outlook.com ([fe80::3ea2:7971:7c79:b09f]) by CY8PR05MB9378.namprd05.prod.outlook.com ([fe80::3ea2:7971:7c79:b09f%3]) with mapi id 15.20.6745.034; Tue, 12 Sep 2023 07:21:50 +0000 Message-ID: Date: Tue, 12 Sep 2023 15:20:56 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: [PATCH V2] xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail Content-Language: en-US From: Wang Jianchao To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <63b3742c-0efe-c096-c737-a0e0419480bd@outlook.com> In-Reply-To: <63b3742c-0efe-c096-c737-a0e0419480bd@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TMN: [ykzJC+USfiPsvAzHzYzPGWj4xCtOW11n1lKnDNepfd4=] X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To CY8PR05MB9378.namprd05.prod.outlook.com (2603:10b6:930:91::8) X-Microsoft-Original-Message-ID: <59dd15dd-5b35-871d-6d3a-ec779975b089@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR05MB9378:EE_|SJ0PR05MB7627:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fae2753-c7be-477c-6bc3-08dbb360ee95 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sVCkk9f5Abex0COt34DBZJ29if8Tks1nEb5ZROJxPP2qShrmEc49+Ey0FNztJoskXWCVVfChH9XU3RhrElDhRbNIHYtcRN+eN1fCPLBeSBmGr3qUu9noM8ivumjWGIXDZkojUZWvasjqNFxrGhYSNjDaOqgFnlJb3wnnZnlxq0RK3nCcFdaCfwZY28UjMg84Q/uudZLMk18R/jtR7jNaNFhxYB0BdHKiULh0VkL2wufYwfRncL3y3cgv+gaZegqDMEUcFX4UNGV+wL/sq+66MykDkJZPrYqczIpThvEzqaYLhMFTUaSQ0CuZRH/EJwd/AQ/2n93SXZBxsX5K1xY2Emqt0IWXgcarJd5WkOhnXukfbxREcn68PyUSnGZ/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?= =?utf-8?B?MGt6ck9Rak1Wbnk3TzM2QzB2SWZ5OXE3U0liOUNnREZWOXYwRGFCK0Qxd0RV?= =?utf-8?Q?oLP/+acK4pN6/fKMHkLfvxhBPQkhgKZnbeS4vjKtHcyU=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fae2753-c7be-477c-6bc3-08dbb360ee95 X-MS-Exchange-CrossTenant-AuthSource: CY8PR05MB9378.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 07:21:50.7559 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR05MB7627 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 00:22:15 -0700 (PDT) X-Spam-Status: No, score=1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FORGED_MUA_MOZILLA,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email In our production environment, we find that mounting a 500M /boot which is umount cleanly needs ~6s. One cause is that ffs() is used by xlog_write_log_records() to decide the buffer size. It can cause a lot of small IO easily when xlog_clear_stale_blocks() needs to wrap around the end of log area and log head block is not power of two. Things are similar in xlog_find_verify_cycle(). The code is able to handed bigger buffer very well, we can use roundup_pow_of_two() to replace ffs() directly to avoid small and sychronous IOs. Changes in V1: - Also replace the ffs in xlog_find_verify_cycle() Signed-off-by: Wang Jianchao --- fs/xfs/xfs_log_recover.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 82c81d20459d..13b94d2e605b 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -329,7 +329,7 @@ xlog_find_verify_cycle( * try a smaller size. We need to be able to read at least * a log sector, or we're out of luck. */ - bufblks = 1 << ffs(nbblks); + bufblks = roundup_pow_of_two(nbblks); while (bufblks > log->l_logBBsize) bufblks >>= 1; while (!(buffer = xlog_alloc_buffer(log, bufblks))) { @@ -1528,7 +1528,7 @@ xlog_write_log_records( * a smaller size. We need to be able to write at least a * log sector, or we're out of luck. */ - bufblks = 1 << ffs(blocks); + bufblks = roundup_pow_of_two(blocks); while (bufblks > log->l_logBBsize) bufblks >>= 1; while (!(buffer = xlog_alloc_buffer(log, bufblks))) { -- 2.34.1