Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1167144ybt; Tue, 7 Jul 2020 09:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3/r0Te+0hZnNsDA5JBiv9csolmnFQbCkln+dbko/1Kx9L6HW7JKPTX+0qJEMAfZki8Z4o X-Received: by 2002:aa7:c3d7:: with SMTP id l23mr53559957edr.18.1594138323007; Tue, 07 Jul 2020 09:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594138323; cv=none; d=google.com; s=arc-20160816; b=IahfYHVWiMpLhJmA3LjmHTyfc30gb3pFBHmBU2ei6n8jvlIOrcWNRYmMYvPBMtbp3V KR/F5Tk71d4vl3PJ+CUTl5yCRsBKQeYIu3fqkVX6PXBnMGFkR6u4oU40aD4Z9xCjziUf snOslWpBMFXXOYgVD0zn3+cIzO0TZUx0Hf0kWu4K96kRFtRb/PFH4iq716ahiBeH3+ec 5GBiCojWOAnX185IQ7lPUmz44Ler2e+JXyYqgOMDyXG/ajJ1NG+XKSxvrnsueiPx3rNg 3TwIhBA6k0tAYzB/BZLLA41uOU8loyxxTcNuqOdqBpZWwmo0RzGUK6xDHixbkRQtl+O5 Kz6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=DUdfSkGt/RDcisiDaWFHDNVtqOex5hWKwvhpfs5qDeg=; b=iEyQUc1FqrC56e2+I9eCPPCQVgdsrdJD8CSJFkE3Ml+I/tFoRju1uBfOJIhwaiWLoE cCD6MduNuklGAabnXxb59LdgwN/McWjxBmoxd+GzseFm3jrRfPzEUNBhPBVNOZWPtxMS WvGDXLKKl9bpan3h5m32yHdXoxB/vTVVIL9fi1L0ZLXYYTZffnHmE4m+QGXdDzfKVpRM 06DYgS9a57yP5ngXt96mTV1z5T3n4rLXpk46TXzN9xCCbaWTesLt5UxBp36KXmEReliL d0KKiRJ2KyL7wGVYAkgPHd5iLfXe1Gq/wLt5ea7ecJ21IyHk9kuJoswYHdTIMx3Rx0tn d0mw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk19si15677931ejb.338.2020.07.07.09.11.39; Tue, 07 Jul 2020 09:12:02 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727936AbgGGQJ0 (ORCPT + 99 others); Tue, 7 Jul 2020 12:09:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:34258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgGGQJZ (ORCPT ); Tue, 7 Jul 2020 12:09:25 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B35872065D; Tue, 7 Jul 2020 16:09:24 +0000 (UTC) Date: Tue, 7 Jul 2020 12:09:23 -0400 From: Steven Rostedt To: Changbin Du Cc: Jiri Olsa , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 05/15] perf ftrace: factor out function write_tracing_file_int() Message-ID: <20200707120923.26f7e349@oasis.local.home> In-Reply-To: <20200627133654.64863-6-changbin.du@gmail.com> References: <20200627133654.64863-1-changbin.du@gmail.com> <20200627133654.64863-6-changbin.du@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 27 Jun 2020 21:36:44 +0800 Changbin Du wrote: > We will reuse this function later. > BTW, trace-cmd.git now has a libtracefs.so library, which I'm hoping within a month to have as a stand alone (probably along with libtraceevent and even a libtracecmd). https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/tree/lib/tracefs This is a library made to interact with the tracefs directory to remove reimplementing it all over the place. -- Steve > Signed-off-by: Changbin Du > --- > tools/perf/builtin-ftrace.c | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c > index dceae70c3a22..003efa756322 100644 > --- a/tools/perf/builtin-ftrace.c > +++ b/tools/perf/builtin-ftrace.c > @@ -166,6 +166,17 @@ static int read_tracing_file_to_stdout(const char *name) > return ret; > } > > +static int write_tracing_file_int(const char *name, int value) > +{ > + char buf[16]; > + > + snprintf(buf, sizeof(buf), "%d", value); > + if (write_tracing_file(name, buf) < 0) > + return -1; > + > + return 0; > +} > + > static int reset_tracing_cpu(void); > static void reset_tracing_filters(void); > > @@ -296,8 +307,6 @@ static void reset_tracing_filters(void) > > static int set_tracing_depth(struct perf_ftrace *ftrace) > { > - char buf[16]; > - > if (ftrace->graph_depth == 0) > return 0; > > @@ -306,9 +315,7 @@ static int set_tracing_depth(struct perf_ftrace *ftrace) > return -1; > } > > - snprintf(buf, sizeof(buf), "%d", ftrace->graph_depth); > - > - if (write_tracing_file("max_graph_depth", buf) < 0) > + if (write_tracing_file_int("max_graph_depth", ftrace->graph_depth) < 0) > return -1; > > return 0;