From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 658C9211272; Fri, 21 Feb 2025 15:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740151450; cv=none; b=sCi8d6uTrjKuHWxGwuza3y6HHXPJ9Rq+KIAUe11qW9JzsayK6vXOx/N2xQ0aF1CN5i1jXr8S73+5R/lO69xSIO9e8P8m5doYrWZcjAGJylQ6oZY8QrFtE0xHGuUTx9XcwZj3aG3Y6eF3ZEwNjmJ8vNwwO3+shbx+Z1ho4Qo/cc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740151450; c=relaxed/simple; bh=gY6RHIDrvwES0t6Smc3ipQT/R3L+7jAoEYQTHTsgQlk=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=ImoeqnA5AiwHqo2UJ60LRTQZ8dAD5/wZxMav9q+CAAB344ynuvB7RVg/hNk+J3FNJb1MX/bxhxU0eBnI4xXBaBIrIFYn1U03H61wpp0VF3L7kiqLxi7zrhWP8vfClvksX/E9KSx00YfmR/VP/j7flF9Ae9WFyzzDmU4wIRR6xoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hYESDCBj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hYESDCBj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3572C4CED6; Fri, 21 Feb 2025 15:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740151450; bh=gY6RHIDrvwES0t6Smc3ipQT/R3L+7jAoEYQTHTsgQlk=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=hYESDCBjNtlL5+EqE1A/VdNrT0iMCpoE4/WBzDh5Px1LgChW78W8RVR4VJvykNFJg 6tbmLCSArIeStLVgZKGm6ZMZ1fCRGgu1c+Yq1X//09ou73I3swvb4q2ydAX5wyj8MX sQukWi5IJxWskfzqEvMGCWjk/Mof6WEmxfrwECOQ= Subject: Patch "xfs: Reduce unnecessary searches when searching for the best extents" has been added to the 6.6-stable tree To: catherine.hoang@oracle.com,cem@kernel.org,chizhiling@kylinos.cn,dchinner@redhat.com,djwong@kernel.org,gregkh@linuxfoundation.org,xfs-stable@lists.linux.dev Cc: From: Date: Fri, 21 Feb 2025 16:23:28 +0100 In-Reply-To: <20250205214025.72516-23-catherine.hoang@oracle.com> Message-ID: <2025022128-likely-cleat-a074@gregkh> Precedence: bulk X-Mailing-List: xfs-stable@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled xfs: Reduce unnecessary searches when searching for the best extents to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-reduce-unnecessary-searches-when-searching-for-the-best-extents.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-113987-greg=kroah.com@vger.kernel.org Wed Feb 5 22:41:28 2025 From: Catherine Hoang Date: Wed, 5 Feb 2025 13:40:23 -0800 Subject: xfs: Reduce unnecessary searches when searching for the best extents To: stable@vger.kernel.org Cc: xfs-stable@lists.linux.dev Message-ID: <20250205214025.72516-23-catherine.hoang@oracle.com> From: Chi Zhiling commit 3ef22684038aa577c10972ee9c6a2455f5fac941 upstream. Recently, we found that the CPU spent a lot of time in xfs_alloc_ag_vextent_size when the filesystem has millions of fragmented spaces. The reason is that we conducted much extra searching for extents that could not yield a better result, and these searches would cost a lot of time when there were millions of extents to search through. Even if we get the same result length, we don't switch our choice to the new one, so we can definitely terminate the search early. Since the result length cannot exceed the found length, when the found length equals the best result length we already have, we can conclude the search. We did a test in that filesystem: [root@localhost ~]# xfs_db -c freesp /dev/vdb from to extents blocks pct 1 1 215 215 0.01 2 3 994476 1988952 99.99 Before this patch: 0) | xfs_alloc_ag_vextent_size [xfs]() { 0) * 15597.94 us | } After this patch: 0) | xfs_alloc_ag_vextent_size [xfs]() { 0) 19.176 us | } Signed-off-by: Chi Zhiling Reviewed-by: Dave Chinner Signed-off-by: Carlos Maiolino Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -1783,7 +1783,7 @@ restart: error = -EFSCORRUPTED; goto error0; } - if (flen < bestrlen) + if (flen <= bestrlen) break; busy = xfs_alloc_compute_aligned(args, fbno, flen, &rbno, &rlen, &busy_gen); Patches currently in stable-queue which might be from catherine.hoang@oracle.com are queue-6.6/xfs-return-bool-from-xfs_attr3_leaf_add.patch queue-6.6/xfs-fix-a-sloppy-memory-handling-bug-in-xfs_iroot_realloc.patch queue-6.6/xfs-streamline-xfs_filestream_pick_ag.patch queue-6.6/xfs-merge-xfs_attr_leaf_try_add-into-xfs_attr_leaf_addname.patch queue-6.6/xfs-don-t-free-cowblocks-from-under-dirty-pagecache-on-unshare.patch queue-6.6/xfs-pass-the-exact-range-to-initialize-to-xfs_initialize_perag.patch queue-6.6/xfs-assert-a-valid-limit-in-xfs_rtfind_forw.patch queue-6.6/xfs-don-t-use-__gfp_retry_mayfail-in-xfs_initialize_perag.patch queue-6.6/xfs-use-try_cmpxchg-in-xlog_cil_insert_pcp_aggregate.patch queue-6.6/xfs-don-t-ifdef-around-the-exact-minlen-allocations.patch queue-6.6/xfs-reduce-unnecessary-searches-when-searching-for-the-best-extents.patch queue-6.6/xfs-validate-inumber-in-xfs_iget.patch queue-6.6/xfs-support-lowmode-allocations-in-xfs_bmap_exact_minlen_extent_alloc.patch queue-6.6/xfs-skip-background-cowblock-trims-on-inodes-open-for-write.patch queue-6.6/xfs-remove-empty-declartion-in-header-file.patch queue-6.6/xfs-fold-xfs_bmap_alloc_userdata-into-xfs_bmapi_allocate.patch queue-6.6/xfs-update-the-file-system-geometry-after-recoverying-superblock-buffers.patch queue-6.6/xfs-call-xfs_bmap_exact_minlen_extent_alloc-from-xfs_bmap_btalloc.patch queue-6.6/xfs-distinguish-extra-split-from-real-enospc-from-xfs_attr_node_try_addname.patch queue-6.6/xfs-error-out-when-a-superblock-buffer-update-reduces-the-agcount.patch queue-6.6/xfs-update-the-pag-for-the-last-ag-at-recovery-time.patch queue-6.6/xfs-check-for-delayed-allocations-before-setting-extsize.patch queue-6.6/xfs-fix-a-typo.patch queue-6.6/xfs-distinguish-extra-split-from-real-enospc-from-xfs_attr3_leaf_split.patch