From patchwork Wed Jul 18 12:47:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10532429 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 4065B6053F for ; Wed, 18 Jul 2018 12:47:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35B2B2915C for ; Wed, 18 Jul 2018 12:47:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29B1529162; Wed, 18 Jul 2018 12:47:50 +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=unavailable 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 C6E4C2915C for ; Wed, 18 Jul 2018 12:47:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19AAA6B000D; Wed, 18 Jul 2018 08:47:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0AAC26B0266; Wed, 18 Jul 2018 08:47:41 -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 E8A9E6B0269; Wed, 18 Jul 2018 08:47:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id 8F6746B000D for ; Wed, 18 Jul 2018 08:47:40 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id h18-v6so1007929wmb.8 for ; Wed, 18 Jul 2018 05:47:40 -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:from:to:cc :subject:date:message-id:in-reply-to:references; bh=v+9JS2c7Tw5KibY5zESrEVlALGGos2Uk1nhW3AGPdvw=; b=dbx+Gb8nyLkRoNDsmE7bk0NI3Lban+lVBzXFVJ0Av2oxoHpVJnpJakBFvojjm1xgEz vRANeZidL7+pQp8q/jRiHSDPm2pQHsZXtP9t3H5yz2eg8G3XJPpjEL4ud1J5MWH2VBsP hqa2khygyS4pPneprfDweLIJcsBW1iTFaW/d7ghoSULhKpguV4tbopbUNAilR8f4ACRS yrP6LbKtFhfFhsg2eVX00tgNi/Diq4zvjQVve9R5XRCIwa3nCPKgySedzBBqR4tgPx1J FEU/TVoUVsxXu2fm0P77iET+MWgs7Yhig+6X73oJdqK/lE2sNRm0lwSJRvW2GcdsNOyR SKZQ== 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: AOUpUlFZAuGHqSNCGUQ48LpQsf1tvs2rE5hRJMbS3XuUKKVjtOPtmMK5 zoMxZdBflVdpL47n8LwlA0139GzrbjdDLcLva/3XwLFowIlkiBzrGFEIDm30sjK5ahUfL1zN04P DMcKC8BB6y1cAKB85/3Gvgb64Lepc/XOZFf2YFSbbASGRufJtrrOFdRFJe6RzlxbV05cWoIi/I7 L4jgWekk9lCMBWXHmCCzxucv1gGdLXHoMskq1rM5gmsRyGGISdJloJzVEOKgeQmUAQKHabKX7mR wjONDhs/9OGV0O0VFZp+JLseS+uGwvn7TCjTTueBi5wN5o5jiHX156reSpztRAr9oXCG5bdmkiH E1JB4bZ0WA/hmT8c5QN0KYGdsSh8HCFw1tOBUP/eeX8AcnCfgvVJRfxEoWspTIa+BxMTJ0vKyg= = X-Received: by 2002:a1c:b915:: with SMTP id j21-v6mr1621057wmf.104.1531918060084; Wed, 18 Jul 2018 05:47:40 -0700 (PDT) X-Received: by 2002:a1c:b915:: with SMTP id j21-v6mr1621036wmf.104.1531918059472; Wed, 18 Jul 2018 05:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531918059; cv=none; d=google.com; s=arc-20160816; b=pBW/GlooavEMQu8dVCRHN6CWTuh5B1XCA3GqY1oZqtEfG/4PMNuNj24NTDj8PnLKwO NOPXJrbCV6jBasQSa4sgcCnQkLNoSCiild4ecXcfc19q2rDc7rzlXTn6W/xrybNsmnTu rofxXZEHpeV4ACSttWXecaeCySsQWz/YiHjiFPdIFUkM5RaYIBNnMWB6+NGVPzog1MLb jDYP87pbVsv8v1XSwUSyRuURomyWaatLg9yKZxgen6Ho794nOebo05emZobMdv9eQ8tX ueL4SNXXsuXJRve13RAztDAUjreI4j6CteyDM7JTOH27gULOAS69kUwjMpIUwXbYKC/T OJXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=v+9JS2c7Tw5KibY5zESrEVlALGGos2Uk1nhW3AGPdvw=; b=re2NK442FA0dwZ62bGvLjlZZHtnDFE26+PjxvddoP9NSfLpTaMasxiJNbWhQY3uX8s wffox9FzaC+S/dxssRT1RGqIicHLpnM6KpkFrGX0H+mBCuz3Ig2EkYdfTaJju5mllSMi 2GmciEW8uQ3MPshq62cu7SRbk3e+0eeV12NKePzDFTu75NOycVnhWPK0n59AuaXzPoGJ NDifIXGFYGnXYn9lqa8PJkWcxJrOBeYzcPmps14eoZUaLmGQWH9mPjV8/6k9CWLpGed1 cPSIVOtRt0u478WLXLAJAmMe2GCil19yaPcpmTJdyjJi1G7b+ZK6bpE5XkVEbRhdf5ju gZbg== 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 u4-v6sor1619017wrt.37.2018.07.18.05.47.39 for (Google Transport Security); Wed, 18 Jul 2018 05:47:39 -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: AAOMgpdugi4SDF7W40LdMnNfnedowq5QETLG4kycovUDXnpRGPy1ArQOhfClGMv3I1+Rfe7bOsq3Sg== 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> 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 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); }