From nobody Thu Apr 9 13:22:32 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 DDD792F5491 for ; Mon, 2 Mar 2026 16:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772468314; cv=none; b=dY81ULFQX0DkNIgzXYfjYANfQhamnUEFiM7Eigh+gVEJilGgh2BuVAjps0jGGUUr4+Cq2mBN7ZDlOeoB8haOdcqic2lY8bypUTecOV7CSmqVGeoii9hhAx00t/BEcfRFxfihWpvErxZ6+rB9SDvsmig4WrRlay/kIasGQot/uWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772468314; c=relaxed/simple; bh=3RyZw1J33eIoZOy7izeY54Rk6a6ye5Bzt8iY6XpOGr0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=RmMlcapmjpe1YaDh/hHWa8yKdpZXZvi5kofk2h0d2zDDXw0gU2zcBH+HsLpMDnP6jVsCAl2cqLuzVb6IOOkBUF5TkynXoY4OoEhLl1nD86ZuPcdmm2s9+XtFHla3y5jKpq3gx8Tws/pHw/Jr/DuA1xKqYKOYuyuvbYCkC7tLtBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ozvc3BXp; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ozvc3BXp" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-827390e8a3cso3004897b3a.0 for ; Mon, 02 Mar 2026 08:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772468312; x=1773073112; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/n5FdJUguFV7iKwaO9oDyh+DvXwYdzvA1C7E2VBJBfk=; b=Ozvc3BXpneokbe6KbtH45nsGIvPWtKkHwO58Jadeqi7vTgvLiiUVIM1tBqHx8ALq8A WJzrUjB5m51087G5bHlg5+M/EVwikeO5GTrKwJdxPA+Jd9Tq6p+FUkepSUJmympBcljK tqNBkzBikJccfFJxpJ/EuaQyXZ9Lwg9EwdGbxFnOAqD7+troZZiyakacAT0BddIbJNaI NtXlCX5tzercuTT5/HsUQ7ZP+CNEIyamE71xPxjJzvTWpq5VhXXrHsCpRtiBR/sUIWn5 IvVLVvWU4TbfU6sHLY0YEWODlA1G8HMt9CYy3xnna3WQKVE2LBuQKSKyP73Ynp3Y+esM qpMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772468312; x=1773073112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/n5FdJUguFV7iKwaO9oDyh+DvXwYdzvA1C7E2VBJBfk=; b=O7ayhp+zZQWH+fEm1kMs63YarJHBKymjXbi63uIk/bswAeXIRbmx/LXgpv7kQv3B1f +2B9VM1CDc+RkHK2riBLFPrOzwS4PtGzWn3hrPTVWEso7Q4Sw2zP89c01D6ZHiUhP6c8 97yc6I6NA+Njyy7lnBrnGUn/NRmJ2AOZ82R6U4/H2YlYOWzxzbSGow/8EW9nvemmVzMP fhbZ1l+IDcTgWv9AaRS6cVAyXqwZbyK1xDC55uPWeyRrCZslrwcZgISz+0pmFPT8CV4z uGJ2wNRyY6X4vEuaqsMPg4EHe8QBjsfIFJI1Oycd+BbzCFsGGTNEEVsYjmUMZq1U2z5I vdnA== X-Forwarded-Encrypted: i=1; AJvYcCXbb1jPwOO48zl23l3X/vi7xoJWakaqyZl70PkYizOkycs4oWA4UmBhAXtAAgs9Zc644+81aWl6MdMYlK8=@vger.kernel.org X-Gm-Message-State: AOJu0YwI56o0SzKYrW8I5wZZr34tEjOyGw+KpWACZODE0cl6cFh4DIZV fvgt+1R8wmX9ggPjgd6f9S7xjP+yfqhDXxd8w54C8hq7jtcCzNXW0UWB754uHw== X-Gm-Gg: ATEYQzyTb6EbMSWsI+i82WMaX1/eHVRG/b9cYO6z4Wv0yyNRuF/h4hXnsYvqQFHPXY/ 5HHWtda8qQq6YJgxuEVar+yYUKFcpx7cwlI5w/zB47xXmEmpnpYdc/xAJpVf5fnLUY16aGxMA/R gHCBbSIEC3BCddV0qxeVG1FUjt9AgQl56v6fSk13l/cgpPmzVDo0xizJ71ZPhbWVmXi1cR/ybFm pVi+Mm2gAVzWsAV7AJQtLsaK+/Hh4SQ9n4HKc7bQhWm6NQSUl2I37rNRqI+WI5zOBaTyHHeAt/C Ts/sGuwBV6p4V5QbdQiUNYuVXwS9TRKX9D7A2uNaTY//jYwTe7fbXcN4hTiibXP6hs4Jc4hfnKO 2uRvaKhzSLvQJ53BmX0XSDDWrKp3P2hfT8ybzVPMBh4uDYBdwy+sfT4R344jLQap7vUMkgEivr9 xBprBd5QILUW7zcxmBNE28NNJxeGYHvqB9EoZFBVe0q+Zp6YgLjwdzpO7gYE7oIYeFE72/ X-Received: by 2002:a05:6a21:594:b0:394:6440:c13 with SMTP id adf61e73a8af0-395c476ef25mr11709902637.29.1772468312103; Mon, 02 Mar 2026 08:18:32 -0800 (PST) Received: from sean-All-Series.. (1-160-230-14.dynamic-ip.hinet.net. [1.160.230.14]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2adfb69fa5asm147567775ad.60.2026.03.02.08.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 08:18:31 -0800 (PST) From: Sean Chang To: Andrew Lunn , Chuck Lever , David Laight , Anna Schumaker , Andy Shevchenko Cc: netdev@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Chang Subject: [PATCH] sunrpc: simplify dprintk macros and cleanup redundant debug guards Date: Tue, 3 Mar 2026 00:18:18 +0800 Message-Id: <20260302161818.63651-1-seanwascoding@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Following David Laight's suggestion, simplify the macro definitions by removing the unnecessary 'fmt' argument and using no_printk(__VA_ARGS__) directly. This ensures the compiler performs type checking and "sees" the variables, silencing the warnings without emitting any code. Verification with .lst files under -O2 confirms that the compiler successfully performs "dead code elimination". Even when variables (like char buf[] in nfsfh.c) or static helper functions (like nlmdbg_cookie2a in svclock.c) are declared without #ifdef, they are completely optimized out (no stack allocation, no symbol references in the final executable) as they are only referenced within no_printk(). This allows for significant cleanup: - Remove redundant #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) from fs/nfsd/nfsfh.c and net/sunrpc/xprtrdma/svc_rdma_transport.c - Remove the #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) guard around nlmdbg_cookie2a and stub function in fs/lockd/svclock.c - Consolidate the dprintk definition to be more idiomatic. Suggested-by: Andrew Lunn Suggested-by: David Laight Signed-off-by: Sean Chang --- fs/lockd/svclock.c | 7 ------- fs/nfsd/nfsfh.c | 8 +++----- include/linux/sunrpc/debug.h | 8 ++------ net/sunrpc/xprtrdma/svc_rdma_transport.c | 25 +++++++++++------------- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index ee23f5802af1..9b978a087b3c 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -47,7 +47,6 @@ static const struct rpc_call_ops nlmsvc_grant_ops; static LIST_HEAD(nlm_blocked); static DEFINE_SPINLOCK(nlm_blocked_lock); =20 -#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) static const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) { /* @@ -74,12 +73,6 @@ static const char *nlmdbg_cookie2a(const struct nlm_cook= ie *cookie) =20 return buf; } -#else -static inline const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) -{ - return "???"; -} -#endif =20 /* * Insert a blocked lock into the global list diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 68b629fbaaeb..91514326d1b4 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -105,12 +105,10 @@ static __be32 nfsd_setuser_and_check_port(struct svc_= rqst *rqstp, { /* Check if the request originated from a secure port. */ if (rqstp && !nfsd_originating_port_ok(rqstp, cred, exp)) { - if (IS_ENABLED(CONFIG_SUNRPC_DEBUG)) { - char buf[RPC_MAX_ADDRBUFLEN]; + char buf[RPC_MAX_ADDRBUFLEN]; =20 - dprintk("nfsd: request from insecure port %s!\n", - svc_print_addr(rqstp, buf, sizeof(buf))); - } + dprintk("nfsd: request from insecure port %s!\n", + svc_print_addr(rqstp, buf, sizeof(buf))); return nfserr_perm; } =20 diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h index ab61bed2f7af..f6f2a106eeaf 100644 --- a/include/linux/sunrpc/debug.h +++ b/include/linux/sunrpc/debug.h @@ -38,8 +38,6 @@ extern unsigned int nlm_debug; do { \ ifdebug(fac) \ __sunrpc_printk(fmt, ##__VA_ARGS__); \ - else \ - no_printk(fmt, ##__VA_ARGS__); \ } while (0) =20 # define dfprintk_rcu(fac, fmt, ...) \ @@ -48,15 +46,13 @@ do { \ rcu_read_lock(); \ __sunrpc_printk(fmt, ##__VA_ARGS__); \ rcu_read_unlock(); \ - } else { \ - no_printk(fmt, ##__VA_ARGS__); \ } \ } while (0) =20 #else # define ifdebug(fac) if (0) -# define dfprintk(fac, fmt, ...) no_printk(fmt, ##__VA_ARGS__) -# define dfprintk_rcu(fac, fmt, ...) no_printk(fmt, ##__VA_ARGS__) +# define dfprintk(fac, ...) no_printk(__VA_ARGS__) +# define dfprintk_rcu(fac, ...) no_printk(__VA_ARGS__) #endif =20 /* diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma= /svc_rdma_transport.c index f2d72181a6fe..ba6fe0fd387d 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c @@ -414,6 +414,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt= *xprt) struct ib_qp_init_attr qp_attr; struct ib_device *dev; int ret =3D 0; + struct sockaddr *sap; =20 listen_rdma =3D container_of(xprt, struct svcxprt_rdma, sc_xprt); clear_bit(XPT_CONN, &xprt->xpt_flags); @@ -559,20 +560,16 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xp= rt *xprt) goto errout; } =20 - if (IS_ENABLED(CONFIG_SUNRPC_DEBUG)) { - struct sockaddr *sap; - - dprintk("svcrdma: new connection accepted on device %s:\n", dev->name); - sap =3D (struct sockaddr *)&newxprt->sc_cm_id->route.addr.src_addr; - dprintk(" local address : %pIS:%u\n", sap, rpc_get_port(sap)); - sap =3D (struct sockaddr *)&newxprt->sc_cm_id->route.addr.dst_addr; - dprintk(" remote address : %pIS:%u\n", sap, rpc_get_port(sap)); - dprintk(" max_sge : %d\n", newxprt->sc_max_send_sges); - dprintk(" sq_depth : %d\n", newxprt->sc_sq_depth); - dprintk(" rdma_rw_ctxs : %d\n", ctxts); - dprintk(" max_requests : %d\n", newxprt->sc_max_requests); - dprintk(" ord : %d\n", conn_param.initiator_depth); - } + dprintk("svcrdma: new connection accepted on device %s:\n", dev->name); + sap =3D (struct sockaddr *)&newxprt->sc_cm_id->route.addr.src_addr; + dprintk(" local address : %pIS:%u\n", sap, rpc_get_port(sap)); + sap =3D (struct sockaddr *)&newxprt->sc_cm_id->route.addr.dst_addr; + dprintk(" remote address : %pIS:%u\n", sap, rpc_get_port(sap)); + dprintk(" max_sge : %d\n", newxprt->sc_max_send_sges); + dprintk(" sq_depth : %d\n", newxprt->sc_sq_depth); + dprintk(" rdma_rw_ctxs : %d\n", ctxts); + dprintk(" max_requests : %d\n", newxprt->sc_max_requests); + dprintk(" ord : %d\n", conn_param.initiator_depth); =20 return &newxprt->sc_xprt; =20 --=20 2.34.1