From patchwork Wed Aug 28 23:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13782081 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 EBC40C71150 for ; Wed, 28 Aug 2024 23:15:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CACA6B007B; Wed, 28 Aug 2024 19:15:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77B736B0083; Wed, 28 Aug 2024 19:15:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 643F06B0085; Wed, 28 Aug 2024 19:15:52 -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 46EE46B007B for ; Wed, 28 Aug 2024 19:15:52 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D6C8D14084C for ; Wed, 28 Aug 2024 23:15:51 +0000 (UTC) X-FDA: 82503213702.15.460C05B Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf18.hostedemail.com (Postfix) with ESMTP id 282AE1C0011 for ; Wed, 28 Aug 2024 23:15:49 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=v66rOvK6; spf=pass (imf18.hostedemail.com: domain of 3pa_PZgYKCIAwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3pa_PZgYKCIAwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724886880; 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=MMRQE9M5HKxzvMTzsEDSmvB+myXexAwhYGndQpAOIRM=; b=yDMq+9Wv0SxsHdhC3SJlOaPLulZN7s9rSklVN4Jgg0wh0kImhAaeIQ3phiqfAI4Bs2zEQE FK3GYY1u61fKX0t5oR6AfcOZQNPhSs3yeU4M+6iiJUsmEVyMMmJ+nHs0rFMr/cxcaG5LzM 0cX/izbHTTub8Eoe0WSg5YyyCzLedhg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=v66rOvK6; spf=pass (imf18.hostedemail.com: domain of 3pa_PZgYKCIAwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3pa_PZgYKCIAwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724886880; a=rsa-sha256; cv=none; b=O8WmygoBksSHcHnYH8cIcWgqKo/esLkcTITgapUSqBP3Gz20cIddQPAzcm9EZJbeij6aPt RRZckw35M9UVgAe3RqQR+30+DMslUePtMLfXdiXem74ZQcNMxU19Nvui3roJNHOunphiQs VcQ6llA++MSqcut+b3yehnLflW3h350= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ad97b9a0fbso2080107b3.0 for ; Wed, 28 Aug 2024 16:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724886949; x=1725491749; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=MMRQE9M5HKxzvMTzsEDSmvB+myXexAwhYGndQpAOIRM=; b=v66rOvK6WYteQhmVb3St9S5nRnyvi9ZNp71+JPqt20aAAN0RsXWxZpr4bHppE7Zk9H tBIQkoLc9WoazvdLnLyieyx2rPyXt+SqpZd2pjfZYNWsgk3lcwH/5GyeOira+l29SA7S EG0RoUo1jz//G+IFvBmSgY3RYersySN6gMHy3ANdNMg+mzZQ77jjysDy84Jn9Dfh3vbo Bh/zB0ggnN2nhb0FZuczjSpdmQYbHNKLblyDi4kZ8nt+dxWKw2BK5e/K2l7tuHgs/Kvb 60Ll+z2pQYpfj9uXnQojDS289sAwB4NOvLL+joPTlyuuJPq5O453rErjfE/DEQEdn/zK R5fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724886949; x=1725491749; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MMRQE9M5HKxzvMTzsEDSmvB+myXexAwhYGndQpAOIRM=; b=LnnQQoj6YBgYp2XkAguMQq1QP35e1WuVU1qFooxc/A5oKOiHxyPNkJY2IbK5vogc40 PIrb2XJc4S9WASmC7OoW/rdGC/3eUmvKeHmL7P5/hkL8+iqYPdB6aya/P8ThN1kBWevn SpaygpWb5riyR+HUhBJS0VwkKwmSFS539Ww8t1VE8MQAg/blpnTv/W4125YWUZjH3ADm NHppciqcLjZqrfjvomRO2V5jpP7N1Yuelvk5+GBKNm/qzU2AYrToOUC9K+ZtLm/zOAmE EZOwFWIGTTG1SpvJLHE5Jyx81VPRqV5LbD07c/nJ0SVPNFHyPDgGgxwkK5dP0ulFmOdf wgHw== X-Forwarded-Encrypted: i=1; AJvYcCV2CzAbYnjUKC9Rh33DCu7RmU1fyBmCqbW/seoEZyk93o/7NtYrjOjTQuKjqJ+82ecOvtMjRi7p2g==@kvack.org X-Gm-Message-State: AOJu0YwUyiJhkGRtYTLmXAZ2XVN7oQtq/8ESLYZ0tThUFKkHiv1W+iYa rZHNK4VXbCNV1fC1QyYHkKfUAu8UknG3CYGy9ovWb66ft/YFRJmSMrsz5oH6fVT6R/5ga0fP1k1 BDw== X-Google-Smtp-Source: AGHT+IHZ+O35i4VghFjFn/vmGMPTny7V3ShVkfOR7KuwKnk76ug3SO1rO9edrN4QbyJehMcztWhlCgXbs0g= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:1513:a:29f6:5d06]) (user=surenb job=sendgmr) by 2002:a05:690c:6382:b0:650:93e3:fe73 with SMTP id 00721157ae682-6d277880caamr395607b3.5.1724886949080; Wed, 28 Aug 2024 16:15:49 -0700 (PDT) Date: Wed, 28 Aug 2024 16:15:36 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog Message-ID: <20240828231536.1770519-1-surenb@google.com> Subject: [PATCH 1/1] alloc_tag: fix allocation tag reporting when CONFIG_MODULES=n 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-Stat-Signature: 6uikk6woqnusu6bihhe7ktcqwyc463m9 X-Rspam-User: X-Rspamd-Queue-Id: 282AE1C0011 X-Rspamd-Server: rspam02 X-HE-Tag: 1724886949-523553 X-HE-Meta: U2FsdGVkX19YU5Kuwro/22SlHqUdM5YHIcYRRrgK7E+ED3sxBq3XGNnvF0NSu/niXaM3wpe4j/YW2zfUY3DVYEyj8JWMVVtv22K0zzyigAabY30ZBpXCTCvo51cgEQ78bgBoSndfhDT65RamISwon/jq3fQdXKN7nj6s135XyYwIFXMni6mEO62k/eXGkS5FK9jMIVb2WpG/ML4Wc+saNZhqQrkgX7tpSohy1p3TUojkSO6rdLQtROXqtkNvI64lMFB8s9Z0D2eCeN8cYy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qj/Nyai5rlBde9rzPWO4NRpDgiefJtgYSAj9AixqgHrZb16XyzujqU7oyHPecq6ljZQwLux2v/iaWfT85ryBom14oeE5yzdc+cDmrS7wiXC0bA6wRw9TWhou5CoRoZeyTM2JFFPI0QHtiw6m9vJIui0R961MQBrUdWusWcO9dk951rmbW4hPPRMemnCYwXAC/GCzy7UTgh3l0pr62hJ0n2j7Svlh36MXGhN/u7D7HLZWatWqke0SgjlN2lgCm3akgmB1YyGURORmitcjS8L6OD6bkebIM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.058934, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: codetag_module_init() is used to initialize sections containing allocation tags. This function is used to initialize module sections as well as core kernel sections, in which case the module parameter is set to NULL. This function has to be called even when CONFIG_MODULES=n to initialize core kernel allocation tag sections. When CONFIG_MODULES=n, this function is a NOP, which is wrong. This leads to /proc/allocinfo reported as empty. Fix this by making it independent of CONFIG_MODULES. Fixes: 916cc5167cc6 ("lib: code tagging framework") Signed-off-by: Suren Baghdasaryan Cc: stable@vger.kernel.org # v6.10 --- lib/codetag.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) base-commit: 9287e4adbc6ab8fa04d25eb82e097fed877a4642 diff --git a/lib/codetag.c b/lib/codetag.c index 5ace625f2328..afa8a2d4f317 100644 --- a/lib/codetag.c +++ b/lib/codetag.c @@ -125,7 +125,6 @@ static inline size_t range_size(const struct codetag_type *cttype, cttype->desc.tag_size; } -#ifdef CONFIG_MODULES static void *get_symbol(struct module *mod, const char *prefix, const char *name) { DECLARE_SEQ_BUF(sb, KSYM_NAME_LEN); @@ -155,6 +154,15 @@ static struct codetag_range get_section_range(struct module *mod, }; } +static const char *get_mod_name(__maybe_unused struct module *mod) +{ +#ifdef CONFIG_MODULES + if (mod) + return mod->name; +#endif + return "(built-in)"; +} + static int codetag_module_init(struct codetag_type *cttype, struct module *mod) { struct codetag_range range; @@ -164,8 +172,7 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod) range = get_section_range(mod, cttype->desc.section); if (!range.start || !range.stop) { pr_warn("Failed to load code tags of type %s from the module %s\n", - cttype->desc.section, - mod ? mod->name : "(built-in)"); + cttype->desc.section, get_mod_name(mod)); return -EINVAL; } @@ -199,6 +206,7 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod) return 0; } +#ifdef CONFIG_MODULES void codetag_load_module(struct module *mod) { struct codetag_type *cttype; @@ -248,9 +256,6 @@ bool codetag_unload_module(struct module *mod) return unload_ok; } - -#else /* CONFIG_MODULES */ -static int codetag_module_init(struct codetag_type *cttype, struct module *mod) { return 0; } #endif /* CONFIG_MODULES */ struct codetag_type *