From patchwork Thu Aug 15 09:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Ge X-Patchwork-Id: 13764580 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 75135C3DA7F for ; Thu, 15 Aug 2024 09:03:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB10B6B009E; Thu, 15 Aug 2024 05:03:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5EFF6B009F; Thu, 15 Aug 2024 05:03:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 925576B00A0; Thu, 15 Aug 2024 05:03:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 735126B009E for ; Thu, 15 Aug 2024 05:03:39 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 01B98A870D for ; Thu, 15 Aug 2024 09:03:38 +0000 (UTC) X-FDA: 82453891758.09.A59A867 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) by imf24.hostedemail.com (Postfix) with ESMTP id 20B3F180014 for ; Thu, 15 Aug 2024 09:03:36 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="KJ8J/pXm"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of hao.ge@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=hao.ge@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723712536; 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:references:dkim-signature; bh=KIxXFek9GnWErg2oi1kCRegTo0ov+46L+2lXaPDEJTs=; b=NM3zjnDhVwCqr/dIqYEkjWuQAXeOazSFF8sN6+2K3nRaVRsP0xhJ6ZguhxXzZC1hZOmvLe Ew1ZTWSpzn1InyITXez4otieg1QoAHu1QuVagJhCFPqY58/hjgVslGtK2Qm1kO2Gb00ZX9 1QI3Jv6+Ov09Q95V2zEKlu0x7s0lB08= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723712536; a=rsa-sha256; cv=none; b=psxxiZqRpxIw3HQtN0a/mq/kuJ4V+HE96CslrCxjxvjrQIUWmcAU0MehhMY6at0OmFIJZx brSH2SRJ+U00AMYM4mSvpoDsgTtJsEglhnLfdMUIJ4m+5X35SVtnwZ9X1BqkegyPGQxYwU DB1LqOQKRVVceBKDfdM6IjqrI92l5pc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="KJ8J/pXm"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of hao.ge@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=hao.ge@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723712614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KIxXFek9GnWErg2oi1kCRegTo0ov+46L+2lXaPDEJTs=; b=KJ8J/pXmJ0e6DIJ5Y5+erb/enczRu6YoLS3Dh54naD4kxN7XYrjOS2KcC3wKytgZXUVMnZ 6WDujFs0uYGoeXqfBEK40SgRagMs2iuNZE8tgswic1Ejtd/zjKmXouzPq+6jjdxwh4+kU/ 2HHiFqswCA/SOX9aeCi37RrBmaxEDrA= From: Hao Ge To: rppt@kernel.org, akpm@linux-foundation.org, surenb@google.com, babka@suse.cz, kent.overstreet@linux.dev, kees@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hao Ge Subject: [PATCH] codetag: debug: mark codetags for cma pages as empty Date: Thu, 15 Aug 2024 17:03:24 +0800 Message-Id: <20240815090324.36065-1-hao.ge@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 20B3F180014 X-Stat-Signature: brihfqdneq4we1u89iypmf9xamztahh5 X-Rspam-User: X-HE-Tag: 1723712616-814006 X-HE-Meta: U2FsdGVkX1/nSDryovj4eZTiNALtze/X+Bd/0TrJNIhUa9bJuGFdevm3uz1E6OLX5f+ogje++mkItEok4id1dQdWTpeARVZAg7nP6gPJJfY6K+1vjvwoTFELJmZHJ5i74tRyyyCciRF7jFgRac0YND6Wm1O7S0uyb9PY6zse19Ko9pA8AxAkJgvu8SDU5N/2j45PcwgzduVdBBuFyb2f9Xy3o4DHXRCYoxmOAfRHoCZ8xqIFfEzr0FSq/agyPrXGImsKjbSiw0zs787eOqPN9N1l2OAdYQKzF/1W5rv1Jfr8HzZ0MRfYAGAhNMU/8ycoZ0crf93KCKDXtUbCI4UnNQf/RG/tjokwvPEppDu4OHi2JFlY7ewDvU+HyTGT0Py6rveWgNobb5CIJObPmpeWgX63sQcMqCqxmH+3AuazdankDe6HQknUZgXp5Av7YywhMDNfdNj8PS5XQDKQkMytq0vH6d5j21BsDbHMdb2Hv/NGYgRH3WomryWuWgFn9JC39VPgAVMryBQem4bAtLS7NiCUfu312GU8vMmoWW79TTNvuGzd/IlDMzN5a6lg5+GOgzxvh1txlLy27rhqY1ozIzK5RdObqJBcKKsg9Pww04R8h+R9DPoft6qvLFap/OElxgPk+0izCEjddq1haagR28KCHy7BG2QrBf+YGVuHjPyCLPvHVrq8a3BypMtDZc5G40sRBTAjgSTNQGZnc/GsZdShOgJ1Kl4V9isr3+qdiIC0En434mb3lC9pFs4mD6EVMnPO44M+IFYZq8M3Ag5h+cHBwDpLQzF8p12j7a1YubA/C+z5dyCQoK/TakglnbXt8IfqrpETtfh9BvxeNO/tU56Xo1Kbr6BpAzL6giHK1SH6jCTImoExumv2vY5mec1VmVGBwNShV9+JBnv0uoF/iHfEmqaTGHVUx45SipPBlSZtZ3Toevo/gOEwdMplW9Yf3bcUJlVPHCinfzq4cKa MCg/05T+ avrq4oaz+zvX0E4c+3nnu7e3hLMGAf6ncxpKC10st6tLerLENiKhl7KIv0eO2YPDId9Xg1yeXHF/KBrxCD/t3oomdJDVfbl3LlfJKervLwgXZn08= 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: From: Hao Ge Here are some warnning [ 1.342603] ------------[ cut here ]------------ [ 1.342608] alloc_tag was not set [ 1.342623] WARNING: CPU: 0 PID: 1 at ./include/linux/alloc_tag.h:130 __free_pages+0x1a4/0x1b4 [ 1.342633] Modules linked in: [ 1.342639] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.11.0-rc3+ #12 [ 1.342645] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 1.342650] pc : __free_pages+0x1a4/0x1b4 [ 1.342654] lr : __free_pages+0x1a4/0x1b4 [ 1.342658] sp : ffff8000833dbcb0 [ 1.342661] x29: ffff8000833dbcb0 x28: ffff000b34d9dac0 x27: ffff80008175f000 [ 1.342669] x26: 00000000000fc000 x25: ffff800082ac6028 x24: ffff80008252e000 [ 1.342675] x23: ffff0000c0660000 x22: 0000000000000000 x21: 0000000000000009 [ 1.342681] x20: 0000000000000000 x19: fffffd7fc3ac0000 x18: ffffffffffffffff [ 1.342688] x17: ffff80008105bf68 x16: ffff800081841bb4 x15: 0720072007200720 [ 1.342694] x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 [ 1.342700] x11: 0720072007200720 x10: 0720072007200720 x9 : 0720072007200720 [ 1.342706] x8 : 0720072007200720 x7 : ffff80008237bad0 x6 : c0000000ffff7fff [ 1.342712] x5 : ffff80008237ba78 x4 : ffff8000820bbad0 x3 : 0000000000000001 [ 1.342719] x2 : 13c63f521095dc00 x1 : 13c63f521095dc00 x0 : 0000000000000000 [ 1.342725] Call trace: [ 1.342728] __free_pages+0x1a4/0x1b4 [ 1.342732] init_cma_reserved_pageblock+0x5c/0xac [ 1.342739] cma_init_reserved_areas+0x2b4/0x3f4 [ 1.342744] do_one_initcall+0x54/0x368 [ 1.342749] kernel_init_freeable+0x23c/0x450 [ 1.342755] kernel_init+0x2c/0x144 [ 1.342760] ret_from_fork+0x10/0x20 [ 1.342764] ---[ end trace 0000000000000000 ]--- To avoid debug warnings while freeing cma pages which were not allocated with usual allocators, mark their codetags as empty before freeing. Reference commit d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty") Fixes: 4b8736964640 ("mm/slab: add allocation accounting into slab allocation and free paths") Signed-off-by: Hao Ge --- mm/mm_init.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/mm_init.c b/mm/mm_init.c index 75c3bd42799b..d7d40a8d738f 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2243,6 +2243,16 @@ void __init init_cma_reserved_pageblock(struct page *page) set_page_count(p, 0); } while (++p, --i); + /* 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); + } + } + set_pageblock_migratetype(page, MIGRATE_CMA); set_page_refcounted(page); __free_pages(page, pageblock_order);