Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1177720ybt; Tue, 7 Jul 2020 09:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN0d0iSiWrd+gRfbnfO3ViI/IWUPPr0Rw9RemJrNd2WokJOzYTy0RIedDxCQwMCOuQiC/w X-Received: by 2002:a17:906:90c1:: with SMTP id v1mr47390896ejw.481.1594139086202; Tue, 07 Jul 2020 09:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594139086; cv=none; d=google.com; s=arc-20160816; b=LZ7YtsBd10YDcGQDjKkBCn9X19rMusjbhQeCBqPq++GbUDWH28/kuVV1YzmzVKciou rmQt+hvmbVgN/pgbHWWrii7wlYDKbBdiUdnl0w45CcKeokRcp3NGyOEr13YA3tj8P1DU 2OfmqKTtf5mNaJbx9nRCkYfMEzo6w4EftR5WrUpHlZAJSJiUx86AQltBwD4cvEMMd9l9 RC+AeB9GtOklEI+Ew8BXAzu6/znYkrFZozhqtIfrBkLJ2kCJi3U940sGC3m9ZfXtFjlf yvzHkuY69HDxyz0PwBkPhKYVmjQcU34AvnQobFG8Wl+WlTqcSee31yjNzTOY20wySSwM Fbdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=o/V0a183aUZD+Zi/OYE7w5PLxlTSdl0Ld1ho7bBqkro=; b=GU2d3KrDctxu5CZ+EaDkJQM7KB2YfoG8c6rcrjBzUffSjW/Hbuea5gIRc9/Q81jljv JNBwTcFzG9m9mP3O53ScTWscpSU1JRWnK6iywjLicw+vZDzPbFL9jH9hlawbUSblCbhT OMgNdOSIC6oT9o3zx+rK2cJqQ8vMX2tCQN2D63ve+/tmokkoAzdAjLgY560GdWp5ry7m k8/ACIGQu0u+NkcJ2ZgLSGnVmRJSjUfl5zJQMWtuNMT6y55ZMavgzZvkVOzZKbtXEgZ2 yQJh3uGWSLJSZofDFPIOoXzEaMOSBZuNeQOIB+CL+sjsh9eb+1e05A5NmCp7iFTJ8qbh R64w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uwwTFk/7"; 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 m26si14868354ejn.667.2020.07.07.09.24.22; Tue, 07 Jul 2020 09:24:46 -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; dkim=pass header.i=@kernel.org header.s=default header.b="uwwTFk/7"; 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 S1727975AbgGGQYN (ORCPT + 99 others); Tue, 7 Jul 2020 12:24:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:38004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbgGGQYM (ORCPT ); Tue, 7 Jul 2020 12:24:12 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 4B83C20675; Tue, 7 Jul 2020 16:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594139052; bh=UaVq6NXc0SWYQMR92lAwPLGqN8lj9+wVijOC9r2BLxA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uwwTFk/7e9zN0g4MJS+efLH5J2ZZvXuspKvdcwrWRQmNiqRS0qSaNWyw+6PnMafUR RzEQW2MOh2jclE75K34LaeKiYQdZYPlJeAiN9xL9uyhO8nrmY5adX6MtkJf0sktR2R VwqfQ9yFtDIt2QrX1w7iRbPedNdyg+321BaO1nQ0= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 3A979405FF; Tue, 7 Jul 2020 13:24:10 -0300 (-03) Date: Tue, 7 Jul 2020 13:24:10 -0300 From: Arnaldo Carvalho de Melo To: Changbin Du Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 05/15] perf ftrace: factor out function write_tracing_file_int() Message-ID: <20200707162410.GC1556@kernel.org> References: <20200627133654.64863-1-changbin.du@gmail.com> <20200627133654.64863-6-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200627133654.64863-6-changbin.du@gmail.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sat, Jun 27, 2020 at 09:36:44PM +0800, Changbin Du escreveu: > We will reuse this function later. > > 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; We've been consolidating these sysfs, tracefs, debugfs, hugetlbfs, etc in tools/lib/fs/, where we have things like: [acme@quaco perf]$ grep "int sysfs__" tools/lib/api/fs/fs.c static int sysfs__read_ull_base(const char *entry, int sysfs__read_xll(const char *entry, unsigned long long *value) int sysfs__read_ull(const char *entry, unsigned long long *value) int sysfs__read_int(const char *entry, int *value) int sysfs__read_str(const char *entry, char **buf, size_t *sizep) int sysfs__read_bool(const char *entry, bool *value) int sysfs__write_int(const char *entry, int value) [acme@quaco perf]$ grep "int debugfs__" tools/lib/api/fs/fs.c [acme@quaco perf]$ grep "int sysctl__" tools/lib/api/fs/fs.c int sysctl__read_int(const char *sysctl, int *value) [acme@quaco perf]$ Please take a look at tools/lib/api/fs/fs.h it already has the functions to find the mount points, etc, so adding those there since you're touchign this area now seems best. - Arnaldo