From patchwork Tue Aug 13 15:07:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13762199 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 693D2C52D7B for ; Tue, 13 Aug 2024 15:08:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB1D56B009E; Tue, 13 Aug 2024 11:08:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A62366B009F; Tue, 13 Aug 2024 11:08:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DB666B00A0; Tue, 13 Aug 2024 11:08:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 701306B009E for ; Tue, 13 Aug 2024 11:08:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1CCF71A0975 for ; Tue, 13 Aug 2024 15:08:05 +0000 (UTC) X-FDA: 82447552530.18.CAC86CA Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 447A4180013 for ; Tue, 13 Aug 2024 15:08:02 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=4XZ9PoZp; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 30Xa7ZgYKCOgcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=30Xa7ZgYKCOgcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723561624; a=rsa-sha256; cv=none; b=N4jWFo7Pj0sZEBzbGOEJp5bnfHXhMSrpzxOX3T7mcGd27k8SS5EDZj71gk0QdorrnW3opr e1qxTB64fqjzs8ZDsG4WLXS4k6hmikYAZGdBFufQrrR0IeiNwRfgRzwpb7l6hbOPqNrX9N 6kAodPNXC2+FMEbrBHvRuRsLCqdqd4o= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=4XZ9PoZp; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 30Xa7ZgYKCOgcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=30Xa7ZgYKCOgcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723561624; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=1x8HY6pqVTVF5kQzcpH4Ucp1zz0s1gAq4xU9MqMd/wE=; b=bBFQ0/v3P8ZsK0WxnjAwvoeDNV2n7MDPGHPZRaqNcuEr8vf6sNRzU+86st6gRBkS6FKA6S Zn0XiseXymY6kJPF3pfSp4/93dAuHu/GSNu/38zhXUEZJqo//3veDtymNZjOfDD9zQo6BX IaZx+T2jJs2AQoB2i+gnpWR+EMjQgA8= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e0b6584bbdcso8827277276.1 for ; Tue, 13 Aug 2024 08:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723561681; x=1724166481; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=1x8HY6pqVTVF5kQzcpH4Ucp1zz0s1gAq4xU9MqMd/wE=; b=4XZ9PoZpFkiOtse445b4g66At+sG9GVDDT60nhr2Oal91+U5yc5caT5jVUbC+2BPEc rZCy7JvPzCpgLPZTFCmU5Yl9OJrqLIyWRUuJI/w5iLTe/TVTsCHp5X1AI24xbOjCY/EL onTtVh3w8RuGmexiA6Jmi6kBAurAh1B8ygUJglVts4Ox7hhn0a52YLCzT/T1FEIU0adR Pz3oVLz9ImOLJ0L5tgHULzIsY5TSUvyJdJ9oA4it780Jg5dgv2Y36khCoZsZ8YM/YzRY FxQS30yXHJoFImwRPOpFd9Z/9tICkva2uJb8zyCA4KpTurZ7QaPiRcgjeg0Wm7t74cOK v2qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723561681; x=1724166481; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1x8HY6pqVTVF5kQzcpH4Ucp1zz0s1gAq4xU9MqMd/wE=; b=pN9YYLwL9G+NUQ6tkl8XIXb1wRJzdvmj/EZMS8p7Nt3Q5AhFEPYDICoYN7O1Kg1wpc zlkDpR6NpKX7kvlqikKeVyUlFgvC9Muc5WzKXlyBKpRh6jEsJc1tnfENMLlYFa1E0luC HmT7zQ6okHj83aCIr1O35IvJ9oSNb+HxxTyUBoH6LrSjrO61cHInRHIi7LFg60unACFj nFAGcX6qHGhJqGtwxX8eYEBBFWsYgF3nI3rq20rELVj4eoaoU/gUztSMNCLvdorCvyx8 adEIyE/7J67hRmPd95iQWDG9AVztJykhebnFUDeNfvCvjK7MeF6suwKx9q86IV5g19jI xxyQ== X-Forwarded-Encrypted: i=1; AJvYcCWClsdZVb/rQxyCmHdGU/fzUMVB1cQkUdHK1px5McqXpDtn2LT981E5Vl4PLFyhMD+ynhUkRNLwdE4f1YuQCogacho= X-Gm-Message-State: AOJu0Yy4XWfEdVlWl882ZsUfN5IFZeaW8FgUd5UC5m0vDvJF19nDQrz3 2cdwFB4Oh3+uvX1FxXiDF4zmlkoe6PUng6+cpmQiOIjLIphfMwodjpjInxvzuAw1rqwdzFU5k5o kbg== X-Google-Smtp-Source: AGHT+IEz36OwLmoBcnEL1WUUu6fUVYlI+FT85j7U+cB0aTgWoq2vINT4jdflqp8Za9uby33WBDXFm+7GRew= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:b416:2d8c:d850:78]) (user=surenb job=sendgmr) by 2002:a25:4844:0:b0:e05:eb99:5f84 with SMTP id 3f1490d57ef6-e113e9066d6mr4889276.4.1723561681199; Tue, 13 Aug 2024 08:08:01 -0700 (PDT) Date: Tue, 13 Aug 2024 08:07:56 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240813150758.855881-1-surenb@google.com> Subject: [PATCH v3 1/2] alloc_tag: introduce clear_page_tag_ref() helper function From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, david@redhat.com, vbabka@suse.cz, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, surenb@google.com, stable@vger.kernel.org X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 447A4180013 X-Stat-Signature: a7t7ttgjkwabkm9fcsy478sety84ahy1 X-Rspam-User: X-HE-Tag: 1723561682-272351 X-HE-Meta: U2FsdGVkX1+90s6g1IbY87FLWo0vrsvdF0oysdC3HroCbSXEQFLiMc2TgrS0p/CCU77xzijQIFGhCegc6Vn0NmHjaQTuiO0u1ENJTYCRnNFNxI+38FabIOIR831GelP3OGGDCEuV6i2snBDGjMXzpKRiTDTqlxT6o5C2dM1BaGB9xj1nRAFAMyXymY0fepV03eFZ0EuWfs5PeXq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4VqU/wZ4kK/HX9Gmx3d5fBf1hxa+de4Y1vk8ZXF0Ij5qeNEWpqd+4HHxhHH4FiV37URwLdGwUObgk/LTRRMJhsq/7i9k98gFamtrWgurk2IU++q5yZMC26hZTZxR3dYYhmdlY5T2FMLAJs2LFh53Z5x1upoImMf1m9cE3Wkd+CsaaxQxzAZNmIf1wjetOhQxXa7ErnCqp78AjOzPaSsQEfL9uCTtgXt33LtCEczz8wxNaCo+ovIK4Nif/GlFo0KN5DUWT+rF6USpUdS9o/H3Jfh9+oB68HeHb4SrA7LRWJyfOzOG30k7otAftdOz9lbAfKTFh6+pkiWh4H/mod2kSlN63oP8yF+BEttoA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000140, 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 several cases we are freeing pages which were not allocated using common page allocators. For such cases, in order to keep allocation accounting correct, we should clear the page tag to indicate that the page being freed is expected to not have a valid allocation tag. Introduce clear_page_tag_ref() helper function to be used for this. Suggested-by: David Hildenbrand Signed-off-by: Suren Baghdasaryan Cc: stable@vger.kernel.org # v6.10 Acked-by: David Hildenbrand Reviewed-by: Pasha Tatashin --- include/linux/pgalloc_tag.h | 13 +++++++++++++ mm/mm_init.c | 10 +--------- mm/page_alloc.c | 9 +-------- 3 files changed, 15 insertions(+), 17 deletions(-) base-commit: d74da846046aeec9333e802f5918bd3261fb5509 diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h index 18cd0c0c73d9..207f0c83c8e9 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -43,6 +43,18 @@ static inline void put_page_tag_ref(union codetag_ref *ref) page_ext_put(page_ext_from_codetag_ref(ref)); } +static inline void clear_page_tag_ref(struct page *page) +{ + if (mem_alloc_profiling_enabled()) { + union codetag_ref *ref = get_page_tag_ref(page); + + if (ref) { + set_codetag_empty(ref); + put_page_tag_ref(ref); + } + } +} + static inline void pgalloc_tag_add(struct page *page, struct task_struct *task, unsigned int nr) { @@ -126,6 +138,7 @@ static inline void pgalloc_tag_sub_pages(struct alloc_tag *tag, unsigned int nr) static inline union codetag_ref *get_page_tag_ref(struct page *page) { return NULL; } static inline void put_page_tag_ref(union codetag_ref *ref) {} +static inline void clear_page_tag_ref(struct page *page) {} static inline void pgalloc_tag_add(struct page *page, struct task_struct *task, unsigned int nr) {} static inline void pgalloc_tag_sub(struct page *page, unsigned int nr) {} diff --git a/mm/mm_init.c b/mm/mm_init.c index 75c3bd42799b..907c46b0773f 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2460,15 +2460,7 @@ void __init memblock_free_pages(struct page *page, unsigned long pfn, } /* pages were reserved and not allocated */ - if (mem_alloc_profiling_enabled()) { - union codetag_ref *ref = get_page_tag_ref(page); - - if (ref) { - set_codetag_empty(ref); - put_page_tag_ref(ref); - } - } - + clear_page_tag_ref(page); __free_pages_core(page, order, MEMINIT_EARLY); } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 28f80daf5c04..3f80e94a0b66 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5821,14 +5821,7 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char void free_reserved_page(struct page *page) { - if (mem_alloc_profiling_enabled()) { - union codetag_ref *ref = get_page_tag_ref(page); - - if (ref) { - set_codetag_empty(ref); - put_page_tag_ref(ref); - } - } + clear_page_tag_ref(page); ClearPageReserved(page); init_page_count(page); __free_page(page); From patchwork Tue Aug 13 15:07:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13762200 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 73A52C52D7F for ; Tue, 13 Aug 2024 15:08:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C13886B009F; Tue, 13 Aug 2024 11:08:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9AD86B00A0; Tue, 13 Aug 2024 11:08:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3D346B00A1; Tue, 13 Aug 2024 11:08:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 844EA6B009F for ; Tue, 13 Aug 2024 11:08:06 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 40A22807FB for ; Tue, 13 Aug 2024 15:08:06 +0000 (UTC) X-FDA: 82447552572.03.E31B5CF Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 54E38C0029 for ; Tue, 13 Aug 2024 15:08:04 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gJOf0M6D; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 303a7ZgYKCOoegdQZNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=303a7ZgYKCOoegdQZNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723561632; a=rsa-sha256; cv=none; b=I/SD2g6Jihe/WohDdZagkEoxrRFbQIZBIVcg/9MtgguGq6wlGNsYUHf7U8bZEp3gwaRvvs 9CzZPpb511X2RXJK8GtopKScPPN1YwyDG+1aMHfuUEUZ52pLTSFwFrvzSQnBD8j/vqB74U qWLwkV3t4V7Atl8TtjjUC1TW4DASZ6c= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gJOf0M6D; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 303a7ZgYKCOoegdQZNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=303a7ZgYKCOoegdQZNSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723561632; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HItAAQ4Cu003jbkia8AheTp1hPIpjiafpUpcTgjSBk4=; b=cBdykaNfEJ9SiRii8f1o5cXapPm9cJKS8F+JHTecltZZMEvSR1gRehr6BO0Nm1QL/+nged OcFWkA7WBdI0/SnomGJV3PGT0NFqs+lLp/HPiWuOQqe1c3wpsskGnQPpFfhPOuZcvLJRJa TEjAAEPcDSfuc3gr4OkawIERnaev12g= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6698f11853aso111885887b3.0 for ; Tue, 13 Aug 2024 08:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723561683; x=1724166483; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HItAAQ4Cu003jbkia8AheTp1hPIpjiafpUpcTgjSBk4=; b=gJOf0M6DILb+mTGvVva31zBJeBy6vesdBwNmjKQa8Q5VXpa7duc1qJck5lyb/AVVbQ ptciIopV6m/kLk06C0evcdjGWfXXyNCAYTLnUC4yCuaBAspuHibxvsl4EVKPITRnf1bm x9Jrn9gk+lvY1Oe4PpSEeXhJS04ltYtKbN7QVpcAhO7YyfyFqG9uQVPIjdoCPmskZLSF TKUesdL5au080XtBL0br+FMXrUOKToKWg2YRjnfskEQ7s+93NCdVtAWc/0xAFQh9xbzv UmhFtzlp8gSKEGlyI8gQS1lnQUb1R4e/U6VOQiWTD1JpamLpFBIDeY4p14v4XU0I9+o4 N1IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723561683; x=1724166483; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HItAAQ4Cu003jbkia8AheTp1hPIpjiafpUpcTgjSBk4=; b=WJEb81YNblYgSs7NTfr1PMIzZhGG22PGZhPjtM7+D6bltLAVwEeMlqjZzLmaq/FwkD JdzLpZNbQME0OeF8wHzWmC1DchMahhvUrbx3VpvWzVbts3DV/vVsZeOBO0jeX5EzLlA7 W8XJZqUwRFgsDdjtKq8+AV5r42OX5iauwVXYvGhxS5t9OmRO03tHlv47ZnfPP4h+8vt+ Z7RIYSFugnaVsAzFBieyreEUeTaXJ1n3EkjHucRYaD6KmKkb9BJBeD9HzEnOT6n0B7nI Zo79xX++TjDOLrE8Zw70LL3k/JpJLlw2UD2x1RIY60bNf17gcuLlNySWuMawQPMPdx8v UFeQ== X-Forwarded-Encrypted: i=1; AJvYcCUuG3G0Jv+McuKxCq5oo6Qoviir9KTgrOnWKekOCdDg48hLElY6GWBNVhDS+m324FPiyZXlbF6dbGhAj+n4Rk1earE= X-Gm-Message-State: AOJu0YwLa0e7mdWKsjTPlfWnMb+04E4aEzX+wOH4G3C5pK+tOop/hr/U 99cszYalfZSLmwYh8HmAMAW0MfXnSnm0AStUEr2p+z8gkZehBPsCLhQv5sDIgrbk98hLylPo3lL JRA== X-Google-Smtp-Source: AGHT+IG/nKnomNtLuqj0m6U9iTDpGVWXD3ZvVIbVbvNz/CQySgPPuus4RRP2iUTRkRmZvV/6nAgz4mxWbJE= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:b416:2d8c:d850:78]) (user=surenb job=sendgmr) by 2002:a0d:d146:0:b0:6a9:3d52:79e9 with SMTP id 00721157ae682-6a975ab0573mr1862217b3.4.1723561683324; Tue, 13 Aug 2024 08:08:03 -0700 (PDT) Date: Tue, 13 Aug 2024 08:07:57 -0700 In-Reply-To: <20240813150758.855881-1-surenb@google.com> Mime-Version: 1.0 References: <20240813150758.855881-1-surenb@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240813150758.855881-2-surenb@google.com> Subject: [PATCH v3 2/2] alloc_tag: mark pages reserved during CMA activation as not tagged From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, david@redhat.com, vbabka@suse.cz, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, surenb@google.com, stable@vger.kernel.org X-Rspamd-Queue-Id: 54E38C0029 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: gnaxcb3t819bjbexyoafz38wzt8955du X-HE-Tag: 1723561684-707963 X-HE-Meta: U2FsdGVkX18ZiL+VhnsePya7hubvhSJO1X4AnroTFD3y41fhU58TqhvLmBNRwesb2ZxX9+3bFEeLMFS+UaqsCYdnol7MjPMD7u6YVGta0XS2L3qhs7DnYUUu3Tpd3QEfeUlgTpTdUq2vXvqy0jjo2gAchILowpifFlizNez3QkLzWVH9F2iUJviYQgHYPWfafgagWfDqvHveIZeVNWOw/78jPZ24uRONq4WmJ1mPCgVuAwh/LLDfpeJezPdS8Tlx+0jiOjx7TvxbwtCETkPKNGx6vV7hAR4afz1xUC7dRQ0ceuwp/W//5vDmK+kUO2EPvRoaf217rDdFbgA6PMWvIgVkGJnHTSWNZMu0nTqcLyorsWaLKyn/pWayoKDtyLFFRxNOFaflX9cnGeJR18TIAP8dk9ezqZ4WPnPCgdb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UwKtdt8HMvWmAqH8yL3QWA+8Gh/CBbsPfyQksdpUONmQ6oLRi6DqU34qj/P39i7Ohs0ZI5FFuyDaDh3SEv0N8ii7Yg7DKtlofiN9rZmuJk1yBD1MPxHERaNo3t+6hRR40Lm0egphNZp9NDGw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.005262, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: During CMA activation, pages in CMA area are prepared and then freed without being allocated. This triggers warnings when memory allocation debug config (CONFIG_MEM_ALLOC_PROFILING_DEBUG) is enabled. Fix this by marking these pages not tagged before freeing them. Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty") Signed-off-by: Suren Baghdasaryan Cc: stable@vger.kernel.org # v6.10 Acked-by: David Hildenbrand --- Changes since v2 [1]: - Add and use clear_page_tag_ref helper, per David Hildenbrand https://lore.kernel.org/all/20240812192428.151825-1-surenb@google.com/ mm/mm_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/mm_init.c b/mm/mm_init.c index 907c46b0773f..13c4060bb01a 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2245,6 +2245,8 @@ void __init init_cma_reserved_pageblock(struct page *page) set_pageblock_migratetype(page, MIGRATE_CMA); set_page_refcounted(page); + /* pages were reserved and not allocated */ + clear_page_tag_ref(page); __free_pages(page, pageblock_order); adjust_managed_page_count(page, pageblock_nr_pages);