From nobody Fri Feb 13 14:07:33 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2E16CE7A95 for ; Mon, 25 Sep 2023 08:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232723AbjIYIWl (ORCPT ); Mon, 25 Sep 2023 04:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232521AbjIYIWi (ORCPT ); Mon, 25 Sep 2023 04:22:38 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 181E7A2 for ; Mon, 25 Sep 2023 01:22:32 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-d8168d08bebso6621688276.0 for ; Mon, 25 Sep 2023 01:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695630151; x=1696234951; darn=vger.kernel.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=4sZK+xCuT0P0uH5eP+c4/6boHa42doWBfySEpYJVCK8=; b=3vMb1WfNB52Ctd8ZUSYd3LaVttK5c7Bfurq43e9L29hBs7NUW8q0+grL80cz4YRTfZ u/mqAWWMBom+VTxVTJp0DOeT0Rz/1VbBBv3e86WhH/Bsy4PiEw7RHGuX4iHAkLyRnmjH XXaYcHZM8HPKX8D8CskW81EF6/FJROCkpEQeXxjPUjqvK6ViOJcMxLkl/Hdcga2XkNbv zmNO8fKxha8IrVBud/Hb4Hie5by8IMGjhhhM662qhj6eMgtdbGzFYf2wV9jvSgv3SPzp 3kngQmiV8uUFuLc0eEoQJ1wXXj2fQD7XRml8KvSwBpO8jHx0XS5Y4Fy6lBeXq2IU4u3u ofdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695630151; x=1696234951; 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=4sZK+xCuT0P0uH5eP+c4/6boHa42doWBfySEpYJVCK8=; b=YR67oEBQZ2V0+qPcQS6nV9TZieuYaBMyYVJdRXjYlefEVFE9GzKnsUG9+TL+1Lotx8 pwHGyrxs8q1E1JtBEiwedQqXeU76LjwVW5AozCz3TuL+vMwOgHkmUmpE68he5RzPDY+D kzc0mSSrabz2hv1XwuHNhfFJoJ4Ro2Q0ijZFM7sqtrlG0fHgbXeaBojHO5hWojP/SfQ1 qsQG1DaiWq9+51I/onOgtedhCt9ZIYJgFHlMXYy5XBd5AIKT5HZ67yEuEXD6T0Zlldx9 hgb//CB1q0swZy2NBswmDbkVt/ABcqfpmxoQQe/kTyogWpKqemcnrp8LD4gRLtbhPOSc Ynow== X-Gm-Message-State: AOJu0YyI+mn89qXpJ0SFELtJcVix+Cgoka3u69Eih8EWXBuHO1+gsRGz x0Tru6azyjsiguwSaz4l3HjG9A== X-Google-Smtp-Source: AGHT+IEwv44FcIamrq7TyieXIPq5bY4OaPs0D1yBi6vYNp4KwxZNNaUgHfeQiKSegaaLKY4KIVfLOQ== X-Received: by 2002:a25:6942:0:b0:d7b:9580:240c with SMTP id e63-20020a256942000000b00d7b9580240cmr6055638ybc.47.1695630151093; Mon, 25 Sep 2023 01:22:31 -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 n80-20020a25da53000000b00d217e46d25csm2127705ybf.4.2023.09.25.01.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 01:22:30 -0700 (PDT) Date: Mon, 25 Sep 2023 01:22:27 -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 , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/12] kernfs: drop shared NUMA mempolicy hooks In-Reply-To: <2d872cef-7787-a7ca-10e-9d45a64c80b4@google.com> Message-ID: References: <2d872cef-7787-a7ca-10e-9d45a64c80b4@google.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It seems strange that kernfs should be an outlier with a set_policy and get_policy in its kernfs_vm_ops. Ah, it dates back to v2.6.30's commit 095160aee954 ("sysfs: fix some bin_vm_ops errors"), when I had crashed on powerpc's pci_mmap_legacy_page_range() fallback to shmem_zero_setup(). Well, that was commendably thorough, to give sysfs-bin a set_policy and get_policy, just to avoid the way it was coded resulting in EINVAL from mmap when CONFIG_NUMA; but somehow feels a bit over-the-top to me now. It's easier to say that nobody should expect to manage a shmem object's shared NUMA mempolicy via some kernfs backdoor to that object: delete that code (and there's no longer an EINVAL from mmap in the NUMA case). This then leaves set_policy/get_policy as implemented only by shmem - though importantly also by SysV SHM, which has to interface with shmem which implements them, and with SHM_HUGETLB which does not. Signed-off-by: Hugh Dickins Reviewed-by: Matthew Wilcox (Oracle) --- fs/kernfs/file.c | 49 ------------------------------------------------ 1 file changed, 49 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 180906c36f51..aaa76410e550 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -429,60 +429,11 @@ static int kernfs_vma_access(struct vm_area_struct *v= ma, unsigned long addr, return ret; } =20 -#ifdef CONFIG_NUMA -static int kernfs_vma_set_policy(struct vm_area_struct *vma, - struct mempolicy *new) -{ - struct file *file =3D vma->vm_file; - struct kernfs_open_file *of =3D kernfs_of(file); - int ret; - - if (!of->vm_ops) - return 0; - - if (!kernfs_get_active(of->kn)) - return -EINVAL; - - ret =3D 0; - if (of->vm_ops->set_policy) - ret =3D of->vm_ops->set_policy(vma, new); - - kernfs_put_active(of->kn); - return ret; -} - -static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma, - unsigned long addr) -{ - struct file *file =3D vma->vm_file; - struct kernfs_open_file *of =3D kernfs_of(file); - struct mempolicy *pol; - - if (!of->vm_ops) - return vma->vm_policy; - - if (!kernfs_get_active(of->kn)) - return vma->vm_policy; - - pol =3D vma->vm_policy; - if (of->vm_ops->get_policy) - pol =3D of->vm_ops->get_policy(vma, addr); - - kernfs_put_active(of->kn); - return pol; -} - -#endif - static const struct vm_operations_struct kernfs_vm_ops =3D { .open =3D kernfs_vma_open, .fault =3D kernfs_vma_fault, .page_mkwrite =3D kernfs_vma_page_mkwrite, .access =3D kernfs_vma_access, -#ifdef CONFIG_NUMA - .set_policy =3D kernfs_vma_set_policy, - .get_policy =3D kernfs_vma_get_policy, -#endif }; =20 static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) --=20 2.35.3