Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp486841imm; Wed, 18 Jul 2018 05:48:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc26/um8ooaD/xAOpEjQBQNn0cnEq8dl+EYbCBZaM5gME26yhBh+BhCrR5JvWkbHZDmWlvJ X-Received: by 2002:a63:4506:: with SMTP id s6-v6mr5853126pga.422.1531918129075; Wed, 18 Jul 2018 05:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531918129; cv=none; d=google.com; s=arc-20160816; b=xYRPJkce6SI086F/pbpEVpKi3rGZlbIe8Mai0uiUBK3QKQ38j7bZPgdE4UfjjCQIPJ TMdVb3FXecSxAd9+nqVYi07umeghIokqujmfHqZ4gkA/NpkVPEBnCipk5h3zcV8Mc2QB H3OIR2Vl+ltbHJ+TvzD4VtgUM4eitbH9c59M94HGMjfz6Z6kbrp49pRGickHzg7ljXgF pYJ6l5wiGAkDHI+Oqeaa4pnvnbuGoCDCB3jf/mti2uKtmurcNaIf3eVRbfKIDavgpSOd 2xdxAQzlq77LTzDVvTYtAIopw0klBi12mHZAiF7Gks3cSYsIZO8W6OdJFcocbW+MB/Sp b2gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=v+9JS2c7Tw5KibY5zESrEVlALGGos2Uk1nhW3AGPdvw=; b=JAwuJ2qLEjjfXjBSZvqdJAjlOLVHgztCCtTXbTsVnJ4LEailADUqdS1/HK0C6Y+sdS qIAOPqxjU14pOZPR6SWs4sSvOkhKVKmAZIgPFuLPVu6XM9BZw8rnvI5r7979ot15L3fT 0UYNWw02SH7mat5sTTZUuMVRQRGKaGETDH/1fE12oQlGfU5KdvxvMhw7xlQCCTt2Ps2Y bIEgsQ6eMw1At5e7LKHrvNEOrv2aUqklIlbmSA9K2lYs0HqtPMVSJhTUIMq5i17QIgsx gMQcHde+lSbDc6SZF4uM7MkaTR3VMQ/tzGLzuRSt7PX1kJba6BUT3Rwz8+H8ja01auXb +UbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31-v6si3102397pla.190.2018.07.18.05.48.34; Wed, 18 Jul 2018 05:48:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731259AbeGRNZ2 (ORCPT + 99 others); Wed, 18 Jul 2018 09:25:28 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35521 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731110AbeGRNZ0 (ORCPT ); Wed, 18 Jul 2018 09:25:26 -0400 Received: by mail-wr1-f67.google.com with SMTP id a3-v6so4569928wrt.2 for ; Wed, 18 Jul 2018 05:47:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v+9JS2c7Tw5KibY5zESrEVlALGGos2Uk1nhW3AGPdvw=; b=CDZ4ujbml0iLul49iU/Dcb4iuNaOYXKUpCeqYlUKWC1pBRuQE+Hf7mvrhxif48K+28 9XstWduXi3+PBBlOqo2pWwnQ2aA7pDf8PknKFBGwoIvA4DrAvfAGNAFr1kDTIVeIRzyG q0EXnmdjhczUUHtKtXRYP3uJMdnYSXvsnjpxpxDJxZ04B1d63Hsg5RHqBBiLOcAYyCQa vXClX4acu4aJXOa5/ujrQmOgxOtIgb9jQ44Vi38RwNRV+fWPHgE7TpjR14lRy07QuDlr 5LmbaZgctRBoPe2UG8uor/20pbP2ieTM8/3n/mKBOFxlhGir9rrTsEWJBuh/JneP7yQf 4kCQ== X-Gm-Message-State: AOUpUlH7ezzfPHp9dydTE+xVQMVZ+iZKzGrwCEI3vKyx/bG6woos/SNm W0LCcgK2uexq02wYrm98Wt8= X-Received: by 2002:adf:fec8:: with SMTP id q8-v6mr4433873wrs.164.1531918059245; Wed, 18 Jul 2018 05:47:39 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id h12-v6sm19597395wmb.3.2018.07.18.05.47.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 05:47:38 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 9988E1240C7; Wed, 18 Jul 2018 14:47:36 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: pasha.tatashin@oracle.com, mhocko@suse.com, vbabka@suse.cz, iamjoonsoo.kim@lge.com, aaron.lu@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [PATCH 3/3] mm/page_alloc: Split context in free_area_init_node Date: Wed, 18 Jul 2018 14:47:22 +0200 Message-Id: <20180718124722.9872-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180718124722.9872-1-osalvador@techadventures.net> References: <20180718124722.9872-1-osalvador@techadventures.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oscar Salvador If free_area_init_node gets called from memhotplug code, we do not need to call calculate_node_totalpages(), as the node has no pages. The same goes for the deferred initialization, as memmap_init_zone skips that when the context is MEMMAP_HOTPLUG. Signed-off-by: Oscar Salvador --- mm/page_alloc.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d652a3ad720c..99c342eeb5db 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6388,12 +6388,28 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) static void __ref alloc_node_mem_map(struct pglist_data *pgdat) { } #endif /* CONFIG_FLAT_NODE_MEM_MAP */ +#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT +static void pgdat_set_deferred_range(pg_data_t *pgdat) +{ + /* + * We start only with one section of pages, more pages are added as + * needed until the rest of deferred pages are initialized. + */ + pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, + pgdat->node_spanned_pages); + pgdat->first_deferred_pfn = ULONG_MAX; +} +#else +static void pgdat_set_deferred_range(pg_data_t *pgdat) {} +#endif + void __paginginit free_area_init_node(int nid, unsigned long *zones_size, unsigned long node_start_pfn, unsigned long *zholes_size) { pg_data_t *pgdat = NODE_DATA(nid); unsigned long start_pfn = 0; unsigned long end_pfn = 0; + bool no_hotplug_context = node_online(nid); /* pg_data_t should be reset to zero when it's allocated */ WARN_ON(pgdat->nr_zones || pgdat->kswapd_classzone_idx); @@ -6409,20 +6425,17 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, #else start_pfn = node_start_pfn; #endif - calculate_node_totalpages(pgdat, start_pfn, end_pfn, - zones_size, zholes_size); - alloc_node_mem_map(pgdat); - -#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT - /* - * We start only with one section of pages, more pages are added as - * needed until the rest of deferred pages are initialized. + /* Memhotplug is the only place where free_area_init_node gets called + * with the node being still offline. */ - pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, - pgdat->node_spanned_pages); - pgdat->first_deferred_pfn = ULONG_MAX; -#endif + if (no_hotplug_context) { + calculate_node_totalpages(pgdat, start_pfn, end_pfn, + zones_size, zholes_size); + alloc_node_mem_map(pgdat); + pgdat_set_deferred_range(pgdat); + } + free_area_init_core(pgdat); } -- 2.13.6