Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp171640ybb; Tue, 7 Apr 2020 19:49:39 -0700 (PDT) X-Google-Smtp-Source: APiQypIPqqgGybSJ62Gp3s8X9qFW8LJa+VNlwA2NDeq5A0dNDN4Lq/KISXD0wTiOsgDWNVMfuTTd X-Received: by 2002:a9d:5190:: with SMTP id y16mr2631354otg.139.1586314179738; Tue, 07 Apr 2020 19:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586314179; cv=none; d=google.com; s=arc-20160816; b=U75bDwE6OgKy4v+kJt6k4xNRNpaew//5YMerjnc2JSZON5RdXH4tHEYGgYS6kERFZZ iabS1ZLOVlep0516FThSkuwd/HTG7pQdw0vEBIaGPIF+1kDOlxYpl/Bkk9A3+11zoKZU lhoJDNmvygJVIakLAMOoZ/um5/LjyGgdP2Awzt/b8A5RVcyeCsBtysy/q0T7fOplt5fL OzTPfMDX+L6foDKTBQm2S+CdQyY9ZZwcj/9kgGZG9T9qB+iwhfievNeYtd1dG78m6evl Sl2Fnu0wUQOJwLt6xsrdZxCuaC2TZRHIH8SgkoUB/ZiHCbvssnsj3Hnt6qMKaXmNrbMX dcyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZyQQtZLU5SDQeyZw8OwNdlYXeYXgHLQtXdRfXNahoSA=; b=ZE27JOEGfEclfgU8IE+WuGlIFXZDqJGyl/N0YsvXM/oaLqHrujJ55dG0y6BUbmpKhm YSCiLBAEgOob+zO2sN3r37jrGdeV2rFIWccznVzdOXYu/i+cItjpTY9aowo0ZIHbFQBW 55+J2+4z1yPPf8ulSgnA3g8eaveU3moFCsTk35Vn4++P5V/xHzMhUiAXNRGHEsipb1B3 1RTqUpaZIZK/pQlwyAO9DOQ1sDhL+CJHVnHwmBOxx7XUkbpwYjgP/rwhgP+8ABfj6ZX9 5lP6W6WZ9uEP3NRXx89YnOd7CTyu+VTKFZ4qIDmUTWPIQD9iM9ufTJq5PaxN6I4pgRi7 5SMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AtYYqL8k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y77si1030515ooa.40.2020.04.07.19.49.25; Tue, 07 Apr 2020 19:49:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AtYYqL8k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726467AbgDHCsi (ORCPT + 99 others); Tue, 7 Apr 2020 22:48:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49693 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726420AbgDHCsi (ORCPT ); Tue, 7 Apr 2020 22:48:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586314116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZyQQtZLU5SDQeyZw8OwNdlYXeYXgHLQtXdRfXNahoSA=; b=AtYYqL8kcZZa3D8BRcjl9chmNr9Ofr2133uaZkVl/X1HKAyruPMIPIH4lnpi3Oi1QhTCFv 8zf+/xtPWbtoDymBLnWxBAfommp4UUUEi/4CYAnSTdOO9cg2QuJ+Zqs+dYbOvYaJQA5e0e 3qwFFDAzSUF8qNdmRjvEzfwI4P4nn9Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-457-PN-p-qFFMKS4AMRQ-F6xCA-1; Tue, 07 Apr 2020 22:48:32 -0400 X-MC-Unique: PN-p-qFFMKS4AMRQ-F6xCA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 137D8801E66; Wed, 8 Apr 2020 02:48:31 +0000 (UTC) Received: from localhost (ovpn-13-77.pek2.redhat.com [10.72.13.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4508B119596; Wed, 8 Apr 2020 02:48:27 +0000 (UTC) Date: Wed, 8 Apr 2020 10:48:24 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Benjamin Herrenschmidt , Michal Hocko , Andrew Morton , Oscar Salvador , Wei Yang Subject: Re: [PATCH v1 2/2] mm/memory_hotplug: remove is_mem_section_removable() Message-ID: <20200408024824.GR2402@MiWiFi-R3L-srv> References: <20200407135416.24093-1-david@redhat.com> <20200407135416.24093-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200407135416.24093-3-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/07/20 at 03:54pm, David Hildenbrand wrote: > Fortunately, all users of is_mem_section_removable() are gone. Get rid of > it, including some now unnecessary functions. > > Cc: Michael Ellerman > Cc: Benjamin Herrenschmidt > Cc: Michal Hocko > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Baoquan He > Cc: Wei Yang > Signed-off-by: David Hildenbrand Assuming no issue to patch 1, this one looks good. Reviewed-by: Baoquan He > --- > include/linux/memory_hotplug.h | 7 ---- > mm/memory_hotplug.c | 75 ---------------------------------- > 2 files changed, 82 deletions(-) > > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 93d9ada74ddd..7dca9cd6076b 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -314,19 +314,12 @@ static inline void pgdat_resize_init(struct pglist_data *pgdat) {} > > #ifdef CONFIG_MEMORY_HOTREMOVE > > -extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages); > extern void try_offline_node(int nid); > extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); > extern int remove_memory(int nid, u64 start, u64 size); > extern void __remove_memory(int nid, u64 start, u64 size); > > #else > -static inline bool is_mem_section_removable(unsigned long pfn, > - unsigned long nr_pages) > -{ > - return false; > -} > - > static inline void try_offline_node(int nid) {} > > static inline int offline_pages(unsigned long start_pfn, unsigned long nr_pages) > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 47cf6036eb31..4d338d546d52 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1112,81 +1112,6 @@ int add_memory(int nid, u64 start, u64 size) > EXPORT_SYMBOL_GPL(add_memory); > > #ifdef CONFIG_MEMORY_HOTREMOVE > -/* > - * A free page on the buddy free lists (not the per-cpu lists) has PageBuddy > - * set and the size of the free page is given by page_order(). Using this, > - * the function determines if the pageblock contains only free pages. > - * Due to buddy contraints, a free page at least the size of a pageblock will > - * be located at the start of the pageblock > - */ > -static inline int pageblock_free(struct page *page) > -{ > - return PageBuddy(page) && page_order(page) >= pageblock_order; > -} > - > -/* Return the pfn of the start of the next active pageblock after a given pfn */ > -static unsigned long next_active_pageblock(unsigned long pfn) > -{ > - struct page *page = pfn_to_page(pfn); > - > - /* Ensure the starting page is pageblock-aligned */ > - BUG_ON(pfn & (pageblock_nr_pages - 1)); > - > - /* If the entire pageblock is free, move to the end of free page */ > - if (pageblock_free(page)) { > - int order; > - /* be careful. we don't have locks, page_order can be changed.*/ > - order = page_order(page); > - if ((order < MAX_ORDER) && (order >= pageblock_order)) > - return pfn + (1 << order); > - } > - > - return pfn + pageblock_nr_pages; > -} > - > -static bool is_pageblock_removable_nolock(unsigned long pfn) > -{ > - struct page *page = pfn_to_page(pfn); > - struct zone *zone; > - > - /* > - * 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, MIGRATE_MOVABLE, > - MEMORY_OFFLINE); > -} > - > -/* 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) > -{ > - unsigned long end_pfn, pfn; > - > - end_pfn = min(start_pfn + nr_pages, > - zone_end_pfn(page_zone(pfn_to_page(start_pfn)))); > - > - /* Check the starting page of each pageblock within the range */ > - for (pfn = start_pfn; pfn < end_pfn; pfn = next_active_pageblock(pfn)) { > - if (!is_pageblock_removable_nolock(pfn)) > - return false; > - cond_resched(); > - } > - > - /* All pageblocks in the memory block are likely to be hot-removable */ > - return true; > -} > - > /* > * Confirm all pages in a range [start, end) belong to the same zone (skipping > * memory holes). When true, return the zone. > -- > 2.25.1 >