From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753483AbaEWRSm (ORCPT ); Fri, 23 May 2014 13:18:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35298 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751813AbaEWRSl (ORCPT ); Fri, 23 May 2014 13:18:41 -0400 Date: Fri, 23 May 2014 13:18:01 -0400 From: Don Zickus To: Jiri Olsa Cc: acme@ghostprotocols.net, peterz@infradead.org, LKML , namhyung@gmail.com, eranian@google.com, Andi Kleen Subject: Re: [PATCH 6/7] perf: Add support to dynamically get cacheline size Message-ID: <20140523171801.GO50500@redhat.com> References: <1400526833-141779-1-git-send-email-dzickus@redhat.com> <1400526833-141779-7-git-send-email-dzickus@redhat.com> <20140523165405.GE1074@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140523165405.GE1074@krava> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 23, 2014 at 06:54:06PM +0200, Jiri Olsa wrote: > On Mon, May 19, 2014 at 03:13:52PM -0400, Don Zickus wrote: > > Different arches may have different cacheline sizes. Look it up and set > > a global variable for reference. > > > > Signed-off-by: Don Zickus > > --- > > tools/perf/util/cpumap.c | 31 +++++++++++++++++++++++++++++++ > > tools/perf/util/cpumap.h | 12 ++++++++++++ > > tools/perf/util/sort.c | 3 +++ > > 3 files changed, 46 insertions(+) > > > > diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c > > index c4e55b7..d833238 100644 > > --- a/tools/perf/util/cpumap.c > > +++ b/tools/perf/util/cpumap.c > > @@ -477,3 +477,34 @@ int cpu__setup_cpunode_map(void) > > closedir(dir1); > > return 0; > > } > > + > > +int cpu__setup_cacheline_size(void) > > +{ > > + const char *mnt; > > + char path[PATH_MAX]; > > + int n, ret, size; > > + FILE *fp; > > + > > + > > + mnt = sysfs__mountpoint(); > > + if (!mnt) > > + return -1; > > + > > + n = snprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu0/cache/index0/coherency_line_size", mnt); > > + if (n == PATH_MAX) { > > + pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX); > > + return -1; > > + } > > + > > + fp = fopen(path, "r"); > > + if (!fp) > > + return -1; > > + ret = fscanf(fp, "%d", &size); > > + fclose(fp); > > + if (ret != 1) > > + return -1; > > you can use filename__read_int Doh. I forgot about that. I can respin this patch or the whole series for that. Perhaps on Tuesday when we come back from our US Holiday. Cheers, Don