linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Don Zickus <dzickus@redhat.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: acme@ghostprotocols.net, LKML <linux-kernel@vger.kernel.org>,
	jmario@redhat.com, fowles@inreach.com, eranian@google.com
Subject: Re: [PATCH 04/19] perf: Allow ability to map cpus to nodes easily
Date: Wed, 19 Mar 2014 09:38:15 -0400	[thread overview]
Message-ID: <20140319133815.GA25953@redhat.com> (raw)
In-Reply-To: <20140319124827.GB7423@krava.brq.redhat.com>

On Wed, Mar 19, 2014 at 01:48:27PM +0100, Jiri Olsa wrote:
> On Fri, Feb 28, 2014 at 12:42:53PM -0500, Don Zickus wrote:
> > This patch figures out the max number of cpus and nodes that are on the
> 
> SNIP
> 
> > +
> > +int cpu_map__setup_cpunode_map(void)
> > +{
> > +	struct dirent *dent1, *dent2;
> > +	DIR *dir1, *dir2;
> > +	unsigned int cpu, mem;
> > +	char buf[PATH_MAX];
> > +
> > +	/* initialize globals */
> > +	if (init_cpunode_map())
> > +		return -1;
> > +
> > +	dir1 = opendir(PATH_SYS_NODE);
> > +	if (!dir1)
> > +		return 0;
> > +
> > +	/* walk tree and setup map */
> > +	while ((dent1 = readdir(dir1)) != NULL) {
> > +		if (dent1->d_type != DT_DIR ||
> > +		    sscanf(dent1->d_name, "node%u", &mem) < 1)
> > +			continue;
> > +
> > +		snprintf(buf, PATH_MAX, "%s/%s", PATH_SYS_NODE, dent1->d_name);
> > +		dir2 = opendir(buf);
> > +		if (!dir2)
> > +			continue;
> > +		while ((dent2 = readdir(dir2)) != NULL) {
> > +			if (dent2->d_type != DT_LNK ||
> > +			    sscanf(dent2->d_name, "cpu%u", &cpu) < 1)
> > +				continue;
> > +			cpunode_map[cpu] = mem;
> > +		}
> > +		closedir(dir2);
> > +	}
> > +	closedir(dir1);
> > +	return 0;
> > +}
> > +
> > diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
> > index b123bb9..d6fde2b 100644
> > --- a/tools/perf/util/cpumap.h
> > +++ b/tools/perf/util/cpumap.h
> > @@ -4,6 +4,9 @@
> >  #include <stdio.h>
> >  #include <stdbool.h>
> >  
> > +#include "perf.h"
> > +#include "util/debug.h"
> > +
> >  struct cpu_map {
> >  	int nr;
> >  	int map[];
> > @@ -46,4 +49,36 @@ static inline bool cpu_map__empty(const struct cpu_map *map)
> >  	return map ? map->map[0] == -1 : true;
> >  }
> >  
> > +int max_cpu_num;
> > +int max_node_num;
> > +int *cpunode_map;
> > +
> > +int cpu_map__setup_cpunode_map(void);
> > +
> > +static inline int cpu_map__max_node(void)
> > +{
> > +	if (unlikely(!max_node_num))
> > +		pr_debug("cpu_map not initiailzed\n");
> > +
> > +	return max_node_num;
> > +}
> > +
> > +static inline int cpu_map__max_cpu(void)
> > +{
> > +	if (unlikely(!max_cpu_num))
> > +		pr_debug("cpu_map not initiailzed\n");
> > +
> > +	return max_cpu_num;
> > +}
> > +
> > +static inline int cpu_map__get_node(int cpu)
> > +{
> > +	if (unlikely(cpunode_map == NULL)) {
> > +		pr_debug("cpu_map not initialized\n");
> > +		return -1;
> > +	}
> > +
> > +	return cpunode_map[cpu];
> > +}
> 
> cool, maybe above function names should not have 'cpu_map..',
> it's like pure cpu-ish stuff, maybe:
> 
>   setup_cpunode_map
>   cpu__max_node
>   cpu__max_cpu
>   cpu__get_node
> 
> or something like that ;-)

Sure.  That works for me. :-)

Cheers,
Don

  reply	other threads:[~2014-03-19 13:38 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 17:42 [PATCH 00/19 V2] perf, c2c: Add new tool to analyze cacheline contention on NUMA systems Don Zickus
2014-02-28 17:42 ` [PATCH 01/19] Revert "perf: Disable PERF_RECORD_MMAP2 support" Don Zickus
2014-02-28 17:42 ` [PATCH 02/19] perf, sort: Add physid sorting based on mmap2 data Don Zickus
2014-03-19 10:45   ` Jiri Olsa
2014-03-19 13:36     ` Don Zickus
2014-02-28 17:42 ` [PATCH 03/19] perf, sort: Allow unique sorting instead of combining hist_entries Don Zickus
2014-02-28 17:42 ` [PATCH 04/19] perf: Allow ability to map cpus to nodes easily Don Zickus
2014-03-19 12:48   ` Jiri Olsa
2014-03-19 13:38     ` Don Zickus [this message]
2014-03-19 13:22   ` Jiri Olsa
2014-02-28 17:42 ` [PATCH 05/19] perf, kmem: Utilize the new generic cpunode_map Don Zickus
2014-02-28 17:42 ` [PATCH 06/19] perf: Fix stddev calculation Don Zickus
2014-02-28 17:42 ` [PATCH 07/19] perf, callchain: Add generic callchain print handler for stdio Don Zickus
2014-02-28 17:42 ` [PATCH 08/19] perf c2c: Shared data analyser Don Zickus
2014-02-28 19:08   ` Andi Kleen
2014-02-28 19:46     ` Don Zickus
2014-02-28 21:03       ` Davidlohr Bueso
2014-02-28 22:28         ` Joe Mario
2014-03-01  0:50           ` Andi Kleen
2014-03-03 14:13         ` Don Zickus
2014-03-03 15:05         ` Don Zickus
2014-03-03 17:23           ` Andi Kleen
2014-03-03 18:07             ` Joe Mario
2014-03-03 18:41               ` Peter Zijlstra
2014-03-03 18:58                 ` Andi Kleen
2014-03-03 19:48                   ` Peter Zijlstra
2014-03-03 20:32                   ` Don Zickus
2014-03-03 21:38                     ` Andi Kleen
2014-03-03 21:41                       ` Don Zickus
2014-03-03 20:30                 ` Don Zickus
2014-03-03 20:26             ` Don Zickus
2014-03-03 21:36               ` Andi Kleen
2014-03-04  9:42                 ` Peter Zijlstra
2014-03-03 18:21           ` Davidlohr Bueso
2014-02-28 17:42 ` [PATCH 09/19] perf c2c: Dump raw records, decode data_src bits Don Zickus
2014-02-28 17:42 ` [PATCH 10/19] perf, c2c: Rework setup code to prepare for features Don Zickus
2014-02-28 17:43 ` [PATCH 11/19] perf, c2c: Add in sort on physid Don Zickus
2014-02-28 18:59   ` Andi Kleen
2014-02-28 19:44     ` Don Zickus
2014-03-01  1:07       ` Andi Kleen
2014-03-01  1:27         ` Namhyung Kim
2014-02-28 17:43 ` [PATCH 12/19] perf, c2c: Add stats to track data source bits and cpu to node maps Don Zickus
2014-02-28 17:43 ` [PATCH 13/19] perf, c2c: Sort based on hottest cache line Don Zickus
2014-02-28 17:43 ` [PATCH 14/19] perf, c2c: Display cacheline HITM analysis to stdout Don Zickus
2014-02-28 17:43 ` [PATCH 15/19] perf, c2c: Add callchain support Don Zickus
2014-03-19 13:00   ` Jiri Olsa
2014-03-19 13:53     ` Don Zickus
2014-03-19 14:05       ` Jiri Olsa
2014-02-28 17:43 ` [PATCH 16/19] perf, c2c: Output summary stats Don Zickus
2014-02-28 17:43 ` [PATCH 17/19] perf, c2c: Dump rbtree for debugging Don Zickus
2014-02-28 17:43 ` [PATCH 18/19] perf, c2c: Add symbol count table Don Zickus
2014-02-28 17:43 ` [PATCH 19/19] perf, c2c: Add shared cachline summary table Don Zickus
2014-02-28 18:57 ` [PATCH 00/19 V2] perf, c2c: Add new tool to analyze cacheline contention on NUMA systems Andi Kleen
2014-02-28 19:42   ` Don Zickus
2014-02-28 21:54     ` Andi Kleen
2014-03-03 14:04       ` Don Zickus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140319133815.GA25953@redhat.com \
    --to=dzickus@redhat.com \
    --cc=acme@ghostprotocols.net \
    --cc=eranian@google.com \
    --cc=fowles@inreach.com \
    --cc=jmario@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).