From patchwork Thu Jul 19 07:35:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10533745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1805D600D0 for ; Thu, 19 Jul 2018 07:35:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01C4E29709 for ; Thu, 19 Jul 2018 07:35:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E633A2971D; Thu, 19 Jul 2018 07:35:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7623229709 for ; Thu, 19 Jul 2018 07:35:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91D636B000C; Thu, 19 Jul 2018 03:35:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A4C56B000D; Thu, 19 Jul 2018 03:35:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76FD26B000E; Thu, 19 Jul 2018 03:35:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 161CA6B000C for ; Thu, 19 Jul 2018 03:35:34 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id u1-v6so3097324wrs.18 for ; Thu, 19 Jul 2018 00:35:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results: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=qb+EwQcCN83uZfyoJKNad3uUtPfbbTIsx2Hll6QjyjfT8IAuoa4KfLLdeET9MS6V1Y PZwe6UpofXd5uBUO8eUUdNPtESnCXPSbzssmHE+K1Rrvv7RVqKHY5MAWRs69hoTCpmd3 4f1u+aBNyT92ffxU7qSlwhNj2zbsnFEsidPsCXWCFKqg2ZNHpfW9mQpWD0IkaV4xizJS SgYAHw6NtCZxTFbuERjOWRgtfwhFgdjrAv5OxKfGxlyWx37KWJyCT8N8U0BEGwdxWOzr 5FGWfPtoWJjLOtsTaWegrvqfTFfr21+zp++R/ZaxpnB1Eha1o2AHatF3PtCZBV/FNSHI AfBA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: AOUpUlHtV0lqr7Teqy67AanlmesSo48vhzThEv+hkjpMH2kcGBfWqAac A4nCGnyFsNSIbNKuhRlDY1umw+Vz0IflBIemAAfcJdoIjh+CTRs/jiGTuUM0exmIn1K+iQmJO0w RlPlUFme3y8EyBXY8/ku4P82AAYNwC5tr0Pz5NmQ8222x/tKyCIo9soRPhkSt/hzoGrGQqH0zVm dNf6eLIsFeAgtbv02FfFAPNsviGW/XZ6kre8FY51Ywe6I998pyNErT7Ak193ZeTBACGC8k2nAU8 NKZ7W3Z+9NQqlv9aDhQHmR9rX+alL9vkQimFBJa2GfMBGUEiOiac76sarJhcc3GZFuiFzKKfGoJ MQogRye/TdvTwGK4OEoXcAUojbdEn0NJ/QLhb2EjLPYp47txVbMju5BZ3POAGkMUfDKRgzG2zw= = X-Received: by 2002:a1c:8e8c:: with SMTP id q134-v6mr3823288wmd.3.1531985733569; Thu, 19 Jul 2018 00:35:33 -0700 (PDT) X-Received: by 2002:a1c:8e8c:: with SMTP id q134-v6mr3823261wmd.3.1531985732794; Thu, 19 Jul 2018 00:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531985732; cv=none; d=google.com; s=arc-20160816; b=kmGwzmNirtXeAPuIqFBVghOmvAd1ruSc2JfoI3tr+Jo6ShR8+RFKBjx6FDO3bBmFTf ZgEo5mf7BJEow4giwr2DadqiZgXjgJgIQZA25CgyqT1iniLSeoTgP1z1L4NPR6KQJeGW d7S/P7n5QvKVx4S1+uLZj50+FhT4DaVhEBWj0omoPZvP13xpbBnYWIOopSu7nVytgxuF Nkep+XXSX6Y5rHmXzBtv9+2PVMV0a8EHhWv/NxJUGAVj7rts/MtZKe03ibt901h5GPql xy4S0+xQujesBV7/vtjZXLIoXoz6TXjm2OeCwdkEBClBlqo8GzZGAsvtMYNQC7mi3irf UB+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=IVlZRCEljb0uQkRW0PlP105rljl3SfH8n+r2kyRS2zVtwvCQp+lX2IVx1dvndxB3aL kEpo7D2SaN8JNfqym/8Rwd5DJzRMGctDQcj6Ks6koOh7Ft6+3zN8RO3JYgTEW5Ghji/P iFn4Q4OAYah4/V1wuBP7BhE66T+SvjqYBN18KIaGfN4TGiuk1fGKbaHKMEOhrvMFVr9f EUm54xULg+CO8h2DI6kclCnFGIbGbzFn8XjsSRBYNWQtwKz+0ZcnnNBR5SW8SFlw2Ovj 1d9crd1XE+D1jgO/VHwdSgb6pZDsERHCKPIK6/VYrFJzHXNV0+F5CyPloW1d1LPPpTKz LSCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r24-v6sor1147806wmh.0.2018.07.19.00.35.32 for (Google Transport Security); Thu, 19 Jul 2018 00:35:32 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: AAOMgpcCPSZhNU+GytuJ3u6vzwnP84PgwRbUcDNyF/wYtbLzmXf0q1l2pZ9m5JKm5IwM1yJuji94Cg== 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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: Thanks 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); }