From patchwork Tue Jul 17 10:56:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10528945 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 41BEE6020A for ; Tue, 17 Jul 2018 10:56:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 301EA283D1 for ; Tue, 17 Jul 2018 10:56:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 242C428429; Tue, 17 Jul 2018 10:56:59 +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 C282A283D1 for ; Tue, 17 Jul 2018 10:56:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3691D6B000C; Tue, 17 Jul 2018 06:56:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 09FF46B000D; Tue, 17 Jul 2018 06:56: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 E83AA6B000E; Tue, 17 Jul 2018 06:56: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 8EEFE6B000D for ; Tue, 17 Jul 2018 06:56:55 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id h18-v6so373305wmb.8 for ; Tue, 17 Jul 2018 03:56: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=aoQ3hjjwbDevILRQhdQeeoqo7f175v8Mth2S6+yE7wU=; b=V757pHeIYtoNpTI7Y+vUvcI+LBZLbrdZUjA6x7ts4MOQuFDr2yOq8d05fs9HlaS6us CH4ttbfz6xfIFrfTSTi9E5akNwZZ7A6NKnk9W/MDyue1GYHsb0w4zDvopwExLO5xfHQ9 RZiWBbeOABw0+EinEBaEu/CzL0tj1fM6pJDtJ+HEvt6q65rjJYCif/r3qu+ARLeqXYAa uOpD3OvvuayHv99HzZJ0R0ETWZKZdb2lThffp6R+1+2ibLqBpMaFJAOuxl7lpQVOv1SU nTAQDCOYsWuH8EmWcMz5HwmakuAicZwjU64utO1W3teTA8WptPA7BjoBSomnDVLmEDcS FLlQ== 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: AOUpUlHq+oJPppVcIKIBZuvi9Id9M2hhG1+gKRgaSbOtzOP2cqRcACsO FHfWXo02+L8M0n0sg5M0oMFb3vEN+7APrbOsC2qXe/Y2ojIFIl2S/IjYMAUdDtd9BRpUmXPTsmA sR5jeVFduqZa7p30zxkR1o3RC7IlQD3cZUzJMkeRXYGAmh5Ghagdd2VW9nTQ5LQeDqoDbW1NptV hMGlOzV5Gjlc4PKWOtnoyOnXy8YEZczMtUX5x3XjtfN0DZkqFZlghMHwpKC4ms3g8908kpuPA2e 87R4JV2At+/9/HeT9/voaS7fmFARtOCrs03uwoGiB4d0IKNfshk81yPIXPXxHxU0jBUmR/jhS17 C3CD8uen269wOK9Fz9rWy19vfRzCtC8S6Q5dxr8N69xfqfiR7u0urXloSDNHw848PzfIWqBTDw= = X-Received: by 2002:a1c:7501:: with SMTP id o1-v6mr1067777wmc.133.1531825015069; Tue, 17 Jul 2018 03:56:55 -0700 (PDT) X-Received: by 2002:a1c:7501:: with SMTP id o1-v6mr1067759wmc.133.1531825014409; Tue, 17 Jul 2018 03:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531825014; cv=none; d=google.com; s=arc-20160816; b=ylEQx1bIzv4YOI6x4zYQi5DbxOX3+0mR3vm0XcFbWjtkbR33jmanD7vPVI5HFcwMx5 s96G/4VTuvh6pwJDjwAA71d3fF7Hvnms1gu4+bIzfRj+4gNd1cZmYzmaN+wTl4hFgiC+ i6Bs1a843MmO3eM9AyKG4qF1zGorq53cPXxydI2gxkZGHnGvwCGSZ9/jVvDVkcLnlD9m oKFwP65Q4XaMwWMLyorAI6HrFtGiHH21liM2rLJmKqmwChy0IidT0gm5Nsc1Fur2zYAn /O8y8KD005GUzc6cwf1RSgda2lVoMtMgM+gZJ4RPTyHGvn5eOq1KWb+xLeyIT/8HQB6O ieQw== 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=aoQ3hjjwbDevILRQhdQeeoqo7f175v8Mth2S6+yE7wU=; b=TxNEIfYU7RvKjNWTFu8Y1IPe2F1ViD6juu0Qlb4AT08BmXc15qmXqGeFc80AxRHt25 IaQvWeBbt7Ef2CUEuO7aPP1dySDinNkL026+DYZoZXG0rX7+2UtRVbNUgce/aWgFx9cT l4GseyFIn05PLLMhPvgpej3vSpHwjbwjWEUaTnZNrLjOSu92s3rzGocm/77p9oPKn+gk PeT2kq0RGGKXmN9Rk8DTSTADd0Rz3ygafywp/+qTKhmiS/ZyEqQ8zW3lCLw5b3e9Gxgb 5Bgkd202xTF7rc7HipOuw6nSc5fDeuc1bNXVfDL9XjZo+D5jn49dlMc8vhs6UtU0H0AP /zeA== 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 j9-v6sor328256wrq.66.2018.07.17.03.56.54 for (Google Transport Security); Tue, 17 Jul 2018 03:56: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: AAOMgpeZujtKV5UphfYTvkXHrI6pq+9uhlqLxQmJ9u7AiqIytaotn8iG9EZiMBTQ3JTeRWkvO52gRA== X-Received: by 2002:adf:88e3:: with SMTP id g32-v6mr940914wrg.62.1531825014118; Tue, 17 Jul 2018 03:56:54 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id z3-v6sm1198901wru.27.2018.07.17.03.56.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 03:56:53 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 94E69123FFA; Tue, 17 Jul 2018 12:56:52 +0200 (CEST) From: osalvador@techadventures.net To: linux-mm@kvack.org Cc: pasha.tatashin@oracle.com, mhocko@suse.com, vbabka@suse.cz, akpm@linux-foundation.org, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [RFC PATCH 1/3] mm: Make free_area_init_core more readable by moving the ifdefs Date: Tue, 17 Jul 2018 12:56:20 +0200 Message-Id: <20180717105622.12410-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180717105622.12410-1-osalvador@techadventures.net> References: <20180717105622.12410-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 #ifdefery out of the function makes it easier to follow. Signed-off-by: Oscar Salvador --- 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));