From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 5AE24313E31 for ; Sun, 1 Mar 2026 16:17:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772381850; cv=none; b=ABdPyXGvXga6I/8OgUfn09XiBZy/UStFZf4ypdTwavDkGK5eQBOfzqoeECpj8cqrraPu2fawz41R4wOAQwiDYXbCo6/cC3gHUxnQltCmWvUBwsXuJKBFL1ZoDvDASqQs5bUGKsw3bwt3+R5XgHZnW65BBzZHIr6Rpmi+xn2luMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772381850; c=relaxed/simple; bh=xqdDTVw/EwGn+QzPwJGCqGgnHV0i8uLIymXCYa+yyR4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P1bDJzctouIk8YXwrOsSfqmVEOI5AV3OF/7kBXQBJPUlxe/YMZ4t0GqGIOtj5CHVY/5PrZBDmJ/JR//nIk3OTqhrSY1NUb5iStZ0Ro64vJYURnCii0uLNPKCxjY6RRvF1a02NSGKxb0E5HRDANiXhmEdkx2bRlzfgKnUTu1T2wE= 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=W19f5zHi; arc=none smtp.client-ip=209.85.210.173 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="W19f5zHi" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-824a9348603so1374004b3a.2 for ; Sun, 01 Mar 2026 08:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772381849; x=1772986649; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2q4LQzRzv9NaruuYrSktCM2cTE1Cwp6g18iGWcF1kVg=; b=W19f5zHiGAT6WUTDpeKbHAq9ZYomkN9CTQ7KIqBk/i8OuW8CpHIlikDnp/TB4CFeKf Sm76uWb9deuYibrRplfHJQI3Qx/HvAUn4bM+dl2f1V/AWFyB7E59zYgS9F4nOetqL8/u z6mhyAPP8a03WLI4unSrL/9AOwckRx/0OzZS3aPC25HW4KIzKzw7XwNFutSX6aDg+NkH PkRvjAxF9OHI5s4NSHTE+4H00flZ1Rvpl1Ab90p1p/y3eUsvMq0rXlSVFIgCstne+b9I JQFYmf69UMaWhLNd9lplA2+IW01tyuMQ0pkWRWO8MwDWcw0spLbHGyfbp24jk8pbQ0Bm 78iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772381849; x=1772986649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2q4LQzRzv9NaruuYrSktCM2cTE1Cwp6g18iGWcF1kVg=; b=c1ik3cSV6faN6KwG9pazTzCesrgYfJ8RxdStQco0c2NY2b+ZHvVFlRd7gbqHvo2pdK jJ8KJzt3iP6CCntocP6zkPs/Tu7euXbo4BsnJeyD5a0yxswiah9TGi6BGA2PI9sudAzT iMae79Eh0l9+x60g0bqoMHz+x0VEBZ+sOOYVnR6vUDtrrIzP/Q8ImJGMkNclJK+eUjg5 mheoFi4rnc4xUBtTAcqd7pEnHL/Rv0Jf6QMhlo1MvDNJNnexohFsV/tn2pNiBCzL0Cn/ 3XiUGd/FlrJKeDvpVFajviobQzYtXA/jPM9T/35cm40yGSf831MYjWSorxGcwhLu2bul Figg== X-Gm-Message-State: AOJu0YxHQaDLKWsc0py4z+zrpv6tWWhJ8ngDbomQfn3aWzPjwPHh2cTt AMvhAl0xU42S9wK8oEUjtfKOGObjLn7urtUBCcFTNDd+5L6VM9RnsJop X-Gm-Gg: ATEYQzyUcu0YU5u9HbhIQZYQ4HGWoFE07qZzvI2m0tA/RQ+Sxn0eKZOVy1OGprh1NgP SbOTnKThUipHaSK1EuQi6Lal9xeDsOwoFEMWvaxCjZXoQwYw+ODQdulp8t0iSjtVAonSPHI8Uij gxqcq4lfcTn4h++cwhJk7QiGGTmQQQws43sU3j1eJnD4VLwL+oQw24aFZd5EJl/lFAsuMzaZB+E HvRGh6OaTr3jjGlRVcWNI8Nrst3TBllazM55lDxfoSs+XPCXbZ8lUTTflzZrzZAzWIDsIvDpKWX Gl5HY5wloMAMryPXxEx7SUHFneEaRNhoPBUQDsdMVpa5qJDhdX8EnXCDemjhkLuV3Pz0CfjZUto p5/7ck+OsMwDxF1iPCoV4guaCecvtC2aiePut4X6/OxXIJcNtkIS/V1j1owWuOz/TqKN7lnGyYL VwKcNnJkaHxf518MBhdcOW8nToktWo0L6zlOtDJwP87HBZIJaYDnvqqUqQk3LaZPnUGN/E X-Received: by 2002:a05:6a21:3a44:b0:395:732:2c8f with SMTP id adf61e73a8af0-395c3b16eb1mr7619251637.65.1772381848651; Sun, 01 Mar 2026 08:17:28 -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 41be03b00d2f7-c70fa61fcdesm8651456a12.11.2026.03.01.08.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2026 08:17:28 -0800 (PST) From: Sean Chang To: Andrew Lunn , Chuck Lever , David Laight , nicolas.ferre@microchip.com, claudiu.beznea@tuxon.dev, trond.myklebust@hammerspace.com, anna@kernel.org Cc: netdev@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Chang , kernel test robot Subject: [PATCH v6 1/2] sunrpc: simplify dprintk macros and cleanup redundant debug guards Date: Mon, 2 Mar 2026 00:17:08 +0800 Message-Id: <20260301161709.1365975-2-seanwascoding@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260301161709.1365975-1-seanwascoding@gmail.com> References: <20260301161709.1365975-1-seanwascoding@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When CONFIG_SUNRPC_DEBUG is disabled, the dfprintk() macros currently expand to empty do-while loops. This causes variables used solely within these calls to appear unused, triggering -Wunused-variable warnings. 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 RPC_IFDEBUG() and associated #if blocks in fs/nfsd/nfsfh.c and net/sunrpc/xprtrdma/svc_rdma_transport.c. - Remove the #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) guard around nlmdbg_cookie2a in fs/lockd/svclock.c. - Consolidate the dprintk definition to be more idiomatic. This fixes the build errors reported by the kernel test robot while improving code maintainability. Link: https://lore.kernel.org/all/69a2e269.050a0220.3a55be.003e.GAE@google.com/ Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202603010612.uRmHYMsi-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202603010852.3RKXCwyF-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202603010808.w3TtG6fC-lkp@intel.com/ Suggested-by: Andrew Lunn Suggested-by: David Laight Signed-off-by: Sean Chang --- fs/lockd/svclock.c | 2 -- fs/nfsd/nfsfh.c | 2 +- include/linux/sunrpc/debug.h | 6 ++---- net/sunrpc/xprtrdma/svc_rdma_transport.c | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 255a847ca0b6..4bac32f009f6 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -53,7 +53,6 @@ static const struct rpc_call_ops nlmsvc_grant_ops; static LIST_HEAD(nlm_blocked); static DEFINE_SPINLOCK(nlm_blocked_lock); -#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) static const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) { /* @@ -80,7 +79,6 @@ static const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) return buf; } -#endif /* * Insert a blocked lock into the global list diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index ed85dd43da18..cb3fb91d18c0 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -105,7 +105,7 @@ 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)) { - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]); + char buf[RPC_MAX_ADDRBUFLEN]; dprintk("nfsd: request from insecure port %s!\n", svc_print_addr(rqstp, buf, sizeof(buf))); return nfserr_perm; diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h index eb4bd62df319..f6f2a106eeaf 100644 --- a/include/linux/sunrpc/debug.h +++ b/include/linux/sunrpc/debug.h @@ -49,12 +49,10 @@ do { \ } \ } while (0) -# define RPC_IFDEBUG(x) x #else # define ifdebug(fac) if (0) -# define dfprintk(fac, fmt, ...) do {} while (0) -# define dfprintk_rcu(fac, fmt, ...) do {} while (0) -# define RPC_IFDEBUG(x) +# define dfprintk(fac, ...) no_printk(__VA_ARGS__) +# define dfprintk_rcu(fac, ...) no_printk(__VA_ARGS__) #endif /* diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c index 9b623849723e..ba6fe0fd387d 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c @@ -414,7 +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 = 0; - RPC_IFDEBUG(struct sockaddr *sap); + struct sockaddr *sap; listen_rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt); clear_bit(XPT_CONN, &xprt->xpt_flags); @@ -560,7 +560,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) goto errout; } -#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) dprintk("svcrdma: new connection accepted on device %s:\n", dev->name); sap = (struct sockaddr *)&newxprt->sc_cm_id->route.addr.src_addr; dprintk(" local address : %pIS:%u\n", sap, rpc_get_port(sap)); @@ -571,7 +570,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) dprintk(" rdma_rw_ctxs : %d\n", ctxts); dprintk(" max_requests : %d\n", newxprt->sc_max_requests); dprintk(" ord : %d\n", conn_param.initiator_depth); -#endif return &newxprt->sc_xprt; -- 2.34.1