From patchwork Sat Feb 10 23:49:36 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: 199330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700638dyd; Sat, 10 Feb 2024 15:52:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXDxevyyDXoi3xqcmWoHp5kHBXFDCHWLrGAvE5BtDjIlZuPxumIKl+CgNd0VRDBYmIj0x5zciquT6kwdVScV8DlQJahmg== X-Google-Smtp-Source: AGHT+IGrH8Ox/HGT7zxow6bWivYfTGbregIdk2Y0kECO2Ig8YVryPr9T8ShIJc4FWJlYuWW73YuB X-Received: by 2002:ae9:e30d:0:b0:785:c28b:d86c with SMTP id v13-20020ae9e30d000000b00785c28bd86cmr2964868qkf.66.1707609143067; Sat, 10 Feb 2024 15:52:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609143; cv=pass; d=google.com; s=arc-20160816; b=L5L++xqihtwGrCXs1dqP8jpW6MHWP+Ud/zoOw+8Nx1A2jqk3t+1ugNqYKRDHV8RL1B LAZX0Ku2hb8wAByURQOsZVLT3Fa5DN/D352bOLJyX9Ftv9+Y35yxQxbLgK0E6ynDhgnq O1/tDBfq0xTbs9AsBzcQf9kgWzXiCgD+WJguXlrQx0O34jsuWlBLZquzV9L+yw7H9WLr /cmW0G4iAMcgCwoc8ODHy87BxOYEajcNSgvfXBDXONhGpNAkF+OGl+e0Ch3qbxEB83kW 7WH6E7m8oOtgbtGkA+DvlLWBH/7EhlW6xbBlsd1Dmoh71UWUWvLlyCUnnFKMlte4MB+2 xjdQ== 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=x00D6P9yOyMiqD2q0GliLWT+bL7NY08ZLZWAqgBxEXY=; fh=gjCU2zwcHunl4tLk63pYjYbzQSp/h/fibU8jDf0sL68=; b=Pw2iaAjDv7q9Q+aptF7PUE4VFUGPzw0d8uaj3qWtM/YBfyDNN5KgvxLHLtodop/Ewu M3vPFbSq28sNz1aTU9Psmb/H6cVXBFMKApqKxXML8qs10FJyD21wTLhDxI9nVGHCAS/E oruSltN9X+lvakDBqvXKHjVdZGFOWSfrG/QZ0roF0EgY3KRj6Zt33oSGAGVZaPET2H7W GxZCgXqnEDhWQ3cjzKD4UCC7gqdxPEcKaptN3ovxES5eXt9Bp4/Wza0te1BNJ35yt9uu nyed3xiP5Fcr7/4aCq+f65g+nf2ucQvMkZxyCA0PwVJzDhmrP1m+wP7jOgaWSrwH9/Te 2lig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bsh7dshm; 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-60589-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUVyC7bPga8pPL0fnBbtup2VqMNnGtEFrenoaGE6ap5zgF11ky9M3BEJ1n04A+Tg52trcTZ1QBjNniGvK9/6+xQ4WenQw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wa6-20020a05620a4d0600b007838dfec439si2816840qkn.297.2024.02.10.15.52.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bsh7dshm; 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-60589-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60589-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C91041C2150D for ; Sat, 10 Feb 2024 23:52:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7612B60882; Sat, 10 Feb 2024 23:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bsh7dshm" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 4E3A2604CF for ; Sat, 10 Feb 2024 23:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609043; cv=none; b=GdjCXyRoaRb1vGoIiPqtvVihtX7rjgelrwmCCU9d0+cvQFmA7ytUDy/nN4ShY43L0jcrR2h/NmHtIvQSpiwf2ipKGOIDmGQWLnghiVm7MbnOimZaQ6g5GxD4zjjFMA9eHW734tVdqkxhVWa8Xu4erb16NWF0d4rS+wYYV736IeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609043; c=relaxed/simple; bh=bAccrTv3hmSTu7zPzthT8nvQoJH35PHedf4O6GRUW3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SSMDGoadZs8delhvMPz/avxJa38vUERmdewpEqiKDMdBahB158CZ4wPh9i1/kUSI0fKdRmIWki0SRb/Nh0XWhjewaR2tiebNyI2MBviDRjh3p8BHke6a7dVadhty6m/hJiHPCQYnaDZ0vu4jOMufF6YNm6h29sZ7k+otC1bzSnk= 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=bsh7dshm; arc=none smtp.client-ip=209.85.167.44 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-lf1-f44.google.com with SMTP id 2adb3069b0e04-5114b2b3b73so2506813e87.0 for ; Sat, 10 Feb 2024 15:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609039; x=1708213839; 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=x00D6P9yOyMiqD2q0GliLWT+bL7NY08ZLZWAqgBxEXY=; b=bsh7dshm4K0Nbe5N2eBL91tg68F66TZi0f/LIzUQjQN5r8FOXqtqnm2hz4MzO3u7V8 PQncXmd2Po1xZkTYiMqsq4/4HoNtz64ufAV91DQdC7xJN2+m3e3ijcpYcDirjEK67Jw4 AfMBofNWutpT103dFQ+LJ0dHpKpPWn0RiBgW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609039; x=1708213839; 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=x00D6P9yOyMiqD2q0GliLWT+bL7NY08ZLZWAqgBxEXY=; b=rU2hhRjo24R8wjI4pguTQpq4g+RaGpzLOlwKKzI1ZqsJH7t/31qiyt0dQlYoDP5ZdH BEfjEeQXug+VyLf6p2OxTPjEB5aq20U2hBCuTeBvM0Tcg9doHQYQz3ElycJwb9jV1ELV 4aJjbGwZ1RmEBbBElIm9nxiFj1FkGKTGjEoLQVUF0+COGaRSg/wIPMnps8dUxt7NRdj4 ShH+RBT5DHRvwkVrV1aUM4LVoprrbZX+yOc2xlT+2uWsUMnviFUGURd5MInSCmorcXcH 8446eKJ22jw5v0iY39Mz8KTsWEl+aap6osHBM/PMQbXASX8bIQ/lNi4ZlkEHIQtFljcn wNQw== X-Forwarded-Encrypted: i=1; AJvYcCWdTQW3atXGBD6j0BFfO7FVR0Zp+jru1DODSEJ7QqSDQww0wQhwWiGezjVicOb7pXLI69gxurJ2aZatIQt/rhuO0TTWdQ70Hl9Aio13 X-Gm-Message-State: AOJu0Yw9aBUEnvE6+cWZwEe8BmLLD3BQ5JHIzxW47G+Ysw32aTz5uDQp vvCpu6DCSyiUcRkMbsAhJ9jJnCkQphEe+xIX9QcfziXcXK7Z+rOribIgvR56 X-Received: by 2002:a05:6512:31d4:b0:510:ee2c:e9c4 with SMTP id j20-20020a05651231d400b00510ee2ce9c4mr2815993lfe.17.1707609039442; Sat, 10 Feb 2024 15:50:39 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV7ySymF3+AZV/6j1K9+VJqK5qT7OPdyNN28fJe2JQqW3xVM2SBYur4wQol+rUwrbeum1oQKxJE2gW7XvXM4MagBlhPedO9CFSwpcSYyFs7LPcPLIxgCe0KpYo234EU1Is2CVFVPkWWkUMYMj/A2MR+etJNsp9MBoXIT7cIs1xYIwJY/Ovxgb/0YVWn9QmJG1iUGqNecxny1WI9D4kxIgNfpIEZ9aeT8SSWYUrj5NrD2yAh6m9U1kIVuhEnZ1IVk/hR5my+nmOe3sVestZnkkup5wU/gZvWFEylKK/FALNsvUtjdiqJc4m+rGadQZ3kivXiDFiXPf1mJWaoNR1AaYWtzMvCOYOYsVDr3JeKFIjzfUSeNURPieCatlRwgbAJQuG6ampB4tYgnwwf1pYtW5s+GyGiC//jfNPXE3RFc4md5VUSuG0VEauzE5/+pCIafiAnhaTKJF1QQtzyKgTHSQPHy00nWD4mKdj055Mq5GWL7sHRLvMRJfRQkf3z6yRoCBAGGdHomteoQ/yY2gcaHqugcMgnTB2Dx+LxDfdZRDTzzxXXxq1rmbADKpATKYjOfHga1gUxQx2qEeZEG32hYsrp91dKbOkW2peqBd/Z3T7buu4Sbg== 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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:39 -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 06/39] dyndbg: use __get_str_strip_nl in prdbg and devdbg Date: Sun, 11 Feb 2024 00:49:36 +0100 Message-ID: <20240210235009.2405808-7-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: 1790557965016161703 X-GMAIL-MSGID: 1790557965016161703 From: Jim Cromie Recently added dyndbg events: prdbg, devdbg have code to strip the trailing newline, if it's there. Instead of removing the newline in TP_fast_assign use __get_str_strip_nl macro in TP_printk. Advantage of such an approach is that the removal is done on the read side (slow path). The change removes also passing of debug message length to prdbg and devdbg events. This use is slightly premature/overkill, since some pr_debugs do not have the expected trailing newline. While those lacks are arguably bugs, this doesn't fix them. Signed-off-by: Jim Cromie Co-developed-by: Łukasz Bartosik Signed-off-by: Łukasz Bartosik --- include/trace/events/dyndbg.h | 27 +++++++++------------------ lib/dynamic_debug.c | 7 +++---- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h index 647c30206a7d..ffd21480cd9d 100644 --- a/include/trace/events/dyndbg.h +++ b/include/trace/events/dyndbg.h @@ -15,46 +15,37 @@ DECLARE_EVENT_CLASS(dyndbg_template, TP_PROTO(const struct _ddebug *desc, const struct device *dev, - const char *msg, size_t len), + const char *msg), - TP_ARGS(desc, dev, msg, len), + TP_ARGS(desc, dev, msg), TP_STRUCT__entry( - __dynamic_array(char, s, len+1) + __string(s, msg) ), 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; + __assign_str(s, msg); ), - TP_printk("%s", __get_str(s)) + TP_printk("%s", __get_str_strip_nl(s)) ); /* captures pr_debug() callsites */ DEFINE_EVENT(dyndbg_template, prdbg, TP_PROTO(const struct _ddebug *desc, const struct device *dev, - const char *msg, size_t len), + const char *msg), - TP_ARGS(desc, dev, msg, len) + TP_ARGS(desc, dev, msg) ); /* captures dev_dbg() callsites */ DEFINE_EVENT(dyndbg_template, devdbg, TP_PROTO(const struct _ddebug *desc, const struct device *dev, - const char *msg, size_t len), + const char *msg), - TP_ARGS(desc, dev, msg, len) + TP_ARGS(desc, dev, msg) ); #endif /* _TRACE_DYNDBG_H */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fcc7c5631b53..9682277f3909 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -886,7 +886,6 @@ static void ddebug_trace(struct _ddebug *desc, const struct device *dev, { struct ddebug_trace_buf *buf; int bufidx; - int len; preempt_disable_notrace(); @@ -900,12 +899,12 @@ static void ddebug_trace(struct _ddebug *desc, const struct device *dev, buf = this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; - len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); + vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); if (!dev) - trace_prdbg(desc, NULL, buf->buf, len); + trace_prdbg(desc, NULL, buf->buf); else - trace_devdbg(desc, dev, buf->buf, len); + trace_devdbg(desc, dev, buf->buf); out: /* As above. */