Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3727156iob; Tue, 17 May 2022 06:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznduqbKn1KQXBxrYiPSNr7oHT9q+UlVkqj3VA/lsJ3UqhSYu4Map/3hZsaRFyxnmOzFf3m X-Received: by 2002:a17:902:d50c:b0:15e:9455:19b2 with SMTP id b12-20020a170902d50c00b0015e945519b2mr21923026plg.140.1652793156861; Tue, 17 May 2022 06:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652793156; cv=none; d=google.com; s=arc-20160816; b=X1qtwz6DbRxydHe23sqh5dW3/Bq14unQBoZDB6ejb27dFZgaJ5VnWdpfHmI3u6y7Aj soqn0RmL8BXuAeUIbU8o5DnaIyuLwdqNKx78Zo4zwhzliHslIAqiXN7+S1qnlUT///lm UhALv64Q9xKyXnEnThoIr3ceES0qCFxgUFN+pA3dH1RLmI3qojKCbo25pjVHqVmWeH/y 24kKT/FMQ4Hec+ASqfxHxfYSDDaj3Gjg75x2F0FpBXnx0NAYOZuIDaLvy739mXoo46u7 fAdY6hqht8HZlk5ewLrZvl+hivRYYSS06URPLcEWUNydBtH1DEr06jR2haJWciRoQd2L Xjaw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=U5JrAt8KBLjN7WCLzECbJfqfP7v6gz8IHstT9m8cVTs=; b=dZeDNXaahdxJCi9iA2F9WpSHXoIvVnJfhRAzkAdKRcuCNh8Xyn099Od5iBN0zi4RI6 Vo/RRyxYOh2Uz4Ag1Kb6+0bTnsFGRwRiJkVapHCSZPI66oJmlPWMbpTK27LSZ9mmX6zP YPmVfHb9K8ktMpKPsDFybPZY1vOgiSwjfGbBXE8iuq5uhQxSwxZ3Tr+G5FnwL4pE1tmy MdzCR2ZoyDOzQoE0RI9XezEW6QtaC995FxpszvxUpSVsCrGgrpG4hGzkSYQtiGSZhbyb SS84excFHUKFAHjkhQk7STBY7rvrpfzBFkCBAA7ezJcWNHZJy/BgRpDSDPAKPuyDk2Ke qezw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="YJUHs/Tz"; 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 m22-20020a634c56000000b003ab1f09b881si15364143pgl.514.2022.05.17.06.12.24; Tue, 17 May 2022 06:12:36 -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=@linux-foundation.org header.s=korg header.b="YJUHs/Tz"; 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 S233707AbiEQAd2 (ORCPT + 99 others); Mon, 16 May 2022 20:33:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbiEQAdZ (ORCPT ); Mon, 16 May 2022 20:33:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7389924F33 for ; Mon, 16 May 2022 17:33:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 39FA6B816AA for ; Tue, 17 May 2022 00:33:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0A1FC385AA; Tue, 17 May 2022 00:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1652747602; bh=0pM6ajRonXAd36beDn0bSIZ5S34lHL+3SAO1ZfDWDBY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YJUHs/Tzpopnj0FkV/p0abeft/SHtGlPtnE3cUHAfI7TfoCxowJ8pQbbVtIbkUi0S lNmZCxe/TRSTUEg9ZN3CaJfh/0II+hvE0DulkxwHOFsRRoqdtUtlmgQ8lruX3eZixN KW2cJLcVEv4sej5IJf1xo5FAKcuwUVvSiYvyvtSk= Date: Mon, 16 May 2022 17:33:21 -0700 From: Andrew Morton To: Jaewon Kim Cc: vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Joonsoo Kim , Mike Rapoport Subject: Re: [RFC PATCH] page_ext: create page extension for all memblock memory regions Message-Id: <20220516173321.67402b7f09eacc43d4e476f4@linux-foundation.org> In-Reply-To: <20220509074330.4822-1-jaewon31.kim@samsung.com> References: <20220509074330.4822-1-jaewon31.kim@samsung.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 Mon, 9 May 2022 16:43:30 +0900 Jaewon Kim wrote: > The page extension can be prepared for each section. But if the first > page is not valid, the page extension for the section was not > initialized though there were many other valid pages within the section. > > To support the page extension for all sections, refer to memblock memory > regions. If the page is valid use the nid from pfn_to_nid, otherwise use > the previous nid. > > Also this pagech changed log to include total sections and a section > size. > > i.e. > allocated 100663296 bytes of page_ext for 64 sections (1 section : 0x8000000) Cc Joonsoo, who wrote this code. Cc Mike, for memblock. Thanks. > > diff --git a/mm/page_ext.c b/mm/page_ext.c > index 2e66d934d63f..506d58b36a1d 100644 > --- a/mm/page_ext.c > +++ b/mm/page_ext.c > @@ -381,41 +381,43 @@ static int __meminit page_ext_callback(struct notifier_block *self, > void __init page_ext_init(void) > { > unsigned long pfn; > - int nid; > + int nid = 0; > + struct memblock_region *rgn; > + int nr_section = 0; > + unsigned long next_section_pfn = 0; > > if (!invoke_need_callbacks()) > return; > > - for_each_node_state(nid, N_MEMORY) { > + /* > + * iterate each memblock memory region and do not skip a section having > + * !pfn_valid(pfn) > + */ > + for_each_mem_region(rgn) { > unsigned long start_pfn, end_pfn; > > - start_pfn = node_start_pfn(nid); > - end_pfn = node_end_pfn(nid); > - /* > - * start_pfn and end_pfn may not be aligned to SECTION and the > - * page->flags of out of node pages are not initialized. So we > - * scan [start_pfn, the biggest section's pfn < end_pfn) here. > - */ > + start_pfn = (unsigned long)(rgn->base >> PAGE_SHIFT); > + end_pfn = start_pfn + (unsigned long)(rgn->size >> PAGE_SHIFT); > + > + if (start_pfn < next_section_pfn) > + start_pfn = next_section_pfn; > + > for (pfn = start_pfn; pfn < end_pfn; > pfn = ALIGN(pfn + 1, PAGES_PER_SECTION)) { > > - if (!pfn_valid(pfn)) > - continue; > - /* > - * Nodes's pfns can be overlapping. > - * We know some arch can have a nodes layout such as > - * -------------pfn--------------> > - * N0 | N1 | N2 | N0 | N1 | N2|.... > - */ > - if (pfn_to_nid(pfn) != nid) > - continue; > + if (pfn_valid(pfn)) > + nid = pfn_to_nid(pfn); > + nr_section++; > if (init_section_page_ext(pfn, nid)) > goto oom; > cond_resched(); > } > + next_section_pfn = pfn; > } > + > hotplug_memory_notifier(page_ext_callback, 0); > - pr_info("allocated %ld bytes of page_ext\n", total_usage); > + pr_info("allocated %ld bytes of page_ext for %d sections (1 section : 0x%x)\n", > + total_usage, nr_section, (1 << SECTION_SIZE_BITS)); > invoke_init_callbacks(); > return; > > -- > 2.17.1 >