From patchwork Wed Jan 10 09:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13515844 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 A9D88C47073 for ; Wed, 10 Jan 2024 09:21:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3ABE46B0075; Wed, 10 Jan 2024 04:21:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35C836B0078; Wed, 10 Jan 2024 04:21:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 186E26B0092; Wed, 10 Jan 2024 04:21:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 083016B0075 for ; Wed, 10 Jan 2024 04:21:39 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D7BD5A03C1 for ; Wed, 10 Jan 2024 09:21:38 +0000 (UTC) X-FDA: 81662858676.14.299D554 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id 419261C0018 for ; Wed, 10 Jan 2024 09:21:37 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VvT59FfZ; spf=none (imf20.hostedemail.com: domain of BATV+17e9c08914743a4dbb9f+7444+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+17e9c08914743a4dbb9f+7444+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704878497; 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:in-reply-to:references:references:dkim-signature; bh=vemtm26RZJwq2BkJen0DsgudNpnNIQOHTlEDhkpMTMQ=; b=YAOwvqR8aZ8H2fGefun2ihgqaR/zrRf2zv5NX3QQ/ODkD52uPfShdNfloa8YVC5NiaK1ts dmXM0X2d5ZHgXftdBf1q34KopDaXrwKW+KQzRtT2TsWtSqwW4TcIsTZ1iu2Cbr2CWmszmT G9JKfmfdQhtsYw3LvEUW1rwdQypb1Qs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704878497; a=rsa-sha256; cv=none; b=rSKssbca89Ix0s+R/AfMHjp8quJm1OcpZrTqXOK2CvxO5lcRI0n75UOyaaeB+aDoJPgWTz ZcznQQdrzkquu6QH9lnpp9NFxnj3qgpmyPKznXPEYT6HOmK1RzVIHG1+8Nw39pxiaxbszk F2PZYBndpiGwimnoV0T5KaDp7/MFOsU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VvT59FfZ; spf=none (imf20.hostedemail.com: domain of BATV+17e9c08914743a4dbb9f+7444+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+17e9c08914743a4dbb9f+7444+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vemtm26RZJwq2BkJen0DsgudNpnNIQOHTlEDhkpMTMQ=; b=VvT59FfZyGViQ4E9bybilVlr/n E58xcBMqiG7yHbZRyzY+MeZqOUO73LE+/oyqen6J0wutWRO0UD5OylhJ4Mqx1GoUwrpWkQ9ockMTO zyTTGC4l3K2AVsMneNh/767/v9arpPkmZu6jv9Kpv6xyiCQwY2IKXC2f87wwmXRPgcGR0L6ncNvtJ bRz65LMjl5Yq3e1j5b56u9hCiLVBySWQ/Sr/aid4EvqC/7O7zhvFA590kdpkdOalJHAgkUUs+n+Vw EHaNxwv8+03GiryNOsM8jEJ2KcP9yx6govhS285icE+S4S6N7L/QIGjZIj5ny8VRfIkY7q9yV3/yB MgyUdYOw==; Received: from [2001:4bb8:191:2f6b:27f:45ef:e74a:3466] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rNUlv-00AsAi-1t; Wed, 10 Jan 2024 09:21:16 +0000 From: Christoph Hellwig To: Matthew Wilcox , Hugh Dickins , Chandan Babu R Cc: "Darrick J . Wong" , Andrew Morton , David Howells , Jarkko Sakkinen , Dave Hansen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Christian Koenig , Huang Rui , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, x86@kernel.org, linux-sgx@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, keyrings@vger.kernel.org Subject: [PATCH 1/2] mm: add a mapping_clear_large_folios helper Date: Wed, 10 Jan 2024 10:21:08 +0100 Message-Id: <20240110092109.1950011-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240110092109.1950011-1-hch@lst.de> References: <20240110092109.1950011-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: 419261C0018 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gjsdkknthnkawmfw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p1wKuWx5LE9zq0vjmaa5dRtg8TpsGkyVbkX18gR6Wn2RwwRQw3R7HHdedzS9t48yV4lr7SEuVF3eMDyEjwOOcrUEYR4lthBXQ48OfuyKMmXV05QLn1HlzlWrmIpi7z4E0KkCJWWzmQMn5IGqbnS42gjgMdf1cIs1EmcG/W2pqu/LmeFSHZ6kRSd+JU/bQnhyYw8/d4NXuM3nsSH3L/ERl2OPFpPOOJ1iAqsRXG0/EQcK+wE1zMn1jbWbUmdQszFsf2aclRin3YTg5VCBsHChsnEguoN9r2d1NnDkmAhiAFFNDnP4FKSwB9WHAlsscZnDpdQCSquwQlablVBk5wzcB+58WVlfHEaO+23495QabhU5OqW+dJcDxQkkR4ZLDR4i3TLuL6mw7slp3t4vUa1oW7DdAEJHSAju30A5YTo/ckVhP2Pp9A== 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: Users of shmem_kernel_file_setup might not be able to deal with large folios (yet). Give them a way to disable large folio support on their mapping. Signed-off-by: Christoph Hellwig --- include/linux/pagemap.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 06142ff7f9ce0e..352d1f8423292c 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -343,6 +343,20 @@ static inline void mapping_set_large_folios(struct address_space *mapping) __set_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); } +/** + * mapping_clear_large_folios() - Disable large folio support for a mapping + * @mapping: The mapping. + * + * This can be called to undo the effect of mapping_set_large_folios(). + * + * Context: This should not be called while the inode is active as it + * is non-atomic. + */ +static inline void mapping_clear_large_folios(struct address_space *mapping) +{ + __clear_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); +} + /* * Large folio support currently depends on THP. These dependencies are * being worked on but are not yet fixed.