Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1401137imm; Thu, 19 Jul 2018 00:36:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcufyYs5MIboWioKDNqnwhRxSPz3puZWaGbi6FC8MSXDzxizr5OkkjtJ0Nd+2SsoxJhQpcz X-Received: by 2002:a63:5d58:: with SMTP id o24-v6mr9025023pgm.349.1531985785431; Thu, 19 Jul 2018 00:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531985785; cv=none; d=google.com; s=arc-20160816; b=tI2Kv+0gDeqt/wHMtOZOTYR4i34UngPXsN3wi2RdL1X+FAJvm+PW+G+0Nlcqstd8ow xiRdvnpNGyvA0bY5B8p9kTR6BNpgVEVvgrB/fKhcjp+KI1bY8V7G/NHzykypNp9sa48/ g8XXMHuy+bsO7G+/8rvf1p78/nDuZZs41vlMWGK6WraBGTFRWM3K0WCwCvQMO4bcDAfZ KAHotxcIEEhjrAFe+5lSI9O60nxoozA/TjcA5dhT6hUpn4UWqYknZWEZ1S6SWqOMOpjP LI8oEkI+gm9N1ovq+RRahJIyv19jOSKU5on5+IVR1r7qet6hySbzrNfJKfXAurY6CAQY 8N0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ZSHVeUmxaRs/bHTRX6MZqfR5Lk1G8TprM3+I0RdvAb0=; b=ewS0osLkaTDnbcNB6ioQG0Wy7BHWUVANDijI2CJ/d48/IeO15typm7YGrgZuA2sPPI zwK1s+Hp0yA6daTNR75PIpAQJ4YR6UOHBxHVKiBo0QHXcAq1qVF4JyA3qDomRpPlHjtI 8H5yPJ1vtPXHk0uXdFAqrSDqbS09+Dc29dpW3JkPAkA7xVv5cOaoGqkTdl9HXF+Vbrah VYc85Y4ib53mMmRzgBVEan/31JTfPj5F/7unZ0xjQuc1eHCETF24sKAu5WlbveTPkXxI e3pexse5k6LfJzXKdllyFgat+WlTB1zS4GHdlgfThH8pMEZfDbMo7rtPC5XtikLzqJh7 q+eQ== 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 d37-v6si4923440plb.481.2018.07.19.00.36.10; Thu, 19 Jul 2018 00:36:25 -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 S1731140AbeGSIRU (ORCPT + 99 others); Thu, 19 Jul 2018 04:17:20 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37590 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbeGSIRU (ORCPT ); Thu, 19 Jul 2018 04:17:20 -0400 Received: by mail-wm0-f67.google.com with SMTP id a19-v6so5265042wmb.2 for ; Thu, 19 Jul 2018 00:35:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZSHVeUmxaRs/bHTRX6MZqfR5Lk1G8TprM3+I0RdvAb0=; b=RsitaOGaKkakwA92eRm0ac2LEr+R9HO3rc5VIrMYO62TnIW/zWG0xa+m1RUiqCQoSm SDc1rNnaHsUkJZ3Nh4lpZP/zuI+3HVBFsEMatVSD0/B9CLYOFzuEgX+zl89gLnqJWdZI R+EaLmbXaFxk1CFiwEyNoQuhDhMtdH2ic/xlNO06qtdcoPSIkJz9KI/ltXicqin8Xfs4 hrlFvcMEdE3/gg/pkWOSXVE6a/RDCjsPMoJPXENfukuYRyFP1Fu1eAr8XfpHuC6cnfmp dGmSLzW2vXDNoLH4kZsLTKjEBgPBId5EkkjArtdoMMhS0tyloD4SVHci3p78W6KroKm5 eJ2g== X-Gm-Message-State: AOUpUlG+fSRWw2S/eL1LzPTN8s7Gvtw6XmD/+jMrF8chXayxDAU5A20b kZqj2dbQPK1BtACPKrccBLQ= X-Received: by 2002:a1c:b788:: with SMTP id h130-v6mr3652561wmf.27.1531985732386; Thu, 19 Jul 2018 00:35:32 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id u185-v6sm3321832wmg.25.2018.07.19.00.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 00:35:31 -0700 (PDT) Received: by techadventures.net (Postfix, from userid 1000) id 2B63E12413E; Thu, 19 Jul 2018 09:35:31 +0200 (CEST) Date: Thu, 19 Jul 2018 09:35:31 +0200 From: Oscar Salvador To: Pavel Tatashin Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , iamjoonsoo.kim@lge.com, aaron.lu@intel.com, LKML , Linux Memory Management List , osalvador@suse.de Subject: Re: [PATCH 3/3] mm/page_alloc: Split context in free_area_init_node Message-ID: <20180719073531.GA8750@techadventures.net> References: <20180718124722.9872-1-osalvador@techadventures.net> <20180718124722.9872-4-osalvador@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 18, 2018 at 10:34:19AM -0400, Pavel Tatashin wrote: > On Wed, Jul 18, 2018 at 8:47 AM wrote: > > > > 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. > > I am not positive this is safe. Some pgdat fields in > calculate_node_totalpages() are set. Even if those fields are always > set to zeros, pgdat may be reused (i.e. node went offline and later > came back online), so we might still need to set those fields to > zeroes. > You are right, I do not know why, but I thought that we were zeroing pgdat struct before getting in the function. I will leave that part out. Since we only should care about deferred pfns during the boot, maybe we can change it to something like: diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 70fe4c80643f..89fc8f4240ca 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6381,6 +6381,21 @@ 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) { @@ -6402,20 +6417,14 @@ 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); + 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. - */ - pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, - pgdat->node_spanned_pages); - pgdat->first_deferred_pfn = ULONG_MAX; -#endif + if (system_state == SYSTEM_BOOTING) + pgdat_set_deferred_range(pgdat); + free_area_init_core(pgdat); } Thanks -- Oscar Salvador SUSE L3