From patchwork Tue Oct 3 09:16:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13407320 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 B3C83E75438 for ; Tue, 3 Oct 2023 09:16:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 384C26B013C; Tue, 3 Oct 2023 05:16:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 335116B013D; Tue, 3 Oct 2023 05:16:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AFC36B013E; Tue, 3 Oct 2023 05:16:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 08C9E6B013C for ; Tue, 3 Oct 2023 05:16:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D54A01C9FC9 for ; Tue, 3 Oct 2023 09:16:34 +0000 (UTC) X-FDA: 81303594708.09.609BA14 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by imf06.hostedemail.com (Postfix) with ESMTP id E9506180019 for ; Tue, 3 Oct 2023 09:16:32 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=s3VgY5Zq; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of hughd@google.com designates 209.85.128.176 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696324593; 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=6szECgvu3nTPHPzEk6DBfoYWo45M6R50iawIs9FUBJg=; b=r9R+Ap/8UTyR9uYEwp0AmWBlZB54Srnxn5CEVpRhGnh0hRfuL3QcdVRJI9qpFJHAWj61YY /fRM2PMMcuoTgBEKw/6s/3/uDgdZ4x0XGNghFOTBAozN5ppQhoVnqVnFwcfHtv4vUUgzih Q0MGEWUYupxpzYjadgIRbsPPw65/a4I= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=s3VgY5Zq; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of hughd@google.com designates 209.85.128.176 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696324593; a=rsa-sha256; cv=none; b=NlsBHCwkDaqK3kGDQXTV1uC+fQegbQFjRCpRTA2QoHfestJKMEdxL6rSM7Wl9WP/I5Mfel GdMMVWoshj3Zy6OqaKv/dstxhUKRxs31+fvR9ESDzWO6WcG/oDgLaLMEokTKeYzHQ1yKmQ 8apzy+5Ii/p03B4yZnEHzXxSNDwzNag= Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-5a1d0fee86aso8520747b3.2 for ; Tue, 03 Oct 2023 02:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696324592; x=1696929392; 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=6szECgvu3nTPHPzEk6DBfoYWo45M6R50iawIs9FUBJg=; b=s3VgY5ZqTO2z2Phmw0XWlCPr7NFvck9vevctQ0iLVj4YFObAlvnKFs9TTDfdPOILSC UcIFkcDLWSQpNerm8mC7e3FGcdnllk9MW+ETzCgnM4IkN5nApW2qGOqRBzJkDfJBMmOi OFLR+bzqnZ/Ky5rtJ8PnYpj446+gRCnUCRMwE+gft3wUZn36xrKEzA3TNCgNK2NTeH1D PgOEZnym3msfFwxAHi6gCV51VijnOFmAxAS89APlmtQcoTKglr0PXsGJtPUXmZY1HoG3 0gg3jGQRelC6AZ1K540SPzgci9K4DnUoWFeGrqFldJIvZeNmhOywNOTSIZEk89Wo7E34 TbAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696324592; x=1696929392; 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=6szECgvu3nTPHPzEk6DBfoYWo45M6R50iawIs9FUBJg=; b=uWcmf0Rq8RHJk48G5KCZXyp+Fr9EAxQ/lOMYM6XsgKOxqoFKQhtWkjHv/iyFgv1wYP 1AWvQDBI77r6qjG7M+gjJj2vghFzYOx+7eHB72Cbtvpo9TF/45qzgDatq7daTeXBl6B4 mZ+VyTeAG0ORjnCFrE38OR9HjXeCKS03Q4xdXQ/Qqs3+ltNtY/3dr2XO6SLRTIpb7Zn2 FM/ZSWqb8lW+vgkbWrcUqVgYSdSZkFWs3i1DNTFfJWqTEYhiZmIhbAdc+A99xDCeCPWx bLmzRHtsXhX2IohUhgi5O8DOy/hTSr/T1dW6sEsc/Rw7emLS8/Aw2nU6WCJleCJxcGuh teJw== X-Gm-Message-State: AOJu0YxDGtBwZaJYXwYnf3l7Cj54x9achyF0uF14kRpYmT/vgP3QZ7EU wDlza5rDvjhkz6pxgWB3QISu2w== X-Google-Smtp-Source: AGHT+IF7TKqrMTfEG37/bwFMCSN9pzNnHHphoLkIAInKebAgyaWY8C3y19zZ2lbUvYlV8i48+gNb6Q== X-Received: by 2002:a0d:ee46:0:b0:5a1:635e:e68 with SMTP id x67-20020a0dee46000000b005a1635e0e68mr11991552ywe.46.1696324591927; Tue, 03 Oct 2023 02:16: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 m14-20020a819c0e000000b00583f8f41cb8sm244237ywa.63.2023.10.03.02.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 02:16:31 -0700 (PDT) Date: Tue, 3 Oct 2023 02:16:29 -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 02/12] kernfs: drop shared NUMA mempolicy hooks In-Reply-To: Message-ID: <302164-a760-4a9e-879b-6870c9b4013@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: E9506180019 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 79eaz9i553i65zintx3oafd4cy1xrzoc X-HE-Tag: 1696324592-240653 X-HE-Meta: U2FsdGVkX1/Ri4QfYfsNfbuldfxuNTX+g5PyNpRBdj3WKsfkZF0+GgtLzgY/KxX9RlMgxg0UF6BtmZaKnGytjNDx1vpJTrLg++Wn33K4aEJHvjFNktz6oS+M53vE6FEegtX65WvWdonBDDynkwCC49jxZbgK8cDa3QNnsUAYdFrux33x8B5E1CNBOnRogYWw4yw+SJC0uFiYMaE5yVT+ghGF+m1IZmAfhwd0M54WQxvHZLHMOWPkNMPLl2QYQedtbYiRq7/1eYM9Kc7yRc7ot8BQehFxh0LoR+RrabJ+nZjKNKsRpJNPBQkxfeyi1QlFI6CPm3Vqnn2l0xDc7Xeh2+CIOZL0WNQCm26mg3NIXobOUNnBkjZDhS+OHL0bg2xpO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YcH0lHKlsvb3SFI9C6OXgKNyJH0ke9H2+DoXOaqxGVv 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: 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)