From patchwork Sun Mar 12 23:40:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 68606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp926025wrd; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) X-Google-Smtp-Source: AK7set+xaOKjj+gm14ZUOAC1U2QviEeSx6Pj9Xn1ZIeJypHm+OVdgiJEg/ouzAC/f+fSebbddyZh X-Received: by 2002:a17:902:f68c:b0:199:2b9f:f369 with SMTP id l12-20020a170902f68c00b001992b9ff369mr36686471plg.32.1678665454364; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678665454; cv=none; d=google.com; s=arc-20160816; b=iuRc88I034FN0k2AwyMYbGauIwed9xAQSEba8SDKA5IJUVydxlWDgcA5t4IWYlqDIL qHEXT/V/QaXudCaZJ3RNILyKB1RWuXsLVOBYu+628JFLdaFA0hJlkm+nFLwujgqqpHMT RYsEA1He+EDDDPHY894dQWGx7HjE2TAAL6g+OXzloXevj36OPRlQv/C3OGDj8gLJuapW Mhvju9tKwXzDYwe7NlapDWQIwAYDInGLf1EsiK8yHr/LyI6xaGrhXykxXX4DUSj67Mi4 rrTZ8pYxbCNSzXRrxtq5RZ5wJmz2qcLsLH3JyQt5A164XKipjeiq/+r0/b4ftjS/Y3Uy s7bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q+mP9OxDgYsiVDAz5z+bfOZyYeqjlm5fObrSUjf3HHE=; b=Kt/+hQiiQpvuiyWcCx0Rd6gMrELjPbwt+emIzD9MAKVfp82+PJ7E5x1AFG6pWyQXxm 7jn1Ne5a/a4S+s0P7EhdPDYxp19iSfjGsZcVZ+uNicnBSJJEDj46PN+xTFboCN6Ff4Qs FO0QiJNgQ6lgFu2S1WULVbpLbet72QWBeJRGDYdCfGniMq5m36z08Sax6Bc0oAsGdx1J 8EgDbOPq5dTdtAJYPaskJtPOoZOEl9n2Zi1aFbOilLrKhJcfhmWGwIjuBUamDOMMX0Rj G5Ds3TdQNjUSnKWZzz1YRxkvtLoYPFZOk1ySpTqzLcEkhrqG/dEd41nJ4ZbCIS3/5gRJ CkQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L1Evxvsp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a17-20020a170902ee9100b0019e6a6c8cfbsi5143800pld.549.2023.03.12.16.57.19; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L1Evxvsp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbjCLXmn (ORCPT + 99 others); Sun, 12 Mar 2023 19:42:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjCLXmg (ORCPT ); Sun, 12 Mar 2023 19:42:36 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D64A2BEE2 for ; Sun, 12 Mar 2023 16:42:32 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so9757461wms.2 for ; Sun, 12 Mar 2023 16:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678664551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q+mP9OxDgYsiVDAz5z+bfOZyYeqjlm5fObrSUjf3HHE=; b=L1EvxvspnWq8VbJ/cBPuwim/GfX7GyDcQh25eB8GiiGs7xV6czGIVCDJwylbb/WhpH jDFWtcEGZEkI905j9O6EBHcKvsGVqjZK04JkCGnQY528FTc/xGSKUQoJ1yY0pPvKCbzb IBNvOTkgsqZyZycwsx8m2Sth1E7Aozlkfg5MUoZCKaaMJPw/6tRWZDo07r5CQODqxUMT 1IeCaq70mfPubXlyZAz0EF4+uo1ZBp0Z928tN4A3fNLcS0TV/nntMus6BBh64bjYsk9h tNxjHKAtpE6j09aXXplCYPYqgmxOLm6RPMn+1oaBSQ4+kPQxO6ASvcd39FdgX1bjTARn 4pFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678664551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q+mP9OxDgYsiVDAz5z+bfOZyYeqjlm5fObrSUjf3HHE=; b=S5sog8jFDX5yqdMvRh1/jzh1WppH+Nl9h9lu29Qp1f1K0vVBRY8Xewf0/6mHMsIEW8 iY6ZtGO8UsImmObrmywZuzmAyvxe13pucOl+gNwVXLfGa5zWACla8dzR387K65McZj/d WR4w8VVeCN313Y1ILU8DUKTgNarzWWq3B6EhHIIQdytszRqrFiFrU0cSlKuno915Y1i0 Pzr8aREYyU5ZMsS0Em8ehHcLTsOHikuQZp+W0+lXLye2IzKwUGvZHQ5ZbyWXdE6P95lO aRF4YsJ2kMaXNNuxLKZOIavxJH9uwym/ssRNbNz52lu6M50blCxNJKqT+EFuo2O/NYv9 /oIQ== X-Gm-Message-State: AO0yUKUdZD/vJU4HBoX6vZI6csZljWDaitdw72+TKRs21KApEa4TUrEU yuLzhKR2X1gxAy8MfZfsoEk= X-Received: by 2002:a05:600c:350c:b0:3eb:3692:6450 with SMTP id h12-20020a05600c350c00b003eb36926450mr10229727wmq.18.1678664550942; Sun, 12 Mar 2023 16:42:30 -0700 (PDT) Received: from lucifer.home (host86-146-209-214.range86-146.btcentralplus.com. [86.146.209.214]) by smtp.googlemail.com with ESMTPSA id iz20-20020a05600c555400b003ed201ddef2sm3698376wmb.2.2023.03.12.16.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 16:42:30 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrew Morton Cc: Thomas Hellstrom , Christian Konig , Matthew Wilcox , Michal Hocko , "Kirill A . Shutemov" , Dan Williams , Jason Gunthorpe , Lorenzo Stoakes Subject: [PATCH 1/3] mm: remove unused vmf_insert_mixed_prot() Date: Sun, 12 Mar 2023 23:40:13 +0000 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760208307560863092?= X-GMAIL-MSGID: =?utf-8?q?1760208307560863092?= The sole user of vmf_insert_mixed_prot(), the drm ttm module, stopped using this in commit f91142c62161 ("drm/ttm: nuke VM_MIXEDMAP on BO mappings v3") citing use of VM_MIXEDMAP in this case being terribly broken. Remove this now-dead code and references to it, but retain the useful description of the prot != vma->vm_page_prot case, moving it to vmf_insert_pfn_prot() instead. Signed-off-by: Lorenzo Stoakes --- include/linux/mm.h | 2 -- include/linux/mm_types.h | 7 +---- mm/memory.c | 57 +++++++++++++--------------------------- 3 files changed, 19 insertions(+), 47 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ce1590933995..ee755bb4e1c1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3330,8 +3330,6 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); -vm_fault_t vmf_insert_mixed_prot(struct vm_area_struct *vma, unsigned long addr, - pfn_t pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 3a028db80ffb..5ef0d0da328a 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -502,12 +502,7 @@ struct vm_area_struct { }; struct mm_struct *vm_mm; /* The address space we belong to. */ - - /* - * Access permissions of this VMA. - * See vmf_insert_mixed_prot() for discussion. - */ - pgprot_t vm_page_prot; + pgprot_t vm_page_prot; /* Access permissions of this VMA. */ /* * Flags, see mm.h. diff --git a/mm/memory.c b/mm/memory.c index 7ca7951adcf5..ee6bcd747867 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2147,8 +2147,20 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, * vmf_insert_pfn_prot should only be used if using multiple VMAs is * impractical. * - * See vmf_insert_mixed_prot() for a discussion of the implication of using - * a value of @pgprot different from that of @vma->vm_page_prot. + * pgprot typically only differs from @vma->vm_page_prot when drivers set + * caching- and encryption bits different than those of @vma->vm_page_prot, + * because the caching- or encryption mode may not be known at mmap() time. + * + * This is ok as long as @vma->vm_page_prot is not used by the core vm + * to set caching and encryption bits for those vmas (except for COW pages). + * This is ensured by core vm only modifying these page table entries using + * functions that don't touch caching- or encryption bits, using pte_modify() + * if needed. (See for example mprotect()). + * + * Also when new page-table entries are created, this is only done using the + * fault() callback, and never using the value of vma->vm_page_prot, + * except for page-table entries that point to anonymous pages as the result + * of COW. * * Context: Process context. May allocate using %GFP_KERNEL. * Return: vm_fault_t value. @@ -2223,9 +2235,9 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) } static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma, - unsigned long addr, pfn_t pfn, pgprot_t pgprot, - bool mkwrite) + unsigned long addr, pfn_t pfn, bool mkwrite) { + pgprot_t pgprot = vma->vm_page_prot; int err; BUG_ON(!vm_mixed_ok(vma, pfn)); @@ -2268,43 +2280,10 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma, return VM_FAULT_NOPAGE; } -/** - * vmf_insert_mixed_prot - insert single pfn into user vma with specified pgprot - * @vma: user vma to map to - * @addr: target user address of this page - * @pfn: source kernel pfn - * @pgprot: pgprot flags for the inserted page - * - * This is exactly like vmf_insert_mixed(), except that it allows drivers - * to override pgprot on a per-page basis. - * - * Typically this function should be used by drivers to set caching- and - * encryption bits different than those of @vma->vm_page_prot, because - * the caching- or encryption mode may not be known at mmap() time. - * This is ok as long as @vma->vm_page_prot is not used by the core vm - * to set caching and encryption bits for those vmas (except for COW pages). - * This is ensured by core vm only modifying these page table entries using - * functions that don't touch caching- or encryption bits, using pte_modify() - * if needed. (See for example mprotect()). - * Also when new page-table entries are created, this is only done using the - * fault() callback, and never using the value of vma->vm_page_prot, - * except for page-table entries that point to anonymous pages as the result - * of COW. - * - * Context: Process context. May allocate using %GFP_KERNEL. - * Return: vm_fault_t value. - */ -vm_fault_t vmf_insert_mixed_prot(struct vm_area_struct *vma, unsigned long addr, - pfn_t pfn, pgprot_t pgprot) -{ - return __vm_insert_mixed(vma, addr, pfn, pgprot, false); -} -EXPORT_SYMBOL(vmf_insert_mixed_prot); - vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { - return __vm_insert_mixed(vma, addr, pfn, vma->vm_page_prot, false); + return __vm_insert_mixed(vma, addr, pfn, false); } EXPORT_SYMBOL(vmf_insert_mixed); @@ -2316,7 +2295,7 @@ EXPORT_SYMBOL(vmf_insert_mixed); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { - return __vm_insert_mixed(vma, addr, pfn, vma->vm_page_prot, true); + return __vm_insert_mixed(vma, addr, pfn, true); } EXPORT_SYMBOL(vmf_insert_mixed_mkwrite); From patchwork Sun Mar 12 23:40:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 68604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp926024wrd; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) X-Google-Smtp-Source: AK7set+rTZm9w085aH4XHnuNtgut3idwlwZciHdCjAqd3hVVPTGrxudb11BdkO2t10zWQb1UTZnQ X-Received: by 2002:a17:902:e550:b0:1a0:42c0:b2a5 with SMTP id n16-20020a170902e55000b001a042c0b2a5mr2980827plf.24.1678665454227; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678665454; cv=none; d=google.com; s=arc-20160816; b=pW9rA36USmoyWgq43gZVrPpB3IsQE2/AFpHm0l/3465JkH+DO90Y0cYhs+mDzX3EdI Dks9SixyAeVF74/CEoMc3H3RN/oq4WoxnYgSf5z9ahocaaL3AHi8J1Rx8NTkYFK6mzKk HacVqshxzcBI0LCt7En2k9PLC1F2b7f8RpXRa4OeGgw1zO1fUD95rdzU34peofxJa9cJ /FfUkHDd06zd+YBS61G1ZN67mOGPwvjNjXlB9ooOryX6SfylQKaCzfC/3Ej2agbpkJW2 J95E/zhDBFwU474AO6HwInRoaeiGN/GQoN1tLo/xbtPmeGiWd14Iqg5e2Lfw4uafV6IA fkOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l5BwzPdb3pP6HQP4bpfNX6Ih3sOxfK6TuzT4vYnYmzI=; b=0kJfacfnLmSUyBXpQV3+Wc7XPlbnjHjjNaMb9QCcj7g5+G2LP9VIgukGTiHw1JMVs3 TKnUplJIq0yrxDyz/2nMLGVZJrJrsLLSJlbxEOQ6OFlEu/t9idsrnb69zNBdagZq/LjV oRlddBninu0c5eglLD7dXzPLTOJIV+x5PYdLm7ZtajBxqPbwbdLEk34bO5GHzfrDhYH3 wSvH+XfbKsPVxw+eI6n3Lkpyymwqq36uFRi+Gwce8Wag1sc3vaDpRUERSBAgbjvnlE2M TZQPc8hxy8WlJs+fmVexC/BVF2x8pQTg68OW5+YjD6ZRILz4Gh+etaI3K/sgmt7jkDKo Vrew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=maz9e2QT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a170902ebd000b00199051ac8f7si5270077plg.188.2023.03.12.16.57.19; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=maz9e2QT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbjCLXmi (ORCPT + 99 others); Sun, 12 Mar 2023 19:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbjCLXmf (ORCPT ); Sun, 12 Mar 2023 19:42:35 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 177D32B9DD for ; Sun, 12 Mar 2023 16:42:34 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id o5-20020a05600c510500b003ec0e4ec6deso3673811wms.3 for ; Sun, 12 Mar 2023 16:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678664552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l5BwzPdb3pP6HQP4bpfNX6Ih3sOxfK6TuzT4vYnYmzI=; b=maz9e2QTegb5aGWaMrUn0W1T4Yb7pAPV4qShHMkAP0jmTAZnGYuceUYaHypxk3ZK3n ZDBqAaSh4+ktG95WP3CVzvvsS2QYlwldP0jD7mTJmW1UGRN168RC1lxMVOZZ1PQh6TOP +y2rQ91YejaLYBVYdHPFlUg3gA+SBPTgCXZkunTCQq/KKrnRLP5bUKBFIC/AQiIgFbRE 9s1UuvtwQdsPaN9SJ22GP58vW9sS051TMmx+qiNlQayml8SjCelQJT8pch0Nw/dG8/SL tYw6OY+zWYtLnjRJ7LUlFPQgbzFk8ileybTIoNKp4/+CPVyIglWvzyNCWtisu9Kn/kcB nHrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678664552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l5BwzPdb3pP6HQP4bpfNX6Ih3sOxfK6TuzT4vYnYmzI=; b=Ncnfm4ip9PHNKcEfFoj5SqqjNJ+L4Bpfsr/g/kBHbhue7yrwwkfzoqcHcjMms+0RZw uyw+CR+C4/s7iPZYQWOqW5X7dYbvQnBSo7CLLzqzdA8/vROCA53vGCjVpXwn09MP1/ih QKekHqVB/beIjVx9GBfpw4HBnNySP3btLbmf61dvkUhwoNQV/JRmw3moGc+fvZAWoyj1 dhWSonWJrvFzfKTNAtormTQylcAoaMFatOcXyOc0inxSLFDtfogiNT78wLfpxe7I9yXE Bq9U27Fd9YaCKS7ck9NRlMEwxhUvszQWy2mFNpzQHHFb6mfimvZHOcQCTERq9CW04lfA ER3Q== X-Gm-Message-State: AO0yUKXr0O1jsUzY3w6GcwS35GLEW+BEl0Kf5Knp0BE9VARtHZxem1+y 7yiLAhhNdPr/sEUuRRTsIRY= X-Received: by 2002:a05:600c:1d29:b0:3eb:3945:d3f4 with SMTP id l41-20020a05600c1d2900b003eb3945d3f4mr10055016wms.2.1678664552343; Sun, 12 Mar 2023 16:42:32 -0700 (PDT) Received: from lucifer.home (host86-146-209-214.range86-146.btcentralplus.com. [86.146.209.214]) by smtp.googlemail.com with ESMTPSA id iz20-20020a05600c555400b003ed201ddef2sm3698376wmb.2.2023.03.12.16.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 16:42:31 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrew Morton Cc: Thomas Hellstrom , Christian Konig , Matthew Wilcox , Michal Hocko , "Kirill A . Shutemov" , Dan Williams , Jason Gunthorpe , Lorenzo Stoakes Subject: [PATCH 2/3] mm: Remove vmf_insert_pfn_xxx_prot() for huge page-table entries Date: Sun, 12 Mar 2023 23:40:14 +0000 Message-Id: <604c2ad79659d4b8a6e3e1611c6219d5d3233988.1678661628.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760208307317800223?= X-GMAIL-MSGID: =?utf-8?q?1760208307317800223?= This functionality's sole user, the drm ttm module, removed support for it in commit 0d979509539e ("drm/ttm: remove ttm_bo_vm_insert_huge()") as the whole approach is currently unworkable without a PMD/PUD special bit and updates to GUP. Signed-off-by: Lorenzo Stoakes --- include/linux/huge_mm.h | 39 ++------------------------------------- mm/huge_memory.c | 31 +++++++++++++------------------ 2 files changed, 15 insertions(+), 55 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 70bd867eba94..3c52fc9d85dc 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -39,44 +39,9 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, pgprot_t newprot, unsigned long cp_flags); -vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write); -/** - * vmf_insert_pfn_pmd - insert a pmd size pfn - * @vmf: Structure describing the fault - * @pfn: pfn to insert - * @pgprot: page protection to use - * @write: whether it's a write fault - * - * Insert a pmd size pfn. See vmf_insert_pfn() for additional info. - * - * Return: vm_fault_t value. - */ -static inline vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, - bool write) -{ - return vmf_insert_pfn_pmd_prot(vmf, pfn, vmf->vma->vm_page_prot, write); -} -vm_fault_t vmf_insert_pfn_pud_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write); - -/** - * vmf_insert_pfn_pud - insert a pud size pfn - * @vmf: Structure describing the fault - * @pfn: pfn to insert - * @pgprot: page protection to use - * @write: whether it's a write fault - * - * Insert a pud size pfn. See vmf_insert_pfn() for additional info. - * - * Return: vm_fault_t value. - */ -static inline vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, - bool write) -{ - return vmf_insert_pfn_pud_prot(vmf, pfn, vmf->vma->vm_page_prot, write); -} +vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write); +vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write); enum transparent_hugepage_flag { TRANSPARENT_HUGEPAGE_NEVER_DAX, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b0ab247939e0..5a0e5e84ab13 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -889,23 +889,20 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, } /** - * vmf_insert_pfn_pmd_prot - insert a pmd size pfn + * vmf_insert_pfn_pmd - insert a pmd size pfn * @vmf: Structure describing the fault * @pfn: pfn to insert - * @pgprot: page protection to use * @write: whether it's a write fault * - * Insert a pmd size pfn. See vmf_insert_pfn() for additional info and - * also consult the vmf_insert_mixed_prot() documentation when - * @pgprot != @vmf->vma->vm_page_prot. + * Insert a pmd size pfn. See vmf_insert_pfn() for additional info. * * Return: vm_fault_t value. */ -vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write) +vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) { unsigned long addr = vmf->address & PMD_MASK; struct vm_area_struct *vma = vmf->vma; + pgprot_t pgprot = vma->vm_page_prot; pgtable_t pgtable = NULL; /* @@ -933,7 +930,7 @@ vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, insert_pfn_pmd(vma, addr, vmf->pmd, pfn, pgprot, write, pgtable); return VM_FAULT_NOPAGE; } -EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd_prot); +EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd); #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD static pud_t maybe_pud_mkwrite(pud_t pud, struct vm_area_struct *vma) @@ -944,9 +941,10 @@ static pud_t maybe_pud_mkwrite(pud_t pud, struct vm_area_struct *vma) } static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, - pud_t *pud, pfn_t pfn, pgprot_t prot, bool write) + pud_t *pud, pfn_t pfn, bool write) { struct mm_struct *mm = vma->vm_mm; + pgprot_t prot = vma->vm_page_prot; pud_t entry; spinlock_t *ptl; @@ -980,23 +978,20 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, } /** - * vmf_insert_pfn_pud_prot - insert a pud size pfn + * vmf_insert_pfn_pud - insert a pud size pfn * @vmf: Structure describing the fault * @pfn: pfn to insert - * @pgprot: page protection to use * @write: whether it's a write fault * - * Insert a pud size pfn. See vmf_insert_pfn() for additional info and - * also consult the vmf_insert_mixed_prot() documentation when - * @pgprot != @vmf->vma->vm_page_prot. + * Insert a pud size pfn. See vmf_insert_pfn() for additional info. * * Return: vm_fault_t value. */ -vm_fault_t vmf_insert_pfn_pud_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write) +vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write) { unsigned long addr = vmf->address & PUD_MASK; struct vm_area_struct *vma = vmf->vma; + pgprot_t pgprot = vma->vm_page_prot; /* * If we had pud_special, we could avoid all these restrictions, @@ -1014,10 +1009,10 @@ vm_fault_t vmf_insert_pfn_pud_prot(struct vm_fault *vmf, pfn_t pfn, track_pfn_insert(vma, &pgprot, pfn); - insert_pfn_pud(vma, addr, vmf->pud, pfn, pgprot, write); + insert_pfn_pud(vma, addr, vmf->pud, pfn, write); return VM_FAULT_NOPAGE; } -EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud_prot); +EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud); #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ static void touch_pmd(struct vm_area_struct *vma, unsigned long addr, From patchwork Sun Mar 12 23:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 68605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp926026wrd; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) X-Google-Smtp-Source: AK7set8cOVSYnQp7bh0+zDZ5tF3Cv6gbeO+6/d2xL4Fxbyc+N+8EgkjiREFeKaE6AjbWq3t6gHrz X-Received: by 2002:a17:902:7085:b0:19f:3e33:b845 with SMTP id z5-20020a170902708500b0019f3e33b845mr2865066plk.26.1678665454400; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678665454; cv=none; d=google.com; s=arc-20160816; b=morjr4xfBjcvHQCQ98Ie32AHLa9M/GNpZ6TAwbYjrGOgsKZti8etQF1CD9HRUJSyZr ooUJ8xglxCrRTkSPaQ5hSd6+9HCJsG9IhR1e3Cb6e/ef0bPrY1oXv2G5uza1SlQndvlv aklfCwyAmScwELbRgqVJ58SUO5phRu75rGcI6nGAvogT5Uo8H0ryDC44/zS7tYOrags6 pVskcrElYAkFOzJjV019wipvcKZMG+NWvTRPXwLCKBs3vUH/pDY+EooaYXv2i1ezgo50 zaQY3BlMm8fiVGebq5KM4Kdkg/4YVewAmkSzrCifIqxcMKTNNQvio2kDs3jHV/2buWJt oNAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=la0p/jvvcd1pW9pC/kzK82qIi7c6KvzFPifjBlwZbrc=; b=PFrzQ3ukquSYCY34OjP9h5xslx9pFgimoTbQlt7zZp5PX7Vm3agOk0W1Wwk8q4tAO5 WEQ8TOCTOo6Za1cjSYNs2JvhVDY3Rq+RNGoJclQShhvxd+bzRzNcwojLqt0IN0ZWDA9O vQFRKnDGyosLdmw3wb8xA2RL8C53i7H9iE76TDRbn8+KreGU3OO9gChLSAtDTbj+ItAK XTcKvN2gtmQNGYwxoduVD8ePlnIT5ATWEUSkpGsOxkNSACatY69UKqzmfewSDtk2/4wQ rgHptu5pktHqT7BAqmWAUvu164rxE3IxOgNolFEI4OSNADeXYnFYgHbKg12JLoHqMSUU giew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aLZj8JfH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb3-20020a170902fa4300b0019fb6f89e0bsi2206875plb.266.2023.03.12.16.57.19; Sun, 12 Mar 2023 16:57:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aLZj8JfH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjCLXml (ORCPT + 99 others); Sun, 12 Mar 2023 19:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjCLXmg (ORCPT ); Sun, 12 Mar 2023 19:42:36 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3141A2BF30 for ; Sun, 12 Mar 2023 16:42:35 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id o5-20020a05600c510500b003ec0e4ec6deso3673824wms.3 for ; Sun, 12 Mar 2023 16:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678664553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=la0p/jvvcd1pW9pC/kzK82qIi7c6KvzFPifjBlwZbrc=; b=aLZj8JfH0eQ7HFdZx/+iprS/tlBFopYdB1aCKQXTt5WK8FgM8bcDbsa+wSY1iKQJxE Sq7nlwxxzv+OkfrXORItUJ0aliFlsx2GYC4bVIbkqOdoz3XJ/8X+6UsBq/gt7H0EZtMt nuAc/KhC3rf0zvdcWc/OLcAHwR9ZY+peyrzGWB24fyZW1aAv3sBtA5JYpdpHACiwUM4C Zn2OTxsvJxQeZs50umFz+7v+OiiQaf/ZCNb2VEVVGtNQsaBRYYbpPPVuAQjUJokXjnKZ skXJHxntFAccCGCVcChxVjMizrL+8AfSuhDiDuW1ANf8qzQ5/J6eKWecB6/XPCdmkVUt dJcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678664553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=la0p/jvvcd1pW9pC/kzK82qIi7c6KvzFPifjBlwZbrc=; b=BYo+FO6rM+8RvJXTOVz8dXHjxHfCubk9NYqDajgoV3oSaZhLOO+D0vLRKCKPcNx05u tApmaw+tyZgPxG39FxfeWWhQuwrdPFTXzGHrHMFrgeuod8kDrqYe/0DbiLyPUzalcksM b7naSqv6FJx/8gA/wCy3jJoPCii7lfvJCcXccYsPkuGlUxstFbY6BP3u0YSrUmpVbUYD eI28T50CL7510GHnjq2f14oecgZdL1S8tqoHkEFLxgZsjbASc9g+6+nnmkoQioH8uQl8 J2dYhdo3nLyIlpFJ+0dechO2Bz0HGOjzOeu3r4V470q8sI2IsrTWfIj2unJIiCVpGAQq q/rg== X-Gm-Message-State: AO0yUKVT5abZlZHDZf+XXTA1AMsXbBVIu1P7eFYvr1pCGKhoI9URQ4fW JapahBvOXI6346QotEQcdtw= X-Received: by 2002:a05:600c:4e87:b0:3eb:38a2:2bcd with SMTP id f7-20020a05600c4e8700b003eb38a22bcdmr9079693wmq.28.1678664553621; Sun, 12 Mar 2023 16:42:33 -0700 (PDT) Received: from lucifer.home (host86-146-209-214.range86-146.btcentralplus.com. [86.146.209.214]) by smtp.googlemail.com with ESMTPSA id iz20-20020a05600c555400b003ed201ddef2sm3698376wmb.2.2023.03.12.16.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 16:42:32 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrew Morton Cc: Thomas Hellstrom , Christian Konig , Matthew Wilcox , Michal Hocko , "Kirill A . Shutemov" , Dan Williams , Jason Gunthorpe , Lorenzo Stoakes Subject: [PATCH 3/3] drm/ttm: Remove comment referencing now-removed vmf_insert_mixed_prot() Date: Sun, 12 Mar 2023 23:40:15 +0000 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760208307682227697?= X-GMAIL-MSGID: =?utf-8?q?1760208307682227697?= This function no longer exists, however the prot != vma->vm_page_prot case discussion has been retained and moved to vmf_insert_pfn_prot() so refer to this instead. Signed-off-by: Lorenzo Stoakes Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index ca7744b852f5..5df3edadb808 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -254,7 +254,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, * encryption bits. This is because the exact location of the * data may not be known at mmap() time and may also change * at arbitrary times while the data is mmap'ed. - * See vmf_insert_mixed_prot() for a discussion. + * See vmf_insert_pfn_prot() for a discussion. */ ret = vmf_insert_pfn_prot(vma, address, pfn, prot);