From patchwork Sat Feb 10 23:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700575dyd; Sat, 10 Feb 2024 15:52:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtRMjEzjw01GxeSujM3nyy1s0y0wCCtABiOfl//JAGfsbIJ/j6KURSLBnBt8bVOeIBtvFP X-Received: by 2002:a05:6358:7303:b0:176:805d:4f1e with SMTP id d3-20020a056358730300b00176805d4f1emr5460623rwg.12.1707609128160; Sat, 10 Feb 2024 15:52:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609128; cv=pass; d=google.com; s=arc-20160816; b=C6tosW93OJIYahOc+irSkcQILrfa6UN7CQKV6eCtcIWbQSk5yQgk2VxFnifoSxYVF4 NJtgws9tu2gl5O4iKbsYdiw+bXQC2xV/jLYqYymPZU2S9oe3z0Je57jG9bwtH68RowHE w4cAFNhdIGxVRVMwErSM0akGAGMkOiCwTGjHlvcG7jVQ08e9d9tAjLyF3bHIzQLWwTSh YMbsgdGc1UBaDUTSq4jz8N10qnfgenum921GtDsjKm0BUhombuwV29YV3trw8ww4BsMm gDALaOx0Buvoiab16fbdlImuYdsroDxYnPN05/9OoZHE7chtrYlkfUqKd+KLWi1b1ilg BlWg== ARC-Message-Signature: i=2; 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=mJESVK7kHt1+7K3a2iTQplxRuP50hVTmiKkfD52o08Q=; fh=5HWISSTTRUm3AP/VLqYGMr62q7HvbZEebRSUnvInYfE=; b=g+PdfaZuk/H5roRaPxRCe5ony3ZRs/e19rd/X4AoJS4HvGFvq061h22iriWOrsw3+W EXhp1O4c4FSOHGTmF29wASzhBNuWSzx8fi3k748pz2NdeKODG+4H1Ss4AtsKe9WIP23x xvpb4B9Rw8CbpXxOeUI18Y9hQDSdIE7rHjuTZWYJI6yKOLsi/n9MU9Onx3S8masJNLko 3ZDE3UdVHsWz2BmEg4CdiECfyOeLkkLbl20inywQ5UedLpf9LYOPn4bWrnHX3LgNN1qr Qk8fiO+EsbV0okz7CSG5GquzaEqjGOzbUmT2zEvPoVAXjN7d/0qxXkScm2dRMlfQNUTw 4o3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y4WEghAA; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCXgAYBdWRkF1VXeqdh9QoOe6LopErsGGxMwC06bQcW0Bilq1ZF5OrC4eRus5VrBBDPsyg50Fx59171JtePCvEOkPVk0cQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id me13-20020a17090b17cd00b00297185aa548si1724937pjb.11.2024.02.10.15.52.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y4WEghAA; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2DF2AB22C20 for ; Sat, 10 Feb 2024 23:52:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D971C605DB; Sat, 10 Feb 2024 23:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Y4WEghAA" Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 C5134604BA for ; Sat, 10 Feb 2024 23:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609041; cv=none; b=LSKijHIvSL9sRHxA3yRfCHVeVgKOOnXrDnROU2QSzMFo1qzDFJjLWFi8qz1UFI6hE7iCLqBmFZFauczpUjoxdJBLyiVyTknHOSCdSftTM71pGLpSZKik5rM2yT4w2Zjdel2ESLiqc7k/bc+MthUmKJha5nZ0DRTnOcH8KOpdEa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609041; c=relaxed/simple; bh=CEm2u5oLoANuCFcHRqanlvBhrRP8jePFysyGpg9GOkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HAN72GXPh8p4wXJO/tCId7gaUUSkdDXY5m1+yEETYsZ0+vhIwbji5xmDIEEqwXG1GsyhAJq7mC5mvoDdU70JN63Ac+SoG/+M+Cb2e0ECH42jr5enc6xhFCpHNiko3OQ7ancyYGVBuY4L89WUajxj4/OTcgLBGdYF4Ax1DAD2cmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Y4WEghAA; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2cf206e4d56so27700721fa.3 for ; Sat, 10 Feb 2024 15:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609038; x=1708213838; 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=mJESVK7kHt1+7K3a2iTQplxRuP50hVTmiKkfD52o08Q=; b=Y4WEghAAak9V/nq8V6yn3g7oTyKN08K8z0dIfkXqNLLvBcvGFXfcT/sj/sNZPEfXLM XB++GTxyxfozCOZDd/c015p6Vd2RnGxpP8iIleU7PRsZVDuMOxjtjYNP0TVL61GFwc9F 2szYnYg353BjDU/jlik+iFQCO/Qmh+t0IGbp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609038; x=1708213838; 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=mJESVK7kHt1+7K3a2iTQplxRuP50hVTmiKkfD52o08Q=; b=sYO8YYmm5iP7xjJb62eDdgNXsrwGAzlTxWQSIAmkQLfqy7140iP30jg2Db4Uz3N7F2 38pEc80t24wlI272AF7J91T5lzQZHEjQ9o/mqsRIaTz4+0wvnzlDy6S/csCpTOmx9IaR 4Q8aBrcWAnTQnd6vUXNys747qsuhgX8vpZOyMkp8idgo9PDO26dX+LD7V7L+3A8ub4nv ptwtp9sye0FHly7Yak9U1H/ZIY8NfuaPIYjtm4AN7FVYRgRV87y0pwzwXv9PFrlDsD7t rCJ5kSVI9naHmLi3nTbqHZLjTDOykTrwoBoIUE2v6nfT7Eq4JHRdGni76PeWNQRf2t0C SaGA== X-Gm-Message-State: AOJu0YzayMRy9glTYTFXLHQ91pOZqdLfElp/U3vQ6mtVnQs4nonyamnj 9GRPsi5ZC3HpBxbJkv3VX7ewNCtXqle2PLf38XHkZ3SSEofdd5j1Tojb+w0f X-Received: by 2002:a19:5209:0:b0:511:79ce:f325 with SMTP id m9-20020a195209000000b0051179cef325mr1576643lfb.31.1707609037846; Sat, 10 Feb 2024 15:50:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUnU0vsLxtkUbNcbT7Arujl/3sW/7tv/nm0MPyXW+L7RPEIemfAuiboHfYHpEovp6knESiGxQUDU7oHl8LWX9pfg+l7apXoAhYfShXHF8Css4OirBKnTd45MkuwevTRvvYnhagwTL352TxZSsevQINxiKhl/RiYLxg3EKRfZ7hPhvPBmccMe4UaF9Bbfdqk08mZAooteiCTjxLnBAF+WEq1XObEZnP3IUxdxOpfIifIz3Pem0rup4v8FtNPxQEOqeaoLIYfR3ikAJP9osWhkzcvtqyWEq/MqwA3rcbP8VA7McIrEzPdC7jfnVK72jCYbgETxgAoC+h3RMDNj9lq8HyDduu0RwMvf58pqmBKHrWgoIvg7FbWEaXvfvB3OdwnJxVo4LlT7m1+p0PFFE7kKrfV0of7lofCYt5a84Otgo7Rq+vVFgNxVz1KBCDWWzzlO32YYmS9GFZgkA5G0MNsEd9AqLTXnuZgbpUal3ZcchxxOvqlkWk5Xg9akEHpNOvm+wHu05y95HpNsuX3NfHR9k4K+BtTlkrmneNQiJH5oKfR39i0WDGK6ufjp3rVZW+G1raw5f79vk/39tiYr7gSaiWsmkvlKlMwJ+QmHuP9nV5e/2fA5w== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:37 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , 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 v4 05/39] tracefs: add __get_str_strip_nl Date: Sun, 11 Feb 2024 00:49:35 +0100 Message-ID: <20240210235009.2405808-6-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557949017994644 X-GMAIL-MSGID: 1790557949017994644 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 -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; ), We can avoid trimming the last \n during write into the tracebuf, by instead stripping it when reading the tracebuf. So do that. [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 Co-developed-by: Łukasz Bartosik 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 + \