From patchwork Wed Jan 22 17:43:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11346173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFF46139A for ; Wed, 22 Jan 2020 17:43:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A05A624125 for ; Wed, 22 Jan 2020 17:43:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Nml0JO94" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A05A624125 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D4E466B000C; Wed, 22 Jan 2020 12:43:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD6A46B000D; Wed, 22 Jan 2020 12:43:31 -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 C13D16B0010; Wed, 22 Jan 2020 12:43:31 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id ABE356B000C for ; Wed, 22 Jan 2020 12:43:31 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 4BCA42C34 for ; Wed, 22 Jan 2020 17:43:31 +0000 (UTC) X-FDA: 76405992222.06.van29_18d5cb3ab72c X-Spam-Summary: 2,0,0,be4cd99178cfafc6,d41d8cd98f00b204,alexander.duyck@gmail.com,:kvm@vger.kernel.org:mst@redhat.com:linux-kernel@vger.kernel.org:willy@infradead.org:mhocko@kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:vbabka@suse.cz:yang.zhang.wz@gmail.com:nitesh@redhat.com:konrad.wilk@oracle.com:david@redhat.com:pagupta@redhat.com:riel@surriel.com:lcapitulino@redhat.com:dave.hansen@intel.com:wei.w.wang@intel.com:aarcange@redhat.com:pbonzini@redhat.com:dan.j.williams@intel.com:alexander.h.duyck@linux.intel.com:osalvador@suse.de,RULES_HIT:41:152:355:379:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:2731:2895:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4117:4250:4321:4385:4605:5007:6261:6653:6742:7576:7875:9010:9413:10004:10400:11026:11658:11914:12043:12048:12114:12297:12438:12517:12519:12555:12679:12760:12986 :13149:1 X-HE-Tag: van29_18d5cb3ab72c X-Filterd-Recvd-Size: 6485 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Jan 2020 17:43:30 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id n96so215200pjc.3 for ; Wed, 22 Jan 2020 09:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=eI6p6MEInjZCHKWZd3a6CL3jD4YUNkjKzQ5d3wA61zk=; b=Nml0JO94Yi7Z0V055K0HCI/PFEbCDgvmVM0UPodbYoFdF0WjI1G9yHic9yQqbq5KBd 0/dURuFDtZdIcyXc0B6anVn1fdbOVsyOfxZYdAVjsikeGrO/ER2gCCcAfDBzB0Wq1wYF G7fzREH7BTHCFFC5KxCyo+2n1wLscSIymTWVc1TMdSQ5Ac/SBJctRG65ags3ZF3bw3GS /RuxC8GDHu+GJhi2hSlyyR73cJ/7atG/So0h9QSxLrJKYeL/AYZDgSGEtL7CiKGG1k61 KGp2P9adQGtCGpR7N27z+bbXl25u3YNVjK9Zg7tvykuns2MYAXrj3hc9tOj5qkb1xIUq e1hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=eI6p6MEInjZCHKWZd3a6CL3jD4YUNkjKzQ5d3wA61zk=; b=KeE2NC1PmMQ5fPZqB9zeDnUQuEL15p7Raa6crwc9lLgUbP21im7Y6JqSqerJ9chM5o tgzREDNY8CfBMs3t71f/lfCWTMaIhDN/yG3V2bX0GROEIX82x4OoIbUnQYguRKNcc2VC ApS59j8uqpDN2BFCuH5iyyy4VR4PRhMQgEvr7pZqsrBfzvw1cCw1aMhU2kNKtymNtnF+ o5tsSFa76q/R9qwOrySGcRn9iNN3+2Yf4dqUS61o0GYjHK44Lwyh892VzT4U3AHBniVW hE2oApRDn4FdlOXwtNR1d937nfpgzsdsiNufs7IHJ1Y3E+RtyKLcSZM2uUbm67xjdJZo 1+kQ== X-Gm-Message-State: APjAAAX5sDaCnWpdsXS6JGZJun8lPbsU8tY7Y5COT6iIUyXom61TrESg IkbnMtGfL05NIul1GMtJKSA= X-Google-Smtp-Source: APXvYqyOujo9zTybEbWxtLbC29f+GQuJ7Og/W6UU8xSrKvJEJCExGn59VDy0J2wdvlHkDzyYXKQdwg== X-Received: by 2002:a17:90a:d807:: with SMTP id a7mr4469723pjv.15.1579715009674; Wed, 22 Jan 2020 09:43:29 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id c22sm47286700pfo.50.2020.01.22.09.43.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jan 2020 09:43:29 -0800 (PST) Subject: [PATCH v16.1 3/9] mm: Add function __putback_isolated_page From: Alexander Duyck To: kvm@vger.kernel.org, mst@redhat.com, linux-kernel@vger.kernel.org, willy@infradead.org, mhocko@kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, vbabka@suse.cz Cc: yang.zhang.wz@gmail.com, nitesh@redhat.com, konrad.wilk@oracle.com, david@redhat.com, pagupta@redhat.com, riel@surriel.com, lcapitulino@redhat.com, dave.hansen@intel.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com, osalvador@suse.de Date: Wed, 22 Jan 2020 09:43:28 -0800 Message-ID: <20200122174328.6142.13364.stgit@localhost.localdomain> In-Reply-To: <20200122173040.6142.39116.stgit@localhost.localdomain> References: <20200122173040.6142.39116.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty 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: From: Alexander Duyck There are cases where we would benefit from avoiding having to go through the allocation and free cycle to return an isolated page. Examples for this might include page poisoning in which we isolate a page and then put it back in the free list without ever having actually allocated it. This will enable us to also avoid notifiers for the future free page reporting which will need to avoid retriggering page reporting when returning pages that have been reported on. Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck --- mm/internal.h | 2 ++ mm/page_alloc.c | 19 +++++++++++++++++++ mm/page_isolation.c | 6 ++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 3cf20ab3ca01..7b108222e5f4 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -157,6 +157,8 @@ static inline struct page *pageblock_pfn_to_page(unsigned long start_pfn, } extern int __isolate_free_page(struct page *page, unsigned int order); +extern void __putback_isolated_page(struct page *page, unsigned int order, + int mt); extern void memblock_free_pages(struct page *page, unsigned long pfn, unsigned int order); extern void __free_pages_core(struct page *page, unsigned int order); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b1cc0dab1c29..f65e398eed89 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3217,6 +3217,25 @@ int __isolate_free_page(struct page *page, unsigned int order) return 1UL << order; } +/** + * __putback_isolated_page - Return a now-isolated page back where we got it + * @page: Page that was isolated + * @order: Order of the isolated page + * + * This function is meant to return a page pulled from the free lists via + * __isolate_free_page back to the free lists they were pulled from. + */ +void __putback_isolated_page(struct page *page, unsigned int order, int mt) +{ + struct zone *zone = page_zone(page); + + /* zone lock should be held when this function is called */ + lockdep_assert_held(&zone->lock); + + /* Return isolated page to tail of freelist. */ + __free_one_page(page, page_to_pfn(page), zone, order, mt); +} + /* * Update NUMA hit/miss statistics * diff --git a/mm/page_isolation.c b/mm/page_isolation.c index e70586523ca3..28d5ef1f85ef 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -113,13 +113,11 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype) __mod_zone_freepage_state(zone, nr_pages, migratetype); } set_pageblock_migratetype(page, migratetype); + if (isolated_page) + __putback_isolated_page(page, order, migratetype); zone->nr_isolate_pageblock--; out: spin_unlock_irqrestore(&zone->lock, flags); - if (isolated_page) { - post_alloc_hook(page, order, __GFP_MOVABLE); - __free_pages(page, order); - } } static inline struct page *