Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2987288rdb; Tue, 12 Sep 2023 20:19:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEb+g72L5iOAmHFUuoearegEcVGzGrmpaFIJRt5+zK8fq+KBwNRbM+8fPCCwELYnMUoTenj X-Received: by 2002:a17:903:41c4:b0:1c3:c687:4789 with SMTP id u4-20020a17090341c400b001c3c6874789mr1712580ple.64.1694575150404; Tue, 12 Sep 2023 20:19:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694575150; cv=pass; d=google.com; s=arc-20160816; b=Ni1kb5WfA67yGSmNFs0C3O5yuce+SIuqdS9pbtV/F63aOL9t9wdgok0bYmBrThojaA OMq1H6cOksSQIdXmuIGPbvAo27xrT1VSKGty8M54TgXcSYWrjkjxAMvpC9WgKLkltrWN V/KeL2vufe0beBoiwAW1EHyY1qr47mJJyaB54C85Uzu2efmlSuZn8yRqnC5+j/pLUT2P 7fCua6/A8WKqQzqx2f2gn/ZItmezWercJZmGGQeBBwV1Kc88PmQJGopH4Fx7ZOQ65sM8 hfZnRW3eJ9WPxH1bAkZdqH8vxtMe0G1gZt907Gy8VpYKh8kuWGLcWfT2sLr87C+iyH3i pcDA== 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=eRG3Jb8bb2nP0BTsCSJTBgtYqBy1CerpCSU9FgeIhCw=; fh=i+A9/SmgdLr1ivN4OGQCJxUKOSNOzQjO7MNr46eUFmY=; b=vdmH8RVYcqoQCjhqtsS8MyCyKh5xGE/DRgws7fNsF906idF/ecYisaZLpHqJUxb2g7 WXKrjb3YVSxZvqwKmsTaaZ+xnD0GRibCNxC74ywkaJ7DlU6pJg1Q+Tc2tGPsZCluWvVP 3VYA23WAFQ+qlRsXzP+5BMrhEmvLU+TfMDauIzYj7FEEARRjtJP4bNyIXq+n4tthSgnE jCy2jBpFn41S+Zi6yXSJR4keTVLCmwqJ1rZ8DPa9i0XzQb9QUE9fWHMAaZrBR/3ZgigQ UhRtpi7g6YzUmTNgoscW/i9PnW9rsQATtYzKo58UK+faL7nbesr3mUDqXPqFa4RHvrD8 1olg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Po1cWBLW; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l15-20020a170902f68f00b001bd9e2b4b46si9649145plg.601.2023.09.12.20.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 20:19:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Po1cWBLW; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 00201824299A; Tue, 12 Sep 2023 18:39:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234247AbjIMBjd (ORCPT + 99 others); Tue, 12 Sep 2023 21:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231204AbjIMBjc (ORCPT ); Tue, 12 Sep 2023 21:39:32 -0400 Received: from CO1PR02CU001.outbound.protection.outlook.com (mail-westus2azolkn19011016.outbound.protection.outlook.com [52.103.10.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 431D7115; Tue, 12 Sep 2023 18:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ih72f4B6CwQSXVjY1exJx/pBm0reLDd4NfQTyxZt+SPmF3Meuv1Swlvke7QRQa0fuWjsMwPKYL2xdU9E9witss6ubwc7bi7pxFpLGNn7r59xyvGO1MRTLeEBfouYnQfVnXjgq7jll5YGIUs7OXLXHocHJgcwqGfccd7uR/7CFd5eu7UJte8lJvduEEXnK4GYy3IqzIF9DDjHBBPpXs2Nno+gjYGLea+332HsSlrGnTy3ZQ7TaCT2DO5vP8fifSqg89mN4v0CMIpCbUSFXNKNAnnSSQGl9MqrGTH3F09j231bCq0UkWmcHAMj/sqMEUAJVaei3pe928rF9r8WgbmtpA== 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=eRG3Jb8bb2nP0BTsCSJTBgtYqBy1CerpCSU9FgeIhCw=; b=LvaZZkQ1zQVsWBUV9LNhGhNqFs9nbV/14KXDKY/cNcdOzeJ94MxttOvmyn75qYvGNSkT4IA0yAYt8UqUQqkLi9fObFCOKZJ9MJ6CLYiZN6efzjXiBxLl2ZUekmpo/Y5mduGz5NZrarApnAiv3NpZjYwhe20Yq58i+1QMBtiKtLxUuRly2xh5rjbye1K5lI6YdLweravD3kLKQ1jRU3nnVC3iJhKFJLb4B+wXRGzDP1sWk90QpLxqJuU9zvvlh8Tn5UX6ioktU020iLX8zi6SRTec3pis622nWLEXKzO/EWROKQ0ut16b6hmh5MICsiqW1o01vainOyPVCi7BA8OKCw== 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=eRG3Jb8bb2nP0BTsCSJTBgtYqBy1CerpCSU9FgeIhCw=; b=Po1cWBLWeJ7DP3hJKLFlkpN4nntzaR/s35KyTYL7kyeCMV/d6Um6+JZYMsf2GMI407ZZCEjBWf+dBHwYXUqmcAFWm6hu34shwn5hEKisn91MRD0dMEBPGLGbc0XMW0RVQO5iJ5mcuJWgHyhOt1DoCeRx2d7NxeCaWPajrFk7qcPKTn3II8O/IhnjeXSOtouNYkg6q1zFjGOgi78Zw5YW6vhPFRYOijs5sqF34k3MitcFXPjFMGgtcnY+UTlf02qkP6LqDUkoTseU67a4aehLNVMFsGgJ8Eh8PqeS4z8LKiW3VMsFXO40KQe5zTFvqBlW3TGHriyWmXvpfowFx65jEQ== Received: from CY8PR05MB9378.namprd05.prod.outlook.com (2603:10b6:930:91::8) by SJ0PR05MB7801.namprd05.prod.outlook.com (2603:10b6:a03:2ca::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.38; Wed, 13 Sep 2023 01:39:26 +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; Wed, 13 Sep 2023 01:39:26 +0000 Message-ID: Date: Wed, 13 Sep 2023 09:38:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: [PATCH V3] 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> <59dd15dd-5b35-871d-6d3a-ec779975b089@outlook.com> In-Reply-To: <59dd15dd-5b35-871d-6d3a-ec779975b089@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TMN: [rJLQNKwNUuvPFL1yeDcZ6fPrcdRBupt03dBDEVDaMEE=] X-ClientProxiedBy: TYCP286CA0048.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b5::11) To CY8PR05MB9378.namprd05.prod.outlook.com (2603:10b6:930:91::8) X-Microsoft-Original-Message-ID: <0a72f462-8b8e-4dec-6ce4-f52e33423957@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR05MB9378:EE_|SJ0PR05MB7801:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a4d7f4d-950c-4bde-b3ff-08dbb3fa436f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rZaDU6nr2nZxd9aug41VZGrpZPKPUUsDRfSICTSWd60z/302xLXQpTRqgL98F0vOKdlKax1VIQdD02Zivog2tVE2544k4yxBJ2R6/k3m19asuBigiaI6AYefZL9i7otWHSLZqBWWBsOoMhYZvMP8OXWunAfGmlhWBuXFW8IHAlR6KnGtDV+1ub7HQY9i5L0G+xoVPimXGvoBErygBEZMUIJ5pgKaOLoXJfGR+nhZ0wlt+/D3V76bOi13WySzf+tA6tGLITb5rg7PvtC9u0K7+drKkN4EPTNVIGSaaf6tpcVOZI4EsmLuu4dNO68rN7GnBenSo7dBo4rFwjwa796e3IlfRSMA1JFssh6Ror4WxXtSZIj3toS5/F+/NMhzDi1/Ez4iPxBENRLpQ7M4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B?WG9NM0k5d09qVm40ODZFdHVJamxBZUlMdUppNnBBekREUEdVaUs0bGFnem1i?= =?utf-8?Q?uGitnokdT6GjfGx6zEPtlq8x9BWqzlQDdeIdWADtL3YM=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a4d7f4d-950c-4bde-b3ff-08dbb3fa436f X-MS-Exchange-CrossTenant-AuthSource: CY8PR05MB9378.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 01:39:26.3027 (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: SJ0PR05MB7801 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 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 18:39:35 -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 autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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. Reviewed-by: Dave Chinner Signed-off-by: Wang Jianchao --- Changes in V2: - Move change log below "---" - Add reviewed-by Dave Chinner tag Changes in V1: - Also replace the ffs in xlog_find_verify_cycle() 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