From patchwork Mon Jun 12 15:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13276829 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 58744C88CB2 for ; Mon, 12 Jun 2023 15:16:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B567D6B0074; Mon, 12 Jun 2023 11:16:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B06C46B0075; Mon, 12 Jun 2023 11:16:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CE7E8E0002; Mon, 12 Jun 2023 11:16:05 -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 8C5AF6B0074 for ; Mon, 12 Jun 2023 11:16:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 55F871C7A28 for ; Mon, 12 Jun 2023 15:16:05 +0000 (UTC) X-FDA: 80894446290.29.F90073A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf29.hostedemail.com (Postfix) with ESMTP id 39FDF120013 for ; Mon, 12 Jun 2023 15:16:02 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686582963; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=F8Is49mqR+xnx8M7svhWuLvI1W26lqHdsz/cDfr6iuM=; b=w9FD/v5laVbjgRLoLfEyzpUxHjdkyZF2SgWkP9klLjzJzESt08HFd4p5WvBghk54WeigTE Ya71PMuiVaP13MdZN/d3yli+rCz5DHR/eQArU94PmzPtyMmw/sOgeZ3skGQx7ew6KLZKcN bRaMZLNmrd2WYAn0bptjhiXjm4PckeY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686582963; a=rsa-sha256; cv=none; b=Q7SSNWMH1bgwqz5FuebFizOovPyFS4MCSsYZwC/Lfvb62wc4YPqE2AZ7CKCFEQiTzZ2iAd OX51rNTdFrMI6coeNXYbwf1tsdLQmIqdIovjWefoGSbGyEfn3SMwGmNLnqr4kbXMCR+Ua1 7q0foSywZ71PaiQlBgb/uyzVjehgOoM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4E5FE1FB; Mon, 12 Jun 2023 08:16:46 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 628073F5A1; Mon, 12 Jun 2023 08:15:56 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , SeongJae Park , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Mike Rapoport , Yu Zhao , Jason Gunthorpe , David Airlie , Daniel Vetter , Dimitri Sivanich , Alex Williamson , Oleksandr Tyshchenko , Alexander Viro , Christian Brauner , Mike Kravetz , Muchun Song , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Naoya Horiguchi , Miaohe Lin , Pasha Tatashin , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [PATCH v3 0/3] Encapsulate PTE contents from non-arch code Date: Mon, 12 Jun 2023 16:15:42 +0100 Message-Id: <20230612151545.3317766-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 39FDF120013 X-Rspam-User: X-Stat-Signature: 98camk8zr146aeobcjhygccyyjj1nkhn X-Rspamd-Server: rspam03 X-HE-Tag: 1686582962-58045 X-HE-Meta: U2FsdGVkX1+6i3ZTkjLD+To9ZXi57UG4Pb81k3rEg5/Qn24Fr3IYgoTvxfi++exU7X4x49gDBFZt/pnlFCcdIlccErT93LlU5t+RUbILe0eX72TdeLvQ35vO0JyGLjuWezoZOocibl/jgyUgy3peFpsyG001Imi/p+lQWxZBsnb6IIiCXkfr8X84FLsXDNMHaVyUb/VkWynAZ5sVF2jMa7SNvCq5hg035z6S51TDQH37g4UUeMWoNohLNVAOiwOl6odzodkKX0kJRNwZ5wB+b6HGcRnnc5vVrpFNoiE4ze5MxhfCBsO/wsIYoNJvrIJ/9EWFhqG97GmwXL3DvHgxYF5qCn88wUHrR8nkxoB5pZWwSR0NqIAV9rZdyeh0grsYdbK8BgsMkrsBtK5oBxj+pj8iLBjeBBDp6Vchcfg33J6FlDJSnTh3BLnSOe6EAZ0eMzuDq1+/w6bN6Ppi+hN6Dd+u9ZBW6vFMFRlGLzsQobIls51wNqqYC0/CH+5iWBbCB28eo5hNV2P8rNrLoK6BO4FNcftLJSo27kWkpDmqGt9luvD1809Dhu1d21Ict2kzBarKLeuXL53YM1NCkWWPIJBB3MwK1kE9rH928gCh09ql96eDrjnibwwv22D/CjZPXogFcRGpXCUHtlFUtZQwfRi6Xjjg4OC3781ZpYJQOP054wXb/kGL9Z0qr5u2engflTRRkXJvmzYLp4sz7aVrpZb19iK1XoncI+i1m5Yn68HNHzQ5oVLnfUhjzZG6mKPh0PwYbg2m9gzdASdBlTvACXbZLUXylIB0rPvS4g9JrKtD0qF0A29zCI+66dPG1YAy9TtVxO7ytNTTRPPZTkNDEJaFoO063QmquSPtU4aiaPIT8N8j8MVZoxX1eLdy3fOkqYsQ/S/3c/ixXnC7oR3/wuC0tzLdmHXL5InIPU74TqAYlYDsIP98Na5z6m3PSp2EV6g/ECsN12v/1f+cZA+ 8Nl4CEXG 6UIlYMUkmzs/hoVSbwLy643YqIp+g8Bf3ZrHYjvcTyQuwoZUpxj79QUAx3K89enwosgdITlzqP2rf92CFbJDk0OIUe8NFNrFxy6xtNcuCynSZZEyEODgz217PNkl5bbC5zLx0dPCCgU8lTPwGqU6aYvGS1buXo5KoLalwnOPBL60BxwZ8lyybHOCPOKsT4m/GWil9knhmODWG/rjUyW1+xtH7bh3Bx5Jsjc9lV41hRjMFk2xRGOK1JqzYUbm6T+PhAoYbuzTEbXMmHJBw/TXzZcoczEDcjKwhZaxF 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: Hi All, (Including wider audience this time since changes touch a fair few subsystems) This is the second half of v3 of a series to improve the encapsulation of pte entries by disallowing non-arch code from directly dereferencing pte_t pointers. Based on earlier feedback, I split the series in 2; the first part, fixes for existing bugs, was already posted at [3] and merged into mm-stable. This second part contains the conversion from direct dereferences to instead use ptep_get()/ptep_get_lockless(). See the v1 cover letter at [1] for rationale for this work. Based on feedback at v2, I've removed the new ptep_deref() helper I originally added, and am now using the existing ptep_get() and ptep_get_lockless() helpers. Testing on Ampere Altra (arm64) showed no difference in performance when using ptep_deref() (*pte) vs ptep_get() (READ_ONCE(*pte)). Patches are based on mm-unstable (49e038b1919e) and a branch is available at [4] (Let me know if this is the wrong branch to target - I'm still not familiar with the details of the mm- dev process!). Note that Hugh Dickins's "mm: allow pte_offset_map[_lock]() to fail" (now in mm-unstable) patch set caused a number of conflicts which I've resolved. But due to that, you won't be able to apply these patches on top of Linus's tree. I have an alternate branch on top of v6.4-rc6 at [5]. Changes since v2 [2]: - Removed ptep_deref() helper - Converted ptep_deref() callsites to use ptep_get[_lockless]() Changes since v1 [1]: - Fixed sh build bug reported by 0-day CI [1] https://lore.kernel.org/linux-mm/20230511132113.80196-1-ryan.roberts@arm.com/ [2] https://lore.kernel.org/linux-mm/20230518110727.2106156-1-ryan.roberts@arm.com/ [3] https://lore.kernel.org/all/20230602092949.545577-1-ryan.roberts@arm.com/ [4] https://gitlab.arm.com/linux-arm/linux-rr/-/tree/features/granule_perf/ptep_get-mm-unstable-lkml_v3 [5] https://gitlab.arm.com/linux-arm/linux-rr/-/tree/features/granule_perf/ptep_get-v6.4-rc6-lkml_v3 Thanks, Ryan Ryan Roberts (3): mm: ptdump should use ptep_get_lockless() mm: Move ptep_get() and pmdp_get() helpers mm: ptep_get() conversion .../drm/i915/gem/selftests/i915_gem_mman.c | 8 +- drivers/misc/sgi-gru/grufault.c | 2 +- drivers/vfio/vfio_iommu_type1.c | 7 +- drivers/xen/privcmd.c | 2 +- fs/proc/task_mmu.c | 33 +++--- fs/userfaultfd.c | 6 +- include/linux/hugetlb.h | 4 + include/linux/mm_inline.h | 2 +- include/linux/pgtable.h | 34 +++--- kernel/events/uprobes.c | 2 +- mm/damon/ops-common.c | 2 +- mm/damon/paddr.c | 2 +- mm/damon/vaddr.c | 10 +- mm/filemap.c | 2 +- mm/gup.c | 21 ++-- mm/highmem.c | 12 ++- mm/hmm.c | 2 +- mm/huge_memory.c | 4 +- mm/hugetlb.c | 2 +- mm/hugetlb_vmemmap.c | 6 +- mm/kasan/init.c | 9 +- mm/kasan/shadow.c | 10 +- mm/khugepaged.c | 22 ++-- mm/ksm.c | 22 ++-- mm/madvise.c | 6 +- mm/mapping_dirty_helpers.c | 4 +- mm/memcontrol.c | 4 +- mm/memory-failure.c | 26 ++--- mm/memory.c | 100 ++++++++++-------- mm/mempolicy.c | 6 +- mm/migrate.c | 14 +-- mm/migrate_device.c | 15 +-- mm/mincore.c | 2 +- mm/mlock.c | 6 +- mm/mprotect.c | 8 +- mm/mremap.c | 2 +- mm/page_table_check.c | 4 +- mm/page_vma_mapped.c | 27 +++-- mm/pgtable-generic.c | 2 +- mm/ptdump.c | 2 +- mm/rmap.c | 34 +++--- mm/sparse-vmemmap.c | 8 +- mm/swap_state.c | 8 +- mm/swapfile.c | 20 ++-- mm/userfaultfd.c | 4 +- mm/vmalloc.c | 6 +- mm/vmscan.c | 14 +-- virt/kvm/kvm_main.c | 11 +- 48 files changed, 316 insertions(+), 243 deletions(-) --- 2.25.1