Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp680345rdb; Thu, 30 Nov 2023 15:42:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZReXdbdBYcYUizNEsBtkck/OBa587cPLwDRXSPY4iyQGV0GZlrfGWYkGSzmzF2Zui56Y5 X-Received: by 2002:a05:6e02:11af:b0:35c:ae0c:b28e with SMTP id 15-20020a056e0211af00b0035cae0cb28emr15056152ilj.9.1701387737451; Thu, 30 Nov 2023 15:42:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701387737; cv=none; d=google.com; s=arc-20160816; b=SvgQM5I4C/xhRK7BIBGMuphvjToxWH3hRRleBSW+epFIXvhWdwtf5EE2DNZpgM9F0k aWTBdSCtMMGWPOsJmHbcFCn5tXjpolrk+qEcLQf5nys/bqEvMTWaF3JtRnVoeAV6KjIv rHsKzA2UmUWvh/IoIJL2aFt2e0QIUCARNX5f02gfHeyb3D3JRJdhd49JZ5HkrtrN/OxU SCV2o6hP+5T+Eg7NfokLhjcoqipeMSlyvZpm43JvnkGWKglgeLfYk924ZB0uSjVNeKyI X0KSS5N5amF3xNM+2hJk1VIpq0gnQJ3Qm6bwxoud5nsXxZ6T7teRtJ/vBnCC8Cz8ufVj MtgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uUSou8Y9ftMqf1PK2crHmzfoy35Q5/lR0Dintg0xKiY=; fh=5X0fEA3It33/1XqHVj0tI6QuGyiCqQhl/WLywB0KI8k=; b=N9a3y5b73h41NUHKglGOFyT4WyfSvHozYSypoTjlFne2ksUc1Jork3BHXVCgdJOPxS yYDHGd6VmNsCAJKEbhhNG2uXZo0nyoIsDkQNeybDIzxJpsoOo6ZkE4WvV4Ym2bRJLGvj FygsFGiOJfyudhuRbVbCqc6ogz3otVG/TjV1yDdFQ6koGJdE2dtm394xvQYTfpSAmzvH ObzPsD+GdDHbT5lWhXC5vMsPs4IbmsDrT1p/QqTDMF6LTmIpvIbkWW+zrx1vDGBjPj1C LOLGSfA+w4w/bWrm2rR6zetHP9kG4/OK8WRaWv5+qBkzBy+4KzdeHsn9WCxQaNMnuQCS GM8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=Ee9srPmw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id 205-20020a6302d6000000b005bdd7cadb98si2255977pgc.54.2023.11.30.15.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 15:42:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=Ee9srPmw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 44A7285BF2CD; Thu, 30 Nov 2023 15:42:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377379AbjK3Xla (ORCPT + 99 others); Thu, 30 Nov 2023 18:41:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377348AbjK3Xl0 (ORCPT ); Thu, 30 Nov 2023 18:41:26 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7521010E4 for ; Thu, 30 Nov 2023 15:41:32 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9fa2714e828so214648566b.1 for ; Thu, 30 Nov 2023 15:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1701387691; x=1701992491; 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=uUSou8Y9ftMqf1PK2crHmzfoy35Q5/lR0Dintg0xKiY=; b=Ee9srPmwlV6fdxvXNR5bmxtguX+6J3llt1jRsWEJbiO0cRjkdzIpYcx0Gl2vrkPWGT xQ8L6rVgS/z1r647hniawq3ZIPhYt8Rz4iYyudFBYSG3qVemPr/ejK2hjLVlFX1AvXax y6/IPqTZHeCN1RvZZcdNfGnmzY92PFPIDXhnyHPu8K1AWaEvjD/+vCNSfRsfjZhxMVeN 9OWsTReahmWLDufof35Dzr23HYAEwZYb6bNX78DL8yWNRGOTLJqIZ+HE/eivwfNU0IoV shxAJwe6v/Uh63efCHvascVqLUs5fOneJi6EuoG0OAilAdcdfnIIBqTl0SYR2xeIYuJo /07A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701387691; x=1701992491; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uUSou8Y9ftMqf1PK2crHmzfoy35Q5/lR0Dintg0xKiY=; b=fzsgoEVEMfgFTIsUB5kGHJAzP34gyGZo6cgauRMFsgO9FFSA3PX6f6BBsH/gpeUAhQ ZXhWUsrnjaace2Ehb1pjHkLHJ0ZxumW4CyGCBfFNTPCZ5qg9SRFOMCSMT5n3QJoCUYpo 9hmNpOVjp4ssPaibofnCgKSNt62HhfUlOIPeomUd8VwAMtFcLx+em6VggkPlzmW1JKAH hma72Oewf2KS72Nddps5Upws6eows5WUgms0cD7JGZXwfiP8pz0rxBcITsXS92ILsTNo 76lCyx4qiBFSik6tKThSMjuuGgGY3DvBAGnpU+20WBMfkZakBX0J5Vcvxv24Vtv41hFm aQ0w== X-Gm-Message-State: AOJu0YwyvzZYxYd+W9qaFxsl2aHPoZ6ToqwWmIMGBsvsE49GdcuXmbL0 /xybarUw19ONDFBZtVUDA8zu X-Received: by 2002:a17:906:10ca:b0:a19:a19b:55f4 with SMTP id v10-20020a17090610ca00b00a19a19b55f4mr217903ejv.132.1701387691072; Thu, 30 Nov 2023 15:41:31 -0800 (PST) Received: from ukaszb-l.semihalf.net (public-gprs368940.centertel.pl. [37.47.72.109]) by smtp.gmail.com with ESMTPSA id 9-20020a170906100900b009ddaf5ebb6fsm1210175ejm.177.2023.11.30.15.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 15:41:30 -0800 (PST) From: =?UTF-8?q?=C5=81ukasz=20Bartosik?= To: Jason Baron , Jim Cromie , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , linux-kernel@vger.kernel.org, upstream@semihalf.com, pmladek@suse.com, sergey.senozhatsky@gmail.com, john.ogness@linutronix.de, Simon Ser Subject: [PATCH v2 05/15] tracefs: add __get_str_strip_nl - RFC Date: Fri, 1 Dec 2023 00:40:38 +0100 Message-ID: <20231130234048.157509-6-lb@semihalf.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130234048.157509-1-lb@semihalf.com> References: <20231130234048.157509-1-lb@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 30 Nov 2023 15:42:12 -0800 (PST) From: Jim Cromie This variant of __get_str() removes the trailing newline. It is for use by printk/debug-ish events which already have a trailing newline. It is here to support: https://lore.kernel.org/lkml/ 20200825153338.17061-1-vincent.whitchurch@axis.com/ which taught dyndbg to send pr_debug() msgs to tracefs, via -x/T flag. It "reused" the include/trace/events/printk.h console event, which does the following: TP_fast_assign( /* * Each trace entry is printed in a new line. * If the msg finishes with '\n', cut it off * to avoid blank lines in the trace. */ if (len > 0 && (msg[len-1] == '\n')) len -= 1; memcpy(__get_str(s), msg, len); __get_str(s)[len] = 0; ), That trim work could be avoided, *if* all pr_debug() callers are known to have no '\n' to strip. While that's not true for *all* callsites, it is 99+% true for DRM.debug callsites, and can be made true for some subsets of prdbg/dyndbg callsites. WANTED: macros to validate that a literal format-str has or doesn't have a trailing newline, or to provide or trim trailing newline(s?). Should be usable in TP_printk* defns, for use in new event defns. Cc: Cc: Vincent Whitchurch Cc: Cc: Cc: Cc: Cc: Simon Ser Cc: Sean Paul Signed-off-by: Jim Cromie Signed-off-by: Ɓukasz Bartosik --- include/trace/stages/stage3_trace_output.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index c1fb1355d309..92a79bd5c0cd 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -19,6 +19,15 @@ #undef __get_str #define __get_str(field) ((char *)__get_dynamic_array(field)) +#undef __get_str_strip_nl +#define __get_str_strip_nl(field) \ + ({ \ + char *s = __get_str(field); \ + size_t len = strlen(s); \ + if (len && s[len-1] == '\n') \ + s[len-1] = '\0'; s; \ + }) + #undef __get_rel_dynamic_array #define __get_rel_dynamic_array(field) \ ((void *)__entry + \ -- 2.43.0.rc2.451.g8631bc7472-goog