Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp879702pxb; Fri, 28 Jan 2022 12:09:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPyT5E/3nQkC9enm1omwBK8Fv7zSijaxFkgs7wHQs5WaXWReto8T/n/VUGiBDz8eaJFUvr X-Received: by 2002:aa7:da07:: with SMTP id r7mr9892975eds.246.1643400566917; Fri, 28 Jan 2022 12:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643400566; cv=none; d=google.com; s=arc-20160816; b=jTn6l2zk1ao9S04ioLbLVn5jr4oq8Ib6YhRUm4KuG8jhVyZe9kLDUyAP9W5+w+14TS DFDxIsGt38jReTCitLu5nbg//U46QQSwwqmoYyg3PdW93iQlOMXyCyXFXYNKeui2zQ6G ZzQ5PI+923Gm0s8rlTPwAaTrfraJmjPcBZYD4lKgS7n9xOLPXhfEarY6s3nFscFCIzgu ntbT9rg867xtEDKCTGhdResu4YqUQqyVu67fkYE4gHkNcjMpJUXjlaamKT3qcoJRC9g1 Myj7h25v2WGcNEUFhvrofdr0q7YiFZGN5tHD9amNAa9OAAOAw8Rsnab+kmaMsykuBEay TB0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1MPyKwwRrd5Zqkq6JfC0i75i2zYU+PrefgEmDbn+ogk=; b=DwMKcKot4QxHPimCdK5A+jCuy+5+57UdIDmMeDaNonOAdJPIqp363vdwLKeHGyGVTL g70mLPkuJO+QMhn63b3aRCHZkHFLqE5QcYHwW/L063zOL88Me9Q5lQyV6bbco/6Bmgt0 iEvhEhUQ0eEcl86TR2c/EJsGFI5uXYKEVM3V4ECvd/nn+N7e0vDQoSVYFXw0UJX3layZ zrjG+EoxO6W/eYH5jOnYps5TY4XVnfW0lPt4WkNAdx2hjrX0Enz46gs9tKSqUDa/QbKN MG28bDvhW3imDEHgWdlTF+aSfAF2TmOHoeXP/enkJr8kliMv3Gly1rGXCPZgTqVQOiYT Ow3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pM3VFquE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd1si4066726ejc.860.2022.01.28.12.09.01; Fri, 28 Jan 2022 12:09:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pM3VFquE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344482AbiA0Vol (ORCPT + 99 others); Thu, 27 Jan 2022 16:44:41 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:41322 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344472AbiA0Voj (ORCPT ); Thu, 27 Jan 2022 16:44:39 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5C3ECB823BB for ; Thu, 27 Jan 2022 21:44:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADE7BC340E8; Thu, 27 Jan 2022 21:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643319877; bh=fSfNtuEYBnQ5rN5RWlV3wSy9TdJ6HHjYxnrKyJcSkRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=pM3VFquEj6AE3vDc/OZR4i9bCkjiCWq9nTk6zv8CGiy1NsDK5XPTy7vzq5ioqT2eY 7uPeFaWzJ0h4qBUw4X5Gx06VzhfO5zFds9/1nG2e9mBUe9Q7QrwF9inlLza02CpByp BAnPkjLKpQ782YbU6OkMzpD+YBb0N+5yoYV6BtxQtqHzfIit7LmmygrnrdQEVBel52 J/wNYfY0npd4eocatJtPmwGqtJ4r12woXatq4Fg1neiqWS9E0NfhnIEWIyftPDt/ps kBqPLNXngrKx/5MT7ampyppCYIWgIozRyEsjcuQ2DK46kW3ey18gJiaHy+Tuy7EvPH nmXaCNWhwxmHQ== From: Tom Zanussi To: rostedt@goodmis.org Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, Tom Zanussi Subject: [PATCH 6/7] tracing: Remove size restriction on hist trigger cmd error logging Date: Thu, 27 Jan 2022 15:44:20 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, hist trigger command error strings are restricted to a length of MAX_FILTER_STR_VAL (256), which is too short for some commands already seen in the wild (with cmd strings longer than that showing up truncated in err_log). Remove the restriction so that no hist trigger command error string is ever truncated. Signed-off-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index ada87bfb5bb8..be4a001a607f 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -727,11 +727,16 @@ static struct track_data *track_data_alloc(unsigned int key_len, return data; } -static char last_cmd[MAX_FILTER_STR_VAL]; +#define HIST_PREFIX "hist:" + +static char *last_cmd; static char last_cmd_loc[MAX_FILTER_STR_VAL]; static int errpos(char *str) { + if (!str || !last_cmd) + return 0; + return err_pos(last_cmd, str); } @@ -739,12 +744,19 @@ static void last_cmd_set(struct trace_event_file *file, char *str) { const char *system = NULL, *name = NULL; struct trace_event_call *call; + int len = 0; if (!str) return; - strcpy(last_cmd, "hist:"); - strncat(last_cmd, str, MAX_FILTER_STR_VAL - 1 - sizeof("hist:")); + len += sizeof(HIST_PREFIX) + strlen(str) + 1; + kfree(last_cmd); + last_cmd = kzalloc(len, GFP_KERNEL); + if (!last_cmd) + return; + + strcpy(last_cmd, HIST_PREFIX); + strncat(last_cmd, str, len - 1 - sizeof(HIST_PREFIX)); if (file) { call = file->event_call; @@ -757,18 +769,22 @@ static void last_cmd_set(struct trace_event_file *file, char *str) } if (system) - snprintf(last_cmd_loc, MAX_FILTER_STR_VAL, "hist:%s:%s", system, name); + snprintf(last_cmd_loc, MAX_FILTER_STR_VAL, HIST_PREFIX "%s:%s", system, name); } -static void hist_err(struct trace_array *tr, u8 err_type, u8 err_pos) +static void hist_err(struct trace_array *tr, u8 err_type, u16 err_pos) { + if (!last_cmd) + return; + tracing_log_err(tr, last_cmd_loc, last_cmd, err_text, err_type, err_pos); } static void hist_err_clear(void) { - last_cmd[0] = '\0'; + if (last_cmd) + last_cmd[0] = '\0'; last_cmd_loc[0] = '\0'; } @@ -5610,7 +5626,7 @@ static int event_hist_trigger_print(struct seq_file *m, bool have_var = false; unsigned int i; - seq_puts(m, "hist:"); + seq_puts(m, HIST_PREFIX); if (data->name) seq_printf(m, "%s:", data->name); -- 2.17.1