From patchwork Mon Nov 25 21:01:36 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: 13885334 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 B1E49D59D7F for ; Mon, 25 Nov 2024 22:38:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A5F96B0088; Mon, 25 Nov 2024 17:38:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 355B66B0089; Mon, 25 Nov 2024 17:38:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 244866B008C; Mon, 25 Nov 2024 17:38:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0522A6B0088 for ; Mon, 25 Nov 2024 17:38:20 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 778E3140AF3 for ; Mon, 25 Nov 2024 22:38:20 +0000 (UTC) X-FDA: 82826082276.04.9E93833 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id B1B9C80002 for ; Mon, 25 Nov 2024 22:38:11 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BOxJlVST; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732574297; 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=/aWUS9CVIst+IEIjbMLK6rFw3y2dIRzWc3iSEL/kmuI=; b=Tx3Dfs3/qFYBIv+aOSX0cwN8jw/NmStlzZX2yr3EJKIz9MlxxomteUvROVf/qmNvAAWRu7 08SWJcH27DmTPBiiM6cNa8vH6wJ1dATWG32mWXml5wlxOwluIpwxD0jmVRinsnhYI2WAnK qc+SkW1dMRIQt6KYPi4jkIQD4FTjaFs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BOxJlVST; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732574297; a=rsa-sha256; cv=none; b=mBLVGv/Oc8GUYLY100DN14pDrcfyjCJ4VcolphDLWtQYc5HUHcft7YQ51foSMqnVGHRb3r ZAkKuhzisBuOo0yU9iuSTe8Oyqb6VcsMSRjI8olI5otzigtZaql0s33C0/2ihcro68wOyV x2I9h+Sdy7zs5FO9ysr5lhZzY1Q3TUs= 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=/aWUS9CVIst+IEIjbMLK6rFw3y2dIRzWc3iSEL/kmuI=; b=BOxJlVSTdII20sdq6hVAWV9/Y+ P4Iy5I+/K+aGTBgVLqpJd/9j35J4bKn9zHaMHVCNM/fndhhJZcxvSeDxFTHdBJbELI2hUIJF/dB9z Hep1IQZ1iD+TAlELeAHXJMjTNvYlHZ9N3vDV7jjNfZAOgwRKqOKYaGQRq8sWO3bZQC9uMjPpMpWSO LpBspn1IedxSfiXpk86Uee0Z/P8n5MGAP+fbpr8/PryNLp63QjnUMeQV25zNSaAXo4BafvEP/hig1 GwqKfr0UIEkROmVRHmtyd2vcDq3aNE5alj7MdjAb4dEEhnw9K3q9a8Yo3mbBF8aW8Wdsaqc4og1Sb jLmK01Gg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFgDP-0000000CUDz-0ryq; 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 , Miaohe Lin Subject: [PATCH v3 04/15] mm/page_alloc: Move set_page_refcounted() to callers of post_alloc_hook() Date: Mon, 25 Nov 2024 21:01:36 +0000 Message-ID: <20241125210149.2976098-5-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B1B9C80002 X-Stat-Signature: ga33g1du4jdaqmfxt113hu6dgw1foa84 X-HE-Tag: 1732574291-170614 X-HE-Meta: U2FsdGVkX1+SFSwqovZZHsAs8ByBjprSQhHGhs/CQQL9MWR+9+1TKMj8EAQU3aLl/kIQkY8HgHLQGtz5PeuJexKA8ToHTQdISrYQIgsmitPmQz2VeOSGo7Mne2pdaAvgrnMQjaCTPxfis70dQJcKf+QFZLI5XsCCGN/2R3hiyAWe00VeXJNcibyPUvEl9z7Z4av5OsP1OxVNOIR4D59Eql8fNSvGlF7AmL8Ee9gZUCqFv0WQAS2ids9vd5iQMj9e35HHNeAC0GUF4mhqYaH/pEQrSxudB1g3DubhgUmP4R28Qg1H4rotUfPJj+UsrTBalcoF9vNzYY9W034RRG7vZDAEQv6fmDj73jZ9rOgdPEV8ttn3yyNR4l8p1l/ZUhD6XD2DHzUk2Wyp6cmst9G6gXLoYsVpyDAU9BeVoBwu1WtqHjEXfKl9hfqeXruAIvJXp06EhQKuAVfFQYLX9qkDKtdbKCvCVlNznuaBe2/pY9n53R4naWQYjYiSykgSUb4v0UMxMpEaAzYaNUcN4SkfsSRuUOHQ6BzM7yjncm+oGdeJ9+fpe5eNR8XqmWJUSGwHbxwsnl3YLOgU0e/zHmWrTbhbdNQjfJLuS8RVV1FOT5nfcAZ+QDvXYEEY0q1ZIRjfj1KKEYXZk4KM3z49jiOUCxFigLuSGx+bBnFRnn6j3X+6jhtWKIbOxgQCE3epuYdYikXqP8bYKXo8UOdWED5NIrs/V4V7wOu/ONMwOi2KNJ+jg7G3CQMAMJL5VQKfUMcGKmAsjIbGMpli23iKabbR6zzxkxzkjmCcsoXHG7KEPUBJdGmhLILNUwIJAISm08/X/CvKlrYV2GO9bvf5e3ScdgPjV1mzho76ufN+iPtvYfAM/M1mbVYbFG2nFwnweRLRyitt0zXypmQJhSbImZr50Aiw+ABy+1op5dq0k4bS5W2sHXtUf4ZaCvwazqZPE4sgZOuYAmmgW987pVRtfwJ DDLfZnaj fQEQLdEn9aN+EygiXjkhFdAM+nK1SNfMm4t2miRAWtR1q10LOIhXPlnPY5xG/vz5MAm15NVmwR/+WVpz0950WaJCgGFCxyBKhxRrTRBgVFV1D0LFu5FJh7q3PFB0N6fFFfIS/a6OZEJlLQQnKlPIV3TVBTzVU+ZQ7sy9wQE7+J2S9Z2+l7ZQwuOAkCg4s/zyzSuyD4XaTJN0u6L9vI1rKIDoyX1zFzO6c+SF0BjF2lUleWauxCjTTb4p2d8HYKW898Vf4l9+AOwLlTBnrJrgUgbr0F6mZ1sFwzcqhw3aX7bfBDr4BrbxCeyQtAA== 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 post_alloc_hook(). Reviewed-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) --- mm/compaction.c | 2 ++ mm/internal.h | 3 +-- mm/page_alloc.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 6009f5d1021a..2915a13b34a5 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -83,6 +83,7 @@ static inline bool is_via_compact_memory(int order) { return false; } static struct page *mark_allocated_noprof(struct page *page, unsigned int order, gfp_t gfp_flags) { post_alloc_hook(page, order, __GFP_MOVABLE); + set_page_refcounted(page); return page; } #define mark_allocated(...) alloc_hooks(mark_allocated_noprof(__VA_ARGS__)) @@ -1868,6 +1869,7 @@ static struct folio *compaction_alloc_noprof(struct folio *src, unsigned long da dst = (struct folio *)freepage; post_alloc_hook(&dst->page, order, __GFP_MOVABLE); + set_page_refcounted(&dst->page); if (order) prep_compound_page(&dst->page, order); cc->nr_freepages -= 1 << order; diff --git a/mm/internal.h b/mm/internal.h index ca400c70199c..9cc5fdc614cf 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -735,8 +735,7 @@ static inline void prep_compound_tail(struct page *head, int tail_idx) extern void prep_compound_page(struct page *page, unsigned int order); -extern void post_alloc_hook(struct page *page, unsigned int order, - gfp_t gfp_flags); +void post_alloc_hook(struct page *page, unsigned int order, gfp_t gfp_flags); extern bool free_pages_prepare(struct page *page, unsigned int order); extern int user_min_free_kbytes; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index adac485e3254..e3a4aaf437f9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1506,7 +1506,6 @@ inline void post_alloc_hook(struct page *page, unsigned int order, int i; set_page_private(page, 0); - set_page_refcounted(page); arch_alloc_page(page, order); debug_pagealloc_map_pages(page, 1 << order); @@ -1562,6 +1561,7 @@ static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags unsigned int alloc_flags) { post_alloc_hook(page, order, gfp_flags); + set_page_refcounted(page); if (order && (gfp_flags & __GFP_COMP)) prep_compound_page(page, order); @@ -6394,6 +6394,7 @@ static void split_free_pages(struct list_head *list) int i; post_alloc_hook(page, order, __GFP_MOVABLE); + set_page_refcounted(page); if (!order) continue;