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 v7] perf stat: Fix wrong skipping for per-die aggregation
Date: Mon, 25 Jan 2021 10:45:54 +0100 [thread overview]
Message-ID: <20210125094554.GB245791@krava> (raw)
In-Reply-To: <de88878b-b184-b1a2-ad91-1069d81c4e53@linux.intel.com>
On Mon, Jan 25, 2021 at 01:47:54PM +0800, Jin, Yao wrote:
> Hi Jiri,
>
> On 1/24/2021 6:57 AM, Jiri Olsa wrote:
> > On Thu, Jan 21, 2021 at 12:21:36PM +0800, Jin, Yao wrote:
> >
> > sNIP
> >
> > > mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
> > > d = cpu_map__get_die(cpus, cpu, NULL).die;
> > > key = (size_t)d << KEY_SHIFT | s; /* s is socket id */
> > > if (hashmap__find(mask, (void *)key, NULL))
> > > *skip = true;
> > > else
> > > ret = hashmap__add(mask, (void *)key, (void *)1);
> > >
> > > If we use 'unsigned long' to replace 'size_t', it reports the build error for 32 bits:
> > >
> > > stat.c:320:23: warning: passing argument 1 of ‘hashmap__new’ from
> > > incompatible pointer type [-Wincompatible-pointer-types]
> > > mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
> > > ^~~~~~~~~~~
> > > In file included from stat.c:16:
> > > hashmap.h:75:17: note: expected ‘hashmap_hash_fn’ {aka ‘unsigned int
> > > (*)(const void *, void *)’} but argument is of type ‘long unsigned int
> > > (*)(const void *, void *)’
> > >
> > > If we use "unsigned int", it's not good for 64 bits. So I still use 'size_t' in this patch.
> > >
> > > Any comments for this idea (using conditional compilation)?
> >
> > isn't it simpler to allocate the key then? like below
> > (just compile tested)
> >
> > jirka
> >
>
> Hmm, Each method has advantages and disadvantages.
>
> My method uses conditional compilation but it looks a bit complicated. The
> advantage is it doesn't need to allocate the memory for key.
>
> If you need me to post v8, I'd love to.
>
> Anyway, either method is fine for me. :)
I believe that the less ifdefs te better, if you could squash this
change with your patch and send it, that'd be great
SNIP
> > + return *key & 0xffffffff;
> > }
> > -static bool pkg_id_equal(const void *key1, const void *key2,
> > +static bool pkg_id_equal(const void *__key1, const void *__key2,
> > void *ctx __maybe_unused)
> > {
> > - return (size_t)key1 == (size_t)key2;
> > + uint64_t *key1 = (uint64_t*) __key1;
> > + uint64_t *key2 = (uint64_t*) __key2;
> > +
> > + return *key1 == *key2;
> > }
> > static int check_per_pkg(struct evsel *counter,
> > @@ -297,7 +309,7 @@ static int check_per_pkg(struct evsel *counter,
> > struct hashmap *mask = counter->per_pkg_mask;
> > struct perf_cpu_map *cpus = evsel__cpus(counter);
> > int s, d, ret = 0;
> > - size_t key;
> > + uint64_t *key;
> > *skip = false;
> > @@ -338,7 +350,11 @@ static int check_per_pkg(struct evsel *counter,
> > if (d < 0)
> > return -1;
> > - key = (size_t)d << 16 | s;
> > + key = malloc(sizeof(*key));
> > + if (!key)
> > + return -ENOMEM;
> > +
> > + *key = (size_t)d << 32 | s;
>
> Should be "*key = (uint64_t)d << 32 | s;"?
yes, I missed this bit
thanks,
jirka
next prev parent reply other threads:[~2021-01-26 20:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 4:05 [PATCH v7] perf stat: Fix wrong skipping for per-die aggregation Jin Yao
2021-01-20 22:07 ` Jiri Olsa
2021-01-21 4:21 ` Jin, Yao
2021-01-23 22:57 ` Jiri Olsa
2021-01-25 5:47 ` Jin, Yao
2021-01-25 9:45 ` Jiri Olsa [this message]
2021-01-26 0:20 ` 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=20210125094554.GB245791@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.