Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp89299imu; Fri, 14 Dec 2018 15:04:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/WmaUV7CgrxiVskHqo4rxpvQG5gIy6QOXNXLV7OdU3KvSLXMwXV+F5vm+B5u0PPnXNgKDt1 X-Received: by 2002:a63:111c:: with SMTP id g28mr4333661pgl.85.1544828677036; Fri, 14 Dec 2018 15:04:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544828677; cv=none; d=google.com; s=arc-20160816; b=s1Pi676Jiwxt+YIoHjL5Zt54XxZAsFbvHSAO5pUSdKmQP5ANlHfT1aWqzD0UEmePIA ARDJ9LVung0sV+zrvr7lvNvZXIg2ZLA6y1Fm+PpdichG80lCQFjmXgmcfCYTURL10B4a maM55yh5f83YWOcSIKmaCIdRtMVmaTsf4eZPuDiFvRCzkesqxYjq20CGCguO/gw4lNf/ OK8h0ajMBxYeWLsLOYriFz2aU76TmrhY1Le9V5ZMTlWHel6uWb+0m7ab6VXl5fqbHMqp mdKJRgn9BPcDNYswJoJwIYZidov8Uae0fCIkpieKZ/5aW5qFO81E3fx4bnDEmpzO/m9+ zPfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=DimBv5q7GksENALkOeOYb6i7ChULbIUvx43bviqjEa8=; b=vHtfbPX6j1+UNum2BvSxl6TnEiUVsi5WiPhUlSfcFwel4KxxghQXoAB5GCgJI75bDZ MnzsZ4G7aRnFhHRaZDi65wBJzj5Go8UY9OotFz66veE9c/WOQFaxvmXxcYHYwDNZ6tkt K/Ssygbl44hdaShyVtVMtEpIA89DP7uKORBQ5UOcp9p8WGNlK8t5XQNggz6hBwbgmX4/ EOoBkQXtesnq2YOlKAJ8q+UW2rcSn0vlRYUfVbpooUr3p+SLwLSwA0TXBOrpW8FmZGDz riFUrGCmZy7594FO3aA04VltA/Jrt68U6AxmLoyeb6JDx7vBlOetBVEbUz8NocU7PbT2 FF8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si5598650pfq.19.2018.12.14.15.04.22; Fri, 14 Dec 2018 15:04:37 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730788AbeLNXDU (ORCPT + 99 others); Fri, 14 Dec 2018 18:03:20 -0500 Received: from outbound-smtp10.blacknight.com ([46.22.139.15]:58917 "EHLO outbound-smtp10.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730521AbeLNXDO (ORCPT ); Fri, 14 Dec 2018 18:03:14 -0500 Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp10.blacknight.com (Postfix) with ESMTPS id C7E2D1C209F for ; Fri, 14 Dec 2018 23:03:12 +0000 (GMT) Received: (qmail 31294 invoked from network); 14 Dec 2018 23:03:12 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.245.71]) by 81.17.254.9 with ESMTPA; 14 Dec 2018 23:03:12 -0000 From: Mel Gorman To: Linux-MM Cc: David Rientjes , Andrea Arcangeli , Linus Torvalds , Michal Hocko , ying.huang@intel.com, kirill@shutemov.name, Andrew Morton , Linux List Kernel Mailing , Mel Gorman Subject: [PATCH 08/14] mm, compaction: Use the page allocator bulk-free helper for lists of pages Date: Fri, 14 Dec 2018 23:03:04 +0000 Message-Id: <20181214230310.572-9-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181214230310.572-1-mgorman@techsingularity.net> References: <20181214230310.572-1-mgorman@techsingularity.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org release_pages() is a simpler version of free_unref_page_list() but it tracks the highest PFN for caching the restart point of the compaction free scanner. This patch optionally tracks the highest PFN in the core helper and converts compaction to use it. Signed-off-by: Mel Gorman --- include/linux/gfp.h | 7 ++++++- mm/compaction.c | 12 +++--------- mm/page_alloc.c | 10 +++++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 0705164f928c..ed9a95b63374 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -543,7 +543,12 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask); extern void __free_pages(struct page *page, unsigned int order); extern void free_pages(unsigned long addr, unsigned int order); extern void free_unref_page(struct page *page); -extern void free_unref_page_list(struct list_head *list); +extern void __free_page_list(struct list_head *list, bool dropref, unsigned long *highest_pfn); + +static inline void free_unref_page_list(struct list_head *list) +{ + return __free_page_list(list, false, NULL); +} struct page_frag_cache; extern void __page_frag_cache_drain(struct page *page, unsigned int count); diff --git a/mm/compaction.c b/mm/compaction.c index 4f51435c645a..8ba9b3b479e3 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -52,16 +52,10 @@ static inline void count_compact_events(enum vm_event_item item, long delta) static unsigned long release_freepages(struct list_head *freelist) { - struct page *page, *next; - unsigned long high_pfn = 0; + unsigned long high_pfn; - list_for_each_entry_safe(page, next, freelist, lru) { - unsigned long pfn = page_to_pfn(page); - list_del(&page->lru); - __free_page(page); - if (pfn > high_pfn) - high_pfn = pfn; - } + __free_page_list(freelist, true, &high_pfn); + INIT_LIST_HEAD(freelist); return high_pfn; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a6e7bfd18cde..80535cd55a92 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2961,18 +2961,26 @@ void free_unref_page(struct page *page) /* * Free a list of 0-order pages */ -void free_unref_page_list(struct list_head *list) +void __free_page_list(struct list_head *list, bool dropref, + unsigned long *highest_pfn) { struct page *page, *next; unsigned long flags, pfn; int batch_count = 0; + if (highest_pfn) + *highest_pfn = 0; + /* Prepare pages for freeing */ list_for_each_entry_safe(page, next, list, lru) { + if (dropref) + WARN_ON_ONCE(!put_page_testzero(page)); pfn = page_to_pfn(page); if (!free_unref_page_prepare(page, pfn)) list_del(&page->lru); set_page_private(page, pfn); + if (highest_pfn && pfn > *highest_pfn) + *highest_pfn = pfn; } local_irq_save(flags); -- 2.16.4