Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5856519iog; Thu, 23 Jun 2022 06:45:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1umwh+iaJiHHBJErJ54E44E6v+OpAHNfK+Q4p8A8qzMseVW4+RRzq7LUDmH2m88A16SX2tP X-Received: by 2002:a05:6402:2553:b0:431:6e08:56de with SMTP id l19-20020a056402255300b004316e0856demr10846984edb.406.1655991925445; Thu, 23 Jun 2022 06:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655991925; cv=none; d=google.com; s=arc-20160816; b=CioGM0VDtYilN+oMShCy+sAahCXPfp3jxCtoKcRfMJzDRYaZDn1d11knRVblT2Wghe vB7RNPpK5TeINx4QueLN6oeRfUJVqEdqisY2ehMrtt+sYOa7qPncWJQ6w1nvnnT/bHwk YcpFnSdMhWkvB5uBxtdyUueCSOtdslhq9hD/HeYAEef2n+l85mi6OR4kFaPRPRPfu1t2 6inboXIglkyFHjBEAuKNVr0fU+vnexpHXyevYxcO57EAKZbPF9YEnQK/tg0rIRGZer3Y 75dlo4WlQ2CfSBfEze5yspuoGVVf5m3IAR114MKhL+GY2M0NG+IdxSy/ZbTjNfv6tmda mezg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1QLhXNXQq+r3hNERezeB41wLtAhbEfpWTSG6Y6DdYeU=; b=cJKn0Ta4Y0BekpAGL2lW4jJ37d6/2lI26XYJfDnVBy55/16gvClBGOtG8jx97FGLvw e5Dv4bQhiox6758CtQra+1zau6/QLP/GRtnFumrGQnPAuGjhEGohX07MQqWFFLX4fj7M mCUNnSyesK9reJxgX3M5bDh9dmdG/DrroJ8BhEqspKUGbOVbclp39MkiFKKpDOBhisc7 rCho+/o6EZArZMqhe35XLvho/N/EsmJZyL9KvsYPw+kivi9+gAoxvFcPZShuk7jd6+CN /j9p/tfyUD1crShWlEYHniXHYnEHw885re+eiT1RKiU3n21H9j797cCEtCKPIp5E4AlR UeMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QvjDTMvb; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr6-20020a1709073f8600b00722eeab7122si1107845ejc.407.2022.06.23.06.45.00; Thu, 23 Jun 2022 06:45:25 -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=@infradead.org header.s=casper.20170209 header.b=QvjDTMvb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231790AbiFWN3B (ORCPT + 99 others); Thu, 23 Jun 2022 09:29:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbiFWN2t (ORCPT ); Thu, 23 Jun 2022 09:28:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 796572FFCB for ; Thu, 23 Jun 2022 06:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1QLhXNXQq+r3hNERezeB41wLtAhbEfpWTSG6Y6DdYeU=; b=QvjDTMvbet4svpj2PO0DW7TArw IVfhGKCjFkBSadPRkxM4lGwZlXrkCbtJ/SaeKJZGi12prlTbSd4hgxXgQp6Tb9vJLi3PDaRCjTOak rnbrjlV/DcuzK2F2SrJAPyLWnH04HotuXNVqza/lj/vtVrmTDg/rAQxlwcPwjvHJZpbolbNXuPG2b cHR51iP44Y0WOegMxiTrEoHNBAX9PKqdruY3i94RpN1Fa86hKwTaeYkWkxAuGOACEFZQiqXYv8V7V rbOFh+I5g9AaNPrNxXy2d17jeFB2ZUjWPgU/zPSddC5VtLgp9MrSS0Mnq/Z2WU+ZnphXQ5NAyLdNC i5a2To6Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4Msw-007tUb-RU; Thu, 23 Jun 2022 13:28:39 +0000 Date: Thu, 23 Jun 2022 14:28:38 +0100 From: Matthew Wilcox To: Mike Rapoport Cc: Baolin Wang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 2/3] mm: Add PUD level pagetable account Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Wed, Jun 22, 2022 at 09:38:30AM -0500, Mike Rapoport wrote: > On Wed, Jun 22, 2022 at 04:58:53PM +0800, Baolin Wang wrote: > > +++ b/arch/loongarch/include/asm/pgalloc.h > > @@ -89,10 +89,15 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) > > static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) > > { > > pud_t *pud; > > + struct page *pg; > > struct page *page; > > looks better IMO. > > > + > > + pg = alloc_pages(GFP_KERNEL & ~__GFP_HIGHMEM, PUD_ORDER); GFP_KERNEL does not include __GFP_HIGHMEM, so you can just use GFP_KERNEL here. > > + if (!pg) > > + return NULL; > > > > - pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_ORDER); > > - if (pud) > > - pud_init((unsigned long)pud, (unsigned long)invalid_pmd_table); > > + pgtable_set_and_inc(pg); > > + pud = (pud_t *)page_address(pg); > > I don't think __get_free_pages() should be replaced with alloc_pages() > here, just call pgtable_set_and_inc() with virt_to_page(pud). I don't understand why you want that. Take a look at the implementation of __get_free_pages(). Converting back to a struct page after calling that seems like a real waste of time to me.