From: Jiri Olsa <jolsa@redhat.com>
To: Jin Yao <yao.jin@linux.intel.com>
Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com,
Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com, ying.huang@intel.com
Subject: Re: [PATCH v3] perf stat: Fix wrong skipping for per-die aggregation
Date: Mon, 4 Jan 2021 11:15:04 +0100 [thread overview]
Message-ID: <20210104101504.GA878104@krava> (raw)
In-Reply-To: <20201225010409.29441-1-yao.jin@linux.intel.com>
On Fri, Dec 25, 2020 at 09:04:09AM +0800, Jin Yao wrote:
SNIP
> void update_stats(struct stats *stats, u64 val)
> @@ -275,16 +276,39 @@ void evlist__save_aggr_prev_raw_counts(struct evlist *evlist)
>
> static void zero_per_pkg(struct evsel *counter)
> {
> - if (counter->per_pkg_mask)
> - memset(counter->per_pkg_mask, 0, cpu__max_cpu());
> + struct hashmap_entry *entry;
> + size_t bkt;
> +
> + if (counter->per_pkg_mask) {
> + hashmap__for_each_entry(counter->per_pkg_mask, entry, bkt) {
> + bool *used = (bool *)entry->value;
> +
> + *used = false;
> + }
> + }
> +}
> +
> +static size_t id_hash(const void *key, void *ctx __maybe_unused)
> +{
> + int socket = (int64_t)key >> 32;
> +
> + return socket;
> +}
> +
> +static bool id_equal(const void *key1, const void *key2,
> + void *ctx __maybe_unused)
> +{
> + return (int64_t)key1 == (int64_t)key2;
> }
please use more descriptive names, pkg_id_hash/pkg_id_equal or such
>
> static int check_per_pkg(struct evsel *counter,
> struct perf_counts_values *vals, int cpu, bool *skip)
> {
> - unsigned long *mask = counter->per_pkg_mask;
> + struct hashmap *mask = counter->per_pkg_mask;
> struct perf_cpu_map *cpus = evsel__cpus(counter);
> - int s;
> + int s, d, ret;
> + uint64_t key;
> + bool *used;
>
> *skip = false;
>
> @@ -295,7 +319,7 @@ static int check_per_pkg(struct evsel *counter,
> return 0;
>
> if (!mask) {
> - mask = zalloc(cpu__max_cpu());
> + mask = hashmap__new(id_hash, id_equal, NULL);
> if (!mask)
> return -ENOMEM;
>
> @@ -317,7 +341,32 @@ static int check_per_pkg(struct evsel *counter,
> if (s < 0)
> return -1;
>
> - *skip = test_and_set_bit(s, mask) == 1;
> + /*
> + * On multi-die system, 0 < die_id < 256. On no-die system, die_id = 0.
> + * We use hashmap(socket, die) to check the used socket+die pair.
> + */
> + d = cpu_map__get_die(cpus, cpu, NULL).die;
> + if (d < 0)
> + return -1;
> +
> + key = (uint64_t)s << 32 | (d & 0xff);
> + if (hashmap__find(mask, (void *)key, (void **)&used)) {
> + if (*used)
> + *skip = true;
> + *used = true;
> + } else {
> + used = zalloc(sizeof(*used));
> + if (!used)
> + return -1;
hum, what's the point of having extra bool value? once the
item is in the hashtab, we have the answer
I think you can add item to hashtab with '1' value and get
rid of that bool allocation
zero_per_pkg will be just removing all items from hashtab
jirka
next prev parent reply other threads:[~2021-01-04 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-25 1:04 [PATCH v3] perf stat: Fix wrong skipping for per-die aggregation Jin Yao
2021-01-04 10:15 ` Jiri Olsa [this message]
2021-01-05 2:40 ` Jin, Yao
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=20210104101504.GA878104@krava \
--to=jolsa@redhat.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
--cc=yao.jin@linux.intel.com \
--cc=ying.huang@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.