From patchwork Fri Mar 8 13:44:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44E8117E9 for ; Fri, 8 Mar 2019 13:44:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D0C2DF20 for ; Fri, 8 Mar 2019 13:44:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 263422DF2F; Fri, 8 Mar 2019 13:44:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEA592DF20 for ; Fri, 8 Mar 2019 13:44:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbfCHNoK (ORCPT ); Fri, 8 Mar 2019 08:44:10 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37289 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbfCHNoK (ORCPT ); Fri, 8 Mar 2019 08:44:10 -0500 Received: by mail-wm1-f66.google.com with SMTP id x10so12365386wmg.2 for ; Fri, 08 Mar 2019 05:44:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B0LSgheigQKYDNu87C/yhSfypvVN6mgElsvHHKqMVDU=; b=sghwDJlzgCMyoePs85Y/xvpChkUrOMerL2EHCBPk8b/Q2axH6o34Ewqp8WOAzaN3Hk qXVi4sl+dVrpOEQ7ZMVc9lJxqg+xZu+riIYqbnkTKCw2AnEM6MR4SYgboysrMlbpydMQ Ase4evS8UCCbTTKlIUlmaj/kL2HH/BofLPwDeOxL9C4CjGNRvTYOE7ZCR7iaeLGaN0K7 fUaXDe4PZxiU6VOrs9rUT4ma40ZTeUphx/J+az0PXyMOQDrGa+0TKBllwDW5I//Ks0Np EhJCwjxOVJKedtdbdoXerydQSe+ZZnOa9Bpuu+QgCKq+tcVMmShyl7IGG93ZkImIXLFi rLmQ== X-Gm-Message-State: APjAAAWHEY7/tZO5Slku4/wWD2F5t7iK/wnXckB2Y4TPXHpxQs6leA41 otpPx1PqaSOyxVrQLjpVVQ4= X-Google-Smtp-Source: APXvYqy6lFi9nJ4r6VBxa8PgXOsTfrH/VOERUQP2ywOVvATsa55L4sxMqSz4egaahkLm0EgAmbBUwQ== X-Received: by 2002:a1c:1a86:: with SMTP id a128mr9277243wma.67.1552052648590; Fri, 08 Mar 2019 05:44:08 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t16sm5650943wmj.47.2019.03.08.05.44.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:44:08 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 1/6] trace-cmd: Fix "trace-cmd reset" command to restore "tracng_on" Date: Fri, 8 Mar 2019 15:44:00 +0200 Message-Id: <20190308134405.21921-2-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308134405.21921-1-tstoyanov@vmware.com> References: <20190308134405.21921-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "trace-cmd reset" command should restore ftrace to its default state. By default, "tracing/current_tracer" is "nop" and "tracing/tracing_on" is "1". This patch sets "tracing/tracing_on" to 1, when the command "trace-cmd reset" is executed. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 8beefab..fc658b2 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -4496,6 +4496,8 @@ void trace_reset(int argc, char **argv) clear_triggers(); tracecmd_remove_instances(); clear_func_filters(); + /* restore tracing_on to 1 */ + tracecmd_enable_tracing(); exit(0); } From patchwork Fri Mar 8 13:44:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3204A1390 for ; Fri, 8 Mar 2019 13:44:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19D762DF2F for ; Fri, 8 Mar 2019 13:44:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EA1F2DF34; Fri, 8 Mar 2019 13:44:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBB342DF20 for ; Fri, 8 Mar 2019 13:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726737AbfCHNoL (ORCPT ); Fri, 8 Mar 2019 08:44:11 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37818 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfCHNoL (ORCPT ); Fri, 8 Mar 2019 08:44:11 -0500 Received: by mail-wr1-f68.google.com with SMTP id w6so21411787wrs.4 for ; Fri, 08 Mar 2019 05:44:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qn3Ovm26CMQF4CDJU/28ZXQFBZMpgXkLqaLJM18hw5E=; b=VDSFo2mBCcWtPiuXCmwUfpPVJyh8Wqcyhf2O0Wro3XQnhhW2YkYBrIyDkphYzc+g7p W2d27Dg6zkN/G7DVbxq30nOIG+uyKTNXl/NtDnSZZ3gPlK5aD+8Lzv4ZzcgMX5qkhZUQ QIYynMili3R/B6FUNVlJQMcsTRyCSd/glIxcJupbwE5MiEsT9m56KVViiaXzunLkpMXU i8NHYrHOFUPg84Gp13Im3NhN8jO/GNE1wTSs2heKjnBW5iVGkOzWGFFfB1uIHQHNk3H/ oiuebnpWQo4y17tk5+7Lyg6+NyQVIEUy4ml/hMcUB5lOW3z63UUaTZpJC2pdoBibyYYQ LhBQ== X-Gm-Message-State: APjAAAVFumEe9am6ZFasrv240PVKhM6gCVrwZa8jUWqKX6X4CU/gfaOt ybk+AbQNLz8x6UGHdriKQ3Y= X-Google-Smtp-Source: APXvYqx5YPp0yBHjvitYMzR5AVZry88JCrHRTqrZJTFnPEebwMX7305XEiiGqIf8myq10+HyaPa5sA== X-Received: by 2002:adf:ef4a:: with SMTP id c10mr10983555wrp.180.1552052649620; Fri, 08 Mar 2019 05:44:09 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t16sm5650943wmj.47.2019.03.08.05.44.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:44:08 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 2/6] trace-cmd: Fix "trace-cmd reset -a -d" segfault Date: Fri, 8 Mar 2019 15:44:01 +0200 Message-Id: <20190308134405.21921-3-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308134405.21921-1-tstoyanov@vmware.com> References: <20190308134405.21921-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a segfault when "trace-cmd reset -a -d" is executed and there is at least one ftrace instance created. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index fc658b2..d7267fe 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -4472,14 +4472,14 @@ void trace_reset(int argc, char **argv) case 'a': last_specified_all = 1; add_all_instances(); - for_each_instance(instance) { - instance->flags |= BUFFER_FL_KEEP; + for_each_instance(inst) { + inst->flags |= BUFFER_FL_KEEP; } break; case 'd': if (last_specified_all) { for_each_instance(inst) { - instance->flags &= ~BUFFER_FL_KEEP; + inst->flags &= ~BUFFER_FL_KEEP; } } else { if (is_top_instance(instance)) From patchwork Fri Mar 8 13:44:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 280321390 for ; Fri, 8 Mar 2019 13:44:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 153242DF20 for ; Fri, 8 Mar 2019 13:44:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06BD82DF2F; Fri, 8 Mar 2019 13:44:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A45C62DF20 for ; Fri, 8 Mar 2019 13:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbfCHNoM (ORCPT ); Fri, 8 Mar 2019 08:44:12 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46132 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbfCHNoM (ORCPT ); Fri, 8 Mar 2019 08:44:12 -0500 Received: by mail-wr1-f68.google.com with SMTP id i16so21398575wrs.13 for ; Fri, 08 Mar 2019 05:44:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HjgYILSVk6MYR5w1Q9TxlsvwEb/cp6vZNW3Z/pHTu9g=; b=SS6IGPb7B40RDYRNj7Pr4BHhrklY+ZDZemk0rj4iQiR5P50DpGjmWo89JRQzFLE8+m KT4SpZ19YN8kl+I1t/EdNFTbMo8EogKSuZgy7Dg+CrcWpNcqfPlnV9tvQuM2iJwJxU4R VuFqhV1/l1g0kfWeP9MQe46mX5e1H+plGKTjkC8KnowJXHGDbK8WFr+I84v/10dQVtI+ VooEIU59nPVrrEM3vdJXnzvSYZNNVjwnNY3hfAZLNAuEbxTSHZ9C+A49yP83HreDn/ty TqFN4OPicgH+FkfHw6dr1XSyDG9XxrouOSUH9fR0YnPMFhFdeBoTWN+3nucS1EYOIU+d fA2A== X-Gm-Message-State: APjAAAXIT1Kyab0on1d7ffHl+nxf9/ZEZntul3iFXOqFid/bkGX7HCH7 t+nAacuYhJGoiCyruFo1+Rg= X-Google-Smtp-Source: APXvYqyGTYmTOBwsECP61LSTSceMoIOnZbpb0xqdmiHeXA9AzCNHhFQseSgs5Z8IpR8CGNs5fJVKGQ== X-Received: by 2002:adf:f88f:: with SMTP id u15mr4358645wrp.117.1552052650608; Fri, 08 Mar 2019 05:44:10 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t16sm5650943wmj.47.2019.03.08.05.44.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:44:09 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 3/6] trace-cmd: Fix "trace-cmd reset" command to restore default clock Date: Fri, 8 Mar 2019 15:44:02 +0200 Message-Id: <20190308134405.21921-4-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308134405.21921-1-tstoyanov@vmware.com> References: <20190308134405.21921-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "trace-cmd reset" command should restore ftrace to its default state. This patch sets "tracing/trace_clock" to its default value "local", when the "trace-cmd reset" command is executed. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index d7267fe..6972b9f 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -3793,6 +3793,14 @@ static void clear_filters(void) clear_instance_filters(instance); } +static void reset_clock(void) +{ + struct buffer_instance *instance; + + for_all_instances(instance) + write_instance_file(instance, "trace_clock", "local", "clock"); +} + static void clear_triggers(void) { struct buffer_instance *instance; @@ -4494,6 +4502,8 @@ void trace_reset(int argc, char **argv) set_buffer_size(); clear_filters(); clear_triggers(); + /* set clock to "local" */ + reset_clock(); tracecmd_remove_instances(); clear_func_filters(); /* restore tracing_on to 1 */ From patchwork Fri Mar 8 13:44:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 587A61390 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 452BC2DF20 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 396742DF30; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 261B02DF20 for ; Fri, 8 Mar 2019 13:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbfCHNoO (ORCPT ); Fri, 8 Mar 2019 08:44:14 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38506 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfCHNoN (ORCPT ); Fri, 8 Mar 2019 08:44:13 -0500 Received: by mail-wr1-f67.google.com with SMTP id g12so21415647wrm.5 for ; Fri, 08 Mar 2019 05:44:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3uXkHmgoem1W6QSbvVaB2yCFnWFJS+wkZ5OZzrrk0Tw=; b=H8bf4OAodWoHZsIAUGWqQk4h4XPeM3V9ZHCjeNNy2tNDCNof9m8LQOOVxj1FWF6Emo mr9KSQjrG8F69/RM1IsXPuuI7MA/kgyOJ0Tq33BxPocilqkeevfaMoTyRw7HTRO6CDuS cwuUU7PYf/vouSUHZ3btzKRP+5GXyrcVt5BoyHAQFICBMUnBUZQvOuDzGxmX1CpBUoqb oenJqQAnEoI38nCCGuPx10IdSL2gZzSq4WE+aMzYdeSD3YyGnBs+/ScEqgLZdDofpfRE kOyjHax+YlqEkJHQJ6f9klJlFFiQQjh2eCkesX9bLw7AbnYKJjD2129dm+h+4/RkF4Sn 03gA== X-Gm-Message-State: APjAAAWehlLT1ilj+D2zALnjMivQjhXilQgR5/2eAvxYU+sM6WOhZtPe /KNS+QvoVtSiQcoiOs5y9ZaHuOg3 X-Google-Smtp-Source: APXvYqxoSR2o8M6621AjBgva4wrVSlW1jjmVnJjREzlmtpdMir6kV0vXEPp1hx9lO9yXeApLlS9Tkg== X-Received: by 2002:adf:f80e:: with SMTP id s14mr11277650wrp.327.1552052651636; Fri, 08 Mar 2019 05:44:11 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t16sm5650943wmj.47.2019.03.08.05.44.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:44:10 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 4/6] trace-cmd: Reafctored add_event_pid()to utilize write_instance_file() Date: Fri, 8 Mar 2019 15:44:03 +0200 Message-Id: <20190308134405.21921-5-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308134405.21921-1-tstoyanov@vmware.com> References: <20190308134405.21921-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch changes add_event_pid() to utilize write_instance_file() for writing set_event_pid instance file, instead of directly opening it. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 89 +++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 6972b9f..a398723 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -1094,30 +1094,64 @@ static void update_sched_events(struct buffer_instance *instance, int pid) static int open_instance_fd(struct buffer_instance *instance, const char *file, int flags); -static void add_event_pid(const char *buf, int len) +static int write_file(const char *file, const char *str, const char *type) { - struct buffer_instance *instance; + char buf[BUFSIZ]; int fd; + int ret; - for_all_instances(instance) { - fd = open_instance_fd(instance, "set_event_pid", O_WRONLY); - write(fd, buf, len); + fd = open(file, O_WRONLY | O_TRUNC); + if (fd < 0) + die("opening to '%s'", file); + ret = write(fd, str, strlen(str)); + close(fd); + if (ret < 0 && type) { + /* write failed */ + fd = open(file, O_RDONLY); + if (fd < 0) + die("writing to '%s'", file); + /* the filter has the error */ + while ((ret = read(fd, buf, BUFSIZ)) > 0) + fprintf(stderr, "%.*s", ret, buf); + die("Failed %s of %s\n", type, file); close(fd); } + return ret; +} + +static int +write_instance_file(struct buffer_instance *instance, + const char *file, const char *str, const char *type) +{ + char *path; + int ret; + + path = get_instance_file(instance, file); + ret = write_file(path, str, type); + tracecmd_put_tracing_file(path); + + return ret; +} + +static void add_event_pid(const char *buf) +{ + struct buffer_instance *instance; + + for_all_instances(instance) + write_instance_file(instance, "set_event_pid", buf, "event_pid"); } static void add_new_filter_pid(int pid) { struct buffer_instance *instance; char buf[100]; - int len; add_filter_pid(pid, 0); - len = sprintf(buf, "%d", pid); + sprintf(buf, "%d", pid); update_ftrace_pid(buf, 0); if (have_set_event_pid) - return add_event_pid(buf, len); + return add_event_pid(buf); common_pid_filter = append_pid_filter(common_pid_filter, "common_pid", pid); @@ -1596,45 +1630,6 @@ static void reset_events(void) reset_events_instance(instance); } -static int write_file(const char *file, const char *str, const char *type) -{ - char buf[BUFSIZ]; - int fd; - int ret; - - fd = open(file, O_WRONLY | O_TRUNC); - if (fd < 0) - die("opening to '%s'", file); - ret = write(fd, str, strlen(str)); - close(fd); - if (ret < 0 && type) { - /* write failed */ - fd = open(file, O_RDONLY); - if (fd < 0) - die("writing to '%s'", file); - /* the filter has the error */ - while ((ret = read(fd, buf, BUFSIZ)) > 0) - fprintf(stderr, "%.*s", ret, buf); - die("Failed %s of %s\n", type, file); - close(fd); - } - return ret; -} - -static int -write_instance_file(struct buffer_instance *instance, - const char *file, const char *str, const char *type) -{ - char *path; - int ret; - - path = get_instance_file(instance, file); - ret = write_file(path, str, type); - tracecmd_put_tracing_file(path); - - return ret; -} - enum { STATE_NEWLINE, STATE_SKIP, From patchwork Fri Mar 8 13:44:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 885CE1803 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75EF72DF20 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A3DD2DF2F; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F3532DF22 for ; Fri, 8 Mar 2019 13:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726171AbfCHNoO (ORCPT ); Fri, 8 Mar 2019 08:44:14 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54446 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbfCHNoO (ORCPT ); Fri, 8 Mar 2019 08:44:14 -0500 Received: by mail-wm1-f65.google.com with SMTP id f3so12692217wmj.4 for ; Fri, 08 Mar 2019 05:44:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hx45oLWm3cO7y7qj3wq6+r7jPLgvW5RIhXHj5w/9PtQ=; b=r+8VGTrULlAW9uFJYxLhuTDbDu/aTp3n3Dp2gc5NRCC7xEKMeMZzL0UX+8cUEi2WMX UVXp8XY/317nSdPvJP/2KwFhVMwasIsyCdJmqs1Osx38DGk4zxcDalmYhtJQVhJbIuTl +oaIW/fTRsfNiRJsMs+h85te4HV/kTEMQpdhdBabQ0yqB4RUx6yNHpov3J+0eWYa1Ej5 dUn/p1sodyG0Hz0r+b6L2FCsaCNSrVjP2PrukG9sXt4RHl+ATzm2lR0vy+c/TrXHEV14 tWIZQfmypWl1ymVOlV3MR1gJLft//SRKk7l8Pdmhh+XCyXzU+mQeuKzrGbvTXuJwn1aw MeFQ== X-Gm-Message-State: APjAAAXwg455lFjPWlOT65BNICxSSAYUQs0IoQ5uDu1JsTRSwHWbB27g euacVC5U/h7A0QiprUYXyfSewQ4a X-Google-Smtp-Source: APXvYqyhYsB2ox9xVegsT9lRm4GukPe0cBhAc0YTd5YXayGVfgTuhV4hb4XJZQ6DIywyy+NycYtx+Q== X-Received: by 2002:a1c:67c2:: with SMTP id b185mr9363444wmc.68.1552052652351; Fri, 08 Mar 2019 05:44:12 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t16sm5650943wmj.47.2019.03.08.05.44.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:44:11 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 5/6] trace-cmd: Fix "trace-cmd reset" command to restore the default value of set_event_pid Date: Fri, 8 Mar 2019 15:44:04 +0200 Message-Id: <20190308134405.21921-6-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308134405.21921-1-tstoyanov@vmware.com> References: <20190308134405.21921-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "trace-cmd reset" command should restore ftrace to its default state. This patch sets "tracing/set_event_pid" to an empty string, when the "trace-cmd reset" command is executed. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index a398723..bdf0c02 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -3796,6 +3796,12 @@ static void reset_clock(void) write_instance_file(instance, "trace_clock", "local", "clock"); } +static void reset_event_pid(void) +{ + add_event_pid(""); +} + + static void clear_triggers(void) { struct buffer_instance *instance; @@ -4499,6 +4505,7 @@ void trace_reset(int argc, char **argv) clear_triggers(); /* set clock to "local" */ reset_clock(); + reset_event_pid(); tracecmd_remove_instances(); clear_func_filters(); /* restore tracing_on to 1 */ From patchwork Fri Mar 8 13:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10844867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE95E1869 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB6A82DF20 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FCFE2DF22; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C0C2DF34 for ; Fri, 8 Mar 2019 13:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbfCHNoP (ORCPT ); Fri, 8 Mar 2019 08:44:15 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52107 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbfCHNoO (ORCPT ); Fri, 8 Mar 2019 08:44:14 -0500 Received: by mail-wm1-f66.google.com with SMTP id n19so12577210wmi.1 for ; Fri, 08 Mar 2019 05:44:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k7RzuzhhDaG+aYWpS7qXWP855XoYR2nMC0Urv+Xlnno=; b=k/kmCdbK8G0M9Y2gY4t3ir+/EjmHTLiNQsOWNzQiG9XcGNpfXHfkKBMx6rq/JfbR/H ON6xHdjtWpiF/wPq9je/8zC/N5COqdWpY+vTvJhfLzOPdVoop2RjczNsT0fkgRWaKZm9 ATvxYNHEGNgwYMXzKCtvgcCnzKER+N0m3fn4JEtoI+fKXctuJ86dUb8Z8TPtBHTHRW1B /IIX7T0k9kQa5ZgJqljvPkp0EWAjo1gve/zbXfk2Ey9KJJotkp8ii7q85BIOGV6Addq2 zBY8wI9xJ0WT3xb7qTQeSRMs95r0ABYhz2+xnrqCiTHJ6ej8R9PsXuEZryo4QcFkhvc7 cZuw== X-Gm-Message-State: APjAAAVUOLdJYOMZ9JCb/eh0BYWKylcaB/gj9gt5ehh90rBdI6+nmQuA LPyeFe+MFn0d5nF2ugJBjNLRXRnm X-Google-Smtp-Source: APXvYqyHDXgUGzVOUrepZUI2lFcufefIPKmWtMsz85mOqN3Bky8WSvDNTuClJsmYPJWk6XheCopu9Q== X-Received: by 2002:a1c:2c4:: with SMTP id 187mr8976416wmc.77.1552052653231; Fri, 08 Mar 2019 05:44:13 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t16sm5650943wmj.47.2019.03.08.05.44.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 05:44:12 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 6/6] trace-cmd: Fix "trace-cmd reset" command to restore the default value of tracing_max_latency Date: Fri, 8 Mar 2019 15:44:05 +0200 Message-Id: <20190308134405.21921-7-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308134405.21921-1-tstoyanov@vmware.com> References: <20190308134405.21921-1-tstoyanov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "trace-cmd reset" command should restore ftrace to its default state. This patch sets "tracing/tracing_max_latency" to 0, when the "trace-cmd reset" command is executed. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index bdf0c02..f4dac2f 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -3801,6 +3801,14 @@ static void reset_event_pid(void) add_event_pid(""); } +static void reset_max_latency_instance(void) +{ + struct buffer_instance *instance; + + for_all_instances(instance) + write_instance_file(instance, + "tracing_max_latency", "0", "max_latency"); +} static void clear_triggers(void) { @@ -4506,6 +4514,7 @@ void trace_reset(int argc, char **argv) /* set clock to "local" */ reset_clock(); reset_event_pid(); + reset_max_latency_instance(); tracecmd_remove_instances(); clear_func_filters(); /* restore tracing_on to 1 */