Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4403876ybb; Tue, 7 Apr 2020 06:55:27 -0700 (PDT) X-Google-Smtp-Source: APiQypIi7b0XazdZcgfOJcZVSmpXOEP9qG1tdceL/IP/JsM5jmz5IRfr7esd+trvKyK2879WupWO X-Received: by 2002:aca:b8c5:: with SMTP id i188mr1694919oif.2.1586267727440; Tue, 07 Apr 2020 06:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586267727; cv=none; d=google.com; s=arc-20160816; b=L4nDq/fBgCR0GJpyEdVd/yBskc94AR5laGR6Y0uJSD9VwxhmwlCSZiaBzFilbtja4V zUtc7YLWmD1oW6W30QSf1AJyyG6+MUal9RWXb4rQwqy/csJglMgxJzdVj3RTsSpUWp4A BBfWIjVF0/FXzlAQtAbphXoeraAaHKgovrTP+ZzaPdIghHzsGV7n9ieHxMqixTKdyiQ8 kLiE7Km0+tFEpSOgAkzu3qEciIijpWlCIW7NKtCg38ou0G2pJy0e43L08D2a3gjB976B t869BzowvoL+YC+poH6uC5GZawjx2VpcE1VuMBGMMSWKmnXQGUYOj2rnSUkyynMfU76a 3PRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zia2yEK0ULLs2OuWDK7UiIqrQbcauP8f06twBGLL674=; b=AIAzPX24GIKqe3VCgRjbZ38CsiMLnVe9a0xZaCdOT1tBtbsfowVqsgixP5uHWAsTuU 15oZSJ+2i6kLYolzdB+GHqE+2RG8u4Td6VJQBZkIYWFmlFs6QmP5O2KewPe4q79YjMqf wQ/VOMS/IxDdKZMIrEOl9CeA6U4jvsB826S/0btQ18VhojwCui+ZfbZrSt+i//OI1dm8 RXCx6VDmLhGTNtbZWAqxEoJQ+xTcGIIe4rNjszG8RXLj5Ch4cpoj2IwEqWcNWiGQ1j1M rhVJCT7+K/663bwDwzHivKnYlT9H9nQIrl1qvm4xnkEi+qpUCrVWFL87Z5UvpLvPvNAe Njmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZZCJDahz; 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 l6si1207926otf.248.2020.04.07.06.55.14; Tue, 07 Apr 2020 06:55:27 -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=ZZCJDahz; 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 S1728979AbgDGNyh (ORCPT + 99 others); Tue, 7 Apr 2020 09:54:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23960 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728966AbgDGNyg (ORCPT ); Tue, 7 Apr 2020 09:54:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586267674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zia2yEK0ULLs2OuWDK7UiIqrQbcauP8f06twBGLL674=; b=ZZCJDahzTbojWHq9UpOF/eHGzunXZ4uXg3Wddwr2MHzCLL1Dzu1fjy1ne7uYwBy3xryNVN LO8AzEjHvk1RipcCHvkifpjHy++wa5oRTciYfzppq8Um7//6w1W/RpLd7d++D3xZHmEUbf 24dVg+/0iYNGXsVE8UetdAc1kp1GTHA= 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-358-K2B4E7D6O9uQfRouXt9wUA-1; Tue, 07 Apr 2020 09:54:30 -0400 X-MC-Unique: K2B4E7D6O9uQfRouXt9wUA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F18019057A6; Tue, 7 Apr 2020 13:54:29 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-167.ams2.redhat.com [10.36.114.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB0847E303; Tue, 7 Apr 2020 13:54:26 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, David Hildenbrand , Michael Ellerman , Benjamin Herrenschmidt , Michal Hocko , Andrew Morton , Oscar Salvador , Baoquan He , Wei Yang Subject: [PATCH v1 2/2] mm/memory_hotplug: remove is_mem_section_removable() Date: Tue, 7 Apr 2020 15:54:16 +0200 Message-Id: <20200407135416.24093-3-david@redhat.com> In-Reply-To: <20200407135416.24093-1-david@redhat.com> References: <20200407135416.24093-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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_hotplu= g.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) {} =20 #ifdef CONFIG_MEMORY_HOTREMOVE =20 -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); =20 #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) {} =20 static inline int offline_pages(unsigned long start_pfn, unsigned long n= r_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); =20 #ifdef CONFIG_MEMORY_HOTREMOVE -/* - * A free page on the buddy free lists (not the per-cpu lists) has PageB= uddy - * set and the size of the free page is given by page_order(). Using thi= s, - * 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) >=3D pageblock_order; -} - -/* Return the pfn of the start of the next active pageblock after a give= n pfn */ -static unsigned long next_active_pageblock(unsigned long pfn) -{ - struct page *page =3D 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 =3D page_order(page); - if ((order < MAX_ORDER) && (order >=3D pageblock_order)) - return pfn + (1 << order); - } - - return pfn + pageblock_nr_pages; -} - -static bool is_pageblock_removable_nolock(unsigned long pfn) -{ - struct page *page =3D 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 =3D page_zone(page); - pfn =3D 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 =3D 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 =3D start_pfn; pfn < end_pfn; pfn =3D next_active_pageblock(pf= n)) { - 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 (sk= ipping * memory holes). When true, return the zone. --=20 2.25.1