Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3339545lqp; Tue, 26 Mar 2024 06:46:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQAy5OCmNx3viTj4I8PHSW/04X4DgezkClTNLre3o36UBBIFXgg7jBO7Zam4rUveGs3gCvJKWPX/EhvoZJ7UI7fhChBDC6Fzg8HFPauQ== X-Google-Smtp-Source: AGHT+IGv2V4YQhjbNi+3MBTlzzeJTPQstSc/qmWCEa+yY3MBjm5f/n6oWcV0Vubn+kPWlpy27k67 X-Received: by 2002:a05:6214:27ca:b0:696:7fc8:b841 with SMTP id ge10-20020a05621427ca00b006967fc8b841mr2049315qvb.16.1711460795888; Tue, 26 Mar 2024 06:46:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711460795; cv=pass; d=google.com; s=arc-20160816; b=ac9MZwLBcv/qkGoIcXi1IZl/xBtzUQC+GWYvp3ePwTc1QrIdcpeN7XqrG1J57OcXzK EUe2bZSA4jApS5BrUHHadnyJqSIQh1gbihW84wLl9Wf8mBiKnIMqalYlI6//BX+QkwBi aU5qjyuEjukkpWPmb6NEV44S7cN0zWR5bcy+zm6vWHuuBrCkWtLBYLkx8M5v9Bw2tQtz FAT4tGE/n9rbUWlKVDHQMbarRacQBh06DOWWhVzXzefySwwEOnXai2FWQbG9tXUNAldQ ieujT/WlfASvlMhuksjPBgdxvXjKRGK9VllioGVloSiA6Jm85SoD8IoiAova41god11z vOAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=shrumq9qIrcE7kSyqf1wntLpPRMKGswyD524ZGOydLc=; fh=Z5G3M5yVQcn3WRPSRelxkCIr3KV23nE+kWZvwcIQ304=; b=j+Q+VbglelSTZHxLEX0OZV/WIcHFKshO5bxli3N5948a7XjBpI02FAZsLaH2eXHTvS /0QgrmfswlrJE+Jt7bgEelgCq827scF+pgCQuwqmq/D5ay3CSSi0NwbPzNNvkr3quXgB E8Ar0RmY5YZdRIxUffkxojc9St6p6Yp277BlTayKsWUSbXZTWtDLwdN/axvv426i4ENB MCSm5lI29uc3v7PdyUYTkttHq30E10B3bimCCAhNN7HpdHOTXenrCpKUzTeMwGpiOJiW Jn/fV/Tkoe6W8DTDzdiJ0WqXpkd7+S9FQoYjyxRWBl6wTOXsesqkgW/GHDgy0M7tDt+7 PMmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1755-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o3-20020ad45c83000000b0069684f7c393si6129095qvh.563.2024.03.26.06.46.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:46:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1755-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9CAE81C3E9F1 for ; Tue, 26 Mar 2024 13:46:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFC8012C54A; Tue, 26 Mar 2024 13:42:25 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D8AE12AAF5; Tue, 26 Mar 2024 13:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711460545; cv=none; b=M9MFq28UbTFA3koJMRFLaOJlLp2wIPptA/tB8gMMfH5ew1EwAfqqDLwPcCyjUhe43AnQlRFiXnbZAmW2gmbWgetzEN3A0F8+crl/xk2bNoT1RG5o7AAB6pqbRl44UkusmtHImZrLQcDdUoRMmV2n6E8Cw6uhS64oHFyEsqEoAMY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711460545; c=relaxed/simple; bh=rTsyKJ+6cQulWFeCm9Ty6fR+GXC23ReLWDU/rqmdMYk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=THuwM3QZ7ey4/RipYcSejN4114j2lAE7jFYgn0lndHl0kvQlDgcj65hq3rx4VnmLVEYYrvXXe4vbjB3b6SWrlAl28TPzu2414QHT0kN6kGO5Wl4Z4UtfmCPi0aoa50Bql4agBnMF6fVA0hSY5PwGQQsD2FFlUEX0bVoAA+8KBcU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4V3rZW3QSMz4f3nKG; Tue, 26 Mar 2024 21:42:11 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 92DBF1A016E; Tue, 26 Mar 2024 21:42:19 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgCHowy00AJmmQiSIA--.63567S7; Tue, 26 Mar 2024 21:42:19 +0800 (CST) From: Kemeng Shi To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jack@suse.cz, ojaswin@linux.ibm.com, ritesh.list@gmail.com Subject: [PATCH 5/5] ext4: expand next_linear_group to remove repeat check for linear scan. Date: Wed, 27 Mar 2024 05:38:23 +0800 Message-Id: <20240326213823.528302-6-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240326213823.528302-1-shikemeng@huaweicloud.com> References: <20240326213823.528302-1-shikemeng@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgCHowy00AJmmQiSIA--.63567S7 X-Coremail-Antispam: 1UD129KBjvJXoW7KFW3Xr1xGFyDJFykWrW5Awb_yoW8ZF43pa nxGFy7ur1xWFn8GFZ8Ga9Yg3WfKw18GF1UAryfG3s3tF13Arn8GFW2yr10vFy7GFZrCrnx Xr45AF1UC3Z7CaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBIb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAv FVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJw A2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE 3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr2 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU058n7UUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ Expand next_linear_group to remove repat check for linear scan. Signed-off-by: Kemeng Shi --- fs/ext4/mballoc.c | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 0f8a34513bf6..561780a274cd 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1075,31 +1075,6 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac) return 1; } -/* - * Return next linear group for allocation. If linear traversal should not be - * performed, this function just returns the same group - */ -static ext4_group_t -next_linear_group(struct ext4_allocation_context *ac, ext4_group_t group, - ext4_group_t ngroups) -{ - if (!should_optimize_scan(ac)) - goto inc_and_return; - - if (ac->ac_groups_linear_remaining) { - ac->ac_groups_linear_remaining--; - goto inc_and_return; - } - - return group; -inc_and_return: - /* - * Artificially restricted ngroups for non-extent - * files makes group > ngroups possible on first loop. - */ - return group + 1 >= ngroups ? 0 : group + 1; -} - /* * ext4_mb_choose_next_group: choose next group for allocation. * @@ -1118,12 +1093,12 @@ static void ext4_mb_choose_next_group(struct ext4_allocation_context *ac, { *new_cr = ac->ac_criteria; - if (!should_optimize_scan(ac) || ac->ac_groups_linear_remaining) { - *group = next_linear_group(ac, *group, ngroups); - return; - } - - if (*new_cr == CR_POWER2_ALIGNED) { + if (!should_optimize_scan(ac)) + *group = *group + 1 >= ngroups ? 0 : *group + 1; + else if (ac->ac_groups_linear_remaining) { + ac->ac_groups_linear_remaining--; + *group = *group + 1 >= ngroups ? 0 : *group + 1; + } else if (*new_cr == CR_POWER2_ALIGNED) { ext4_mb_choose_next_group_p2_aligned(ac, new_cr, group); } else if (*new_cr == CR_GOAL_LEN_FAST) { ext4_mb_choose_next_group_goal_fast(ac, new_cr, group); -- 2.30.0