From patchwork Mon Sep 25 08:22:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 144499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1346642vqu; Mon, 25 Sep 2023 09:47:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFc+dPAkKB/nHeRQ4LnQeHTKGoGYU4JmpbEpbyHFN6E1hjC5DH/4PPJpMmyXow5A1eGXDW X-Received: by 2002:a05:6358:2822:b0:143:5d3f:f397 with SMTP id k34-20020a056358282200b001435d3ff397mr10152629rwb.16.1695660456337; Mon, 25 Sep 2023 09:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695660456; cv=none; d=google.com; s=arc-20160816; b=0zkQAXQxUyvJ/pjAOcu/OU+DNL25MtR+EDrhnlgAZg3tky2yUDnhT6k2SzaGJ0e6mC IluR51mqaiv9mGi957vgcbWkuy2NRSY4e+FWE62RS6uH9Z6PD5YMJ6ZYI1rYHHdeOdP/ 2zAiImMz94rbchDURaArZjQ+W6t4rBDYCgk645vwo9NtCBu17Jsw05F69WeeLqUnFl5W LuYkZWpZ0EQXzx8dbUYptrXHVF3o3gnuTesW8zgwcpT7aXmflIY+eN830iJFfC5Lw+CO k6FEM8HAVMs1RTX2a8W2cOAho+2UFO6+j5XuTaRwYOgovlHVvy/uiFNd5+6uCbccEzYK YK7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=4sZK+xCuT0P0uH5eP+c4/6boHa42doWBfySEpYJVCK8=; fh=PKJfMUzgaCa5W48Ppxzzb+jI+5sm22s8VnfSndR+ybA=; b=f/x9ko28n/iL5L63KN4NOvXABpoGLQ+Rdqv1TCK7bqu+hJf5EtGdYTRbFY0l+2yft7 LJXFfqfr5eMM7pgvFYlWTGBtRuthH0X/4k7UHntiTR+9WJDtkskKztECQ/urh0o+j+D7 Z8XJjqonnXGqPdcklKgYT+TNh7ZKnvFIimyl2PQuACFjPqAj5ftHXQh/6dKfM+gFJ3GE eRfW/DRErC0m0YnlLNZqNyXtyWKmw2faia8yiwsd/EOgNBaSHPBI/p9HrsgnIAiutXQz zewD6aQglqr8E46gGgU7xs4lmH4oyZpqQX8IW749NG85ewS1BA5qeS3VefBVjsJMI08t Iasw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3vMb1WfN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id az1-20020a056a02004100b00578a2466521si10686267pgb.676.2023.09.25.09.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 09:47:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3vMb1WfN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0645881B2110; Mon, 25 Sep 2023 01:22:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232727AbjIYIWk (ORCPT + 30 others); Mon, 25 Sep 2023 04:22:40 -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-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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 01:22:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778028858540773367 X-GMAIL-MSGID: 1778028858540773367 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 *vma, unsigned long addr, return ret; } -#ifdef CONFIG_NUMA -static int kernfs_vma_set_policy(struct vm_area_struct *vma, - struct mempolicy *new) -{ - struct file *file = vma->vm_file; - struct kernfs_open_file *of = kernfs_of(file); - int ret; - - if (!of->vm_ops) - return 0; - - if (!kernfs_get_active(of->kn)) - return -EINVAL; - - ret = 0; - if (of->vm_ops->set_policy) - ret = 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 = vma->vm_file; - struct kernfs_open_file *of = 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 = vma->vm_policy; - if (of->vm_ops->get_policy) - pol = of->vm_ops->get_policy(vma, addr); - - kernfs_put_active(of->kn); - return pol; -} - -#endif - static const struct vm_operations_struct kernfs_vm_ops = { .open = kernfs_vma_open, .fault = kernfs_vma_fault, .page_mkwrite = kernfs_vma_page_mkwrite, .access = kernfs_vma_access, -#ifdef CONFIG_NUMA - .set_policy = kernfs_vma_set_policy, - .get_policy = kernfs_vma_get_policy, -#endif }; static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)