Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp340213rwn; Thu, 8 Sep 2022 02:24:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LBosc0Rprv3mbmLBOdumbw4RxSezkmJs622SAqpSXTrDsQGfbe+i2BWLcE9BkjbYaqqSv X-Received: by 2002:a17:902:a704:b0:174:3ad5:30b8 with SMTP id w4-20020a170902a70400b001743ad530b8mr7851246plq.14.1662629055196; Thu, 08 Sep 2022 02:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662629055; cv=none; d=google.com; s=arc-20160816; b=0wqtPAxfNPYAIHazcHcel9bvlvtwAHXqeHZ5e+696NTBl+pu7diuZSKXEQfVHUW/gu MSEGc1tq2XpuXeIVya2lXRjXSMLgDaou8c3VdaTb1z/KQWUyef7J7suXr3P5xGhNg/5o ifpw8U/TQnUmOfd4DeEFVpFPYgIzq+G/TlxWvwy7L3TfNe7UNa7uSFZxAKAE3qIjg3YI QVgdDA3rZmj1NRJYS4p4w4w6k/x5TI1TvmygZ7t1vHewG9KIvIN8tyL7iee7NIECOJMG F4Q0ab7jRBMzaQN1AGlkEZMGj2gjXOIibca4WQwX4B5XDiR9eaBWipqqYAF1js0WeI0l wyAA== 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:dkim-signature:dkim-signature; bh=HLsO7kNea/ZPllJuIGUm5eeyvHOkZ4P6VFk2t1Xyfzc=; b=tFXmnpQaLNQvzyQyJksVJWQuX4VcILTsFBcCz5JXrxBfGD8xMIkHokzuvooFCKSml3 KF0FIF+qrWJG/tRaqGiOQwNyAd8C/x8zVb7W/sEFZ90gOihvc7K9BbW0I2YxbS8sXWN8 WSlKAF8oiIGeb9xv3AbBwASCWcdWOpqNd0X/EU+iz5mKy4/I6C7Fr3Oh/JLisNe59qh5 OZ5+HxmiB+3FHbDKQ2FQiuZx7Ph1elVy+ZU+r7hioz8axzjwtB7erj5/Rp1EbR367Z8b hlmlNj5Ycd+DJ2R7zBzy8xL8s21zv9VHRSg+4mnIg7BLGVGXJb6BG/twcPKrMKCgSFN1 e1Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Z5P3L4Gf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020a1709028d8c00b001727963f929si18083339plo.130.2022.09.08.02.24.02; Thu, 08 Sep 2022 02:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Z5P3L4Gf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231428AbiIHJXe (ORCPT + 99 others); Thu, 8 Sep 2022 05:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbiIHJXN (ORCPT ); Thu, 8 Sep 2022 05:23:13 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2EEE126C for ; Thu, 8 Sep 2022 02:21:50 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C6A831FA95; Thu, 8 Sep 2022 09:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662628896; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HLsO7kNea/ZPllJuIGUm5eeyvHOkZ4P6VFk2t1Xyfzc=; b=Z5P3L4GfBaCXPMg5ygyz5KtTyYhXYXnkYBUSB17dMP419p4leQmKS43hR/7IX+xPtT7A3g 3HkVgPCKid/5WzSBWU6CJa+iAkUhYgXQQEIygdgUON/uyQj99mVa8yhyDhRGcMitqIIsEE iQ+V+s8eMUYcw5xj48Gsgi603ogrhwY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662628896; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HLsO7kNea/ZPllJuIGUm5eeyvHOkZ4P6VFk2t1Xyfzc=; b=lLCCB2hnM0BL9jr0ww68zX4gA+boeSWksFeRlw2T+YhrR2KCgbm4+t80le4c8Gx0H+3esb h/3fxMe4pMlVhdBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B89A213B5E; Thu, 8 Sep 2022 09:21:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wfEKLSC0GWO0RAAAMHmgww (envelope-from ); Thu, 08 Sep 2022 09:21:36 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 0F0D8A067E; Thu, 8 Sep 2022 11:21:36 +0200 (CEST) From: Jan Kara To: Ted Tso Cc: , Thorsten Leemhuis , Ojaswin Mujoo , Stefan Wahren , Harshad Shirwadkar , Jan Kara Subject: [PATCH 0/5 v3] ext4: Fix performance regression with mballoc Date: Thu, 8 Sep 2022 11:21:23 +0200 Message-Id: <20220908091301.147-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3096; h=from:subject:message-id; bh=yFEXB/lrsmhhdUOeaq3O6/9Z2nFMTjgU96U6QVEZhaU=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBjGbQNJl4PyGv72BP2186vItijdYkKbXwnrrWVvdzr FzXJKpeJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYxm0DQAKCRCcnaoHP2RA2XSkB/ wIsggCJHhXf4BLJLdibLulBiu7tI7XCy61YuTIkabUeYFbTRoJDByMW9HtIGOIzfBVx6owF81CHF+h WJjQ+wGWhoUPdkDhuv3F6PXChlLtS8CuQ6jz1qfvSTw1vNyB7mPVPk/pyFoW7igu36IjrcwfTG0YJB KJxa3HvuP8yH9jO4pvlgEqQZcDkEoXCvrZbdVQyjVwFpaT64ZtlhcKNfKUxp6mP6dChoaNn0UTAKg0 t4LTYkAtT2Sofwd2w6/m/MD/ydrVhiYVqn2qJi/mLfKoblbsalmRLekthm4Bd1pKnGa+sVIYqFTpDh 8BmWEVyAATD2NA0a6AJeEMXDaVeptX X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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-ext4@vger.kernel.org Hello, Here is the third version of my mballoc improvements to avoid spreading allocations with mb_optimize_scan=1. Since v2 there are only small changes and fixes found during review and testing. Overall the series looks mostly ready to go, I just didn't see any comments regarding patch 3 - a fix of metabg handling in the Orlov allocator which is kind of independent, I've just found it when reading the code. Also patch 5 needs final review after all the fixes. Changes since v1: - reworked data structure for CR 1 scan - make small closed files use locality group preallocation - fix metabg handling in the Orlov allocator Changes since v2: - whitespace fixes - fix outdated comment - fix handling of mb_structs_summary procfs file - fix bad unlock on error recovery path Original cover letter: The patches fix the performance regression I was able to reproduce with reaim on my test machine: mb_optimize_scan=0 mb_optimize_scan=1 patched Hmean disk-1 2076.12 ( 0.00%) 2099.37 ( 1.12%) 2032.52 ( -2.10%) Hmean disk-41 92481.20 ( 0.00%) 83787.47 * -9.40%* 90308.37 ( -2.35%) Hmean disk-81 155073.39 ( 0.00%) 135527.05 * -12.60%* 154285.71 ( -0.51%) Hmean disk-121 185109.64 ( 0.00%) 166284.93 * -10.17%* 185298.62 ( 0.10%) Hmean disk-161 229890.53 ( 0.00%) 207563.39 * -9.71%* 232883.32 * 1.30%* Hmean disk-201 223333.33 ( 0.00%) 203235.59 * -9.00%* 221446.93 ( -0.84%) Hmean disk-241 235735.25 ( 0.00%) 217705.51 * -7.65%* 239483.27 * 1.59%* Hmean disk-281 266772.15 ( 0.00%) 241132.72 * -9.61%* 263108.62 ( -1.37%) Hmean disk-321 265435.50 ( 0.00%) 245412.84 * -7.54%* 267277.27 ( 0.69%) The changes also significanly reduce spreading of allocations for small / moderately sized files. I'm not able to measure a performance difference resulting from this but on eMMC storage this seems to be the main culprit of reduced performance. Untarring of raspberry-pi archive touches following numbers of groups: mb_optimize_scan=0 mb_optimize_scan=1 patched groups 4 22 7 To achieve this I have added two more changes on top of v1 - patches 4 and 5. Patch 4 makes sure we use locality group preallocation even for files that are not likely to grow anymore (previously we have disabled all preallocations for such files, however locality group preallocation still makes a lot of sense for such files). This patch reduced spread of a small file allocations but larger file allocations were still spread significantly because they avoid locality group preallocation and as they are not power-of-two in size, they also immediately start with cr=1 scan. To address that I've changed the data structure for looking up the best block group to allocate from (see patch 5 for details). Honza Previous versions: Link: http://lore.kernel.org/r/20220823134508.27854-1-jack@suse.cz # v1 Link: http://lore.kernel.org/r/20220906150803.375-1-jack@suse.cz # v2