Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1161908rdb; Fri, 22 Dec 2023 17:53:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGd8VE6KvyT/nuHJqefA8Lryb84Usr/3iB7ablbIdj/rjjIAaiAUnUQAnc/foBhI0lu/8Dd X-Received: by 2002:a05:6214:301e:b0:67f:440d:4876 with SMTP id ke30-20020a056214301e00b0067f440d4876mr2066097qvb.52.1703296397111; Fri, 22 Dec 2023 17:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703296397; cv=none; d=google.com; s=arc-20160816; b=Ja9BOcH6QRVc67SVqz+0x6/yaAIWPaaTW8jKhDcukkuz85FFMrk9nREOFLdza1bEiP ehIKkIv6wSERbEb2zhRhVNWTDWqsPsEK45nJSBmbSvDwY3wliBKaN+vLEthzmjjQdd3F etED55j46DBqhqpwDTXdDtR7oejGwKp1f5XipPABo3/OaMlUlRdgcqGcstLv2fH3RXFK KW4Rso0Mi6mCwJ2TYuN1HE+Zi5G/b5mS1UyejMu3DahJp5p7PVRpDFgq2yu215PMbCNl 8hd2dnBW+hWieGudpDL3W3aTTrOaCF/xcwU+peEWoqgTdPJonj9z9o8x71PeOlkYc5y+ fIEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/OrCC8hRkFVVFckIY/fWc4cxoRlnVDDBYGNc0w+EmnM=; fh=pC62+Xzu9rWxP3EwkFQHy3M37dHcdVo9RRC56IjE3s4=; b=BbiRszvckewTCWPtp8MqkQr9xP+6GZsATMsw0OhLGcBsDJ1e9htzBGZySoCkkIYW4V 3nF+jjvOrU916j1C0ZN1Q+Ps1r5xaZZ8mTKpu+3/jpotBXSMo82zCRET3AHUPMfFyKpM F4AjDntaI/YiKI65pva8HEtXs/VZU6/acRwNd42ZSU+fp8Uu1OgphroIVXcUQyv+SeNF DlhEF5jX/nofxoQUJ69eKi+3zl+qVdbYibgvOvXcQoCujxhLQ3xNzCj42tItGpAdIew5 al4lfTqOiD5Uv7PLoR9U6YYgkWgkQ2IMxq0bFGRbpFQmapaPungI2DL7OvH0VQ3C6gTc 0YtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=FQp0vGLX; spf=pass (google.com: domain of linux-kernel+bounces-10165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10165-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y7-20020a0cc547000000b0067f7061ef47si5660716qvi.320.2023.12.22.17.53.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 17:53:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=FQp0vGLX; spf=pass (google.com: domain of linux-kernel+bounces-10165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10165-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C4C101C21CAA for ; Sat, 23 Dec 2023 01:53:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DC4A8C07; Sat, 23 Dec 2023 01:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=semihalf.com header.i=@semihalf.com header.b="FQp0vGLX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 23B6C53A6 for ; Sat, 23 Dec 2023 01:51:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=semihalf.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=semihalf.com Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5543aec7440so2124996a12.1 for ; Fri, 22 Dec 2023 17:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1703296317; x=1703901117; 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=/OrCC8hRkFVVFckIY/fWc4cxoRlnVDDBYGNc0w+EmnM=; b=FQp0vGLX21rjkCaUhT2tv/FXpn1PGPF7fhD4FyLhsgDipeL7YoiBfBN4z9UARhtTDp mwo0l90Ez2KFQVfN1Lhx7XI45Ohv8v6nGFExGFllRK+QKH/ok7HGaC9QDRgoDaLqbm0D 7l6Ae1mFdweqxjWMNOc8UQ0dJNURuLuvqcKmSWjIlrCENIb5dPoeEFvKoxVhqgh1k+lJ lq7X0MvPZAI1CBnugcDttntUQsgIY6xeGgmn8k+4HoLpsSsBdUg29/cLztqjXroOCpOk hvawkV24fqHYyF/QeKsPEIju9H669G6dmT2FLl72vFxJdhHnmf3ABLx/tTpkIK4Usb7Y RqxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703296317; x=1703901117; 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=/OrCC8hRkFVVFckIY/fWc4cxoRlnVDDBYGNc0w+EmnM=; b=xG7joS06wRcDD2Y8R02rn4bQgBZtxl0/Z5IMuYa0ppQAuuPARWeYGvlmo/k1EdBNWF ifBWYw7sBmNBwgchGtxRDUQPh3eOFW35jwA0bwrt50WuF6DQMtkwFNnKvzlm5pPRMJu+ QDXPXGWq/OU0OSulpken8MKAGgD93DiMwZAIeHjai/gk8OVDqd0asyoR8Dhrkce8wnoY Ip0V/OchfznCbBrG6l8bltag4enuUIkXr6N6oyk1bqpHhgskENrpa+5p8TyvAXlwss1d lil2WAIs+n1KgxdlcCysTpsM4kPY5qHKjES64i/3gv0PyXuoLOToktHzxdZuOLLTHeKY +QxA== X-Gm-Message-State: AOJu0YxOv05AH1xA4mur3ntmtkwf0PxT1w6bMo5ZADq4KQjDtOmBOqj/ 58M03azBBs8rV0FncCWGayQpxZYiCZty X-Received: by 2002:a50:f695:0:b0:554:730b:8809 with SMTP id d21-20020a50f695000000b00554730b8809mr632294edn.9.1703296317511; Fri, 22 Dec 2023 17:51:57 -0800 (PST) Received: from ukaszb-l.semihalf.net (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id h2-20020a0564020e8200b005532a337d51sm3288494eda.44.2023.12.22.17.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 17:51:57 -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 , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v3 05/22] tracefs: add __get_str_strip_nl - RFC Date: Sat, 23 Dec 2023 02:51:14 +0100 Message-ID: <20231223015131.2836090-6-lb@semihalf.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231223015131.2836090-1-lb@semihalf.com> References: <20231223015131.2836090-1-lb@semihalf.com> 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=UTF-8 Content-Transfer-Encoding: 8bit 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 [1] 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. [1] https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@axis.com 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index c1fb1355d309..283533a17e62 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -19,6 +19,19 @@ #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 = trace_seq_buffer_ptr(p); \ + size_t len; \ + trace_seq_printf(p, "%s", __get_str(field)); \ + trace_seq_putc(p, '\0'); \ + 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.472.g3155946c3a-goog