Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2564161rbb; Wed, 28 Feb 2024 06:01:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhMEIXYVmDMS78TFHWhcaxO448J6DnYUIrK3fqQ1MtEDSnWeNQqSihvdMcxQrUkI3YkojIR6RTQPX8+IzyNO9v6Rx4dX+gpIcxYU+fnA== X-Google-Smtp-Source: AGHT+IGRMsY0HgQlYw3uBIrLUP6eZW4i0alQVjq53xIg1iDaZSJ3Ro2UcT4iUh+RqGIRDdnmmum2 X-Received: by 2002:a05:622a:1755:b0:42e:80bb:f25b with SMTP id l21-20020a05622a175500b0042e80bbf25bmr11182003qtk.60.1709128876080; Wed, 28 Feb 2024 06:01:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709128876; cv=pass; d=google.com; s=arc-20160816; b=GCF35tZ18OzeR77egPqahroPT5OwPifqlcd7C4yHKBuxH7m70EqpJfV2v7GtbgBgzV 1P4hEn+IofMF8FrtCSkiy14P3LJ6gpU9045JHShbGsxcdvFkWoWnfuSnqId+2KUKGUMd k876TALX2H7ZH4fwki3+jqtFDHTaI94XS0NpcSbJW4UgMRzrEaMCSMWI0sjRsdbsKizP y7hgmYru6syT0aDuPHWSMGCo6EGWxX2rsxcdTAjR2dPG+dYPqRoO0YqRzn468DXuBZZb X6me9Hq2vTDE6FNjj3zC/d7rCzNV+4cz2RioEd9TtN0ZHyb3yeQVko+1JNP0K1nC2CNP uhyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=cUtsPQv9OWiN9ArQeNJbDnriB4Lb6A10DDPTYCXzFKY=; fh=pROKrtudychdWfX1/6j/Uq9afXUKMuzpYQEwL/mZsxw=; b=NLU4xYoy4B5WVWgEwTeWtjWaxLcWpzCBGd3e9nlkXBiO7H6ZJE/IJGGe0kk5rkgtIn Y6jJqaFPUcjBLBD9dd3JLtD0Cq12e+7aHyDo/waMt2Fnejm8nt0J/f9rfstfsDTyDWOL ZOlzh/JFpOJSEOZZ5c5vnEwI++MorQb/d+jY/XHTgp2ojHGQ8A6x72SqVqT4Hw4W0Lih WSexOL81lht/a1jcLGArat6uVOi7fdmNjwmnek95dX2/DJlxWVouv+l8zGpd9RGAG22e +qhJ/MaAeV4Er2Ct2iaaPwGUQjg4EfoltFVoP7PlZ/1VUVw6cTcI2ZSHyC0McbUD2kV9 G9BQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-85144-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85144-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h14-20020ac8514e000000b0042dbe70836dsi8997583qtn.489.2024.02.28.06.01.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 06:01:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85144-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-85144-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85144-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EE1391C260F2 for ; Wed, 28 Feb 2024 14:00:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63BF2157E74; Wed, 28 Feb 2024 14:00:24 +0000 (UTC) Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [195.130.137.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C557D14F9FA for ; Wed, 28 Feb 2024 14:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.89 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128823; cv=none; b=FNPHT+pIwEpEUT2930Et9dFUufl2HMx5cBDpHkLLMQO8ovXl5Qh4fAFipO+LIIozTwYRwftZAeXmBZEmi/YB+Q7Er9hvxPit012Z89IYoVUrgc6sQ1RsbnN3oIV/g0kDy5b1W7OiWICmWa2Ny0S0UFjpyzM7Gh5ZNuGuhqzU+Fo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128823; c=relaxed/simple; bh=4RDX7e5uLT6BzbyOJ79PymaRYtEzEpblMVdATSHcbSo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P8DiFeVMYAhjbkXSOZsklm895eoiJBCfKwDIVb+6cKK3WqMzlfRKkNHd5XXcI3cB7M7vliXhhaWAlF+mrYMDAhC4gsPIxYhvyvR2WsO9LbDZ905wHa/omKDFOu10e7eS5E5WCqOxvwJ9eACTYjihvtyVV+1FZJwI+79xZnxt4Go= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:48c4:26a9:d9ec:22cb]) by laurent.telenet-ops.be with bizsmtp id se072B0024gWvPH01e07C9; Wed, 28 Feb 2024 15:00:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1rfKTV-001tZB-DQ; Wed, 28 Feb 2024 15:00:07 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1rfKTe-006hlC-T9; Wed, 28 Feb 2024 15:00:06 +0100 From: Geert Uytterhoeven To: Chris Down , Petr Mladek , Greg Kroah-Hartman , Andy Shevchenko , Jessica Yu , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jason Baron , Jim Cromie , Ilya Dryomov , Xiubo Li , Jeff Layton Cc: linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/4] dev_printk: Add and use dev_no_printk() Date: Wed, 28 Feb 2024 15:00:03 +0100 Message-Id: <8583d54f1687c801c6cda8edddf2cf0344c6e883.1709127473.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When printk-indexing is enabled, each dev_printk() invocation emits a pi_entry structure. This is even true when the dev_printk() is protected by an always-false check, as is typically the case for debug messages: while the actual code to print the message is optimized out by the compiler, the pi_entry structure is still emitted. Avoid emitting pi_entry structures for unavailable dev_printk() kernel messages by: 1. Introducing a dev_no_printk() helper, mimicked after the existing no_printk() helper, which calls _dev_printk() instead of dev_printk(), 2. Replacing all "if (0) dev_printk(...)" constructs by calls to the new helper. This reduces the size of an arm64 defconfig kernel with CONFIG_PRINTK_INDEX=y by 957 KiB. Fixes: ad7d61f159db7397 ("printk: index: Add indexing support to dev_printk") Signed-off-by: Geert Uytterhoeven --- include/linux/dev_printk.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h index 6bfe70decc9fb3bc..ae80a303c216be55 100644 --- a/include/linux/dev_printk.h +++ b/include/linux/dev_printk.h @@ -129,6 +129,16 @@ void _dev_info(const struct device *dev, const char *fmt, ...) _dev_printk(level, dev, fmt, ##__VA_ARGS__); \ }) +/* + * Dummy dev_printk for disabled debugging statements to use whilst maintaining + * gcc's format checking. + */ +#define dev_no_printk(level, dev, fmt, ...) \ + ({ \ + if (0) \ + _dev_printk(level, dev, fmt, ##__VA_ARGS__); \ + }) + /* * #defines for all the dev_ macros to prefix with whatever * possible use of #define dev_fmt(fmt) ... @@ -158,10 +168,7 @@ void _dev_info(const struct device *dev, const char *fmt, ...) dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) #else #define dev_dbg(dev, fmt, ...) \ -({ \ - if (0) \ - dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ -}) + dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) #endif #ifdef CONFIG_PRINTK @@ -247,20 +254,14 @@ do { \ } while (0) #else #define dev_dbg_ratelimited(dev, fmt, ...) \ -do { \ - if (0) \ - dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ -} while (0) + dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) #endif #ifdef VERBOSE_DEBUG #define dev_vdbg dev_dbg #else #define dev_vdbg(dev, fmt, ...) \ -({ \ - if (0) \ - dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ -}) + dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) #endif /* -- 2.34.1