From patchwork Wed Jul 25 22:01:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10544859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9F4D180E for ; Wed, 25 Jul 2018 22:01:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D79872A891 for ; Wed, 25 Jul 2018 22:01:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBFC32A8A1; Wed, 25 Jul 2018 22:01:57 +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 54C062A891 for ; Wed, 25 Jul 2018 22:01:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F08996B0005; Wed, 25 Jul 2018 18:01:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E88516B0006; Wed, 25 Jul 2018 18:01:54 -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 CB2676B000A; Wed, 25 Jul 2018 18:01:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 63F956B0005 for ; Wed, 25 Jul 2018 18:01:54 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id q24-v6so3645683wmq.9 for ; Wed, 25 Jul 2018 15:01:54 -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=09jE8HQnR78gKgCVm3YT0g0xgTev+DzLs5mljNQWB3Y=; b=iGaQaQXmYAyM223AE8iic8TWSzrYbE3Dum/Z6gZtC6fERCVjGlooTH8I1qBsMiRStd UcKHnR3o89frFNzfWqIxQ9EyECi6glJkqUyVTJ4Zfw4G4BauOBYtvxjB4GXSKJM+zAZE qI5ayGQfInmj0Urbx9l+seDLUwPfV1NOZH4TM9w5CyrLqJsJ/0NzSdeV78E/Hv6SkHNF kJAZjacDPvq868EVmrtB7dK5NXTWFklAaneb1a4kWDC0QLoNji+zHQlU9slt4olUHJ5B QnNNW0BWMphHLKltC64pt8bhdf7weFbPh6y+38363E+wGpM07OR+XfJzV5Mvi+WKOX++ UIlA== 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: AOUpUlF/WYiKw2ucd2yk6l/sbvTJ9EVJ4RWg1Udp4C011nbkdRrcnoUL 7zXsytRFsCJJf0SEWr16HB7yTfXrmUS1HR7HscwgQQFgzmusLGVeBJduOJX0zahzTMA5BlL59tK Jhbl3udlVyl65Pg8Lr1FJvHlQ/gndDoi6P1di1WJHv92KIn3pyU68u+sszJVsf77EKfnZb2RZwN +5nlFbkSDjkrIoCODTGrSGHakLejqEvvCPRmJe+K48CdH6owBrds9jf9mDtMEPxEK1LGJRn881E M4z9sO6551Jrf2ErdMVQD6HH0zaL2xAqciGaGXXzUj3mUqVjDCUiORVcaH+xs6+1tbhAufWveXi YVvFckNNSHgtwuOT9fREPXHAZkwOIBfKdQURp84v/umkT0I6abUQPoqXL9BTZn0KCV73OlJaQA= = X-Received: by 2002:a1c:ea9b:: with SMTP id g27-v6mr5346342wmi.152.1532556113927; Wed, 25 Jul 2018 15:01:53 -0700 (PDT) X-Received: by 2002:a1c:ea9b:: with SMTP id g27-v6mr5346299wmi.152.1532556112529; Wed, 25 Jul 2018 15:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532556112; cv=none; d=google.com; s=arc-20160816; b=oHrdqrAMj1L/6exoHGXDwlh6x6VZrjlou1XcValQXHTuul6bKsanG2Gdfy9xhDMpCB mE43pRuDCcEc+Zb4aLERR+hw30blT/clUV7v5K1K2T9C7MClifOd5Hd7WLRL6OL4BJft syRGqcZLrsd2sbJyOiA6TlIHl+HNn+ty+MQvQ+zqN0Sk2aOgq7L23gXPQqTw4ClAfQcf 8+udYzRekl8bb+vmoaqvgoHALQv8mwXWnScaiEb45LbG5RQaRJQujwTOcw/CcMo+k4wf UhpVWpFkepZJCe6U7SfSjp3wNPRLwA4RyKIZHXtcLFDLVEerZgQP2bcAiWkcVUhZ61pM gsnw== 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=09jE8HQnR78gKgCVm3YT0g0xgTev+DzLs5mljNQWB3Y=; b=Vg19Nz80wtqkTom0pWf7oxsx9wR508W9vs4Ti6JqjelXOy7EO/W2RrC+6AS5DFYfjM DSMxgsMtDDVk7fZRFD/jCxhtKJ7CUhujYJF/V3UYs8Di3Ym9guhRQFEfHdB+TidUeClm hf2gfrPXgL24Cyo97VJTbqN86iJPDrSiExrOkUklMRBEVqPt6Rkvpe2DSkK8/aSaZHD4 7jAvvFFt9fB6NaJjBXSeJ7Hc2GrlXStypFdjoIdNVJzWTQ6FGU5gu/IFVKnJs8VPoZmA xTBaMT+sIJX1mddbZe1YceugI/7XfF4sLkdFlDmyyWOyZOs7dPa0nJ/2J9x5l18P+4+a WIPQ== 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 t2-v6sor6206364wra.73.2018.07.25.15.01.52 for (Google Transport Security); Wed, 25 Jul 2018 15:01:52 -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: AAOMgpftDpqxZHhmCrzBUf2teT6QSC+bN02o7cZGNJDJl8UR5DTe2sCvdgCrDXjNUB/kathH+yaUqg== X-Received: by 2002:a5d:4542:: with SMTP id p2-v6mr15773813wrr.191.1532556112278; Wed, 25 Jul 2018 15:01:52 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id b11-v6sm9642302wma.34.2018.07.25.15.01.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 15:01:51 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 4DC21124364; Thu, 26 Jul 2018 00:01:50 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, mgorman@techsingularity.net, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, Oscar Salvador Subject: [PATCH v3 1/5] mm/page_alloc: Move ifdefery out of free_area_init_core Date: Thu, 26 Jul 2018 00:01:40 +0200 Message-Id: <20180725220144.11531-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180725220144.11531-1-osalvador@techadventures.net> References: <20180725220144.11531-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 Moving the #ifdefs out of the function makes it easier to follow. Signed-off-by: Oscar Salvador Acked-by: Michal Hocko Reviewed-by: Pavel Tatashin --- mm/page_alloc.c | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e357189cd24a..8a73305f7c55 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6206,6 +6206,37 @@ static unsigned long __paginginit calc_memmap_size(unsigned long spanned_pages, return PAGE_ALIGN(pages * sizeof(struct page)) >> PAGE_SHIFT; } +#ifdef CONFIG_NUMA_BALANCING +static void pgdat_init_numabalancing(struct pglist_data *pgdat) +{ + spin_lock_init(&pgdat->numabalancing_migrate_lock); + pgdat->numabalancing_migrate_nr_pages = 0; + pgdat->numabalancing_migrate_next_window = jiffies; +} +#else +static void pgdat_init_numabalancing(struct pglist_data *pgdat) {} +#endif + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static void pgdat_init_split_queue(struct pglist_data *pgdat) +{ + spin_lock_init(&pgdat->split_queue_lock); + INIT_LIST_HEAD(&pgdat->split_queue); + pgdat->split_queue_len = 0; +} +#else +static void pgdat_init_split_queue(struct pglist_data *pgdat) {} +#endif + +#ifdef CONFIG_COMPACTION +static void pgdat_init_kcompactd(struct pglist_data *pgdat) +{ + init_waitqueue_head(&pgdat->kcompactd_wait); +} +#else +static void pgdat_init_kcompactd(struct pglist_data *pgdat) {} +#endif + /* * Set up the zone data structures: * - mark all pages reserved @@ -6220,21 +6251,14 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) int nid = pgdat->node_id; pgdat_resize_init(pgdat); -#ifdef CONFIG_NUMA_BALANCING - spin_lock_init(&pgdat->numabalancing_migrate_lock); - pgdat->numabalancing_migrate_nr_pages = 0; - pgdat->numabalancing_migrate_next_window = jiffies; -#endif -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - spin_lock_init(&pgdat->split_queue_lock); - INIT_LIST_HEAD(&pgdat->split_queue); - pgdat->split_queue_len = 0; -#endif + + pgdat_init_numabalancing(pgdat); + pgdat_init_split_queue(pgdat); + pgdat_init_kcompactd(pgdat); + init_waitqueue_head(&pgdat->kswapd_wait); init_waitqueue_head(&pgdat->pfmemalloc_wait); -#ifdef CONFIG_COMPACTION - init_waitqueue_head(&pgdat->kcompactd_wait); -#endif + pgdat_page_ext_init(pgdat); spin_lock_init(&pgdat->lru_lock); lruvec_init(node_lruvec(pgdat)); From patchwork Wed Jul 25 22:01:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10544861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43551180E for ; Wed, 25 Jul 2018 22:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 311572A88B for ; Wed, 25 Jul 2018 22:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 252742A8A0; Wed, 25 Jul 2018 22:02:00 +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 87F8D2A88B for ; Wed, 25 Jul 2018 22:01:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DA4A6B0006; Wed, 25 Jul 2018 18:01:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1DA506B0008; Wed, 25 Jul 2018 18:01:55 -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 E12D36B000C; Wed, 25 Jul 2018 18:01:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 7067E6B0006 for ; Wed, 25 Jul 2018 18:01:54 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id w2-v6so5149536wrt.13 for ; Wed, 25 Jul 2018 15:01:54 -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=77A9+rW8amb86L2JkMZP3auBwcWTGSGmGoibnY+fYSg=; b=VwpCTket+Tw7d2niMq60soaN8tu1gDxvd++OpveTPARgiu1kEe+0oLDAIQ7H2UAolF xD5GJlDtwxBud3xtkEeZHIIWyi3R2k0ae0y6dPrYPm7jz+/85LjeSqtx1qtUD5KVPlVc 6gbqFHDP/0IdjlS6SQd2TMCrn8bKD/QBv4tCYbfG2IafnL2yT1r13SFqJGE9auMXQzZk akFCcPh7DLEHnk7l5x3fjzlolPmumo2XhJZV2Gaw3HWNa40E1/zEFILU4leggMmE2Srv BNFqPKGSj6mmnw0vCysG1A32N8ZySJCzv/i19zuwkwaevomW+zcIRF0wI2bxPz1R5tCQ BJ6g== 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: AOUpUlEPBjz0+b8nXtE0usSIrmCBJdIwCZ/Wqd1un+7PMfxOu9kVD3lY Wa3kEBVKJfJSiFR9hMW/QA2u45+Yz4SC0hTAj1CaxRRSe9XYkOZGRW+P6o9yLH3VPSikHCTRG64 sZKciXVxGoCN5/AEqo437l7JR3vzKJZKblmHvcNRTkG1fgdG3pW6s8QjqRsZHkygBx9ZZ4zVGV3 e7hgDAZbvjOZF9mjTKV6FCx9edfO5Apnc0bcpzwMc0RLjKtWkz3hV2pewy9VsWsPphB1s8vorrg DvXBrLfnpPRLgkUrDmsOc2Vh/KbXAA923MM+a4rEaR6hK52XAu33trYhg8P6OYb/lu5EfR17reL yp5l9IY0IeRO0Iug633viAIU3hkgN93Vj7naA4DltIlud7I1nSQzMj5xea9vOqL/EOTtLUSzCA= = X-Received: by 2002:adf:a907:: with SMTP id u7-v6mr15537034wrc.175.1532556114010; Wed, 25 Jul 2018 15:01:54 -0700 (PDT) X-Received: by 2002:adf:a907:: with SMTP id u7-v6mr15536998wrc.175.1532556113010; Wed, 25 Jul 2018 15:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532556112; cv=none; d=google.com; s=arc-20160816; b=Ow3FGvboif5qF18NM3pku8kW3w/0vjkG6pbigHMrIIRSAcjFeI+C2X5AeklTTbaYwP NFsDHGXS0zIdWEfzZgjBMlD5fVK+rlcEMjfWu6qGfdqtMYNFncYoxe+NLZWtYimPFUYs Q2U3ItGPAhwl/KoPctIoYNnUCwXa4mHfw6JEV3iH+XIAzR04bwdmffQWHaA23zs0JbHT I2hjB4fELg62WAdHJkniFvHZcbahpHt30Jf2y2dnIF3PSWd8WxP5psf00zXcQ1X66wAl YIZwAVTcBeXl9mChODsx/670iM5+OAymEmeO87EMHUwRQJ+tTZptl5UeLydS6cioVyXI Rhvg== 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=77A9+rW8amb86L2JkMZP3auBwcWTGSGmGoibnY+fYSg=; b=zrOVcFmmJVA5c7+HUXkOJCvbpKtwbJwCv6kXjgcGYC2PfmgR1d+PUsLsck4KLMtHWm osvLt6cdtdfrNCRP7fy8syQyz4Cscp04Et86qWjOB3Y/ne34ZVOw8p0nvIED87v9m0u/ EbWUfzsKDkGRnY7+AiLGn3WuJ5BQxTJMDi+S5iQ5Nbsg72/JBrOrVNcW/D2AmMQgTtvX Ox4CN1biAOGYCqdMZv1YS4rRmVWB4zoIWs/zpwdGVx8rcfaJuq9KKQbIW5rXsLpwLICA uPyirQNv9bzqyO6qwwAnNcliNg/zitRx3IzeSHxxkVAktp/y895rxM/1gYIEMHdNOyDs IA8A== 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 a15-v6sor5953170wrr.42.2018.07.25.15.01.52 for (Google Transport Security); Wed, 25 Jul 2018 15:01:52 -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: AAOMgpeaquYtbdLwSQ8H0jFBpURGiJ1eIb/ZAbJwBob/mN3Vw8Um+xRfRxxMlpRRldBbJh9eZeGRCA== X-Received: by 2002:adf:efc1:: with SMTP id i1-v6mr15174035wrp.151.1532556112719; Wed, 25 Jul 2018 15:01:52 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id b198-v6sm6708359wme.11.2018.07.25.15.01.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 15:01:51 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 878AA124365; Thu, 26 Jul 2018 00:01:50 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, mgorman@techsingularity.net, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, Oscar Salvador Subject: [PATCH v3 2/5] mm: access zone->node via zone_to_nid() and zone_set_nid() Date: Thu, 26 Jul 2018 00:01:41 +0200 Message-Id: <20180725220144.11531-3-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180725220144.11531-1-osalvador@techadventures.net> References: <20180725220144.11531-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: Pavel Tatashin zone->node is configured only when CONFIG_NUMA=y, so it is a good idea to have inline functions to access this field in order to avoid ifdef's in c files. Signed-off-by: Pavel Tatashin Signed-off-by: Oscar Salvador Reviewed-by: Oscar Salvador Acked-by: Michal Hocko Signed-off-by: Pavel Tatashin Signed-off-by: Oscar Salvador Reviewed-by: Oscar Salvador Acked-by: Michal Hocko --- include/linux/mm.h | 9 --------- include/linux/mmzone.h | 26 ++++++++++++++++++++------ mm/mempolicy.c | 4 ++-- mm/mm_init.c | 9 ++------- mm/page_alloc.c | 10 ++++------ 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 726e71475144..6954ad183159 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -940,15 +940,6 @@ static inline int page_zone_id(struct page *page) return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; } -static inline int zone_to_nid(struct zone *zone) -{ -#ifdef CONFIG_NUMA - return zone->node; -#else - return 0; -#endif -} - #ifdef NODE_NOT_IN_PAGE_FLAGS extern int page_to_nid(const struct page *page); #else diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index ae1a034c3e2c..17fdff3bfb41 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -842,6 +842,25 @@ static inline bool populated_zone(struct zone *zone) return zone->present_pages; } +#ifdef CONFIG_NUMA +static inline int zone_to_nid(struct zone *zone) +{ + return zone->node; +} + +static inline void zone_set_nid(struct zone *zone, int nid) +{ + zone->node = nid; +} +#else +static inline int zone_to_nid(struct zone *zone) +{ + return 0; +} + +static inline void zone_set_nid(struct zone *zone, int nid) {} +#endif + extern int movable_zone; #ifdef CONFIG_HIGHMEM @@ -957,12 +976,7 @@ static inline int zonelist_zone_idx(struct zoneref *zoneref) static inline int zonelist_node_idx(struct zoneref *zoneref) { -#ifdef CONFIG_NUMA - /* zone_to_nid not available in this context */ - return zoneref->zone->node; -#else - return 0; -#endif /* CONFIG_NUMA */ + return zone_to_nid(zoneref->zone); } struct zoneref *__next_zones_zonelist(struct zoneref *z, diff --git a/mm/mempolicy.c b/mm/mempolicy.c index f0fcf70bcec7..8c1c09b3852a 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1784,7 +1784,7 @@ unsigned int mempolicy_slab_node(void) zonelist = &NODE_DATA(node)->node_zonelists[ZONELIST_FALLBACK]; z = first_zones_zonelist(zonelist, highest_zoneidx, &policy->v.nodes); - return z->zone ? z->zone->node : node; + return z->zone ? zone_to_nid(z->zone) : node; } default: @@ -2326,7 +2326,7 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long node_zonelist(numa_node_id(), GFP_HIGHUSER), gfp_zone(GFP_HIGHUSER), &pol->v.nodes); - polnid = z->zone->node; + polnid = zone_to_nid(z->zone); break; default: diff --git a/mm/mm_init.c b/mm/mm_init.c index 5b72266b4b03..6838a530789b 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -53,13 +53,8 @@ void __init mminit_verify_zonelist(void) zone->name); /* Iterate the zonelist */ - for_each_zone_zonelist(zone, z, zonelist, zoneid) { -#ifdef CONFIG_NUMA - pr_cont("%d:%s ", zone->node, zone->name); -#else - pr_cont("0:%s ", zone->name); -#endif /* CONFIG_NUMA */ - } + for_each_zone_zonelist(zone, z, zonelist, zoneid) + pr_cont("%d:%s ", zone_to_nid(zone), zone->name); pr_cont("\n"); } } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8a73305f7c55..10b754fba5fa 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2909,10 +2909,10 @@ static inline void zone_statistics(struct zone *preferred_zone, struct zone *z) if (!static_branch_likely(&vm_numa_stat_key)) return; - if (z->node != numa_node_id()) + if (zone_to_nid(z) != numa_node_id()) local_stat = NUMA_OTHER; - if (z->node == preferred_zone->node) + if (zone_to_nid(z) == zone_to_nid(preferred_zone)) __inc_numa_state(z, NUMA_HIT); else { __inc_numa_state(z, NUMA_MISS); @@ -5287,7 +5287,7 @@ int local_memory_node(int node) z = first_zones_zonelist(node_zonelist(node, GFP_KERNEL), gfp_zone(GFP_KERNEL), NULL); - return z->zone->node; + return zone_to_nid(z->zone); } #endif @@ -6311,9 +6311,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) * And all highmem pages will be managed by the buddy system. */ zone->managed_pages = freesize; -#ifdef CONFIG_NUMA - zone->node = nid; -#endif + zone_set_nid(zone, nid); zone->name = zone_names[j]; zone->zone_pgdat = pgdat; spin_lock_init(&zone->lock); From patchwork Wed Jul 25 22:01:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10544863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5BDE1805 for ; Wed, 25 Jul 2018 22:02:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92FB12A88B for ; Wed, 25 Jul 2018 22:02:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8746E2A8A0; Wed, 25 Jul 2018 22:02:02 +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 272C32A88B for ; Wed, 25 Jul 2018 22:02:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5603C6B0007; Wed, 25 Jul 2018 18:01:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 52E056B0008; Wed, 25 Jul 2018 18:01:55 -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 054226B000A; Wed, 25 Jul 2018 18:01:55 -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 980066B0007 for ; Wed, 25 Jul 2018 18:01:54 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id u21-v6so2093139wmc.8 for ; Wed, 25 Jul 2018 15:01:54 -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=Ad4OTLIPpMcbeOgRn7cNcAJiN8JJ4IImE90/3zrSenU=; b=mjZHiUdzWVkxMMUCnAcLg0mqQQulV23qOqXGKA/ISdrK9GdaZBgY7zHMgDONnpNZQZ TR6OLVlwLZ08pjQapeDJ8xcWAyezZhe5F56bCv8AjuZSF+oP5ehOLjqTYwnRnUkaobSK O8FNQEUiDTGN0dOZwbP5luQG3EDD5qKfnDGQdafiJ21xqRW/4RHoV6F/5YZTUEsiHCGK 5V/FqyKOSff99bQFoVz0sutKYEvtdvvXVgi2AD06cigkrNJ5dGYJH9hOCPIJdEcZ2pi7 qQx2lJ8pP9UXrKyJtgk9P1lFMlS48qGPh364trZNHqBJuX1v87v2sutottVCv2NEKNri uRRQ== 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: AOUpUlEZQi/E1QMX7liOZuJfu+SqKekcfkiiVqttU96itlowqEDM0yo0 9rGXi0UD4Ihw54PNN8PDbd1UNAnYb/IiiksymaWybb0BKe9ERRnX7z8XVJCOtLIJO6r6p+j0c4l Kehz12HFT4a9ttasgKJ/zusO/eczo6mtcoUOzuRhYEAhuivSUubT2DgB+fheyWzXiFz5MiAu2Vn kJ0JFnFevG4HZaFeawHcCQDyHrL44gE0MlUKRYQvRKrsT49UrZMB15SWdy/8FAdFiDKdSjYDBHg 1Man+W5wLY1eVOcO9xCWh456XZALQcqk6/ISmFbyZY3Okkl1h44kycWyIdPFBxiBqOcie1v9l+T XpcKH8iN9lRZfnsg4pRopIxsRzfMJs4Vh5uT/pkbhHYhgBlQpvqEYi4pedL7CSzX45o1K0yYhw= = X-Received: by 2002:a1c:90cf:: with SMTP id s198-v6mr5800498wmd.5.1532556114126; Wed, 25 Jul 2018 15:01:54 -0700 (PDT) X-Received: by 2002:a1c:90cf:: with SMTP id s198-v6mr5800473wmd.5.1532556113361; Wed, 25 Jul 2018 15:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532556113; cv=none; d=google.com; s=arc-20160816; b=HbW3uH+nyrmNOoBNoOhMdcL73U6BZJDWdZELYaQ/7F4I7SYrI+gfBYogYhWVlpBvfo QvUiiQdUrXwm343wqGsfadDA28YcFDyKOADvhmJXTR28uewEm6aXgj56rcatm922X2a7 Mux8pAlazxAvIb2wO9u3cBb17ikugKWxcY+62uPgP+rMM1EdHLg1CpgWOsjIqqWM4tVF IiXE9OwHDGnFP14mFHcLApbTUrlhJfMJ5F/lEHOGH+tPxCKFK52fF8Oeawve3jC7hPqg hqnBy90inVrGhH1F1C3vTpcFAkhtZoeGrv1ahX7q85YEHcu+D3xGQDSjLj3KOXwgsMKL SSlw== 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=Ad4OTLIPpMcbeOgRn7cNcAJiN8JJ4IImE90/3zrSenU=; b=XSpnB3pwyoY/JB6ycVaVrxp/QENShmlvKWNhu3HoGmQsWw2k3fgaVtoslLk9xRfrgI vFpQwjGFlh98806nYOTOXfYkuz4oyjo2S9OotPWCZuToYLqTwdLXKiwO9+324h/ehzz0 ZEwnRGdLDuy7IeewvgPUc3cknReHqCXPMok8nZL/2ffVMPtrCqfDN8kwvCs7oC5rvA8V od8Y3mTl4P5lfxRf5GFpI81ftxDJMgiVyw6W5zu73cLQUNNY/lh6GLzB/YVT9FtS5tgU qXmzGVyEGIRu0tDs+4bVaWkRBm7T4Q3P7efU8Kt6qvo+scWvfYyiSUchRDm+shT+s4Ef 6qRQ== 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 l24-v6sor1109863wme.49.2018.07.25.15.01.53 for (Google Transport Security); Wed, 25 Jul 2018 15:01:53 -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: AAOMgpchnNwSDYXydPO96tsdnWQg2kVs8zmBXVoG3BPLNpkKwoonPv5Icvawctv1nC0wAIgER7wkZw== X-Received: by 2002:a1c:4887:: with SMTP id v129-v6mr5401757wma.129.1532556113118; Wed, 25 Jul 2018 15:01:53 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id v2-v6sm142494wrn.97.2018.07.25.15.01.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 15:01:51 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id C2EEB124366; Thu, 26 Jul 2018 00:01:50 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, mgorman@techsingularity.net, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, Oscar Salvador Subject: [PATCH v3 3/5] mm/page_alloc: Inline function to handle CONFIG_DEFERRED_STRUCT_PAGE_INIT Date: Thu, 26 Jul 2018 00:01:42 +0200 Message-Id: <20180725220144.11531-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180725220144.11531-1-osalvador@techadventures.net> References: <20180725220144.11531-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 Let us move the code between CONFIG_DEFERRED_STRUCT_PAGE_INIT to an inline function. Not having an ifdef in the function makes the code more readable. Signed-off-by: Oscar Salvador Acked-by: Michal Hocko Reviewed-by: Pavel Tatashin --- mm/page_alloc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 10b754fba5fa..4e84a17a5030 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6376,6 +6376,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 inline 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 inline 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) { @@ -6401,16 +6416,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, zones_size, zholes_size); alloc_node_mem_map(pgdat); + pgdat_set_deferred_range(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 free_area_init_core(pgdat); } From patchwork Wed Jul 25 22:01:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10544865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3A09180E for ; Wed, 25 Jul 2018 22:02:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 927892A88B for ; Wed, 25 Jul 2018 22:02:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86A802A8A0; Wed, 25 Jul 2018 22:02:05 +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 F2E892A88B for ; Wed, 25 Jul 2018 22:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFB406B000C; Wed, 25 Jul 2018 18:01:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EABA36B000D; Wed, 25 Jul 2018 18:01:55 -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 CB4A36B000E; Wed, 25 Jul 2018 18:01:55 -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 649636B000C for ; Wed, 25 Jul 2018 18:01:55 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id f13-v6so3682577wmb.4 for ; Wed, 25 Jul 2018 15:01:55 -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=Id+mrqjnu26knFarWg2kIgattDnTOoEqy5e1QbH6y3s=; b=XSpmgQbt8fzO9Sm0ZLXt4BoetcdbsEpG8ShWC86QP+RUNIpoiWQb0jK/1qV7zQOUlf 0AP8yyFFRCaABXRtnBSIh54uPQEEPYJsZBbIDfKKi8HiFV0+7fvPL0Hn1YxOzGLewcmz sP+IYu1i5t9479f4iqNy3x6kwpvZihEw77EzuTuWuqB6oZTu9ONfKkAGHIG4zALFcSy8 HZyF+A+5yLGCx7ZU8HuSBJyb4+oYtuppCMcNOCVeYG1QQWXHcSY3fSOh7AeBra5123oY wXKxe3F/oIpXc413aLsbcyslTxLSRnwdle1Ra5Rw0aJwHabHsM2sKFedIgg75xY3/IPQ uFwA== 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: AOUpUlFRnVR5nttmKSxeJKTLPZgSQO0L6ZQ4ODFotVFbMSl8vyAMpjoV 1IFA4wP9UyJuZWQH34bJTz3GzkHI7+WtKYB/rk93Ijle3XonAVsqEbpnTgdJMGZksERwcaGDOEP FcrHygNzC/a1OAJBYI5XaTrd4OXFCDzenMZCE6eRkkfwarzQ+g0hDX4Ab0BUAIfUFtVjZIGVZWy us5XvgZ8imWpVnRtjh8DpfKIfoQsl3ichnNyEnaqgkzoNjW7OgjJdkBg0Bis8WHotE8/VQquKgp ZHb9ta2OCIOXECfYsLMN2Qu1fAtESpxWQxCVDqJ6N7KjCyH5RUONTBYNy/6pKndjKlrFJI0EOS7 GVXrvgS9zStYLmoftC3uXrEHOdd8e0l1omH1FC15VDfoPdw/9XrqypBbD1wRAuVunhQ6YSTRhQ= = X-Received: by 2002:adf:c5d3:: with SMTP id v19-v6mr15940139wrg.169.1532556114979; Wed, 25 Jul 2018 15:01:54 -0700 (PDT) X-Received: by 2002:adf:c5d3:: with SMTP id v19-v6mr15940109wrg.169.1532556114165; Wed, 25 Jul 2018 15:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532556114; cv=none; d=google.com; s=arc-20160816; b=mAbYlJNnci71UQ/McZnylM1fCoHznYxLS4rVDZrnv0dtIqe1rm/poZ4xH7uMoazkji OrkEm7vyTF7Yz+J/uutYcWB28WwKLEtHHl3+hSWULb1fTSWFZhkPeS7xYc41+zM5yR9W wyHPQQDGjgk9itasg4SMZUgQq8JhLh2A2ffgp38KUE6VTpiVNTzbkbaS2Lm1JajIkaO0 l/qyJ4JzBXy54k8uPUyHOzChWPJhuGHVVkUbETfZPkTAmNqzm6v0IJYgcY40h2p5gdIH fenAfldhGLHrsMkAyzV0fvwDLKiDB0dQLLqkiCskFNycQJxoycmTtC92gKkXIhIBdQoi SSLA== 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=Id+mrqjnu26knFarWg2kIgattDnTOoEqy5e1QbH6y3s=; b=CRXdC0pGy+KX3fjkZVdb6xhbDi6yCZOHf0df0eANRXR+mJmIjP213RHoFuyrZyV2wb NAXo/LxY+bMatIUc6h8LmvO0nxqCj9KaVBrQs7MhJW0iKumsXMymvdCkE5lG7EO2w4vQ xU8/o1jJBa3QwLSQ+dffcLVk4P9mWN940/nVlZXbwUcxEVEBth+w2Zrzv9OgqnP3a538 WuGId32Bivyo21xY9JQgYnOign795eBWhGsQkrOWkfmjjU14wmW+/xcwYPvo9a67aSp2 T16FyRlkeOCiD6Ljd+cRe6vcss1IvpKMsQ6/V/H9MGEYJJ5wSVj8vFcFh2FfwYf70I/x zW1g== 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 g18-v6sor1449666wmd.76.2018.07.25.15.01.54 for (Google Transport Security); Wed, 25 Jul 2018 15:01:54 -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: AAOMgpdXr7ZpURGDvQ4QrP7r+GbCiIHafp2RLqyBFS+hqwXk2LaB+lf1hP14ke09aY+/SPFKpK4Tfg== X-Received: by 2002:a1c:9e89:: with SMTP id h131-v6mr5450015wme.13.1532556113866; Wed, 25 Jul 2018 15:01:53 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id e204-v6sm5183748wma.8.2018.07.25.15.01.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 15:01:53 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 1E390124367; Thu, 26 Jul 2018 00:01:51 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, mgorman@techsingularity.net, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, Oscar Salvador Subject: [PATCH v3 4/5] mm/page_alloc: Move initialization of node and zones to an own function Date: Thu, 26 Jul 2018 00:01:43 +0200 Message-Id: <20180725220144.11531-5-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180725220144.11531-1-osalvador@techadventures.net> References: <20180725220144.11531-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 Currently, whenever a new node is created/re-used from the memhotplug path, we call free_area_init_node()->free_area_init_core(). But there is some code that we do not really need to run when we are coming from such path. free_area_init_core() performs the following actions: 1) Initializes pgdat internals, such as spinlock, waitqueues and more. 2) Account # nr_all_pages and nr_kernel_pages. These values are used later on when creating hash tables. 3) Account number of managed_pages per zone, substracting dma_reserved and memmap pages. 4) Initializes some fields of the zone structure data 5) Calls init_currently_empty_zone to initialize all the freelists 6) Calls memmap_init to initialize all pages belonging to certain zone When called from memhotplug path, free_area_init_core() only performs actions #1 and #4. Action #2 is pointless as the zones do not have any pages since either the node was freed, or we are re-using it, eitherway all zones belonging to this node should have 0 pages. For the same reason, action #3 results always in manages_pages being 0. Action #5 and #6 are performed later on when onlining the pages: online_pages()->move_pfn_range_to_zone()->init_currently_empty_zone() online_pages()->move_pfn_range_to_zone()->memmap_init_zone() This patch moves the node/zone initializtion to their own function, so it allows us to create a small version of free_area_init_core(next patch), where we only perform: 1) Initialization of pgdat internals, such as spinlock, waitqueues and more 4) Initialization of some fields of the zone structure data This patch only introduces these two functions. Signed-off-by: Oscar Salvador --- mm/page_alloc.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4e84a17a5030..a455dc85da19 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6237,21 +6237,9 @@ static void pgdat_init_kcompactd(struct pglist_data *pgdat) static void pgdat_init_kcompactd(struct pglist_data *pgdat) {} #endif -/* - * Set up the zone data structures: - * - mark all pages reserved - * - mark all memory queues empty - * - clear the memory bitmaps - * - * NOTE: pgdat should get zeroed by caller. - */ -static void __paginginit free_area_init_core(struct pglist_data *pgdat) +static void __paginginit pgdat_init_internals(struct pglist_data *pgdat) { - enum zone_type j; - int nid = pgdat->node_id; - pgdat_resize_init(pgdat); - pgdat_init_numabalancing(pgdat); pgdat_init_split_queue(pgdat); pgdat_init_kcompactd(pgdat); @@ -6262,7 +6250,35 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) pgdat_page_ext_init(pgdat); spin_lock_init(&pgdat->lru_lock); lruvec_init(node_lruvec(pgdat)); +} + +static void zone_init_internals(struct zone *zone, enum zone_type idx, int nid, + unsigned long remaining_pages) +{ + zone->managed_pages = remaining_pages; + zone_set_nid(zone, nid); + zone->name = zone_names[idx]; + zone->zone_pgdat = NODE_DATA(nid); + spin_lock_init(&zone->lock); + zone_seqlock_init(zone); + zone_pcp_init(zone); +} + +/* + * Set up the zone data structures: + * - mark all pages reserved + * - mark all memory queues empty + * - clear the memory bitmaps + * + * NOTE: pgdat should get zeroed by caller. + * NOTE: this function is only called during early init. + */ +static void __paginginit free_area_init_core(struct pglist_data *pgdat) +{ + enum zone_type j; + int nid = pgdat->node_id; + pgdat_init_internals(pgdat); pgdat->per_cpu_nodestats = &boot_nodestats; for (j = 0; j < MAX_NR_ZONES; j++) { @@ -6310,13 +6326,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) * when the bootmem allocator frees pages into the buddy system. * And all highmem pages will be managed by the buddy system. */ - zone->managed_pages = freesize; - zone_set_nid(zone, nid); - zone->name = zone_names[j]; - zone->zone_pgdat = pgdat; - spin_lock_init(&zone->lock); - zone_seqlock_init(zone); - zone_pcp_init(zone); + zone_init_internals(zone, j, nid, freesize); if (!size) continue; From patchwork Wed Jul 25 22:01:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10544867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67FA4180E for ; Wed, 25 Jul 2018 22:02:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56A832A88B for ; Wed, 25 Jul 2018 22:02:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B2FA2A8A1; Wed, 25 Jul 2018 22:02:08 +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 A9A562A891 for ; Wed, 25 Jul 2018 22:02:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 479F36B0008; Wed, 25 Jul 2018 18:01:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 400E66B000D; Wed, 25 Jul 2018 18:01:56 -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 2C8576B000E; Wed, 25 Jul 2018 18:01:56 -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 AEF8B6B0008 for ; Wed, 25 Jul 2018 18:01:55 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id d1-v6so5162339wrr.4 for ; Wed, 25 Jul 2018 15:01:55 -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=rskVcuLW5mTCFv880bF+K7VIucHqpnfomG/ohSkecG0=; b=VGGYpxWvsq5gZ9qjjMEc4ngvlHXbEGK/YBZjuv1STvf5TQ2YfoIERrirdqdvWTQw9T kD25rX0/jSjOCUQmVg8Y6+coCyVi2t5WUvnacDycDrJWArz6S+3XIcX0zCAgHf4gN5sH OzauSBZinRjJfmmNS45+DW3WtirigspVY/dDK8qZKKwV+gTz9i96UVpHAlT2DirIHENP os8WMWK3cYwLgwti6mzJgPl3oDabLtIfcTPo7cBG9xLIiaS/b072YSchpneqDqJgzLpd bF+8AR6TFkOY3LhCaH3aiiuwuoHLjt2h3RopB9+Imno5PkyOxJOTcU5ZqnJIEsoV6056 u2pA== 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: AOUpUlEEyM0F+qBrc1uGJ27AMz8MVxvRf17xe3xa/ps1t4oePguV2DuW k9YSBNlBmrqeCkDfUFBfh7CVCYcL0QkR5vvay76a+xTC3FMegbozHC926i/crPjRbCYYsBvxIvQ +khrltzP14e4QLObp9EhCXwAgmRpk/y1/l1IiflkxHcRt1YzQ6RLSGjw9wQxFbhbePRmfQPMvAv YtTH/AGWfLlAO2RUy6O5iP3ZcZMWLiD0Yy85RTHWTug58YZ6hQIsJ45JT5s675WuBaRtgwPLMm1 xfFgsuGbEUc5WwjyXcvqmRkGJ+QJo6nAKRUT9/QvWYhq51w7v48aYXnw14H9AMXK/oFXWAdHhKp XQsGYyNZ9xmQb9XuHdVfxq7Km1xFxaBPT73VyOMaukGMhJK63MBBC/Ivxyovg/vA4lJITOxd9Q= = X-Received: by 2002:adf:9303:: with SMTP id 3-v6mr15853335wro.197.1532556115279; Wed, 25 Jul 2018 15:01:55 -0700 (PDT) X-Received: by 2002:adf:9303:: with SMTP id 3-v6mr15853313wro.197.1532556114622; Wed, 25 Jul 2018 15:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532556114; cv=none; d=google.com; s=arc-20160816; b=HvQGZFUSfxUmBDRrtxJlgtQIh+k5Ao1Cx+fEc53QP85JtFx3kdVdV9dh1TVInTG0Hu OTKszKAqeHXSECjJDj+QhEGRuHAUYtvQQgZZaciaOSy9dnDCs47o+u5JHGKPN+ZGvjjp 6Hjxk2mWK5Uq6i4wu/IP753p0X924qFGAnQ4rFXfcMY/6UHfXsJ4xL0UMozjQcXfk2Ll GaY1Z8+aGeK3UGPlRwg/b5KHQ6l3cw1XnwGmKytTwRW5lufMG5c+7nVd5ismLxUENNnq qTCLaK5EjChA+bLcC/UzcvW7B8jMS+JwF0EJ23ReOD5T00Gu/Yrty1j2ba0X/kk/qGPk xbbg== 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=rskVcuLW5mTCFv880bF+K7VIucHqpnfomG/ohSkecG0=; b=BK6Ci+2KONMWJkH3aoBhkNq3KkB4HHa52VFjciIj9HB9fxgp2E5NPr768P9cEoXJbW kRDRkXEQeDrdJuFUOsCbTRb1LqoSChlwEoBVNeKmH+TWp7APS2OnM5qYdbxkcMpaqeDf c+qdZlDYr84wtf43PmBYvqMZc3t8SGV9D1ziftJDppUo8fPTBapHg6Fq7CtZABjbR+tX V9MFXGeUTHqvqfSZw5eg8vTOerm8jKsH94abCc6h7bIeCNF+tihegzBLEiBPuHybgimk rumVvtHzqyjvwm7DpODY2GWdiJX9AOcfP64t331Hmu9v63SyOOg86jNJdKXuQAxfUryL lK9g== 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 s4-v6sor6194264wrp.65.2018.07.25.15.01.54 for (Google Transport Security); Wed, 25 Jul 2018 15:01:54 -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: AAOMgpfDY8YVBm0vBDEeDHjQVFUDCMNZsVqHRinE5AeLSxniHw/159rWqT+u6KglbXJodd3YHqaNyw== X-Received: by 2002:adf:fac1:: with SMTP id a1-v6mr14978854wrs.74.1532556114299; Wed, 25 Jul 2018 15:01:54 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id d14-v6sm20991515wrr.12.2018.07.25.15.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 15:01:53 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 6E8C6124368; Thu, 26 Jul 2018 00:01:51 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, mgorman@techsingularity.net, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, Oscar Salvador Subject: [PATCH v3 5/5] mm/page_alloc: Introduce memhotplug version of free_area_init_core Date: Thu, 26 Jul 2018 00:01:44 +0200 Message-Id: <20180725220144.11531-6-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180725220144.11531-1-osalvador@techadventures.net> References: <20180725220144.11531-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 Currently, we call free_area_init_node() from the memhotplug path. In there, we set some pgdat's fields, and call calculate_node_totalpages(). calculate_node_totalpages() calculates the # of pages the node has. Since the node is either new, or we are re-using it, the zones belonging to this node should not have any pages, so there is no point to calculate this now. Actually, we set the values to 0 later on with the calls to: reset_node_managed_pages() reset_node_present_pages() The # of pages per zone and the # of pages per zone will be calculated later on when onlining the pages: online_pages()->move_pfn_range()->move_pfn_range_to_zone()->resize_zone_range() online_pages()->move_pfn_range()->move_pfn_range_to_zone()->resize_pgdat_range() This introduces the memhotplug version of free_area_init_core and makes hotadd_new_pgdat use it. This function will only be called from memhotplug path: hotadd_new_pgdat()->free_area_init_core_hotplug(). free_area_init_core_hotplug() performs only a subset of the actions that free_area_init_core_hotplug() does. Signed-off-by: Oscar Salvador --- include/linux/mm.h | 1 + mm/memory_hotplug.c | 23 +++++++++-------------- mm/page_alloc.c | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6954ad183159..20430becd908 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2001,6 +2001,7 @@ extern void free_area_init(unsigned long * zones_size); extern void free_area_init_node(int nid, unsigned long * zones_size, unsigned long zone_start_pfn, unsigned long *zholes_size); extern void free_initmem(void); +extern void free_area_init_core_hotplug(int nid); /* * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 4eb6e824a80c..bef8a3f7a760 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -978,12 +978,11 @@ static void reset_node_present_pages(pg_data_t *pgdat) pgdat->node_present_pages = 0; } + /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) { struct pglist_data *pgdat; - unsigned long zones_size[MAX_NR_ZONES] = {0}; - unsigned long zholes_size[MAX_NR_ZONES] = {0}; unsigned long start_pfn = PFN_DOWN(start); pgdat = NODE_DATA(nid); @@ -1006,8 +1005,11 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) /* we can use NODE_DATA(nid) from here */ + pgdat->node_id = nid; + pgdat->node_start_pfn = start_pfn; + /* init node's zones as empty zones, we don't have any present pages.*/ - free_area_init_node(nid, zones_size, start_pfn, zholes_size); + free_area_init_core_hotplug(nid); pgdat->per_cpu_nodestats = alloc_percpu(struct per_cpu_nodestat); /* @@ -1017,18 +1019,11 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) build_all_zonelists(pgdat); /* - * zone->managed_pages is set to an approximate value in - * free_area_init_core(), which will cause - * /sys/device/system/node/nodeX/meminfo has wrong data. - * So reset it to 0 before any memory is onlined. - */ + * When memory is hot-added, all the memory is in offline state. So + * clear all zones' present_pages because they will be updated in + * online_pages() and offline_pages(). + */ reset_node_managed_pages(pgdat); - - /* - * When memory is hot-added, all the memory is in offline state. So - * clear all zones' present_pages because they will be updated in - * online_pages() and offline_pages(). - */ reset_node_present_pages(pgdat); return pgdat; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a455dc85da19..a36b4db26b50 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6265,6 +6265,25 @@ static void zone_init_internals(struct zone *zone, enum zone_type idx, int nid, } /* + * Set up the zone data structures + * - init pgdat internals + * - init all zones belonging to this node + * + * NOTE: this function is only called during memory hotplug + */ +void __paginginit free_area_init_core_hotplug(int nid) +{ + enum zone_type j; + pg_data_t *pgdat = NODE_DATA(nid); + + pgdat_init_internals(pgdat); + for(j = 0; j < MAX_NR_ZONES; j++) { + struct zone *zone = pgdat->node_zones + j; + zone_init_internals(zone, j, nid, 0); + } +} + +/* * Set up the zone data structures: * - mark all pages reserved * - mark all memory queues empty