From patchwork Tue Feb 11 22:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11377035 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 B8BED13A4 for ; Tue, 11 Feb 2020 22:46:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7BCB820714 for ; Tue, 11 Feb 2020 22:46:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UVWz0nCQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BCB820714 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 ABD1C6B034F; Tue, 11 Feb 2020 17:46:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A46646B0351; Tue, 11 Feb 2020 17:46:32 -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 936646B0352; Tue, 11 Feb 2020 17:46:32 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 75CDB6B034F for ; Tue, 11 Feb 2020 17:46:32 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2A7B8181AEF15 for ; Tue, 11 Feb 2020 22:46:32 +0000 (UTC) X-FDA: 76479331824.04.smell66_1be643021ba1e X-Spam-Summary: 2,0,0,17b5a073498aeb21,d41d8cd98f00b204,alexander.duyck@gmail.com,:kvm@vger.kernel.org:david@redhat.com:mst@redhat.com:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:yang.zhang.wz@gmail.com:pagupta@redhat.com:konrad.wilk@oracle.com:nitesh@redhat.com:riel@surriel.com:willy@infradead.org:lcapitulino@redhat.com:dave.hansen@intel.com:wei.w.wang@intel.com:aarcange@redhat.com:pbonzini@redhat.com:dan.j.williams@intel.com:mhocko@kernel.org:alexander.h.duyck@linux.intel.com:vbabka@suse.cz: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:13149 :13161:1 X-HE-Tag: smell66_1be643021ba1e X-Filterd-Recvd-Size: 6486 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Feb 2020 22:46:31 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id w15so14615992wru.4 for ; Tue, 11 Feb 2020 14:46:31 -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=lZRwr3nMHRBktKFSV5Mq10r8EzROhEGh/FsmDXkj5s8=; b=UVWz0nCQ/n8kmTOHKn86Gkoa3EPtzkq+4JVjUqPbfgBPDgmEJaph9S6hs2sBak3jnU g2QHDxMYKDlKkSe/LGHE+hp1vu1mfvaOPkerXAuf6C72Dr47sF0u92JEa1eTvqlf/1nl /ZuJoRL/qnqdmms5dhCbNXOo8e7yfbcSWt8vcwuLHyxwH3/1/CJGDEIOD9366lXX0Lfg FtwE7sZudGoQrMrouqgktpZkk1XT7cQSid7VKMOzEwu+BlwNzmZm7Yf3z+gDxkzkDSAy 4Sk8Ikw0hh+cWYrMZE8xG7DV6nGWdHW/dHl61rYYLxTWL1X95FfA86wCKOMpg4MqBLSf BXwg== 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=lZRwr3nMHRBktKFSV5Mq10r8EzROhEGh/FsmDXkj5s8=; b=EScpTorN/qRf6npIrzS6lqYL3CJYpZEdM/v4QimWbbY8bGL5pbby1whNkxdjJzC3wf H1ca2AgGXN5nVtWaL+PD8I/xd6m2ZwkNckIIXI+0/Kz1iOae2qytJNZneiLrgcPISRy9 vPFccxCRb6ks+O614MiR7ely/Dp3KrPxL1vN4S0TQ2R3SDwP8oIq/Im+z4PtBsCSMnAK MccnNOudzLDHtdoMXc8JquTZ3f5iVMISozimDe/q7GgU2OWmuBsgnIGiVrJpAgu9OA9v XEv1/uC5kraWbyR8HfT36m6hQV7z1qxwbZ7GeGEyh2jUO2SSPFpJ7fVLS8HGqfoa1gh8 3wrw== X-Gm-Message-State: APjAAAXbgXYnF7hPjpN+npQmSfCcagLFUTJKdIqilRwOvrz4IshAcsd7 KNw1FGmbsh2iXJIrN+pDvqw= X-Google-Smtp-Source: APXvYqw/X8oh8x+2FHV4J/a8al9ZHaabt10Yx+k/wL6WSpd9P7SvzsR/yXN4EvmjPBua26XidW2KBw== X-Received: by 2002:adf:b7c2:: with SMTP id t2mr11022446wre.269.1581461190406; Tue, 11 Feb 2020 14:46:30 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id 133sm5999318wmd.5.2020.02.11.14.46.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2020 14:46:29 -0800 (PST) Subject: [PATCH v17 3/9] mm: Add function __putback_isolated_page From: Alexander Duyck To: kvm@vger.kernel.org, david@redhat.com, mst@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, konrad.wilk@oracle.com, nitesh@redhat.com, riel@surriel.com, willy@infradead.org, lcapitulino@redhat.com, dave.hansen@intel.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, mhocko@kernel.org, alexander.h.duyck@linux.intel.com, vbabka@suse.cz, osalvador@suse.de Date: Tue, 11 Feb 2020 14:46:24 -0800 Message-ID: <20200211224624.29318.89287.stgit@localhost.localdomain> In-Reply-To: <20200211224416.29318.44077.stgit@localhost.localdomain> References: <20200211224416.29318.44077.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 Acked-by: Mel Gorman --- 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 de916aa06a27..b711fc0159d9 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 a9fd7c740c23..2c11a38d6e87 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -117,13 +117,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 *