From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 7B00B3F23B7 for ; Fri, 1 May 2026 16:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777652300; cv=none; b=QIEG2weftujyUeDLtaD4rh1wXeSuG/UTn/iWaKs5Rtbrg1QJCyk4UMTdROnssAFicuDxAk0cI8V37Zeson+2/gcAccEdksVIuTC/CDV8sfLSqZVSHTzqL6vMJx9oaI40STe+V0XRNnwY8iw0VRq5ATAnvrq8mcnP6tO1ZtVal04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777652300; c=relaxed/simple; bh=fHm5Pyi5rYT8KdARR59qs5ux4lfu67iP4VQ5zTLygx4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tHc9MR/4nuCj0d0WTzY6io9qU+nN2NgBBsslTAO9XMRGorGzPR5kU84ROYh5qbVzn/GPEPKyJ4Oyfr5HgIYoKqEqvzyTk+ngXv6w6W4FYxl2MopgtfOyx/XfzP6ogsLep/lqKIbIEKlucaa/7CcCTa5+6CJo1hl16B2UtV32XSA= 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=nXniiiqu; arc=none smtp.client-ip=209.85.214.180 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="nXniiiqu" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2b9ea536877so1633235ad.1 for ; Fri, 01 May 2026 09:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777652274; x=1778257074; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CO64OyUjm/s1GHWMBBxHpdtkBMmcP5rdEOIfDDfkOlU=; b=nXniiiquTxQzEY57CNolpVQY8CzF9eSzzvP/bXGfUiSyYesszRbW8odeB/NDCPurC6 EuOqzrDBUxIzpthPb/fEaNS61wyxr8lzO1PrN5bK6pwKF9UN4Rf2VYYIqAZaSMYxtKOT im9IwZ+Suo89Bsb491njoTXcS7OGxlO4l8D5cWxj8S60O2/SPSm21/Ao7x9caZeCc3jU qktkr71uKGfZKu9m5zcsG8ew1kkWL1y31Bga5fBgQCMLMlesA++euJ2FNqGsFt3oPrGE UoIjagL9+EE61kUmTK09UMK1q04CI89E7V0JvtEG2e2fa4Pe8wPAl//7Rx7pRx39F0On 8jmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777652274; x=1778257074; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CO64OyUjm/s1GHWMBBxHpdtkBMmcP5rdEOIfDDfkOlU=; b=f4p2LRXHyMU3uEbUFDoP0air+4x8QVFDh6I4Mp/QMXHDfgvqlpagRl3p5y4NM7uudH QsqYmogaiu0Yhkg+oW1DOygsDaR9DV9nnchAGvNDpR2j3/RJP+2SaLRlY+SOHHCYToSf uLmnx9NcXpgPtho8leEP+8fxHuQ+jeCQY95DlYqc0IN2K4RNmtbxnujdQMsbbJ2sAz40 ZVWLPVyNJHDtIpqudqQ4yW3tB05vKqn9pSM5UwZ8LINEEirdlles1Sb8kM798uUmvRm1 LI3RZtF8QBjjOfHoDofxzwSKkYC86BLBzIrB2r70XLRlxDQ8P3mtQNGq0Av8lLm52kZa uUMg== X-Forwarded-Encrypted: i=1; AFNElJ8uXiXQyif5XcdCv09uYzaVbRdJWoVuuyqt2KwZs09lN4wrQmg4DA/Svca7yUnLRp4+WroFjaPhYITVvgM=@vger.kernel.org X-Gm-Message-State: AOJu0YxLBvYwTrwiaJ7L9BufGGh7cSIdgFNLFs7Jg7bGfMOYfsN/PTIs 7PvcG/UmpnKWRe3T15F2LXmNZoMJ/wHJr5QI/xj0mkxZclUL5GhyPCffFqGnetR3 X-Gm-Gg: AeBDieuX164923IIW8qAzad32aeKxCn+udTiGJjeu3eHspaHIfPJkSOBohe28RvYmKX CY++IICAu6aXwVWZ8fSTSeAXxRc6xzjNN39jfI6/SziZiluk3m9nuc8pBbK07SwW9SBTY0iTZ44 6cgMt3rTRLl9XAIy7STP8YPHziHaEADr2X2OJbEIbr4tI2clMhwz9VBoCRX7BVz1pzJ/eS46Vgu yKQ36YYrsX/XWVSYryFy94SZVmxOVbxZcKQVGyKqtOH68RB5wvPDsmyZV1Bevebua4lj/zA5uWm gun3OXEcezpsDSJU01p9cgcCvpVITSpqCcP1xiyrrJfKr5idJ/y/O6QcCGkAgTSkgpsz+HJZ9m/ STAdi6bWdfp4BL57TkzaH9ySkad+TXxTMUURGjWFJDTumsV/VGSD1IcxGYUk5FF4l9rr2zGyCNv vIW3qHD7EfEnugLjJ1V55zXJJ7msX84m506gz27N4I X-Received: by 2002:a17:902:e746:b0:2b2:9a70:3f0a with SMTP id d9443c01a7336-2b9f1cc33bemr1177405ad.4.1777652273764; Fri, 01 May 2026 09:17:53 -0700 (PDT) Received: from nova ([134.208.63.146]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9caa7ee38sm25974855ad.16.2026.05.01.09.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 09:17:53 -0700 (PDT) Date: Sat, 2 May 2026 00:17:50 +0800 From: Qian-Yu Lin To: Steven Rostedt Cc: mhiramat@kernel.org, david.laight.linux@gmail.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH] trace_printk: replace _______STR with __UNIQUE_ID(STR) Message-ID: References: <20260429165707.7020-1-tiffany019230@gmail.com> <20260429134226.49e95e9d@robin> <20260501111939.0536140a@gandalf.local.home> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260501111939.0536140a@gandalf.local.home> On Fri, May 01, 2026 at 11:19:39AM -0400, Steven Rostedt wrote: > On Fri, 1 May 2026 22:40:17 +0800 > Qian-Yu Lin wrote: > > > I propose using a compound literal in v2, which eliminates the local > > variable entirely and requires no extra include: > > > > #define trace_printk(fmt, ...) \ > > do { \ > > if (sizeof((char[]) \ > > {__stringify((__VA_ARGS__))}) > 3) \ > > do_trace_printk(fmt, ##__VA_ARGS__); \ > > else \ > > trace_puts(fmt); \ > > } while (0) > > > > This fully eliminates the shadowing risk without any compile overhead. > > Have you tested to make sure a string with no arguments still produces the > trace_puts() and one that has arguments calls do_trace_printk()? > > I'm fine with that one if it still works. > > -- Steve Yes, I verified it with the preprocessor output. I created a minimal test file: // kernel/trace/test_trace_printk.c #include void test(void) { trace_printk("no args\n"); trace_printk("with arg %d\n", 42); } Then ran make kernel/trace/test_trace_printk.i. The no-args case has sizeof((char[]){"()"}) which is 3, so 3 > 3 is false and it falls through to trace_bputs/trace_puts. The args case has sizeof((char[]){"(42)"}) which is 5, so 5 > 3 is true and it goes to trace_bprintk/trace_printk with the argument 42 correctly passed through. Qian-Yu