Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp217184iog; Fri, 24 Jun 2022 02:39:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tEH3oN2x74jvGCoGRLmO0C8RsoekEKhlO/5Vd08lrZ5jp5oipkZgT57AnODDe7LhjR0vyV X-Received: by 2002:a05:6402:3216:b0:435:a061:d662 with SMTP id g22-20020a056402321600b00435a061d662mr16364500eda.275.1656063582874; Fri, 24 Jun 2022 02:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656063582; cv=none; d=google.com; s=arc-20160816; b=ySgZlKgySggiFBNejxXtapsF7AfNPnP2xr75IzQCxcmZLBqPklNJaFoaxTklGcvOz0 gMb23icflqkS8Dzl5LimyTu451lk1WlW+VR/SIfouF8W5+HH8BQTB9gzBbqrVm1FryTw JAH94VUsLg94Ruz2P8l8VX7pTwjLiYlSIrXBvW+FhLs1t9hYb+zlUBLgd6B1AhsYhHGN fi3EU/DjcaUeJ7xAkqTIVNMMYnzBW38jghyEAhML/KxRjhrT62Y+cE1V4djItNh4l6ap WVn3IGVF55HcgEbz8gxv6l4Y0DScaMaWA6r0cgj1rmkfdC6KnX3N/nbtzcdEbvugaMsm qiMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=ApOczrdcyxWxPo2CGena+ZbmdZhXz0PWrGu8KADosNE=; b=MSlJGy1LOvLBMsYrz1RBAFm7FWxbgA4tJZJn7Pu+FMq3P1qg1EDWEFz7Md0T2oqfJx dKcLZgAuw8BR3EEQfqRIBUUGXW914VnfZ/YgkGx3ftEgVDudESXqIJZvceq26opwQ+Sj F1TTsiHuHEKL9FqL33v2xlA1jP3KhxZ2+jjTerRTnWTPLSNqU++EbIN/Ezw8R3c6NOPY +718Z0MI5Dy/Vvzzk3oHjsQMA/RMJqdLYd2W2chQ2RWJAQsq/0qtAUsa96xbO+sE4rfO 9/x8Csq8Nt0KnCOY/dy8wtyfvCiAABYkrnQxiuI3XISea0JiZxk/JSIrVfwS0+Jn3Uy4 m+pA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a05640227d000b00435728c0adbsi2946162ede.158.2022.06.24.02.39.18; Fri, 24 Jun 2022 02:39:42 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbiFXIwg (ORCPT + 99 others); Fri, 24 Jun 2022 04:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiFXIwd (ORCPT ); Fri, 24 Jun 2022 04:52:33 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D515D6E7AA for ; Fri, 24 Jun 2022 01:52:31 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R951e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VHGcxXq_1656060747; Received: from 30.97.49.29(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VHGcxXq_1656060747) by smtp.aliyun-inc.com; Fri, 24 Jun 2022 16:52:28 +0800 Message-ID: Date: Fri, 24 Jun 2022 16:52:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [RFC PATCH v2 2/3] mm: Add PUD level pagetable account To: Matthew Wilcox , Mike Rapoport Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 6/23/2022 9:28 PM, Matthew Wilcox wrote: > 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. Yes. Thanks. > >>> + 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. IMO I have no strong preference. The code can be simpler with using __get_free_pages(), however like Matthew said it will add more conversion.