From patchwork Mon Nov 25 21:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13885269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 932FDD59D71 for ; Mon, 25 Nov 2024 21:02:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2B316B0098; Mon, 25 Nov 2024 16:01:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C850E6B0093; Mon, 25 Nov 2024 16:01:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C4F36B0092; Mon, 25 Nov 2024 16:01:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 511136B0093 for ; Mon, 25 Nov 2024 16:01:55 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F950120EAC for ; Mon, 25 Nov 2024 21:01:55 +0000 (UTC) X-FDA: 82825839180.19.42C441D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 4043720017 for ; Mon, 25 Nov 2024 21:01:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RkA4VhMk; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732568509; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KITuz3gfgFofNiX2ze/7jfnfQhEBGdSEA1sxkx4u09Q=; b=Ri7aM7rUXAwO8b2otjV5smSIn5cxlGLWoQrX3MlxWmQ7vmj3ShNpNVqDvGkRpvWfXRMjO+ eDRpTPkS5JgU7elot61xsgnCHnIh7WgukDQ4yX9jLqgXBSjSIrzKsevQVCwXm8cmUzLbS/ FybACeSltypfvU4Gw/bGWbczuKXcAdY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RkA4VhMk; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732568509; a=rsa-sha256; cv=none; b=d3ha8KXqs5TAKPw2sapUcgLd7ffwhSLYbZX46Psb4B+5+rXEKT6mq4UNvokMZby7kaj0qr qMfEVprsK3RjA6tO0/skk5+09t/3JOggoiacSGinFLsyGrojKMv3GMokdLW+yh14Jc+48T OMimDraxeQMUvrT0x9rp2TvpLywLNzA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KITuz3gfgFofNiX2ze/7jfnfQhEBGdSEA1sxkx4u09Q=; b=RkA4VhMkpAa6kBjjky9CQYvmNi YfYrpEp9M7YHpEYoAJDyQ1V6oyQs58tdxeULiFAvKTUc+HYYPAiRWrWiGVe+ZsnFfkxWDegDN3O8Q h+WpE8TcOmW0DrfAjLTpn39+JupH+9D3IV/I2FRosY6ZOXbhSL0X39c64rnzSFiaz7e3esjXUU3Ye zbWiexfuWIjPETDpbLSKhP4VCzyBnC3SfeRm7QttCBkMvzF7PwRafKa8blKbodj9WDQPiWTykfP4P 7SMy1bjEl33P5P+Q+4N1B4whSar4Z4h6hMOUcuz3swtQRZAf/NZpgG6p8wLt3mSTStZ22dWnagXVR YraJgY5w==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFgDP-0000000CUE8-2PsB; Mon, 25 Nov 2024 21:01:51 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, David Hildenbrand Subject: [PATCH v3 08/15] mm/page_alloc: Move set_page_refcounted() to callers of __alloc_pages_may_oom() Date: Mon, 25 Nov 2024 21:01:40 +0000 Message-ID: <20241125210149.2976098-9-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241125210149.2976098-1-willy@infradead.org> References: <20241125210149.2976098-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4043720017 X-Stat-Signature: ektq9n8fe7k94y135pa4yes684occ3c5 X-Rspam-User: X-HE-Tag: 1732568507-866647 X-HE-Meta: U2FsdGVkX1+hybFa8cRuG/MwLif9PgwhZpKCXswu1rM/t7PZLqYZvq6YxULrdtUp2LTS7lvZJ4/b85fjX9teMyxJREwz+vVZri6r5kaYXHmFDEZlEycpGU2NirlhXbst9hzmanaj+9KcRpo3z7YhX46oWpwFR3NwK3cyVeocdVY9fzHKv/abN//CaiSapXVb30CREEDSxejvlunDTkPIcmKv54lP76uHesQb8E4iYgXoDnTxupJNefM8f45xae6cHvTKfD4D9OREPeG5oExyv3rILVCa5PBri7RD5T2kHpa0qPH3yx70U96U/P1xezqwccTic+bSL81pC4Ml92u/vjTIc8Sf30ogr5vZc53dQcyQSQbp23wlzTzFGRuVjhNzARZTQJwrrP8Os5es9wqEnYT8GQNbfvJ9vV2WkuDCskNcoLLMrhSyU0iA/Cd9Oy+o/tAbWuDheMh8JPB5mLKxPnAvv9M1jq6dTWTt+Q2i/6ZsfZbunqXQCsYzUuFXm9hvenqZYZ6UhcWyfe1nk783U6yL7VhU2x7iYM08ODWE0ygb0wOApuxYEaF+ZGalKDOB505ECHW/6CIpfXxHnWTolZCiIT6DNX9QcpPhRxEBz0Xsn1sAbSrbYMqWLLxwup2grrg+gZ9TBsnASxy56VxU7lresnYUTfv95DlDJuL2tchLVqGPsHEII4323Wl3nknBO4UzN1rW3OJOk8lUNr4RA7TgOtGK0FeDnF+FkaIyCosAxitfyYcw6nC5Z9gI8jlKuHz64lDDZ+6+C4gOupNG/8iFZ67uDnjLQWg6fIwJxx3UYMFSN838/5ervJBIDrh4XzjKGpzCpWqvQMjwuxQznnGGbl/8OmX+ip02XDiipSbpxU0oAKPLTytcSu08YFLOVkn1ScAp9vRZ5EZClWEBWbpMi8zS5majrfKMklxyV0zV3mFpvMxasAfrLjPUqtXxq2y+bw8NzVWGk88V+jl H4uV7Wyr RNUkCAssfU8w9NxTJj073xeiSF2Us6iDVANFQe9YmtR38A6SFDCJER3io45NAxrDMdSDsI258251oFcHSgoHHCsvDZWotgqQjk9wVr2kMRoyR2BbKAJ7qx6tC60RBGsq4Gy9qCgvnzcZC5wu5MxCFO6y7/3Lq9xW1Ra3tSAGiEJ2YpqIqk7iFdTeNkm9HtMDRxUyvJyAf5jQjgKla8PxLEXl+KxHKoNGEmmeKIe07luxta74zZPC/yfh/fctXgu7h0aRdQ6hpQnBkZOAtHjhhAUD+yVVnCbHcnBF1 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: List-Subscribe: List-Unsubscribe: In preparation for allocating frozen pages, stop initialising the page refcount in __alloc_pages_may_oom(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/page_alloc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c9e5c69f0cb9..514994cd67b8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3638,10 +3638,8 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, page = get_page_from_freelist((gfp_mask | __GFP_HARDWALL) & ~__GFP_DIRECT_RECLAIM, order, ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac); - if (page) { - set_page_refcounted(page); + if (page) goto out; - } /* Coredumps can quickly deplete all memory reserves */ if (current->flags & PF_DUMPCORE) @@ -3686,8 +3684,6 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, if (gfp_mask & __GFP_NOFAIL) page = __alloc_pages_cpuset_fallback(gfp_mask, order, ALLOC_NO_WATERMARKS, ac); - if (page) - set_page_refcounted(page); } out: mutex_unlock(&oom_lock); @@ -4471,8 +4467,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, /* Reclaim has failed us, start killing things */ page = __alloc_pages_may_oom(gfp_mask, order, ac, &did_some_progress); - if (page) + if (page) { + set_page_refcounted(page); goto got_pg; + } /* Avoid allocations with no watermarks from looping endlessly */ if (tsk_is_oom_victim(current) &&