Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2912396lqt; Tue, 23 Apr 2024 05:42:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJCLiM70tTdAhGxejRZ4rcRuLXWaohd7tkeq01tfRtI5Kc/gtHGxCKXs/f15bsjPEsziUbjOQzWngo2fecDgc/UcHNI9L98yZ3bPcrFg== X-Google-Smtp-Source: AGHT+IF9ef7vZA4fXYLH/yvdxrCIAFhwhcHEp/hQtevGXbQG5dS+7XU9gsF9IGnwTMWekkhjHYd+ X-Received: by 2002:a05:620a:1677:b0:790:7292:b06b with SMTP id d23-20020a05620a167700b007907292b06bmr6956404qko.11.1713876127961; Tue, 23 Apr 2024 05:42:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713876127; cv=pass; d=google.com; s=arc-20160816; b=xZQw2EED6ofKsIFzK7cgcDMDUP5F22TS4oUA1S28vtVL4oZddqjz7WPhv0qP2FtUlW b+HB+v5lI+Q4ekwMRdjkgmxkWPE2E5l2H9pJCS3nCeZfEfTavmgT+Go+BF7dfxpbS4RX 3aDln+jbn52Y545V/aN5FA90talrsLxanU602ySp186yQEYypb2AiD6+R0lCkuo0aiBx wJ43kpYvL79BJY63kwrqGgqC1N2CRim93zlXRLCw2I4qkNbWrFMGwZouAPlZnz2okVoI b8kK45wwO/8fwnI9U5K0zt3X8DoWSxpSjRdpVEA4kJsGH3BhATVXhajLvLQoEi05F5QC nSJA== 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=GFoi0GMPtlKqU08nPh4EzBhnV1WaMltvy5y4TRHSTiM=; fh=Z5G3M5yVQcn3WRPSRelxkCIr3KV23nE+kWZvwcIQ304=; b=PfhUnMDqe3/RBWX0lAY/19OG/cklyfUGfGM57JzEQFVkVA/ZQVc2/u3suEL08KI2XG X0ih6Ffsvxvl18x4c7WcrvAw6IfGVTj42RrL/x5Rd0UdYDZXEKHvIUqPHuhb1IsEWjso KvJ1wKYXI/QF4u5dvgHwZJNMYDj+HQgVgoo67H4mfGu+0wNRc/oVn+d0Y+EeRLJl9eAd udO/vTgd3ICGF9FPRKheoLDpjEbNJZH5l1ZZAj7qnrmw4FltkY7CxAZEuHpKNXkjuMBX VGFzG0jvpxmk/k25JpZ0HutcCwZB27ppNV08Oc7YaoyLfZAM8kAr5yeysR5uTcey0Okh U62w==; 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-2160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2160-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 ee27-20020a05620a801b00b007906577610bsi5156650qkb.121.2024.04.23.05.42.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:42:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2160-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-2160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2160-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 5F67D1C21D3E for ; Tue, 23 Apr 2024 12:41:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6527F13443E; Tue, 23 Apr 2024 12:40:55 +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 E2C0112D777; Tue, 23 Apr 2024 12:40:51 +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=1713876055; cv=none; b=F52xvvSOYP7r7+Hmt4+lSRTgAU1VQFtOY5Ef5Vkrb86fvdqRz/l26zd2OPytXvZ9hj4KWaHoYnc281S/s6HGj7MFsNOFDR9BV3OweQwe5apNqw7HNjo/QhetXj1tey7uA3WCd/yU5QPRwNI6wr8Y6hCi3cHgeMCchAUbL9g79Hk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713876055; c=relaxed/simple; bh=t1U/InzqxiUqGU+e34imVaTcWHfcqLRThUU4nLPa18Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gpNWE+EZxpXDuk8T25qMMuTMJijkhSaqMFDz9vx5Dj7chuWaKuTs+9jJ8JeEILxekH8qqPDeMirfbsVUxsLo9PLaMWv3JjHIwrOsDVfIoXvl/GjqOxXdg8wSlKdqzRa/Rct1DmkRsmw3jz7PMpWdzphu4lzUIQlZ4QjVEw+g9g0= 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 4VP1tg4nx2z4f3kkd; Tue, 23 Apr 2024 20:40:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 7BEA01A0179; Tue, 23 Apr 2024 20:40:48 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgA3VQ5OrCdm2gAAKw--.9734S3; Tue, 23 Apr 2024 20:40:48 +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 v2 1/5] ext4: keep "prefetch_grp" and "nr" consistent Date: Tue, 23 Apr 2024 20:40:42 +0800 Message-Id: <20240423124046.974134-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240423124046.974134-1-shikemeng@huaweicloud.com> References: <20240423124046.974134-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:cCh0CgA3VQ5OrCdm2gAAKw--.9734S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr1Uur48urWfuFyfWw1rJFb_yoW8GrWUpF nak3y7Cr4rXr1UAayUG3Z0gw18Kw40gw12qFyIkryqq347ZryfJrsrtr4ruFWUZF47AFy3 uFnIy3W8WF1UGa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvCb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2Kf nxnUUI43ZEXa7IU1X_-DUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ Keep "prefetch_grp" and "nr" consistent to avoid to call ext4_mb_prefetch_fini with non-prefetched groups. When we step into next criteria, "prefetch_grp" is set to prefetch start of new criteria while "nr" is number of the prefetched group in previous criteria. If previous criteria and next criteria are both inexpensive (< CR_GOAL_LEN_SLOW) and prefetch_ios reachs sbi->s_mb_prefetch_limit in previous criteria, "prefetch_grp" and "nr" will be inconsistent and may introduce unexpected cost to do ext4_mb_init_group for non-prefetched groups. Reset "nr" to 0 when we reset "prefetch_grp" to goal group to keep them consistent. Signed-off-by: Kemeng Shi Reviewed-by: Ojaswin Mujoo Reviewed-by: Jan Kara --- fs/ext4/mballoc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 12b3f196010b..a61fc52956b2 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2856,6 +2856,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) group = ac->ac_g_ex.fe_group; ac->ac_groups_linear_remaining = sbi->s_mb_max_linear_groups; prefetch_grp = group; + nr = 0; for (i = 0, new_cr = cr; i < ngroups; i++, ext4_mb_choose_next_group(ac, &new_cr, &group, ngroups)) { -- 2.30.0