Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp328497rwn; Thu, 8 Sep 2022 02:11:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR73Y1qmTIxs4jy8DIKTyEuUGhGGbI9DF1c0ygFBmVwAKPB17GWixxxjmq8egU7kGecrgKn5 X-Received: by 2002:a17:906:5d0e:b0:742:7a6:a1c3 with SMTP id g14-20020a1709065d0e00b0074207a6a1c3mr5156616ejt.732.1662628265722; Thu, 08 Sep 2022 02:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662628265; cv=none; d=google.com; s=arc-20160816; b=xwILv9dWyhtVtm/sT4OYN+bSbjZ+vVSJI6vc+oTXnHPkml+LZoYMdn0zX/AIY0EK03 iW9ZhxJ5H9SnMk1cR3gM7+Z+zhE7UJoD9HipWezQFTPY8QRpyjVoifIWt0Lke1qG5ADH l6heXqrr3Q7F9Bfh9LTYFq1pYQTrYYPWCyx4gZqTutT3UT0y3axwA6y101+SvP7g54PX iKZqeIJu1O6FnxaOxxvsAk+imGelgL4PGnx8hlwaoEj0HZyYEdydfGIBl7lP7SxxUwSV 2tstJysUSmf6vCKJ5rXf33e0xJVDbNPRIYnV/DXWR3Bq7cSwgzB0ramoNNvaNZ+uhlcG nVgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=obl0mTcf7xhT0XStiytJVYagY1eGg64RuTPV72/pNOo=; b=yXr1h1AMkPT66kj1TXfMCciacHZiTsS6bxPxWuiqlFfN12jZMJpOl56ZJed6OaIrSn CJoZIX5wEbYUyxbBCbqLSR6ahfuVIRfOlXcQpPsSP+gJUvOiuUM38viZuAyAyjSE+CaN 0M3y+ZmS/6MIkC9ctKGyc4cd/mg6QOJQC0PPYdTcSEJaqUn0QjB6Wlk3LBmHe6V/NsCU 8NzaGDIX6DXI7NroY9uLllDqn1j3d2Y/Xy6oN0l34Iqlqn5YIv0nj5DlGPJxXiFeDB+R hlxsDtw4nx9ZmBbkY5d+nWBTenyUmQrwpT3EyUa9XIwmalXlZcfLmfBcrJePE0e7vV1q iOyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=wPsdN3eN; dkim=neutral (no key) header.i=@suse.cz header.b=SW81Khjh; 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 bv1-20020a170906b1c100b0073dd2302a8fsi1178359ejb.724.2022.09.08.02.10.40; Thu, 08 Sep 2022 02:11:05 -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=wPsdN3eN; dkim=neutral (no key) header.i=@suse.cz header.b=SW81Khjh; 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 S229502AbiIHI5U (ORCPT + 99 others); Thu, 8 Sep 2022 04:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiIHI5U (ORCPT ); Thu, 8 Sep 2022 04:57:20 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CF1BF756A for ; Thu, 8 Sep 2022 01:57:19 -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 DC87F1F8A3; Thu, 8 Sep 2022 08:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662627437; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=obl0mTcf7xhT0XStiytJVYagY1eGg64RuTPV72/pNOo=; b=wPsdN3eNtdUTcCyAWBuD/YTG/dZhHTUpmOAwdbx8sM95T3PzdX8N9i71q1b6dTbpwYcJRJ CvBL6eZpUSSa3b2xoEzoUp1izuYBu1BaqDpuv/Mp2ZdU8OSRuqB9x4Jzt+Ic6vecMEGZ8E k0fskYYP5f4g7NF3ClBLB3Ke+pQgKj4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662627437; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=obl0mTcf7xhT0XStiytJVYagY1eGg64RuTPV72/pNOo=; b=SW81Khjh20Tc+GRypl/i6RETa56n2PRC3pUa4nd/qKHjjWkSfH7RYQpZByzXI1Tx/OZY8C jeLD29bSXTUKtNCA== 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 CBF9C1322C; Thu, 8 Sep 2022 08:57:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FLrDMW2uGWMcOgAAMHmgww (envelope-from ); Thu, 08 Sep 2022 08:57:17 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 39B35A067E; Thu, 8 Sep 2022 10:57:17 +0200 (CEST) Date: Thu, 8 Sep 2022 10:57:17 +0200 From: Jan Kara To: "Ritesh Harjani (IBM)" Cc: Jan Kara , Ted Tso , linux-ext4@vger.kernel.org, Thorsten Leemhuis , Ojaswin Mujoo , Stefan Wahren , Andreas Dilger Subject: Re: [PATCH 2/5] ext4: Avoid unnecessary spreading of allocations among groups Message-ID: <20220908085717.2kln432koqxbz3ja@quack3> References: <20220906150803.375-1-jack@suse.cz> <20220906152920.25584-2-jack@suse.cz> <20220907180507.3byq5uts42e6dpkn@riteshh-domain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220907180507.3byq5uts42e6dpkn@riteshh-domain> 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 On Wed 07-09-22 23:35:07, Ritesh Harjani (IBM) wrote: > On 22/09/06 05:29PM, Jan Kara wrote: > > mb_set_largest_free_order() updates lists containing groups with largest > > chunk of free space of given order. The way it updates it leads to > > always moving the group to the tail of the list. Thus allocations > > looking for free space of given order effectively end up cycling through > > all groups (and due to initialization in last to first order). This > > spreads allocations among block groups which reduces performance for > > rotating disks or low-end flash media. Change > > mb_set_largest_free_order() to only update lists if the order of the > > largest free chunk in the group changed. > > Nice and clear explaination. Thanks :) > > This change also looks good to me. > Reviewed-by: Ritesh Harjani (IBM) Thanks for review! > One other thought to further optimize - > Will it make a difference if rather then adding the group to the tail of the list, > we add that group to the head of sbi->s_mb_largest_free_orders[new_order]. > > This is because this group is the latest from where blocks were allocated/freed, > and hence the next allocation should first try from this group in order to keep > the files/extents blocks close to each other? > (That sometimes might help with disk firmware to avoid doing discards if the freed > block can be reused?) > > Or does goal block will always cover that case by default and we might never > require this? Maybe in a case of a new file within the same directory where > the goal group has no free blocks, but the last group attempted should be > retried first? So I was also wondering about this somewhat. I think that goal group will take care of keeping file data together so head/tail insertion should not matter too much for one file. Maybe if the allocation comes from a different inode, then the head/tail insertion matters but then it is not certain whether the allocation is actually related and what its order is (depending on that we might prefer same / different group) so I've decided to just keep things as they are. I agree it might be interesting to investigate and experiment with various workloads and see whether the head/tail insertion makes a difference for some workload but I think it's a separate project. Honza -- Jan Kara SUSE Labs, CR