From patchwork Wed Feb 28 14:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13575544 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 C550714F998 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=1709128825; cv=none; b=tE2qaYeyIRRuq9G+VknbLipmYq6uA6WoDVJFtXrsjbBbUzZK+5u4N47xgevVz6KWXiNvt7x6MsUElWMR6pqO7LWtR18bOQ15u0dQR7xfGqLWAlw25czn3JwPHbWWb/+w2hIeCxZ05i+REQLYQu2euEFMuztn2kC5wq3tzMOOqEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128825; c=relaxed/simple; bh=G6EOV4ZQQfHL4BuKa3yWbKTAxpwYG330vI+JSSZwK9g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mqTCSaDEL3n7ZhTZ+0qtIO/7TIwNW1M1v5LaCFQButWNqOM+/uFF0dCYnhWfgfQP2cB2389MSGtE4Iy0ZFko1IjClOSH1KI4KKk3fsc6u7n2oIXwpf5uSQ4t7gF7ycG/V5TT5CcyPZO2ZeLMZUu0x7Z0MPTvEE2rJtieD7HWRxE= 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 se072B0034gWvPH01e07CA; 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-001tZ9-DK; Wed, 28 Feb 2024 15:00:07 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1rfKTe-006hl9-S8; 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 1/4] printk: Let no_printk() use _printk() Date: Wed, 28 Feb 2024 15:00:02 +0100 Message-Id: <56cf92edccffea970e1f40a075334dd6cf5bb2a4.1709127473.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When printk-indexing is enabled, each printk() invocation emits a pi_entry structure, containing the format string and other information related to its location in the kernel sources. This is even true for no_printk(): while the actual code to print the message is optimized out by the compiler due to the always-false check, the pi_entry structure is still emitted. As the main purpose of no_printk() is to provide a helper to maintain printf()-style format checking when debugging is disabled, this leads to the inclusion in the index of lots of printk formats that cannot be emitted by the current kernel. Fix this by switching no_printk() from printk() to _printk(). This reduces the size of an arm64 defconfig kernel with CONFIG_PRINTK_INDEX=y by 576 KiB. Fixes: 337015573718b161 ("printk: Userspace format indexing support") Signed-off-by: Geert Uytterhoeven --- include/linux/printk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 8ef499ab3c1ed2ec..e4878bb58f663370 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -126,7 +126,7 @@ struct va_format { #define no_printk(fmt, ...) \ ({ \ if (0) \ - printk(fmt, ##__VA_ARGS__); \ + _printk(fmt, ##__VA_ARGS__); \ 0; \ }) From patchwork Wed Feb 28 14:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13575542 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 C5686150990 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: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 /* From patchwork Wed Feb 28 14:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13575540 Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) (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 C1F8F149DE5 for ; Wed, 28 Feb 2024 14:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128823; cv=none; b=TaWuurS1X/Vbstx/XAOUOwYtvw6nt/QEZJKfb+xw/bITIDk13gQKbpFMR5qdwSJcc1JXClAPEv9hxyQdjNKQL0sAiR9F+kwqxgbv12m6aifU+1jHooo7g0TXN2KI8Thk0knXfoxnGLfDqRPYwM/bU4h5UATVer7TYAMwCtFU04Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128823; c=relaxed/simple; bh=QsCae0o9eyN75UvvnzCtyzD7Q33sU4Xy0REKuZlqxLw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aOleBBw/qrw2Hhy5rCjUCa4Kmq/L5oFJg6R8WcYwwujEakjeg/zLluVTgwNNOCbPoj8wOLS2f0vhGbCm+wYkHChzYsHeRTyWHYVDpssObDuw9SI2kz+MypRq1Y33zHVE2hctZCJsHg+5hdPhQIgtEW8JWXpONYylaVVfy1T+NdY= 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.132.53 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 andre.telenet-ops.be with bizsmtp id se072B0074gWvPH01e07Ym; 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-001tZC-DU; Wed, 28 Feb 2024 15:00:07 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1rfKTe-006hlF-Uu; 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 3/4] dyndbg: Use *no_printk() helpers Date: Wed, 28 Feb 2024 15:00:04 +0100 Message-Id: <32e18ceb528b99d9147be9c1af578a1965e2bad9.1709127473.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When printk-indexing is enabled, each printk() or dev_printk() invocation emits a pi_entry structure. This is even true when the call is protected by an always-false check: while the actual code to print the message is optimized out by the compiler, the pi_entry structure is still emitted. Fix this by replacing "if (0) *printk(...)" constructs by calls to the corresponding *no_printk() helpers. Note that this has minimal impact, as most (all?) callers of dynamic_{pr,dev}_debug() are protected by checks for DYNAMIC_DEBUG anyway. Still, using the helpers serves as a good example to follow. Signed-off-by: Geert Uytterhoeven --- include/linux/dynamic_debug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4fcbf4d4fd0a29d1..ff44ec346162a164 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -305,9 +305,9 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define dynamic_pr_debug(fmt, ...) \ - do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_dev_dbg(dev, fmt, ...) \ - do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) + dev_no_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__) #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ groupsize, buf, len, ascii) \ do { if (0) \ From patchwork Wed Feb 28 14:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13575543 Received: from albert.telenet-ops.be (albert.telenet-ops.be [195.130.137.90]) (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 E00151509AB for ; Wed, 28 Feb 2024 14:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128824; cv=none; b=ShmYrJnJpO9+1iK4zt4AU7ruYBXWRUA0pr+yUrCE4Q4KOT5YhKkyzNNSUplRQMx7xIoycp0HjIAIp0lFJUnrVM6uoNa8NwXjw8eadAY3ojDl2/qOGzIcipoVRz7MkFE+D9WTeVx3xGwSSN3j+9lnIPIzs0RRyj6ToLao1EUdOGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128824; c=relaxed/simple; bh=D8NXY2ItVpwUES37gGIiU5wimOI8cGreVo83CtoNigw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WHMBh1Urbtd+dLmvqp/kF4AEw4I0hzrPSP41v/POv28iDsiQLzl5VWpFV1PxuWvBfDgURpGnp/se24pCFPZddOtiH4JEdORSg2YqnVu7M4TzP2neHlPtZKhyl1YGQeFL7II1YTAaoOlH2AEhcOD2SkrSpaLHMFH71si6Bw3hBjU= 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.90 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 albert.telenet-ops.be with bizsmtp id se072B0044gWvPH06e07Y7; 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-001tZG-EJ; Wed, 28 Feb 2024 15:00:07 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1rfKTe-006hlI-Vc; 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 4/4] ceph: Use no_printk() helper Date: Wed, 28 Feb 2024 15:00:05 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When printk-indexing is enabled, each printk() invocation emits a pi_entry structure. This is even true when the call is protected by an always-false check: while the actual code to print the message is optimized out by the compiler, the pi_entry structure is still emitted. Fix this by replacing "if (0) printk(...)" constructs by calls to the no_printk() helper. This reduces the size of an arm64 kernel with CONFIG_PRINTK_INDEX=y and CONFIG_CEPH_FS=y by ca. 4 KiB. Signed-off-by: Geert Uytterhoeven --- include/linux/ceph/ceph_debug.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h index 11a92a946016eab5..5f904591fa5f9e57 100644 --- a/include/linux/ceph/ceph_debug.h +++ b/include/linux/ceph/ceph_debug.h @@ -27,17 +27,13 @@ ##__VA_ARGS__) # else /* faux printk call just to see any compiler warnings. */ -# define dout(fmt, ...) do { \ - if (0) \ - printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ - } while (0) -# define doutc(client, fmt, ...) do { \ - if (0) \ - printk(KERN_DEBUG "[%pU %llu] " fmt, \ - &client->fsid, \ - client->monc.auth->global_id, \ - ##__VA_ARGS__); \ - } while (0) +# define dout(fmt, ...) \ + no_printk(KERN_DEBUG fmt, ##__VA_ARGS__) +# define doutc(client, fmt, ...) \ + no_printk(KERN_DEBUG "[%pU %llu] " fmt, \ + &client->fsid, \ + client->monc.auth->global_id, \ + ##__VA_ARGS__) # endif #else