From patchwork Fri Mar 8 14:31:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845017 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 932B614DE for ; Fri, 8 Mar 2019 14:31:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E01D2F024 for ; Fri, 8 Mar 2019 14:31:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71EE12F0C7; Fri, 8 Mar 2019 14:31:31 +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 5D4942F024 for ; Fri, 8 Mar 2019 14:31:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726588AbfCHOba (ORCPT ); Fri, 8 Mar 2019 09:31:30 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36149 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbfCHOba (ORCPT ); Fri, 8 Mar 2019 09:31:30 -0500 Received: by mail-wm1-f67.google.com with SMTP id j125so12644818wmj.1 for ; Fri, 08 Mar 2019 06:31:28 -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=9RHgqU8nn0PP+caEF3ZjBz0MN0WO4lkw5eG8njQAhCE=; b=IFte7Nj2u02rzaAKShZLST5ul+XPKMgFj7Q0w2feCiTeRU/R81lhCmROC+WAoiW5Bd /yNDpYY/nyAMuthQDQYNdoN5tClZtyd5ZCGFOuQkdldv+upHGq05B2nKuT77TOV/9TwH ie+cFcqorXUUz4z0dKUf8pfTAip02OX+GumoXrGHjA7LijqxBU9G3CKn28Hpwlk+Jn8F uRtVgtHMr+4uuvOXj0oLbdp5HGvF1TLO4j8/MH+F3ufaRY3TaDPR8BkRWNxPaYYghI+g /Lh5tCNyKR8MptvHTZstudIdud6VSllXYtMmuI8XX8DQdI4Xsywz+KB8UyEBmQKfw7Ji ExHQ== X-Gm-Message-State: APjAAAUJiKnQcFPL9eLwYn6rXZf/10e0VTBVAqXcUaKJoEkbiT0sCWCQ RwcdHSWZR+2lVyxBP1Sf5fYAed/W X-Google-Smtp-Source: APXvYqwKQiSbeqGG7Reifq6paMKROx1aC41jATU1w/T9e4K8juM5h6TMvwfPVp/tSVCD4m/BQ4wA5w== X-Received: by 2002:a1c:1f51:: with SMTP id f78mr8878419wmf.28.1552055488206; Fri, 08 Mar 2019 06:31:28 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:27 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 1/7] kernel-shark: Fix a bug in ksmodel_set_next_bin_edge() Date: Fri, 8 Mar 2019 16:31:19 +0200 Message-Id: <20190308143125.31168-2-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 From: Yordan Karadzhov The modification of the last bin of the model makes no sense (this is my mistake). The comment above the code that is doing this modification is partially correct, however it speaks about increasing the size of the last bin, while the code below the comment changes the lower edge of this bin. The actual increase of the size of the last bin is done in ksmodel_set_upper_edge() where the lower edge of the Upper Overflow bin gets shifted (max + 1). This effectively increases the size of the last bin. Link: http://lore.kernel.org/linux-trace-devel/20190221124205.21115-4-ykaradzhov@vmware.com Reported-by: Tzvetomir Stoyanov Reviewed-by: Slavomir Kaslev Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model ..") Signed-off-by: Yordan Karadzhov Signed-off-by: Steven Rostedt (VMware) --- kernel-shark/src/libkshark-model.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index b6d3612..4bd1e2c 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -266,15 +266,6 @@ static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo, /* Calculate the beginning of the next bin. */ time = histo->min + next_bin * histo->bin_size; - /* - * The timestamp of the very last entry of the dataset can be exactly - * equal to the value of the upper edge of the range. This is very - * likely to happen when we use ksmodel_set_in_range_bining(). In this - * case we have to increase the size of the very last bin in order to - * make sure that the last entry of the dataset will fall into it. - */ - if (next_bin == histo->n_bins - 1) - ++time; /* * Find the index of the first entry inside * the next bin (timestamp > time). From patchwork Fri Mar 8 14:31:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845019 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 E7B7C17E4 for ; Fri, 8 Mar 2019 14:31:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D756D2EEEC for ; Fri, 8 Mar 2019 14:31:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBB502F024; Fri, 8 Mar 2019 14:31:31 +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 71A1B2F0C1 for ; Fri, 8 Mar 2019 14:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726591AbfCHObb (ORCPT ); Fri, 8 Mar 2019 09:31:31 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43125 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbfCHObb (ORCPT ); Fri, 8 Mar 2019 09:31:31 -0500 Received: by mail-wr1-f67.google.com with SMTP id d17so21584067wre.10 for ; Fri, 08 Mar 2019 06:31:30 -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=f4LRVDBiMsJ/bJu+7KVLxNU+ZsffCAUGuK2tNmRfnHKbVPDOfKcrmr4bajlSk1umBo dDVJacMRbFpMmQDDZtwRJUN+5kLh60w+4Q1so38KrT985A9DY1KeBxnkNYo9gC4AgWvO aF2WaajSQRrCFW0FRnTOhAseFP90MhG2frq06ohjEHYY8gb6hAgqvYIDWaCxWPrHr3G3 bAiDQY8Bnbf9kPrKxeSU419E58T3sm3UirTZU2M5p4/D5D/olPHGQ4g2lJZelvp9pWXx +7SfcdzHshzi6t8FjnQJTpCcDGZHyipgl+I1LxXG6XMfXJMoG8XCiVO9LPKBF5Gm1dY5 IZUQ== X-Gm-Message-State: APjAAAWL2KEBPlXhmjQiPVKBFd7YKxXcSeZUqoXBVz+FPnTIdXHu4u7F fMBoxdSLvMUnqbf32X4Bt8+9Kx68 X-Google-Smtp-Source: APXvYqxaRCJP8LeX/L1FEhCZG5Y6Ptk5b+9zs1YWIJXs7qMV0xfroS1Fl7NCpt/ZXluLUsKH3KpF1g== X-Received: by 2002:a05:6000:124a:: with SMTP id j10mr10909014wrx.26.1552055489379; Fri, 08 Mar 2019 06:31:29 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:28 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 2/7] trace-cmd: Fix "trace-cmd reset" command to restore "tracng_on" Date: Fri, 8 Mar 2019 16:31:20 +0200 Message-Id: <20190308143125.31168-3-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 14:31:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845021 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 B075D139A for ; Fri, 8 Mar 2019 14:31:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0EFD2F03B for ; Fri, 8 Mar 2019 14:31:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9538B2F083; Fri, 8 Mar 2019 14:31:32 +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 399A72F03B for ; Fri, 8 Mar 2019 14:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbfCHObc (ORCPT ); Fri, 8 Mar 2019 09:31:32 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42584 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbfCHObb (ORCPT ); Fri, 8 Mar 2019 09:31:31 -0500 Received: by mail-wr1-f67.google.com with SMTP id r5so21576983wrg.9 for ; Fri, 08 Mar 2019 06:31:30 -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=Me2yqThq7SxZu5jYl1/sTsazb+DtNHNzFC9TiqEGjDH36h+tyDzMQgtVYbmCC3RXrh vsVKw+8L5g7Jt/L17vGrDis7dhTZ2EmhJtaliSnM1pZNixhBnUn+xmz7jNdMQB+W7mHy kFx856xMo5tMYxniX9niz82Vk9N9EI9rVES3ahRrF5xQDf6Ygf1/Ih0OY7q8EHISMD4l WUjiS0qHZy+/6kUaWZrAB76CoClJfyCae63I6kC8dPRPZqwj5NTqgUK88s/shy+hS4x4 Hpwd0A5vYbx6Fl44Nbbhz4fDgN+fyd/tOqGlnx6+pCcoAsFfZz/wtNhLZ3qTM3tF4geH 5sxg== X-Gm-Message-State: APjAAAV8jalu8pXYCOXFe234ri5WMbaKz5CaoBQ7rDRJcKiPfCEfEGWI c2OM5SG7309RGxR0kUlrvgg= X-Google-Smtp-Source: APXvYqwzqurCUEWvcoXXTlueXYr0xAePPmoEhbRjfygDWDOOXOYfTKYA7EaCNGMIKfyXWQ6t8eyEgQ== X-Received: by 2002:a5d:6288:: with SMTP id k8mr11981053wru.173.1552055490264; Fri, 08 Mar 2019 06:31:30 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:29 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 3/7] trace-cmd: Fix "trace-cmd reset -a -d" segfault Date: Fri, 8 Mar 2019 16:31:21 +0200 Message-Id: <20190308143125.31168-4-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 14:31:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845023 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 8C1F4139A for ; Fri, 8 Mar 2019 14:31:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8402EF7F for ; Fri, 8 Mar 2019 14:31:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70D7C2F042; Fri, 8 Mar 2019 14:31:33 +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 113DC2F03B for ; Fri, 8 Mar 2019 14:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726622AbfCHObc (ORCPT ); Fri, 8 Mar 2019 09:31:32 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41938 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbfCHObc (ORCPT ); Fri, 8 Mar 2019 09:31:32 -0500 Received: by mail-wr1-f65.google.com with SMTP id n2so21587627wrw.8 for ; Fri, 08 Mar 2019 06:31:31 -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=MMOzKWX6JnI6Rrv6pipUrbH9bMQSm+TaBRnkhmXAkK7NY9/Sy4HKGrjP01veHrnB7y UVuYrwWFJmk/P3ucPvMAJNhxwzBW2Qe37NykuTGszT9p5W0w7Sj7SvR2w1hRGRt0tlzF nQYhZwSumIRUcxbjtrEpQrVkXb/fdr/jg41eb9p63zh3IrkhzMaNWKcZ/meoMcdp/hJN LpRhoYc18Vh5PX5pEULCLOFSMfWsPXyS+IjKX1Ew5YIqbsp9zxsRHacV5vfvAkXgfcbt O7kQbv49MnUTzjXgvP5tMlstM67e/8BohPKuZZCvvoadmb2UDNczE8b6w6yOY4qiRxnM Nxag== X-Gm-Message-State: APjAAAUh8Ys2QtDG9Bp2B7XjDpOna0WLtNedNVAC8HY+g2IoKIm0ODQB kC57Xns+CJ4/Wb+RxHamfJA= X-Google-Smtp-Source: APXvYqx5JZjILDPE9iOJ6/mGOfVOhckJbCFsnIewOA2LdgVFaXI/eZ5gIGDbcCOwBY0g75f+xvSNiQ== X-Received: by 2002:adf:fc87:: with SMTP id g7mr10936943wrr.136.1552055491076; Fri, 08 Mar 2019 06:31:31 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:30 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 4/7] trace-cmd: Fix "trace-cmd reset" command to restore default clock Date: Fri, 8 Mar 2019 16:31:22 +0200 Message-Id: <20190308143125.31168-5-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 14:31:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845025 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 1DB6214DE for ; Fri, 8 Mar 2019 14:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B0612ED8A for ; Fri, 8 Mar 2019 14:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F39062EEEB; Fri, 8 Mar 2019 14:31:34 +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 8F3BD2EECF for ; Fri, 8 Mar 2019 14:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726631AbfCHObe (ORCPT ); Fri, 8 Mar 2019 09:31:34 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52667 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbfCHObe (ORCPT ); Fri, 8 Mar 2019 09:31:34 -0500 Received: by mail-wm1-f68.google.com with SMTP id f65so12741711wma.2 for ; Fri, 08 Mar 2019 06:31:32 -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=eZqt5v+BMVbAQZDbI7pasEEJq6cca5Y4zLgq8iFtlEQNMKJvv0dAK0cA7/lKn7MGve hUi1A1unQH4WPDtR7Rw4ICiRGtMMsuD6kEh/zWwJ2jWwQYuTr9kPiJcOEDtDiwRTNqvT qCRvHsKZsevMm19vP5vlN5mCgyM5gkbXzVn6N0lPThmG3a0e4B4MDZFWOhcyVZFVcrYf LToWq1ypQ1+LIW448Yfz8RJqIZ644u1UE2e7OZDpm1VgZMuPJXpxcooh+QlNFqRTSW9a iP8dF/cipxhNEvDLCn5pmTDqL/vvhEIlMe7n/5E0En05d+bcFfHC58SET0D2jDdaceXX E56Q== X-Gm-Message-State: APjAAAVqyaegnqYnPLok5ubY/nRD7QwGyeOfb8gS5DOUe+kr+mC79abU RgzNUkvZ/vkG17yFdjqENgZ63qpU X-Google-Smtp-Source: APXvYqz5PDVSBymv/EGQYOvGLiaKgbAtMPXZQjbuNnmJhISLlSnWZzc+ekxmw5NS4G3tyUh2BzqWDQ== X-Received: by 2002:a1c:4d17:: with SMTP id o23mr9568154wmh.53.1552055492081; Fri, 08 Mar 2019 06:31:32 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:31 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 5/7] trace-cmd: Reafctored add_event_pid()to utilize write_instance_file() Date: Fri, 8 Mar 2019 16:31:23 +0200 Message-Id: <20190308143125.31168-6-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 14:31:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845027 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 A0E2217E4 for ; Fri, 8 Mar 2019 14:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 913EF2EECF for ; Fri, 8 Mar 2019 14:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85A172EEEB; Fri, 8 Mar 2019 14:31:35 +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 36C762ED8A for ; Fri, 8 Mar 2019 14:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbfCHObf (ORCPT ); Fri, 8 Mar 2019 09:31:35 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34647 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbfCHObe (ORCPT ); Fri, 8 Mar 2019 09:31:34 -0500 Received: by mail-wm1-f66.google.com with SMTP id o10so9078311wmc.1 for ; Fri, 08 Mar 2019 06:31:33 -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=uPwElAqNrKJ92KSIdzijZnAjsZVQxRNv5mINqalhjuWq9Jfhf62pbG39cgx5gish8z LGAiVci+sA1tntUZyw9e8KeKK55fgrRcD96jdTcW0J5xZWjdPE9VTVSrkPPH5vcTNDwE uYNHcrOQ2Wzt0c4OQhcTmDcvdBBrwI1LSfOsujAT1PnoYalTucM6qRXQRHcGpZHAisyt RORiXrjqxcxXm8uaH9g2lNV/3MvEvjy4evelwKxxKLGqY29ukzL7fVsU2QJZ89W70RVD BXfrH22RjClJGvRrsq5LqrxlDAoY2VEP63KKMWWOmnUWQ9ZYU36/DgiiZRZxfjZh/T1z myTQ== X-Gm-Message-State: APjAAAUvJK+dD5hR6yCegUGHUkOAJEq4Gjy5Ga08Vk5M2umEQSnGIvw9 f/Jq+0XnqecYqsrQ/iszb5o= X-Google-Smtp-Source: APXvYqwqjToiTE6DxiUPOhvdbIKkJhblEkiBGb5LIKWP1LczdQxBqJ9NaHoNMXgzU5KE/86lkf1ddg== X-Received: by 2002:a1c:4c08:: with SMTP id z8mr8513287wmf.99.1552055492983; Fri, 08 Mar 2019 06:31:32 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:32 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 6/7] trace-cmd: Fix "trace-cmd reset" command to restore the default value of set_event_pid Date: Fri, 8 Mar 2019 16:31:24 +0200 Message-Id: <20190308143125.31168-7-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 14:31:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10845029 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 C3863139A for ; Fri, 8 Mar 2019 14:31:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0D8C2EEEB for ; Fri, 8 Mar 2019 14:31:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A56712F038; Fri, 8 Mar 2019 14:31:36 +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 313952EDCB for ; Fri, 8 Mar 2019 14:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfCHObg (ORCPT ); Fri, 8 Mar 2019 09:31:36 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36857 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbfCHObf (ORCPT ); Fri, 8 Mar 2019 09:31:35 -0500 Received: by mail-wr1-f68.google.com with SMTP id o17so21605232wrw.3 for ; Fri, 08 Mar 2019 06:31:34 -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=mPynn1eM53ByCP+zSRSpTpmiYsR8i5WpVTZY9CcWqRg=; b=akv1gHMMfOFMm4L/1f7wAZ/NRPeedPwdaKIPeXK00mQksot+m4uJRXqGqFL/+vQwft zLGejhwdgYxcKZxWlSH8eYnd9zx2tRCdBTvZfEi4jdYx5MeWnYUR4RjNOzKQQ7pi6XRD hRcgk/CQX2aOQZ6BErI+zxnrx40ptgdQ8mr7pcyoC+szilBySx8EKCq8By2cpTL2At6N RC939u20KTCnVBcOKQTUwJK78J+xmp9GPnp5CRblGXQJnVoUGGvahpQRFirn6PiWmYhS eO1H4ggZLZJiV2NWTAylEo+ES8gIdzeDKrRAgACCrfr/d9smQl3O5hrp/JQH5V4cdt2b FI2w== X-Gm-Message-State: APjAAAVFUJv5tIiuF3KBs6hmQpD5LJ4O0nF5IGDhmUbhOOGDAYGYicEZ KsP/s8yX85tjDdietXJHtQbAh7Fh X-Google-Smtp-Source: APXvYqw8GRRftPCxck4C+hHGZUJwDIjvN/SCSv804UCRcEHVIuKOkIItf3DM7HmS00MCjM857q/yEA== X-Received: by 2002:a5d:464b:: with SMTP id j11mr4522393wrs.307.1552055494018; Fri, 08 Mar 2019 06:31:34 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id t3sm13495654wmc.20.2019.03.08.06.31.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 06:31:33 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 7/7] trace-cmd: Reafctored reset_max_latency() to utilize write_instance_file() Date: Fri, 8 Mar 2019 16:31:25 +0200 Message-Id: <20190308143125.31168-8-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308143125.31168-1-tstoyanov@vmware.com> References: <20190308143125.31168-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 reset_max_latency() to utilize write_instance_file() for writing set_event_pid instance file, instead of directly opening it. It also changes the function to work per instance. Signed-off-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 99 ++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index bdf0c02..dfbb0cd 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -814,19 +814,49 @@ static void clear_trace(void) fclose(fp); } -static void reset_max_latency(void) +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) { - FILE *fp; char *path; + int ret; - /* reset the trace */ - path = tracecmd_get_tracing_file("tracing_max_latency"); - fp = fopen(path, "w"); - if (!fp) - die("writing to '%s'", path); + path = get_instance_file(instance, file); + ret = write_file(path, str, type); tracecmd_put_tracing_file(path); - fwrite("0", 1, 1, fp); - fclose(fp); + + return ret; +} + +static void reset_max_latency(struct buffer_instance *instance) +{ + write_instance_file(instance, + "tracing_max_latency", "0", "max_latency"); } static void add_filter_pid(int pid, int exclude) @@ -1094,45 +1124,6 @@ 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 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; -} - static void add_event_pid(const char *buf) { struct buffer_instance *instance; @@ -1931,6 +1922,14 @@ static int read_tracing_on(struct buffer_instance *instance) return ret; } +static void reset_max_latency_instance(void) +{ + struct buffer_instance *instance; + + for_all_instances(instance) + reset_max_latency(instance); +} + void tracecmd_enable_tracing(void) { struct buffer_instance *instance; @@ -1941,7 +1940,7 @@ void tracecmd_enable_tracing(void) write_tracing_on(instance, 1); if (latency) - reset_max_latency(); + reset_max_latency_instance(); } void tracecmd_disable_tracing(void) @@ -3801,7 +3800,6 @@ static void reset_event_pid(void) add_event_pid(""); } - static void clear_triggers(void) { struct buffer_instance *instance; @@ -4506,6 +4504,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 */