From mboxrd@z Thu Jan 1 00:00:00 1970 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 CF666C5B552 for ; Mon, 9 Jun 2025 06:08:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CE686B007B; Mon, 9 Jun 2025 02:08:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37F136B0088; Mon, 9 Jun 2025 02:08:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 294F06B0089; Mon, 9 Jun 2025 02:08:49 -0400 (EDT) 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 0AFD96B007B for ; Mon, 9 Jun 2025 02:08:49 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7CD0CBEA22 for ; Mon, 9 Jun 2025 06:08:48 +0000 (UTC) X-FDA: 83534833536.29.0B886BF Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) by imf07.hostedemail.com (Postfix) with ESMTP id 7680240003 for ; Mon, 9 Jun 2025 06:08:46 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tFt3+5Au; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf07.hostedemail.com: domain of hao.ge@linux.dev designates 95.215.58.180 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=1749449326; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vfAvyAuRWliibUaARgdBDzm75P3vNxLwJns/0rYb7pE=; b=ymjoH+gNZwyqzYs6LUXQ9DidfZpMrS+vVK70RZcz1KagoznvFz42T++EQsS/4SuCg84JJE tJdEobc9JXZnVKalJ66NRd19olz4V+saDJABM9V0Etixkw92YSxD4qUtS527mOUyTR0dpY hXzooFiQpQeaTFszzuqK8yY84RZ+nG0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tFt3+5Au; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf07.hostedemail.com: domain of hao.ge@linux.dev designates 95.215.58.180 as permitted sender) smtp.mailfrom=hao.ge@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749449326; a=rsa-sha256; cv=none; b=FS/VjNXWiqAmMxloKVGhIarzaIJ2UccEcX1JIbhV52KkRnm1bMkZ2O0QoddH8LGhgUknB1 +0+iIyShHLx4QXrTvc/DS3c4j047y5LvBySmjaOvu5P1AtCF5q2IsrrEHlCob/RIIVjeux C2BDkcwM48NUFdNRAxYcH2DLT8fsG70= Message-ID: <177e1f6b-50f0-4c0a-bb0b-514283e009a2@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1749449324; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vfAvyAuRWliibUaARgdBDzm75P3vNxLwJns/0rYb7pE=; b=tFt3+5Au/OlayXrj2ggXiz1eoKI28pkLjPGGTh+ROelRyDBxTX9zJF5KHMTZOMaMUmPwIG BrlpkjC551DEgMIsRG3TdKy0sPwIN+43YNGKXlT8CZL5mWOfjkFA4vYfh1qLcQMe9nABrj Y7gIYExQKOMak6diMZom51l9cp4llvY= Date: Mon, 9 Jun 2025 14:08:03 +0800 MIME-Version: 1.0 Subject: Re: [PATCH] mm/alloc_tag: add the ARCH_NEEDS_WEAK_PER_CPU macro when statically defining the percpu variable alloc_tag_counters. To: Andrew Morton , Suren Baghdasaryan , Kent Overstreet Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Hao Ge References: <20250529073537.563107-1-hao.ge@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Ge In-Reply-To: <20250529073537.563107-1-hao.ge@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7680240003 X-Stat-Signature: 9zd5riudaj9uzmf91zao6hxaxk6cmx17 X-Rspam-User: X-HE-Tag: 1749449326-645894 X-HE-Meta: U2FsdGVkX18mpkiO4BD4IT00fVpQelFF4U7mJuZjH/z3LkkuMPktkygO3offfp5CeOTRs9TplfJVlFJIBKzneheH2ZucCqBJEaF25TeYSlij373QUWypErJ8BqVJNokNIIpkAP4K9mUI34DgA3bUqS1Cl9Tyru1P7wUMQMYDbcCqdBjtHxFS442FSeRHGuq8OgiqnA/KMTTQcwgOxNkANixZ6/tWcEJN0Er16kXfA+Y4R7Erur+SMoErzRNp0zoFC7JsgiouTaxMVpNgw7S2wHUvXZV7SMlbLsA7I1G7IZUTt+IUWmbgw3/pLGQiKTJISvrkZWb8t32cyGdOrQ9v13+IpXjSN3YLeyn8N0H7aP+EBnRvIPoGGTXOtX8oOuKJ6mtl3oV5DYkoyEknUKLb951cghPsHIiTHDBTyFhFX8D/ODhLB+Ay/Qk0U/Tc0xBqdiJoImpGBq2SjLFBLX2iPQKof8wr7Mh5zcgb33ynGX8Yrma1/ydWp1Csu83FCEyejnEW1bWju7G2WVTIAuHAzBeysWlitwmHicoQ7w8bWF86GggKSKaiW47Tj4B6MBGYjj6t57WvLre6NtPFjDUth8nr82pMqy/2HRI6Vnro1PqLIVS+P/Ty1hM6eAEKwdGNJC7r5Hm4J2YsvcYgMhAsC2/qzhsV2ASI6wFMQxQGNo4H7ZYJ1a2XPPPC9P/EYeBy3P7kmkkEW/iLMprAMLx57G6vBLWyz/0PAMlddfZqFSMWWr+aS7TObEVrVuYqrXi/O8IlysOcPI2+P6Pm47HnR0cUn6Wqz49c5btFkCnu6OW7Hnk5ZeeJxboP3NOz7zn4xqRKiULmnAjykSLGuJpVEUm5ToRQsYbDFIcJFXxPQw0zejWj0ffTagGhuu7IQAQpSbo69dBEdcf4M14UZzryFDL4E0dsn9AQ7gW7qKeFdaXbhS+f3i9AfMm84AXpH6NgLOC9YXT2KBt5mh7C7f+ jHpVJhfi j3bWGPX4F6GcUklbX1FvREmNXnkqIUR0KOdJP2DAugjI3CPm4Wb5ue9OfmKehMpA/bNJHBzv5jbWBM0BIzMV38WxhjN2adK2WR7FnTuWRPDo4iV5T6t6a0/PLJCCTNvGbjyAcLSD2fAjVsft7im8o4B2ZwqcU+3aPws+KVCPS9hSkrYSRGVZLndIo1yzrDFTsJr+Y2CAyP4Xg63r2MAtp5jmTAC9eAW7C/VKxf9NKGqrADcj3OT6xz/F21rZXWT2paVDfrsl2zoVplg0UGyQxkO/JppvW8m1+Vb1Q/KUfgyEGArwla3CX9O6P1iApbm5rX/LxI6TO54eX83ow3XsHjo4X9A== 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: On 2025/5/29 15:35, Hao Ge wrote: > From: Hao Ge > > Recently discovered this entry while checking kallsyms on ARM64: > ffff800083e509c0 D _shared_alloc_tag > > If ARCH_NEEDS_WEAK_PER_CPU is not defined,there's no need to statically > define the percpu variable alloc_tag_counters. > > Therefore,add therelevant macro guards at the appropriate location. > > Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling") > Signed-off-by: Hao Ge > --- > lib/alloc_tag.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c > index c7f602fa7b23..d1dab80b70ad 100644 > --- a/lib/alloc_tag.c > +++ b/lib/alloc_tag.c > @@ -24,8 +24,10 @@ static bool mem_profiling_support; > > static struct codetag_type *alloc_tag_cttype; > > +#ifdef ARCH_NEEDS_WEAK_PER_CPU > DEFINE_PER_CPU(struct alloc_tag_counters, _shared_alloc_tag); > EXPORT_SYMBOL(_shared_alloc_tag); > +#endif /* ARCH_NEEDS_WEAK_PER_CPU */ > > DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT, > mem_alloc_profiling_key); Hi Suren I'm sorry to bother you. As mentioned in my commit message, in fact, on the ARM64 architecture, the _shared_alloc_tag percpu variable is not needed. In my understanding, it will create a copy for each CPU.  The alloc_tag_counters variable will occupy 16 bytes, and as the number of CPUs increases, more and more memory will be wasted in this segment. I realized that this modification was a mistake. It resulted in a build error, and the link is as follows: https://lore.kernel.org/all/202506080448.KWN8arrX-lkp@intel.com/ After I studied the comments of DECLARE_PER_CPU_SECTION, I roughly understood why this is the case. But so far, I haven't come up with a good way to solve this problem. Do you have any suggestions? Thanks Best Regards Hao