From patchwork Fri Dec 14 23:03:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 10731787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C915F1399 for ; Fri, 14 Dec 2018 23:03:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D46528767 for ; Fri, 14 Dec 2018 23:03:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D6472878F; Fri, 14 Dec 2018 23:03:38 +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=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 E424428767 for ; Fri, 14 Dec 2018 23:03:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3289F8E021E; Fri, 14 Dec 2018 18:03:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E9A48E021D; Fri, 14 Dec 2018 18:03:15 -0500 (EST) 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 ED1228E021E; Fri, 14 Dec 2018 18:03:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 763588E021D for ; Fri, 14 Dec 2018 18:03:14 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id x15so3461414edd.2 for ; Fri, 14 Dec 2018 15:03:14 -0800 (PST) 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=DimBv5q7GksENALkOeOYb6i7ChULbIUvx43bviqjEa8=; b=raMEnosvfw/tRO7le3zIrgiegReKcpMf15thou0CLcDfrRYl5OLzYWJdPmMxNixUeq 0UtxLg+Pmyem33LOkctL596jChv7odFO3LV9plJ39cbvzmm4cF9FTmiMeA3mExILtn18 hayawnypdfoLCPspld3cT//Qgoc6aZOEdjvG0fthJtepNjavHoT57xWaSxdnvB+DT0Or Dd7HYNta1qf1g9jWvrRbMx33FEO+laAAk+HSeeRvXv++QoyE2ws0LAuCEMbVLBDfLmTh gmxUbV9WGgOvWnQ8M/pgkt35+GQoAq6GaypJujCC2wzS7JQ8FEiQ6wJtaAe1NU54z7a8 NUUg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.233 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Gm-Message-State: AA+aEWZPsniXo4ENi6TbrPP6zVTaV2eao9s2O4igT5190hvC8PvSiFuU JX49SzA37iWZzCjmaLVZ6n3VQgbk0IxGXX1eG3s4/d0xAVyj34KBs7A5zDyIYPykmlTcC+NAg7X rAiZJGfrFKaObdl8iy/DJXICKJYs1T6KXmnh6oOkP4SsNctsSa/kwwGwldDZtj+tJFA== X-Received: by 2002:a50:8bb5:: with SMTP id m50mr4362790edm.211.1544828593981; Fri, 14 Dec 2018 15:03:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/XoKkBhDRNHIyEXXB/5ltMsb+0xbKsAQPKVHQE9Ka/eai1n+uBjl4I/POPDWiVOTaoODigT X-Received: by 2002:a50:8bb5:: with SMTP id m50mr4362767edm.211.1544828593097; Fri, 14 Dec 2018 15:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544828593; cv=none; d=google.com; s=arc-20160816; b=Ax8UanoBEz9+LpF7xsiX3c9QMhYFoZbUdx98SlnMrY43vTrzPtARfLz8cmmEWtqnT3 wO0rDcgU+of8GuZwUzqiPI78hDF6jXynyJ6T2O6qdtFevSV5miOOR/pPWL6bnQlLsNZa q5kgGGTECnMX+kiFxRKgqsoqJFjBl74zdy9AdOxQR9ZirHij3k3iaAZpCKX54MIoM87t TFI7kMKMrq0xgveA5XSVLe+aX6z79JmJYuUdifEp6deOxChrqZxQm3UqVZXU5RMbYsYf lEBsVVTsNFz96WYAfR7JUmWxD8orqEtEcRGw08kTAAi41jlgRHpb7+7IfJE5qXNp84c9 K1iA== 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; bh=DimBv5q7GksENALkOeOYb6i7ChULbIUvx43bviqjEa8=; b=oS/oZPxVdMQcKAW0pXkjpyHvMtxdWszsjw16W8MJUKMoTpIiPN6Xou2wTxSw+efPT/ UU3FIDW5fTka4auUY7f5sTR+ouuS1W2wvGCvuAfAWMmFeJaTD684KO+2tRy+47wCEPnj 1F1lhQu0Dx949MhQOatA6XV3cwMQAypBj0vWoUpmr9pgQelDf/yLHKJbJ8wreOOSDkT+ QtKuUMuCQHqU8m7ICO0qNYfW1KKqpyvR/CpFVHE9gerfdf0GykjJY/tXfHBZsDDAPc4/ 44VeEfDOZAmxexOKh97lLslp7SvXozc/TSgRcJjN0PkRrADzQyEpefVCvRXWvUm9BCHR O0Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.233 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from outbound-smtp16.blacknight.com (outbound-smtp16.blacknight.com. [46.22.139.233]) by mx.google.com with ESMTPS id 89si2196684edr.235.2018.12.14.15.03.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 15:03:13 -0800 (PST) Received-SPF: pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.233 as permitted sender) client-ip=46.22.139.233; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.233 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp16.blacknight.com (Postfix) with ESMTPS id BF8111C1D19 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> 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 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 Acked-by: Vlastimil Babka --- 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);