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: 16631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2924758vqg; Wed, 15 Nov 2023 17:30:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPaHX5BH5M4vO6I8c6Sg7CdBd3+7BSijczMNX6RZ7M/RuQl8RyHhry/L7WnXAJvdW9c109 X-Received: by 2002:a05:6a20:9382:b0:187:4329:f065 with SMTP id x2-20020a056a20938200b001874329f065mr5743280pzh.38.1700098248332; Wed, 15 Nov 2023 17:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700098248; cv=none; d=google.com; s=arc-20160816; b=SQbTkp/dx5ziXSQEU3cfNndabuMn3Dm/EE+DOmrGqJ56y48uGj8PEMC8Gaf4M+p1FF ep0YO5Y0tWchevH+WLZkXoa8T4Fs42yV5gSE/jdlaMA8BGVWL0H1xJQxlQ0lywuX3mnJ E6DOEzihbpiHCX59pdvnpOF8UHk1yhqkgfZOyNVOjbjUzWUqUsr47yOM+HvGJQ1RR2DU wQlXkH7k7PwmdruzTqQfYoMBF85jT/Vqz6/6EkG3WdfXAXaQXahnyT0HnMUeYEBdkTYt XTdACBG48N23utOsl19hvQaMsBqc/Elt2TTgBkwP1f97E95gGoVzo8BKGXw/usXYE7DJ 7DPg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=4PU7kaICTCYIryKeefw2/Ev2pNew0CTTu+cawaO/2M4=; fh=o+FJD7UTEFgAOwGBZppViFyhRpBzPGRfoO/6xzRNnMs=; b=SghhcFhMRngpaCMCD4eVTEYhJP85jQq81688lgM2x/gOkS6XtQgmI/9XHsgH3eGbqm Msrsh6Af7I4bLjW9YKOqEMISeYT8UXgIGQkCKo+SVU/PrhnABY8FpZgmk444eLmY/dHx L7Oe+iJa1Bu1d5K8cdFhfzWwtEes14MmQJHx+H/sj6TokOFdBRT6Ly8efJ6wnJc3zXKG uF2O+bdWh83z2Q18XhVaukianHKIR27uABwqqPrFnhMYfoKZWKRbbE+r66lAQTcTN726 fnH78YLQkTkzOlAKn6UzayaVTqakaxrKAHtQnI99whoX8via8UBhLopG6E/vqn3o6xKB 011Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bGT1faX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k24-20020a63ba18000000b005be00780b3bsi11084227pgf.843.2023.11.15.17.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:30:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bGT1faX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 66DB2808D217; Wed, 15 Nov 2023 17:30:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230024AbjKPB3T (ORCPT + 28 others); Wed, 15 Nov 2023 20:29:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjKPB3R (ORCPT ); Wed, 15 Nov 2023 20:29:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE94182 for ; Wed, 15 Nov 2023 17:29:14 -0800 (PST) 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-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-E34-e6psNDaq8YrzhyyDxQ-1; Wed, 15 Nov 2023 20:29:12 -0500 X-MC-Unique: E34-e6psNDaq8YrzhyyDxQ-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-581d59ea23dso63117eaf.1 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=AwxBKJX0lysjUI0ax7J95NT/DLSUfflYuzZ9thrg98uSZvf3c7rFmv9vzlSceTcPiX Czr/M4VvAna0g2vQBRVukpCuugE4yFI6dcaQf5szxbvYNDbh7vS1SbDOT55t6Zwq+vIa 0QmhNMiIEEGaAlS+dptY4IH/V9g5aaiVsV0I4SSHsofDE2WDIkoBNOH1w5ZFV4cTpsnZ FYdvwrBKR8dR9TkvORgvSBnrN10lkEEOg4/YMWVn/G7xw9ean7Ei8lUUisS6pcCEeAsM daejX9fpjNXMFtdpiBW3Dzfaf6i7K9HWEI0V2CEiA0AxzsU5ypfK3cqdOOcIfF0kAjTS e7IA== X-Gm-Message-State: AOJu0YyRCynY/1nABsN25mY/d9CxIJNq+3jBMdZpyrcgapso1Op1lQBO 1W4ayWz36s/CRKKtinRqMduVBfOTmIuevtWM0VH52vS3C/5mzjgPYEnKb5Ahd2MMJm4hGSycQyf gv1+dgjmTk1S34lw9/eY1NRk5eYiYGabMtVNrDfXdxrUxoUOjjVj60XgmWW8HtD/hI+qjysFOEW nrTz6Wpw== X-Received: by 2002:a05:6358:7e55:b0:16b:96fc:650e with SMTP id p21-20020a0563587e5500b0016b96fc650emr7346647rwm.3.1700098151525; Wed, 15 Nov 2023 17:29:11 -0800 (PST) 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-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Wed, 15 Nov 2023 17:30:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782682220960078526 X-GMAIL-MSGID: 1782682220960078526 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(-)