From patchwork Fri Jul 19 09:16:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13737038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A3C1C3DA5D for ; Fri, 19 Jul 2024 09:17:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F13256B0082; Fri, 19 Jul 2024 05:17:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC3A66B0083; Fri, 19 Jul 2024 05:17:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8A8B6B0088; Fri, 19 Jul 2024 05:17:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B607D6B0082 for ; Fri, 19 Jul 2024 05:17:24 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 17DB6A22F8 for ; Fri, 19 Jul 2024 09:17:24 +0000 (UTC) X-FDA: 82355948808.21.C1BCFBE Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf19.hostedemail.com (Postfix) with ESMTP id EE5D81A0013 for ; Fri, 19 Jul 2024 09:17:21 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=dEqB+J7v; dkim=pass header.d=suse.com header.s=susede1 header.b=dEqB+J7v; spf=pass (imf19.hostedemail.com: domain of wqu@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=wqu@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721380621; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=+9zOBKmiMiyox+b82YU9nto9KW7INaT88iuJAGyfj/I=; b=65OmT7r9AZ+QgwxBKzEBnkb8VaS5t1bm1sDu5xCcThnR3SOPgioDED3K9aW5ntpXlZk2QV zkZhwSRboBnwxJMGT/DEap6XvH3kWILeVLMAdxqNZSRjYilxVwHjOKCPYN+J11gFehLzR+ lzoAFLrbIVXfI3KCciIKHu+jjkcTuzI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=dEqB+J7v; dkim=pass header.d=suse.com header.s=susede1 header.b=dEqB+J7v; spf=pass (imf19.hostedemail.com: domain of wqu@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=wqu@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721380621; a=rsa-sha256; cv=none; b=XqzX02up699SI9ulQLrnON3eh5kAK/h4hBD4fW7sUB95xgAo6m3ztcx0uvTdNQxUTHMYuv AiMH2zKP5YYKXwjCSdtrsyK+PWkFtuOl9sqgkgjGPvo+2/0hp9DW0QQ974GifW9Ejyfx9v 8TacfvLTBz9MrsOfUAlWeFgYfA0nNYU= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 51E5F2193C; Fri, 19 Jul 2024 09:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1721380640; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+9zOBKmiMiyox+b82YU9nto9KW7INaT88iuJAGyfj/I=; b=dEqB+J7vOzvAb4vRwsmrn/rwpeizHUNnrNdgvMk0qN0650JFjH1loMuyU3XdnTkVfJl1Wt J9OXjW3ndp9MyMQm9CLnIWBml8GpM5pjTiEQXwDNNf1fOZ96nCIk7UpmBleqPovQhEmUN8 Is9KGr5O4dFe0Cx4t8DdTbLeOjhLk5g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1721380640; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+9zOBKmiMiyox+b82YU9nto9KW7INaT88iuJAGyfj/I=; b=dEqB+J7vOzvAb4vRwsmrn/rwpeizHUNnrNdgvMk0qN0650JFjH1loMuyU3XdnTkVfJl1Wt J9OXjW3ndp9MyMQm9CLnIWBml8GpM5pjTiEQXwDNNf1fOZ96nCIk7UpmBleqPovQhEmUN8 Is9KGr5O4dFe0Cx4t8DdTbLeOjhLk5g= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 84FAF136F7; Fri, 19 Jul 2024 09:17:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id zFj8Dx0vmmZPRAAAD6G6ig (envelope-from ); Fri, 19 Jul 2024 09:17:17 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v6 0/3] btrfs: try to allocate larger folios for metadata Date: Fri, 19 Jul 2024 18:46:56 +0930 Message-ID: X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Rspamd-Action: no action X-Spamd-Bar: / X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: EE5D81A0013 X-Stat-Signature: bb35qnj5mqo6on5hec3erbg4dogug5px X-HE-Tag: 1721380641-425692 X-HE-Meta: U2FsdGVkX1+7qxlW2yO1FHb87HZ+AY+H5qgUlcAnRB7n48dExXeRS4vNzPhjvIMuQuKFFZeltlmjUVm0OHfCC2hTI2eK1oHY1lEjXKpqqs/3992ANi3om46Jq/6YL6vmd5qTwoF4BzPMd++pfgeBY4tpCuf6lyx4TeT0Nu13dLz3IKs10mr+L1gWdTDs5ooV+kDKQ/LJQOol80G+X3HiDhNuKHRyztE+hmkYL3kwu80nRlZZ1Jsozb3I25oG4vpKecJMBlDz0/iAaHAXmjduFaybS5BhAj1rDTPUxB2fKynXw86nX5VILldEBZQKM/GlJg36nQIhEC9O6etYbr+cekds+VdWZWjIBIPu6oosEsVZzXekpggV1ULsecFUk1JTAKAPwtaMDF8amHYPo37bO1zpMqN/tpKU8sI1mmSivO7lkj7JNWE+AGDqwUXATqJC8nktHNhW/7nYwfne2Z/Fd2zO7qyAbYLwGMNu/Ga53ddpi/4N4ivcHSqfOKYy0EZ4v+qIAbpTrIHuMhnlPTsce6bAHgjgc4YYCJkzI3tdlF0bTaatzNFVoVNcYLry9W7HgUoQhAwhbPpR4ZbaVBvMKMOFm+zAcQhI5EcbglfiBsskHNZp+QXOr8XGnqJJpyQrrWVRP6PAwqyW2VjKYV0yHmFl7735LWJr0/C4mGwPo3LKRnZ7OcRQSiYaT3CI/VrFBfPqWOt38djQUnvyeC/GTyJJzpPmYBcwJwi4EloVYh4kRSBXU2bh8rV5zkWFTGywf8b3nSEVSmHbcSoY2WHMZgKqazNsHHCeeWxqZTuBCzSwMdBZk+Vhom/dd51K5V68JrelHIq8ABmr6+8FgM0YPvo/YASIaZPxZ0DEhKQe7FcjN7ZhNYAI70axEZpFPXw56JaPsu7f9xLKCJfnnw4pbU1BIGt8IAcH+Tn3ztwy2zvJmtavHXzcsFs/50YxL85GlENeEoGm8y8dilfh48l dG8HKZPk fnWF3iy1yEDqjiRpEkuMF66PYtqLpkS4uOdNxQM7fxxpYb8vn5aPhvdaoChwwJjGhYl3PZviYt/hYdauc5eZ3KnwLyi4z2KpqDWZPJTRXQLnm5Yf8Jwjzlk0ZxjqwxU/U8HFS+CSvNrOatAIoftQiEwc9JYanLm9DbcO3fDwxjp8LqyRT6kByr8eHnOcYw5dj6XqWIPJHWqgrWdY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: [CHANGELOG] v6: - Add a new root_mem_cgroup definition for CONFIG_MEMCG=n cases So that users of root_mem_cgroup no longer needs to check CONFIG_MEMCG. This is to fix the compile error for CONFIG_MEMCG=n cases. - Slight rewording of the 2nd patch v5: - Use root memcgroup to attach folios to btree inode filemap - Only try higher order folio once without NOFAIL nor extra retry v4: - Hide the feature behind CONFIG_BTRFS_DEBUG So that end users won't be affected (aka, still per-page based allocation) meanwhile we can do more testing on this new behavior. v3: - Rebased to the latest for-next branch - Use PAGE_ALLOC_COSTLY_ORDER to determine whether to use __GFP_NOFAIL - Add a dependency MM patch "mm/page_alloc: unify the warning on NOFAIL and high order allocation" This allows us to use NOFAIL up to 32K nodesize, and makes sure for default 16K nodesize, all metadata would go 16K folios v2: - Rebased to handle the change in "btrfs: cache folio size and shift in extent_buffer" This is the latest update on the attempt to utilize larger folios for btrfs metadata. The previous version exposed a reproducibe hang at btrfs/187, where we hang at filemap_add_folio() around its memcgroup charge code. Even without the problem, I still believe for btree inode we do not really need all the memcgroup charge, nor using __GFP_NOFAIL to work around the possible memcgroup limits. So in this update, suggested by the memcgroup people from SUSE, there is a new patch to make btree inode filemap folio attaching to use the root memcgroup, so that we won't be limited by the memcgroup. Then for the patch enabling the larger folio, I reverted back to the old behavior that we only try larger folio once without extra retry, just to be extra safe. Qu Wenruo (3): memcontrol: define root_mem_cgroup for CONFIG_MEMCG=n cases btrfs: always uses root memcgroup for filemap_add_folio() btrfs: prefer to allocate larger folio for metadata fs/btrfs/extent_io.c | 112 ++++++++++++++++++++++++++----------- include/linux/memcontrol.h | 8 ++- 2 files changed, 84 insertions(+), 36 deletions(-)