From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3790C54E64 for ; Mon, 25 Mar 2024 18:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LR4JJPRvQ6xYHePlXlmDgPrjypT5zRn/OJUTwGdKHUE=; b=Vy0X4a+4YIPyvo vuP+/yRJOIbMmak5gkqksfVYxLNLCDpvJ+AF+Rh4xQXbn/OJPOhKe7LleTZ6IbIVRHt7UoRAdlj0P KqinF/lWskrD3XJBfdfkBWN5/F/I25igi04BjJgMcM/g317RJjqFmgnClm7kAhTvL+A+UiwoF/Ylh PF4CRFO63BF2OEHAT6Tr4W7aRYZhIDv9KsmFUwxnhi/u0YSzADWvMCZxzy4dyGpiDKzvzeiOQaTUI kxNBmPESrjX6c+JKdqbteGHnCVEAlOBFg/sWMaF/KzEiLJo3CRt+4qRpN8UoE0s9g0TNeqT40LiPU 0IlpNJPNV9lJAJau5nNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ropXC-00000001TMq-2udO; Mon, 25 Mar 2024 18:59:03 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ropX7-00000001TKB-1vlD for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2024 18:59:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711393134; 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: in-reply-to:in-reply-to:references:references; bh=lGdQaCGcBkbZ2z9bjtfUzgfe0ZmyyKivIRm0X4ayYz0=; b=aH1+Mc9CpYASsGoFVsnVCbCCgja9EgMjBlIKVAPyL9lf1nueTR2orBSGnKS67D39S/Om1v 2pZpVmHkWUPgnK5z781yAsTWTsWfa9NZyXIIJSSk7cusvsJwc5QM09geTqEywAhjfupoq3 2BCpIvlkmNiMOcuLkjfM5gjSg6Bhx7g= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-vRRmmNS-NqGZd4Am6r1xqQ-1; Mon, 25 Mar 2024 14:58:53 -0400 X-MC-Unique: vRRmmNS-NqGZd4Am6r1xqQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69152af7760so17265646d6.1 for ; Mon, 25 Mar 2024 11:58:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711393133; x=1711997933; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lGdQaCGcBkbZ2z9bjtfUzgfe0ZmyyKivIRm0X4ayYz0=; b=EvDYnGavZHq+2pZvnMZTOoidxuvhh9RCOHgvu84LCKovf2v/Zqxqsbev7rXCrAzsb4 mvpY3zmqLvJprUceI2jDrSbqoS/iRvs1vz1wd41SGIyrYc5ISbIZSnKs2zYP0nW0y6qw Fog84WG51hxD/gBBaIXmZEiUi52E4jNY31+K3XHG4kPTLUbNbAutuqtC5Mg7XyjmCoXv ClevpB3L2N2V/Lt/9qcA6ffx9ptZBTHH4JB5dKT9YJ6Oqp0ip0/2mBax5LxVU3hcOr8K fswfefuy/xHNZQOPoWrpNuAKZFNclO6tt2oKmVCEbfZi5l1Qai+4/U7sXa1xxitqoKO4 n26A== X-Forwarded-Encrypted: i=1; AJvYcCU1Dkuxfqyi7ytk4Yh5DS22h32qIGuWw+/mf+VNn1YTt6fhtCd7Y1ax2z7epb7KeBZzvxWiVvgcCvSMyqrM+Vq4iB8bNEowkQg8uXCNwNhejL4BqI4= X-Gm-Message-State: AOJu0YxK7YxY3MG/Uice9hNWpUfl+uD6Ptg0ro2Y+hxPibmAQsN8jNwa Nsy3K5VLIjmtEv7IVie+bULvXpgoAljG19BXekMeSv5Bt4FEIxxDvzShyIk2p/HN4XqUwp+e9YC +KKLAUrO4oPdbrX3tURKp3UG0E/mE+hvB/T2/dv+dVUpN1jmA2UAcfvKZxChrY03xGfVsuBN+ X-Received: by 2002:a05:6214:3d13:b0:696:7b12:3744 with SMTP id ol19-20020a0562143d1300b006967b123744mr8189330qvb.0.1711393132761; Mon, 25 Mar 2024 11:58:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE4pfdS6Owjbbcw6cCZoeZVpTG6xXlLRqHsMW/sJVGfLOPBLf6CMPjo5ntIkMeQpg5wPfu7g== X-Received: by 2002:a05:6214:3d13:b0:696:7b12:3744 with SMTP id ol19-20020a0562143d1300b006967b123744mr8189311qvb.0.1711393132312; Mon, 25 Mar 2024 11:58:52 -0700 (PDT) Received: from x1n ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id kd26-20020a056214401a00b006968e1bed43sm1380686qvb.79.2024.03.25.11.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:58:51 -0700 (PDT) Date: Mon, 25 Mar 2024 14:58:48 -0400 From: Peter Xu To: Jason Gunthorpe Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Christophe Leroy , Matthew Wilcox , Rik van Riel , Lorenzo Stoakes , Axel Rasmussen , Yang Shi , John Hubbard , linux-arm-kernel@lists.infradead.org, "Kirill A . Shutemov" , Andrew Jones , Vlastimil Babka , Mike Rapoport , Andrew Morton , Muchun Song , Christoph Hellwig , linux-riscv@lists.infradead.org, James Houghton , David Hildenbrand , Andrea Arcangeli , "Aneesh Kumar K . V" , Mike Kravetz Subject: Re: [PATCH v3 00/12] mm/gup: Unify hugetlb, part 2 Message-ID: References: <20240321220802.679544-1-peterx@redhat.com> <20240322161000.GJ159172@nvidia.com> MIME-Version: 1.0 In-Reply-To: <20240322161000.GJ159172@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240325_115857_590806_71056AD9 X-CRM114-Status: GOOD ( 49.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 22, 2024 at 01:10:00PM -0300, Jason Gunthorpe wrote: > On Thu, Mar 21, 2024 at 06:07:50PM -0400, peterx@redhat.com wrote: > > From: Peter Xu > > > > v3: > > - Rebased to latest mm-unstalbe (a824831a082f, of March 21th) > > - Dropped patch to introduce pmd_thp_or_huge(), replace such uses (and also > > pXd_huge() users) with pXd_leaf() [Jason] > > - Add a comment for CONFIG_PGTABLE_HAS_HUGE_LEAVES [Jason] > > - Use IS_ENABLED() in follow_huge_pud() [Jason] > > - Remove redundant none pud check in follow_pud_mask() [Jason] > > > > rfc: https://lore.kernel.org/r/20231116012908.392077-1-peterx@redhat.com > > v1: https://lore.kernel.org/r/20231219075538.414708-1-peterx@redhat.com > > v2: https://lore.kernel.org/r/20240103091423.400294-1-peterx@redhat.com > > > > The series removes the hugetlb slow gup path after a previous refactor work > > [1], so that slow gup now uses the exact same path to process all kinds of > > memory including hugetlb. > > > > For the long term, we may want to remove most, if not all, call sites of > > huge_pte_offset(). It'll be ideal if that API can be completely dropped > > from arch hugetlb API. This series is one small step towards merging > > hugetlb specific codes into generic mm paths. From that POV, this series > > removes one reference to huge_pte_offset() out of many others. > > This remark would be a little easier to understand if you refer to > hugetlb_walk() not huge_pte_offset() - the latter is only used to > implement hugetlb_walk() and isn't removed by this series, while a > single hugetlb_walk() was removed. Right. Here huge_pte_offset() is the arch API that I hope we can remove, the hugetlb_walk() is simply the wrapper. > > Regardless, I think the point is spot on, the direction should be to > make the page table reading generic with minimal/no interaction with > hugetlbfs in the generic code. Yes, and I also like your terms on calling them "pgtable readers". It's a better way to describe the difference in that regard between huge_pte_offset() v.s. huge_pte_alloc(). Exactly that's my goal, that we should start with the "readers". The writters might change semantics when merge, and can be more challenging, I'll need to look into details of each one, like page fault handlers. Such work may need to be analyzed case by case, and this GUP part is definitely the low hanging fruit comparing to the rest. > > After this series I would suggest doing the pagewalk.c stuff as it is > very parallel to GUP slow (indeed it would be amazing to figure out a > way to make GUP slow and pagewalk.c use the same code without a > performance cost) Yes. I hope there shouldn't be much perf degrade, I can do some more measurements too when getting there. And btw, IIUC the major challenge of pagewalk.c is not the removal of walk_hugetlb_range() alone - that may not be that hard if that's the solo purpose. The better way to go is to remove mm_walk_ops.hugetlb_entry() altogether, which will cause a change in all callers; that's "the challenge".. pretty much labor works, not a major technical challenge it seems. Not sure if it's a good news or bad.. One thing I'll soon look into is to allow huge mappings for PFNMAP; there's one request from VFIO side for MMIO. Dropping mm_walk_ops.hugetlb_entry() seems to be good for all such purposes; well, I may need to bite the bullet here.. for either of the purposes to move on. > > Some of the other core mm callers don't look too bad either, getting > to the point where hugetlb_walk() is internal to hugetlb.c would be a > nice step that looks reasonable size. Agree. > > > One goal of such a route is that we can reconsider merging hugetlb features > > like High Granularity Mapping (HGM). It was not accepted in the past > > because it may add lots of hugetlb specific codes and make the mm code even > > harder to maintain. With a merged codeset, features like HGM can hopefully > > share some code with THP, legacy (PMD+) or modern (continuous PTEs). > > Yeah, if all the special hugetlb stuff is using generic arch code and > generic page walkers (maybe with that special vma locking hook) it is > much easier to swallow than adding yet another special class of code > to all the page walkers. > > > To make it work, the generic slow gup code will need to at least understand > > hugepd, which is already done like so in fast-gup. Due to the specialty of > > hugepd to be software-only solution (no hardware recognizes the hugepd > > format, so it's purely artificial structures), there's chance we can merge > > some or all hugepd formats with cont_pte in the future. That question is > > yet unsettled from Power side to have an acknowledgement. > > At a minimum, I think we have a concurrence that the reading of the > hugepd entries should be fine through the standard contig pte APIs and > so all the page walkers doing read side operations could stop having > special hugepd code. It is just an implementation of contig pte with > the new property that the size of a PTE can be larger than a PMD > entry. > > If, or how much, the hugepd write side remains special is the open > question, I think. It seems balls are rolling in that aspect, I haven't looked in depth there in Christophe's series but it's great to have started! > > > this series, I kept the hugepd handling because we may still need to do so > > before getting a clearer picture of the future of hugepd. The other reason > > is simply that we did it already for fast-gup and most codes are still > > around to be reused. It'll make more sense to keep slow/fast gup behave > > the same before a decision is made to remove hugepd. > > Yeah, I think that is right for this series. Lets get this done and > then try to remove hugepd read side. Thanks a bunch for the reviews. -- Peter Xu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel