From patchwork Fri Sep 22 07:09:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 143618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5818925vqi; Fri, 22 Sep 2023 12:29:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFICeuFMXmHfVFrDCNV7dEsECvWCxLdOoTQDNu9qmCV+rBGKMaWzJXFMN6TugCm9fl0K1FF X-Received: by 2002:a17:902:f548:b0:1b8:9fc4:2733 with SMTP id h8-20020a170902f54800b001b89fc42733mr354496plf.3.1695410948557; Fri, 22 Sep 2023 12:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695410948; cv=none; d=google.com; s=arc-20160816; b=F9u47xgoc5N4UoL7Ii9DYy9itXyrsTPOK4XsSom+fTbj9d/VpPGqwzQFlWvA272WgD 3K/YAJhpi24/9rFRQ/ozLHzyf5yxr9tFHA34tA9LxlONcl5JASTo02uYMbKl478pk9sh fK4bMmFQZt44gtZnEmEjh6ZS1+6NqmA9ip2qumoE6d4z95waW78h/QaV55+fqA//H+sD 7P1CanSe+FNDiL4hNwlnqxGr+FVIf8DeR0insitaa2JZyVuCZzKa7UWwX/HO7Sm9dGtm XGnKdy8PmqcW3CDRJ4aoaU0lHMrnwdS1eOTB6a8bCLK9Rd9BqprBmAj3BO+j+GPBCKFj mJIQ== 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:date:subject:cc:to:from :dkim-signature; bh=0NMcmRX/w2n3M3EQea1/2ZhpgRQyZV6LdD1tfFyUHrY=; fh=KSy1dDf6lUvgdoPctzpy47/Mjv6bi14N3nvpkZLQDdc=; b=wRdLaWqOcb/BFENqMFe4vgz2GJ34v79WUVGSoFiD3u+zQu47VJ6RnqV+vRmnG/c+h7 rfhvAhoTRsXrmCAzjg8j9FLEQ5X61IAPrvcDXlJGk/if8+RRrH3bo91kjVPq7S5hgW9g o0LDUXvzB1mEQOqoc/UWnDKxioSF/xhGw7nH3lIgBWd74c7rfLDQo/yK4VKA4EfD9/ET TZghY/zPglJbQVO38NrFbU+yX53hoDfzLxgCHJRzjWwIic7jYh0ihVW+LSy0LbdwFq8o ZrFCuWTcqcA7123oCCyFgAHwBn2Zgh6yFehAMXFW6YIdY3xbzUQxrs/MJdeP6bUNfQNv tYNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fPPxKFrT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y15-20020a17090322cf00b001c470c25409si4841745plg.327.2023.09.22.12.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:29:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fPPxKFrT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A0FA883421A5; Fri, 22 Sep 2023 00:10:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbjIVHKj (ORCPT + 30 others); Fri, 22 Sep 2023 03:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjIVHKd (ORCPT ); Fri, 22 Sep 2023 03:10:33 -0400 Received: from out-217.mta0.migadu.com (out-217.mta0.migadu.com [91.218.175.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFDC318F for ; Fri, 22 Sep 2023 00:10:27 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1695366626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0NMcmRX/w2n3M3EQea1/2ZhpgRQyZV6LdD1tfFyUHrY=; b=fPPxKFrTLFfvL3jUV7itB9gMnKWR/r7Snjv26hnF+iiC5cBKWt1EOcJiso/9kwp07Pc/E/ xO9LzRFYie1qlDtSrkxynAhhzP/0j+M5qMOLAGoypKYac3zL2PZvrY3sznXwcP3QWg6wwc 6fDf5t+PpwLmQdL+crOn+jgf7v0Hej8= From: Yajun Deng To: akpm@linux-foundation.org, mike.kravetz@oracle.com, muchun.song@linux.dev, glider@google.com, elver@google.com, dvyukov@google.com, rppt@kernel.org, david@redhat.com, osalvador@suse.de Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Yajun Deng Subject: [PATCH 4/4] mm: don't set page count in deferred_init_pages Date: Fri, 22 Sep 2023 15:09:23 +0800 Message-Id: <20230922070923.355656-5-yajun.deng@linux.dev> In-Reply-To: <20230922070923.355656-1-yajun.deng@linux.dev> References: <20230922070923.355656-1-yajun.deng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 00:10:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777767230327661908 X-GMAIL-MSGID: 1777767230327661908 The operations of page count in deferred_init_pages and deferred_free_range is the opposite operation. It's unnecessary and time-consuming. Don't set page count in deferred_init_pages, as it'll be reset later. The following data was tested on an x86 machine with 190GB of RAM. before: node 0 deferred pages initialised in 78ms after: node 0 deferred pages initialised in 72ms Signed-off-by: Yajun Deng --- mm/mm_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 1cc310f706a9..fe78f6916c66 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1984,7 +1984,7 @@ static void __init deferred_free_range(unsigned long pfn, if (nr_pages == MAX_ORDER_NR_PAGES && IS_MAX_ORDER_ALIGNED(pfn)) { for (i = 0; i < nr_pages; i += pageblock_nr_pages) set_pageblock_migratetype(page + i, MIGRATE_MOVABLE); - __free_pages_core(page, MAX_ORDER, MEMINIT_LATE); + __free_pages_core(page, MAX_ORDER, MEMINIT_EARLY); return; } @@ -1994,7 +1994,7 @@ static void __init deferred_free_range(unsigned long pfn, for (i = 0; i < nr_pages; i++, page++, pfn++) { if (pageblock_aligned(pfn)) set_pageblock_migratetype(page, MIGRATE_MOVABLE); - __free_pages_core(page, 0, MEMINIT_LATE); + __free_pages_core(page, 0, MEMINIT_EARLY); } } @@ -2068,7 +2068,7 @@ static unsigned long __init deferred_init_pages(struct zone *zone, } else { page++; } - __init_single_page(page, pfn, zid, nid, true, false); + __init_single_page(page, pfn, zid, nid, false, false); nr_pages++; } return (nr_pages);