From patchwork Tue Oct 3 09:15:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13407319 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 A7BA7E7543A for ; Tue, 3 Oct 2023 09:15:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AB766B013A; Tue, 3 Oct 2023 05:15:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 334A76B013B; Tue, 3 Oct 2023 05:15:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AEAC6B013C; Tue, 3 Oct 2023 05:15:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 068376B013A for ; Tue, 3 Oct 2023 05:15:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BF72EC0212 for ; Tue, 3 Oct 2023 09:15:21 +0000 (UTC) X-FDA: 81303591642.05.CD6032D Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf17.hostedemail.com (Postfix) with ESMTP id 020CE4000B for ; Tue, 3 Oct 2023 09:15:19 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=hSWdFDpz; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696324520; a=rsa-sha256; cv=none; b=koP1lwJCrDwQofODEn4rlCNTOwYbCm01NOBEPwPv8/pODPPVJvuH+VvuSP0LsJ5akQWOMj 4PayfesFe7aZJoMDXTGXBc8c67N11kUjhhvH2RCvUo/GQtfzT61ZOCz+kAygeoYV9p0cw0 2m8bKBrQhayB28WwE8/TkmJomVLsVfo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=hSWdFDpz; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696324520; 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=VwYZSOOB/glvz2EnW/qnimnVXLIQ+wJ0Ri+lf09J6gI=; b=G5Ls1jy0XGCr/86+W/Hcss6j+djyWFcFDOHxDl0D8ZAEgYTY/y2QTgLNTfZlcpTlNwH8DH oBnstIXH0RohrDCBXJuPG6GtdFKmktggJzV43yhGtIf7dH3k1Js8aEvewpC5hVkAgsoNab 2Ai/dLZp2B37AOufgdl3B9Z6vwiWQc8= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-579de633419so8376157b3.3 for ; Tue, 03 Oct 2023 02:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696324519; x=1696929319; darn=kvack.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=VwYZSOOB/glvz2EnW/qnimnVXLIQ+wJ0Ri+lf09J6gI=; b=hSWdFDpzGJ5Q0ktLUZdTcN9z3cxmRV5BuT+OYJpNflB0qlYfyrDehgOMp3SbhbZ8JT aH22M1PdjntdRfUpVAny7NtG4/H+74/ckVEriTTLfGtb+ayaiPJbw2YvfVexR7/E3gsb 3dVKKfmG3pIUXqFrdpno/DpSqZeV7ItQfgG8zIKZtBuFwSo0C/przEZUMO1YvO4GZRJH qNAY5IbXRVRmOgpGMKDT1UUsdOEeVQLMQKuriwfwirpjT3US3MP6H9l7I05wOpZ9V/71 +JwmQQoPlpk8/5cC1eMDeGHdYpVEKI+aXXC8V4U6F5Bf2fb4LyJz19IMfpMRddcFKxSV YrDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696324519; x=1696929319; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VwYZSOOB/glvz2EnW/qnimnVXLIQ+wJ0Ri+lf09J6gI=; b=TuGGWErpJ8ZtJSc12kyDmt40uo8vjDyB1oXdCmPZHmP6pbU10Vhl6bxA7gD8T4vPr4 E+2LfvZI+oJmTyWLSJ6zRfN3JmkYheIuv/d4qaiZd29tgDS4WBI3vN77OBW1KrvVUKsu dk51hNSKTwlJ10+5bOXcJ4aEDLhR7lg2mSLo4OQLVmSAAfpw7INgc3HOKq4EOTBGe3Pa CyD8YtYjV0vLj2wm+hJFoFNHN7drWW3Jb7AhZfMmXd9AHSPrSdS2e/OBzr+R/VOTp1OD E1y2H5PyAyuugx3B93ig+oOU2/nP/xqi69aHSSy0lOxXHKThbTP+lAnN8MnnKLvvz+bg yyjg== X-Gm-Message-State: AOJu0Yw7q6QAMbtoKZq4KVfUIO0SGTa4tez5SSHBnNDXxMoulfKTt6G6 DlDuwJBOWTd4bnFCmjPXMThHgQ== X-Google-Smtp-Source: AGHT+IHGzltakHVdO+OL/afC9cmnMy82Tb0Z7wP4Wxec5m1WelVAghemXtF1xjfUCVDqbZcaUXYemA== X-Received: by 2002:a81:8907:0:b0:59b:518a:639c with SMTP id z7-20020a818907000000b0059b518a639cmr14262844ywf.36.1696324518906; Tue, 03 Oct 2023 02:15:18 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id m131-20020a817189000000b005950e1bbf11sm244244ywc.60.2023.10.03.02.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 02:15:18 -0700 (PDT) Date: Tue, 3 Oct 2023 02:15:09 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Andi Kleen , Christoph Lameter , Matthew Wilcox , Mike Kravetz , David Hildenbrand , Suren Baghdasaryan , Yang Shi , Sidhartha Kumar , Vishal Moola , Kefeng Wang , Greg Kroah-Hartman , Tejun Heo , Mel Gorman , Michal Hocko , "Huang, Ying" , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 01/12] hugetlbfs: drop shared NUMA mempolicy pretence In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 020CE4000B X-Stat-Signature: negotmq97yoaaymm3jxr48qqhnw4hzsc X-Rspam-User: X-HE-Tag: 1696324519-491621 X-HE-Meta: U2FsdGVkX19t032c8jrnNmGXDD6J8oXV2Jy3DI4VyjmE6IrAq+HwK2eQUK1DFOPpFbnv4O/HbD+xpaaD4rg8HnWEvp9aulDatkbboH7srR9PFKrGdLnl3y35I0OzVpQJ6JMg0pbl6SYJIi5ZME2XE15D/dU0AX+2eFyMFmbl1aRpe7CnVIOsS4iI4RbjwKSIzPJUtlGcZ+UTC9rqsUaKa4I2Kp6mNZDCRkTEcjMnP/eIRgwcJWmEu7E9GfKASIaTpPw9PhtHs5imB8GNMTJK4XfpJaj0gaQkW8WSXC3ZtLN3CDNTfZMNfN920hBbyjEpnLp1Cs9tgNI8m5pJKvl+Quixl/AnIHogv0JkUXdQI9giMc+MrHa2U/VoG5Sg6FC0PTUJWvP6XS7mPNtx6BMojINWuZVTwy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XM3rLNSjKYDpXKycXxmhR4TVUVs= 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: hugetlbfs_fallocate() goes through the motions of pasting a shared NUMA mempolicy onto its pseudo-vma, but how could there ever be a shared NUMA mempolicy for this file? hugetlb_vm_ops has never offered a set_policy method, and hugetlbfs_parse_param() has never supported any mpol options for a mount-wide default policy. It's just an illusion: clean it away so as not to confuse others, giving us more freedom to adjust shmem's set_policy/get_policy implementation. But hugetlbfs_inode_info is still required, just to accommodate seals. Yes, shared NUMA mempolicy support could be added to hugetlbfs, with a set_policy method and/or mpol mount option (Andi's first posting did include an admitted-unsatisfactory hugetlb_set_policy()); but it seems that nobody has bothered to add that in the nineteen years since v2.6.7 made it possible, and there is at least one company that has invested enough into hugetlbfs, that I guess they have learnt well enough how to manage its NUMA, without needing shared mempolicy. Remove linux/mempolicy.h from linux/hugetlb.h: include linux/pagemap.h in its place, because hugetlb.h's recently added use of filemap_lock_folio() requires that (although most .configs and .c's get it in some other way). Signed-off-by: Hugh Dickins Reviewed-by: Matthew Wilcox (Oracle) --- fs/hugetlbfs/inode.c | 41 +---------------------------------------- include/linux/hugetlb.h | 3 +-- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 926d01c493fb..0586c90cb9a5 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -83,29 +83,6 @@ static const struct fs_parameter_spec hugetlb_fs_parameters[] = { {} }; -#ifdef CONFIG_NUMA -static inline void hugetlb_set_vma_policy(struct vm_area_struct *vma, - struct inode *inode, pgoff_t index) -{ - vma->vm_policy = mpol_shared_policy_lookup(&HUGETLBFS_I(inode)->policy, - index); -} - -static inline void hugetlb_drop_vma_policy(struct vm_area_struct *vma) -{ - mpol_cond_put(vma->vm_policy); -} -#else -static inline void hugetlb_set_vma_policy(struct vm_area_struct *vma, - struct inode *inode, pgoff_t index) -{ -} - -static inline void hugetlb_drop_vma_policy(struct vm_area_struct *vma) -{ -} -#endif - /* * Mask used when checking the page offset value passed in via system * calls. This value will be converted to a loff_t which is signed. @@ -853,8 +830,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, /* * Initialize a pseudo vma as this is required by the huge page - * allocation routines. If NUMA is configured, use page index - * as input to create an allocation policy. + * allocation routines. */ vma_init(&pseudo_vma, mm); vm_flags_init(&pseudo_vma, VM_HUGETLB | VM_MAYSHARE | VM_SHARED); @@ -902,9 +878,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, * folios in these areas, we need to consume the reserves * to keep reservation accounting consistent. */ - hugetlb_set_vma_policy(&pseudo_vma, inode, index); folio = alloc_hugetlb_folio(&pseudo_vma, addr, 0); - hugetlb_drop_vma_policy(&pseudo_vma); if (IS_ERR(folio)) { mutex_unlock(&hugetlb_fault_mutex_table[hash]); error = PTR_ERR(folio); @@ -1283,18 +1257,6 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) hugetlbfs_inc_free_inodes(sbinfo); return NULL; } - - /* - * Any time after allocation, hugetlbfs_destroy_inode can be called - * for the inode. mpol_free_shared_policy is unconditionally called - * as part of hugetlbfs_destroy_inode. So, initialize policy here - * in case of a quick call to destroy. - * - * Note that the policy is initialized even if we are creating a - * private inode. This simplifies hugetlbfs_destroy_inode. - */ - mpol_shared_policy_init(&p->policy, NULL); - return &p->vfs_inode; } @@ -1306,7 +1268,6 @@ static void hugetlbfs_free_inode(struct inode *inode) static void hugetlbfs_destroy_inode(struct inode *inode) { hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb)); - mpol_free_shared_policy(&HUGETLBFS_I(inode)->policy); } static const struct address_space_operations hugetlbfs_aops = { diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 3c4427a2396d..a574e26e18a2 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -30,7 +30,7 @@ void free_huge_folio(struct folio *folio); #ifdef CONFIG_HUGETLB_PAGE -#include +#include #include #include @@ -513,7 +513,6 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb) } struct hugetlbfs_inode_info { - struct shared_policy policy; struct inode vfs_inode; unsigned int seals; };