From patchwork Thu Nov 16 01:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13457475 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 97817C072A2 for ; Thu, 16 Nov 2023 01:29:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6A056B03BC; Wed, 15 Nov 2023 20:29:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B19E16B03BD; Wed, 15 Nov 2023 20:29:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E19C6B03BE; Wed, 15 Nov 2023 20:29:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8D4856B03BC for ; Wed, 15 Nov 2023 20:29:16 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 53AD080543 for ; Thu, 16 Nov 2023 01:29:16 +0000 (UTC) X-FDA: 81462084312.28.DAFFFC2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 442C84000D for ; Thu, 16 Nov 2023 01:29:14 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bGT1faX8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700098154; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=4PU7kaICTCYIryKeefw2/Ev2pNew0CTTu+cawaO/2M4=; b=yCXPgEHzgv//mKuC2LjtnY911GorpMyf59FNrpIwPeWsit/IZD+guQgDJmc3W4y3noYbl9 a/dre0hgYjuYV+SDnbi7IzHaeOi6PYC1VJAEspwmXnVZYlA860cnLLAOkaiYktSw9sNCQN zic1JlNDnS7aBuBf00q6M1Lf/r4kDZg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bGT1faX8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700098154; a=rsa-sha256; cv=none; b=Z5+dyX0ivHmZpaViHZDD6ldTwny0HrGbYmxtEDrHi4zjCGKq1SR6FzgAyZ7+oZF9IX4JfV dpUTA+HAUGecVu+VKevXF4mBCyngYM/1YD3MWLTxVJAXF71G/75jUIW7kH6AAafVd+B+CX 3h4z55BblFJ+pM1yOkqWrKXPpUi8Q5A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700098153; h=from:from: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:content-transfer-encoding; bh=4PU7kaICTCYIryKeefw2/Ev2pNew0CTTu+cawaO/2M4=; b=bGT1faX8UOC6hAK9KienBvMOUdKIZa0GmFVCK+kNctTMIhrwcxyhVHA7FlnQK4zxYQxqI5 IVuZ+hv0DP9lsoudZOtnMz56Fl9wb3rFQvioBGzj5/ZpPbcT4mr73fMQo+ao6jduZrphTv d8PnyuINFVTCR+NX8Jr6F1saWtSJx3Q= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-GXSaMuLxOxKhEtAbkZYe5A-1; Wed, 15 Nov 2023 20:29:12 -0500 X-MC-Unique: GXSaMuLxOxKhEtAbkZYe5A-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-584102dd90bso67665eaf.0 for ; Wed, 15 Nov 2023 17:29:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700098151; x=1700702951; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4PU7kaICTCYIryKeefw2/Ev2pNew0CTTu+cawaO/2M4=; b=raBgUzc8jzl/Bue9wtdw0ZHty/ztqDzlkvwd60GFhWJ7BbA+7u3s0qKgH0dKftz8au fbTnfr11a7tikJARuD8PQCOmg4mA8o9VojX4KS9zSLA2Zzaqc8ovcS27jL5I9yYJxufj 2wZUTieDBRxZ64dNDKSkFNLSa6sdBXaxsL/qTUqJ0r9CsnTEHuuhHGqyoBicqGqluj89 HFKSCana6P7eIVRo/mnoHdkIUCVIzxp8EzniuB6VUigAlk4jcaap83IkPCK945s+q4qi 0r5DGF8Xv8RRJYJ7vaKdageIp0OPbg64Kt+hbINQrI74Xma10+6P8dxYRS1O+BeXZmUK pv/Q== X-Gm-Message-State: AOJu0YyBiDgPQLmj05JhWgTmHGm3LR6DouHHOpvFFOblv7hwVaWzbf5t RCTEnu5z+BkDmagr90QNVCB8FoYdzjHlBJcP2X0YsVRt0M/bTOBanX8IpnWHVLOopg2mGyQLWpP KYwqhcNvEFrY= X-Received: by 2002:a05:6358:7e55:b0:16b:96fc:650e with SMTP id p21-20020a0563587e5500b0016b96fc650emr7346642rwm.3.1700098151469; Wed, 15 Nov 2023 17:29:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFImde6pf3JVssBAvi5nvxUOfTkQFEUHKzKi5Co8doDN7L44uxCciulaI4uHmQLQCXmL97l4Q== X-Received: by 2002:a05:6358:7e55:b0:16b:96fc:650e with SMTP id p21-20020a0563587e5500b0016b96fc650emr7346617rwm.3.1700098151045; Wed, 15 Nov 2023 17:29:11 -0800 (PST) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id c24-20020ac85198000000b0041e383d527esm3922598qtn.66.2023.11.15.17.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:29:10 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Kravetz , "Kirill A . Shutemov" , Lorenzo Stoakes , Axel Rasmussen , Matthew Wilcox , John Hubbard , Mike Rapoport , peterx@redhat.com, Hugh Dickins , David Hildenbrand , Andrea Arcangeli , Rik van Riel , James Houghton , Yang Shi , Jason Gunthorpe , Vlastimil Babka , Andrew Morton Subject: [PATCH RFC 00/12] mm/gup: Unify hugetlb, part 2 Date: Wed, 15 Nov 2023 20:28:56 -0500 Message-ID: <20231116012908.392077-1-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 442C84000D X-Stat-Signature: uet6bza7cmpg368fohnrjjukfwsef4ry X-HE-Tag: 1700098154-82837 X-HE-Meta: U2FsdGVkX19utuTZ+cRUsqPEgGtw2sC2gl0FkY7lSZ4wPfeQNZ2kvzaUQAQD3B/3bh1Em6ypbHc3kCZPPwkQwpc7UxVsXjhJCWKA9EJLEUMX7q+SvS4kDzax7Ig3A49jCgyCOks8rgrzffThTsVhA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IrkiHcVXaFHD/pG/hSWr7EViBV35N9KL0mdPD5MFTC65qdtaI6l83m/zOfQaITFU6YUggYI+4l4t9jVWK7XHniy4Ez7goXujjqTrrkoHMIcPOL9JdGE/am2GoqJafZdSpNSMSCcioFvRISd7VKHMPU8PNVkmbZRSAMj/ofIp9Jt+oYmhOmMV3vXpWGgrXTzL9PSadmEu9KBQ4VbSoKBt6wf+ 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: List-Subscribe: List-Unsubscribe: This patchset is in RFC stage. It's mostly because it is only yet tested on x86_64 in a VM. Not even compile tested on PPC or any other archs, it means at least the hugepd patch (patch 11) is mostly untested, or even not compile tested. Before doing that, I'd like to collect any information from high level. If anyone would like to provide any testing either over hugepd or CONT_PMD / CONT_PTE on ARM (before I reach there..), or RISCV over 64K Svnapot, that'll be very much appreciated. I'm copying PPC, ARM, RISCV list for that. It can be as simple as "./run_vmtests.sh -t gup_test -a" for now, making sure hugetlb pages can be allocated along the way; the non-hugetlb gup tests will guaranteed to be covered more or less, I suppose. In summary, this is a continuous work for previous series: https://lore.kernel.org/all/20230628215310.73782-1-peterx@redhat.com And this more or less is my current take to move one more small step towards merging hugetlb code into generic mm code, as much as we can. That part-1 series dropped follow_hugetlb_page(). The plan of this one is to further drops hugetlb_follow_page_mask(). The hugetlb GUP will use the same code path for generic mm after whole set applied. It means the generic code will need to at least understand hugepd, and that's already done like so in fast-gup. Fortunately it seems that's the only major thing I need to teach GUP to share the common path for now besides normal huge PxD entries. Non-gup can be more challenging, but that's a question for later. Patch layout: ============= Patch 1-4: Preparation works, mm generic part Patch 5-6: Bugfixes; I think patch 5 if verified can be merged earlier Patch 7-11: Preparation works, gup part Patch 12: Drop hugetlb_follow_page_mask() More information can be found in the commit messages of each patch. Any comment will be welcomed. Thanks. Peter Xu (12): mm/hugetlb: Export hugetlbfs_pagecache_present() mm: Provide generic pmd_thp_or_huge() mm: Export HPAGE_PXD_* macros even if !THP mm: Introduce vma_pgtable_walk_{begin|end}() mm/gup: Fix follow_devmap_p[mu]d() to return even if NULL mm/gup: Drop folio_fast_pin_allowed() in hugepd processing mm/gup: Refactor record_subpages() to find 1st small page mm/gup: Handle hugetlb for no_page_table() mm/gup: Handle huge pud for follow_pud_mask() mm/gup: Handle huge pmd for follow_pmd_mask() mm/gup: Handle hugepd for follow_page() mm/gup: Merge hugetlb into generic mm code include/linux/huge_mm.h | 34 +++---- include/linux/hugetlb.h | 10 +- include/linux/mm.h | 3 + include/linux/pgtable.h | 4 + mm/gup.c | 197 +++++++++++++++++++++++++--------------- mm/huge_memory.c | 117 +++++++++++++----------- mm/hugetlb.c | 75 +-------------- mm/internal.h | 6 +- mm/memory.c | 12 +++ 9 files changed, 233 insertions(+), 225 deletions(-)