Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp629306rwb; Thu, 6 Oct 2022 02:10:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VuuI9hGbIJncrLzHGkU7G6ZESMmimYKSp/aYP3e7vdr1dJRmUi5/eho3vjegsg6c/sxlD X-Received: by 2002:a17:90a:3f86:b0:20a:e7dc:340a with SMTP id m6-20020a17090a3f8600b0020ae7dc340amr4231843pjc.157.1665047406272; Thu, 06 Oct 2022 02:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665047406; cv=none; d=google.com; s=arc-20160816; b=SZ0idAbbOSSx+re7/w/r2BaA4xgQhCn+T9KrVx2sL6ddbjnWw1/+EUnXSPYI8tdcFN 6Tw49DV2DTjBmfEBLy/j6ohq6wxJmNQVIk9qLsB84/5efDqxffWWoamfW5R6K0wZBbbG TzN2UiIPSG8pdaiX1vl+0cN85ptGeYmcKPlvPoexFsobFbVWo2XhUjGdX9Cd5Ydzxbkj PKTmrCLziIiQBfu63DFqmBG9Q9UHGzeRM7vBEPHfwX6EyCZ5avtEmHvdR6v+AtRuagkd riWbioSzjltY1ohZcmmfhyQ8nHHZmVtSWCeB880BF8wrVXmvDA7ORg3LDunF0zndP+ex iWaw== 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=c2icCegbf3s68u8LLC7CDK6sFXkipsoPomf5JYEyME8=; b=rV5iKD8BzerwcnhmGzyI+lIHhOY3bHgT+qYYA+U8TnbWztPn7V1W/NWvdnqh/vjifQ KQaQzO+dTNpQKtU8CyrYBoka/BIL1FroCULqW/zcJmEkB3KrjBrPpWnwo2GXJ56Ao7OV 4A7KuFmciU4u4Cwsd8euRySJTBkGWSUyzQTpTYbjK9cH4utvDQUogJ8KD9wmEU52M4hA xpOthnr9Qouf+IeUAeOZaZ3x90k0kxOqEKMGYy9TnTlwuhSe4/Qb2cx3Io6Vm9phe+u1 KTAYKU5X0dE1/Ezv+4Vc+19cfKIPXWDSOTIWNnnz/SSeiEop5tpgZj76MSJ784pjiBbT vLpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=FJUidb+0; dkim=neutral (no key) header.i=@suse.cz; 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 d7-20020a170902654700b0017f8723b451si2947481pln.427.2022.10.06.02.09.44; Thu, 06 Oct 2022 02:10:06 -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=FJUidb+0; dkim=neutral (no key) header.i=@suse.cz; 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 S230450AbiJFJAK (ORCPT + 99 others); Thu, 6 Oct 2022 05:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbiJFJAG (ORCPT ); Thu, 6 Oct 2022 05:00:06 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC7C17A9A; Thu, 6 Oct 2022 02:00:00 -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-out1.suse.de (Postfix) with ESMTPS id 823FF219F4; Thu, 6 Oct 2022 08:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1665046799; 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=c2icCegbf3s68u8LLC7CDK6sFXkipsoPomf5JYEyME8=; b=FJUidb+0ergppSUrx7cQDbhiIQcMRsczrqHma3foEVz42iT+qPh2s8xjOCyr+sxCLYIKSx 3R8gROsg13SSjPjEC8TrHWn+G6dWyDhIOU0gsAzoUncZWoS4tsidJhZDMiCshHApVjQ8S5 5mFNzEy5rVT9QHz8K28hS9yvoW1+yyg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1665046799; 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=c2icCegbf3s68u8LLC7CDK6sFXkipsoPomf5JYEyME8=; b=Esw09XR3njIjsZGo1r3XPs3KFL9nw1tZS5R4IFhDcmvexygHKGn7+L/RYWtsGoAl0X7wjn U6EA8p0I1RgeeiBw== 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 5D7811376E; Thu, 6 Oct 2022 08:59:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lCbPFg+ZPmNNRQAAMHmgww (envelope-from ); Thu, 06 Oct 2022 08:59:59 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 8B59FA0668; Thu, 6 Oct 2022 10:59:58 +0200 (CEST) Date: Thu, 6 Oct 2022 10:59:58 +0200 From: Jan Kara To: Ojaswin Mujoo Cc: Jan Kara , linux-ext4@vger.kernel.org, Theodore Ts'o , Ritesh Harjani , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Dilger , rookxu , Ritesh Harjani Subject: Re: [RFC v3 8/8] ext4: Remove the logic to trim inode PAs Message-ID: <20221006085958.l2yfkqkupqsxiqbv@quack3> References: <20220929125311.bmkta7gp4a2hmcny@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 Thu 06-10-22 12:25:00, Ojaswin Mujoo wrote: > On Thu, Sep 29, 2022 at 02:53:11PM +0200, Jan Kara wrote: > > On Tue 27-09-22 14:46:48, Ojaswin Mujoo wrote: > > > Earlier, inode PAs were stored in a linked list. This caused a need to > > > periodically trim the list down inorder to avoid growing it to a very > > > large size, as this would severly affect performance during list > > > iteration. > > > > > > Recent patches changed this list to an rbtree, and since the tree scales > > > up much better, we no longer need to have the trim functionality, hence > > > remove it. > > > > > > Signed-off-by: Ojaswin Mujoo > > > Reviewed-by: Ritesh Harjani (IBM) > > > > I'm kind of wondering: Now there won't be performance issues with much > > more inode PAs but probably we don't want to let them grow completely out > > of control? E.g. I can imagine that if we'd have 1 billion of inode PAs > > attached to an inode, things would get wonky both in terms of memory > > consumption and also in terms of CPU time spent for the cases where we > > still do iterate all of the PAs... Is there anything which keeps inode PAs > > reasonably bounded? > > > > Honza > > > Hi Jan, > > Sorry for the delay in response, I was on leave for the last few days. > > So as per my understanding, after this patch, the only path where we > would need to traverse all the PAs is the ext4_discard_preallocations() > call where we discard all the PAs of an inode one by one (eg when > closing the file etc). Such a discard is a colder path as we don't > usually expect to do it as often as say allocating blocks to an inode. > > Originally, the limit was added in this patch [1] because of the time > lost in O(N) traversal in the allocation path (ext4_mb_use_preallocated > and ext4_mb_normalize_request). Since the rbtree addressed this > scalability issue we had decided to remove the trim logic in this > patchset. > > [1] > https://lore.kernel.org/all/d7a98178-056b-6db5-6bce-4ead23f4a257@gmail.com/ I agree the O(N) traversal is not in any performance sensitive path. > That being said, I do agree that there should be some way to limit the > PAs from taking up an unreasonable amount of buddy space, memory and CPU > cycles in use cases like database files and disk files of long running > VMs. Previously the limit was 512 PAs per inode and trim was happening > in an LRU fashion, which is not very straightforward to implement in > trees. > > Another approach is rather than having a hard limit, we can throttle the > PAs based on some parameter like total active PAs in FS or FSUtil% of > the PAs but we might need to take care of fairness so one inode is not > holding all the PAs while others get throttled. > > Anyways, I think the trimming part would need some brainstorming to get > right so just wondering if we could keep that as part of a separate > patchset and remove the trimming logic for now since rbtree has > addressed the scalability concerns in allocation path. I agree the fact it took until 2020 for someone to notice inode PAs can be cumulating enough for full scan to matter on block allocation means that this is not a pressing issue. So I'm OK postponing it for now since I also don't have a great idea how to best trim excessive preallocations. Honza -- Jan Kara SUSE Labs, CR