From patchwork Wed May 9 18:59:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathieu Malaterre X-Patchwork-Id: 10390637 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 59A4B60353 for ; Wed, 9 May 2018 19:00:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48858285A6 for ; Wed, 9 May 2018 19:00:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B4D3285AA; Wed, 9 May 2018 19:00:16 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID 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 0746A285A8 for ; Wed, 9 May 2018 19:00:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4FEF6B0568; Wed, 9 May 2018 15:00:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9B1636B0569; Wed, 9 May 2018 15:00:13 -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 879BD6B056A; Wed, 9 May 2018 15:00:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 258D36B0568 for ; Wed, 9 May 2018 15:00:13 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id v2-v6so34853wmc.0 for ; Wed, 09 May 2018 12:00:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fAo588UllvcubBjP5YkspmAW/29hWWAs9nuDqTT8omA=; b=RynZkmvpOrxCC6pK9xNLR4yr0ta1sG0vcyvUoF5K6OhxCv981KfRHf2q7S9k2pC+y6 99+J4wjz/+7sOl6+fnmFHhKq/gZTvUph6sN7SYS1JTjDmxEGh7bgqSVIJw6F060WUZO4 lT1Ru5IqcmtM8pFLHt5DqGkt6gSUSt5lQvhxal/UAInomy9Rk5jna7sXBZLTP8ThEtpT kG6rlfBKgq2l/JV//ewqfqDOsHhCqnzM6q6JjsBkZ5wnMST4ClrexcQcsADYIrFR4QXz +Jx0fU9Stza40h4eKi4uOOsVW4f5vFVAOpWmF2l+xwsi1v4u8EIS6Dbh/4sMbnAC1GEO NBOw== X-Gm-Message-State: ALKqPwfTC0oVxD5jlXElaBZKDMk2iZbfJRRW+T4+wCe0nT/lwbyPHTIy wdNgSph+lpD1W5FJZ2uQo5VjurrK+h3so1TvQbjhftPXUbYXMjIWbg30BgHjp7OIpM5Jdd96UYM Tf5U3WvMs5CMYabHi+QLmadFAkaoA0LrkfT6AzR88RnKKBsGcN39R1m/8kSQr4RW0SqyXoZKhFg FeCaQMglYq7CMZlLezrJHefSaC5drsNDhk2YdC/vOpi8XZp1c3JzD0nExMbtoBoF2G3S+MZNOYx 5HHombZq+5cnHWUQFgc5wF3yQM0Ti6nGJz+C5Y7C7i7xISGgEN6asGvAA0eZHB4Z4JLPPmmSCih EzbvMFdHvBJgw6NymBRq0TSlIlWl2Rc4OnTUEyBWrlofZICBo3jxU5HMQkXkCnp0SXIRAUOqZg= = X-Received: by 2002:a1c:8c6:: with SMTP id 189-v6mr6284333wmi.19.1525892412423; Wed, 09 May 2018 12:00:12 -0700 (PDT) X-Received: by 2002:a1c:8c6:: with SMTP id 189-v6mr6284295wmi.19.1525892411233; Wed, 09 May 2018 12:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525892411; cv=none; d=google.com; s=arc-20160816; b=xMFs0zd+qqllH4AvoQP/FNG9kvaijMDJVE3KMBh79vMe/inWyPCUd90N+ZDu1LFLVh aCIXg1/jY5QJ1wOoN7zxhVedvaXjJzeEeDrlhhkAwztZh55LfRMhp7wjpeeoYyioAX2B t2lu2U4jcndwnbxR+B6C6qMMYWuBAAAylPqIJkVfzgmrFKrgF7KLkfzxgV4hB4Z8qj7N pX/iDZmlNkmdXrzOV3gb9zvlUx79pd/YwQPYMe1LroKPzirX81CeyWWTy+dGsDO3XdMz c5PmFjYBFIIS6uAae20Xd9RhqIt4pJAdxsgIdAN/4Vh9sK+qt8n/jyFMX7+7ofONKU5r O9gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature :arc-authentication-results; bh=fAo588UllvcubBjP5YkspmAW/29hWWAs9nuDqTT8omA=; b=F8mNP60RBg3OsMUryTjZ9G0xK8LWiv80nyGZS5jqVA6maCnQJHVLNRVB/guH7XEMX2 bviDKWBvDL8A7vY3x6eRrHgCKPOZNilaBT50AhuO/Pvj/z+rbNrwupCEwhztCkHdJPsY TqgLxnm8/9GG5+3eb1OQHjLWzVyf5/2zOPEBhB+pscub9kIrIMrC3scdCWBKcmV/y0tn bn1OvyjFBWV4MbZSirpvA+WbdC8mPxI2/mboofM5WNJtTH62O9cOXTaBVPfe2HQPM+j3 Vvgj300TjpuI/+688qUpSfr18RU14QXSTf5apV/SKXrF5yCzwQoS4RYTqSL47XbTAh0k JIkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b6Hwnl6I; spf=pass (google.com: domain of mathieu.malaterre@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mathieu.malaterre@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 s59-v6sor12906390wrc.52.2018.05.09.12.00.11 for (Google Transport Security); Wed, 09 May 2018 12:00:11 -0700 (PDT) Received-SPF: pass (google.com: domain of mathieu.malaterre@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b6Hwnl6I; spf=pass (google.com: domain of mathieu.malaterre@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mathieu.malaterre@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fAo588UllvcubBjP5YkspmAW/29hWWAs9nuDqTT8omA=; b=b6Hwnl6I8+cxT4i1DkBHtxBwvDT4Gg2HSOc1iih3+9WGB4+1LWY6O4jr9HAyHDMK5b v9yLRCe4QhKzXNIkX8HE0lZSAt4uyarqmAZBctbV4bERJ9cxQWWAjb9XCoag6SYTZBfa GQA9M/lUtL3LjorNn9RwQ9w8B3XGj1drVLQUVaZ+VNFZFBLjHNDpY9fyNFKfb1hZdLvI EZoNm7QTVPJpEebn4QZ7MfMPuOT4CVgiu9shaPXkvlsrdsPLBf35XHgShyxwTEUM3vys 8Msg/0d5cqhTdwuPkwQdmGmXMAelZQdOclU2SgyN+kkcODXkoC096p/ZZZsshDu0ll3v aWhg== X-Google-Smtp-Source: AB8JxZqknKJ33u/SG39PfFPMNo0cB0d8Qbe5BXNWGfBeKJJ/8BLjz7U4n7grRufwha54VhYAP574XQ== X-Received: by 2002:adf:ba4a:: with SMTP id t10-v6mr35204655wrg.219.1525892410780; Wed, 09 May 2018 12:00:10 -0700 (PDT) Received: from macbookpro.malat.net (bru31-1-78-225-226-121.fbx.proxad.net. [78.225.226.121]) by smtp.gmail.com with ESMTPSA id a14-v6sm45031522wra.84.2018.05.09.12.00.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 12:00:09 -0700 (PDT) Received: by macbookpro.malat.net (Postfix, from userid 1000) id CD3B110C04F8; Wed, 9 May 2018 21:00:08 +0200 (CEST) From: Mathieu Malaterre To: Michal Hocko Cc: Mathieu Malaterre , Andrew Morton , Michal Hocko , Vlastimil Babka , Dan Williams , Joonsoo Kim , Pavel Tatashin , Greg Kroah-Hartman , Reza Arbab , Thomas Gleixner , Mel Gorman , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] =?UTF-8?q?mm:=20move=20function=20=E2=80=98is=5Fpagebl?= =?UTF-8?q?ock=5Fremovable=5Fnolock=E2=80=99=20to=20mm/memory=5Fhotplug.c?= Date: Wed, 9 May 2018 20:59:57 +0200 Message-Id: <20180509190001.24789-1-malat@debian.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180505201107.21070-1-malat@debian.org> References: <20180505201107.21070-1-malat@debian.org> MIME-Version: 1.0 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 Function ‘is_pageblock_removable_nolock’ is not used outside of mm/memory_hotplug.c. Move it next to unique caller: ‘is_mem_section_removable’ and make it static. Remove prototype in . Silence gcc warning (W=1): mm/page_alloc.c:7704:6: warning: no previous prototype for ‘is_pageblock_removable_nolock’ [-Wmissing-prototypes] Suggested-by: Michal Hocko Signed-off-by: Mathieu Malaterre Acked-by: Michal Hocko --- v2: this function can be made static, make it so include/linux/memory_hotplug.h | 1 - mm/memory_hotplug.c | 23 +++++++++++++++++++++++ mm/page_alloc.c | 23 ----------------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index e0e49b5b1ee1..9566d551a41b 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -107,7 +107,6 @@ static inline bool movable_node_is_enabled(void) } #ifdef CONFIG_MEMORY_HOTREMOVE -extern bool is_pageblock_removable_nolock(struct page *page); extern int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap); extern int __remove_pages(struct zone *zone, unsigned long start_pfn, diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f74826cdceea..9342e120518a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1237,6 +1237,29 @@ static struct page *next_active_pageblock(struct page *page) return page + pageblock_nr_pages; } +static bool is_pageblock_removable_nolock(struct page *page) +{ + struct zone *zone; + unsigned long pfn; + + /* + * We have to be careful here because we are iterating over memory + * sections which are not zone aware so we might end up outside of + * the zone but still within the section. + * We have to take care about the node as well. If the node is offline + * its NODE_DATA will be NULL - see page_zone. + */ + if (!node_online(page_to_nid(page))) + return false; + + zone = page_zone(page); + pfn = page_to_pfn(page); + if (!zone_spans_pfn(zone, pfn)) + return false; + + return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, true); +} + /* Checks if this range of memory is likely to be hot-removable. */ bool is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 905db9d7962f..52731601ca5a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7701,29 +7701,6 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, return false; } -bool is_pageblock_removable_nolock(struct page *page) -{ - struct zone *zone; - unsigned long pfn; - - /* - * We have to be careful here because we are iterating over memory - * sections which are not zone aware so we might end up outside of - * the zone but still within the section. - * We have to take care about the node as well. If the node is offline - * its NODE_DATA will be NULL - see page_zone. - */ - if (!node_online(page_to_nid(page))) - return false; - - zone = page_zone(page); - pfn = page_to_pfn(page); - if (!zone_spans_pfn(zone, pfn)) - return false; - - return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, true); -} - #if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA) static unsigned long pfn_max_align_down(unsigned long pfn)