From mboxrd@z Thu Jan 1 00:00:00 1970 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 CE991C30658 for ; Fri, 5 Jul 2024 13:24:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460D76B009A; Fri, 5 Jul 2024 09:24:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4105B6B009E; Fri, 5 Jul 2024 09:24:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D84E6B00A0; Fri, 5 Jul 2024 09:24:34 -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 0A7916B009A for ; Fri, 5 Jul 2024 09:24:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ABC23819A6 for ; Fri, 5 Jul 2024 13:24:33 +0000 (UTC) X-FDA: 82305768426.20.BC57ECD Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf24.hostedemail.com (Postfix) with ESMTP id 9EF96180018 for ; Fri, 5 Jul 2024 13:24:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=ujpc489k; spf=pass (imf24.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720185856; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RI1x0wJ1+JJTcTJDJ2YPYh/0aofRmdFfu4awl092hi0=; b=dEUBUOQHbGV20Wz1/k4v2jngW7BQ1zb4GHVu0NVoGMboL0QGIAsIONjpqb4mtH8cGkfZE2 Geb76bPLU5LV7w/gR8si1FV0WtUClfp3L/AJSV55QU5sBzaJDCzZzJoGpCJSolxyl1FNTp GotU0GpevPius+TlhPKnHxygJLOhkZk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=ujpc489k; spf=pass (imf24.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720185856; a=rsa-sha256; cv=none; b=v9NId9GbtWz+zPXXmO9hzTmgxgIYPi2wNweDFYn9es0hrlVXx2LY92Y1JmiIkKXht3tKdM 9lnnlh2UHo7NLzpPlaw70Sv+xhVzGl3ueMa8USBWxKk3PvBz8VKGOqIfGELfsntl6OnLRy ntjCK8AN93dtq9dxCBGz1R2fmdlNWes= Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 mout-p-201.mailbox.org (Postfix) with ESMTPS id 4WFvPN028Wz9t4r; Fri, 5 Jul 2024 15:24:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1720185864; h=from:from:reply-to:subject:subject: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=RI1x0wJ1+JJTcTJDJ2YPYh/0aofRmdFfu4awl092hi0=; b=ujpc489kYfI5CnIfvxBb+PVX93H2UwcqFo/dVZ0+jF/MDJqF1XaxxKsGD8BWyLb0BPjMLn FvwRySW+vd9W8jSoW4cOnd8qEU5Yp9xa7amLTb8sAhXfxXM9ZOJWraBLgjhStd9PzhC+Ej scDeEQRviHNvwIccuzMF/R9X0ep9yfdc0F8Oe9haOh6DrDYGSsK+8wh50sVSl7VtjjfaAP 7K+rmK/Y3ANFUjZ6dkmZh21tYlObAQbH+q9BWVegwWy4ukxKKz4wnd4SHz5wsa7N19EKji FovQIf6lKk+VOLB+EPtbw9tOrfZMjm1eBKkJNYGBCdsyGPQomt9JR7rLCNs8Gg== Date: Fri, 5 Jul 2024 13:24:18 +0000 From: "Pankaj Raghav (Samsung)" To: Dave Chinner Cc: Matthew Wilcox , Ryan Roberts , chandan.babu@oracle.com, djwong@kernel.org, brauner@kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, yang@os.amperecomputing.com, linux-mm@kvack.org, john.g.garry@oracle.com, linux-fsdevel@vger.kernel.org, hare@suse.de, p.raghav@samsung.com, mcgrof@kernel.org, gost.dev@samsung.com, cl@os.amperecomputing.com, linux-xfs@vger.kernel.org, hch@lst.de, Zi Yan Subject: Re: [PATCH v8 01/10] fs: Allow fine-grained control of folio sizes Message-ID: <20240705132418.gk7oeucdisat3sq5@quentin> References: <20240625114420.719014-1-kernel@pankajraghav.com> <20240625114420.719014-2-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9EF96180018 X-Stat-Signature: 1ios4ab1e7b3i7rckfmh6js638yose3g X-HE-Tag: 1720185868-389872 X-HE-Meta: U2FsdGVkX19V6IhTeMOcp+/yhL66b+hxelJYFd/R3gCZBKHSho1VP+Lw4+soeOYXdgH2f4EdIH4fMb1AxYpI/26IanaRUTroGnCnrxqENvr72tDBNOslWg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yO7n4PCp1fxKVvRThPMdkFfkN0GiS9wCMSv8DwkuekfQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: > > I suggest you handle it better than this. If the device is asking for a > > blocksize > PMD_SIZE, you should fail to mount it. > > That's my point: we already do that. > > The largest block size we support is 64kB and that's way smaller > than PMD_SIZE on all platforms and we always check for bs > ps > support at mount time when the filesystem bs > ps. > > Hence we're never going to set the min value to anything unsupported > unless someone makes a massive programming mistake. At which point, > we want a *hard, immediate fail* so the developer notices their > mistake immediately. All filesystems and block devices need to > behave this way so the limits should be encoded as asserts in the > function to trigger such behaviour. I agree, this kind of bug will be encountered only during developement and not during actual production due to the limit we have fs block size in XFS. > > > If the device is > > asking for a blocksize > PAGE_SIZE and CONFIG_TRANSPARENT_HUGEPAGE is > > not set, you should also decline to mount the filesystem. > > What does CONFIG_TRANSPARENT_HUGEPAGE have to do with filesystems > being able to use large folios? > > If that's an actual dependency of using large folios, then we're at > the point where the mm side of large folios needs to be divorced > from CONFIG_TRANSPARENT_HUGEPAGE and always supported. > Alternatively, CONFIG_TRANSPARENT_HUGEPAGE needs to selected by the > block layer and also every filesystem that wants to support > sector/blocks sizes larger than PAGE_SIZE. IOWs, large folio > support needs to *always* be enabled on systems that say > CONFIG_BLOCK=y. Why CONFIG_BLOCK? I think it is enough if it comes from the FS side right? And for now, the only FS that needs that sort of bs > ps guarantee is XFS with this series. Other filesystems such as bcachefs that call mapping_set_large_folios() only enable it as an optimization and it is not needed for the filesystem to function. So this is my conclusion from the conversation: - Add a dependency in Kconfig on THP for XFS until we fix the dependency of large folios on THP - Add a BUILD_BUG_ON(XFS_MAX_BLOCKSIZE > MAX_PAGECACHE_ORDER) - Add a WARN_ON_ONCE() and clamp the min and max value in mapping_set_folio_order_range() ? Let me know what you all think @willy, @dave and @ryan. -- Pankaj