From: Chris Phlipot <cphlipot0@gmail.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] perf tool: Fix build when sysconf doesn't support cache line size
Date: Mon, 4 Jul 2016 17:47:12 -0700 [thread overview]
Message-ID: <577B0390.60602@gmail.com> (raw)
In-Reply-To: <20160705002641.GA5324@kernel.org>
On 07/04/2016 05:26 PM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jul 04, 2016 at 05:19:20PM -0700, Chris Phlipot escreveu:
>>
>>
>> On 07/04/2016 03:48 PM, Arnaldo Carvalho de Melo wrote:
>>> Em Thu, Jun 30, 2016 at 10:12:34PM -0700, Chris Phlipot escreveu:
>>>> Enable perf to build on libc implementations where sysconf() doesn't
>>>> support _SC_LEVEL1_DCACHE_LINESIZE as a parameter.
>>>>
>>>> For example, the Bionic implementation does not support this as a
>>>> paremter. Older versions of Bionic will throw an error when this is passed
>>>> in as a parameter, and more recent versions will just return 0 as the
>>>> cache line size.
>>>>
>>>> Signed-off-by: Chris Phlipot <cphlipot0@gmail.com>
>>>> ---
>>>> tools/perf/perf.c | 4 ++++
>>>> 1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
>>>> index 8f21922..113ca5b 100644
>>>> --- a/tools/perf/perf.c
>>>> +++ b/tools/perf/perf.c
>>>> @@ -509,7 +509,11 @@ int main(int argc, const char **argv)
>>>>
>>>> /* The page_size is placed in util object. */
>>>> page_size = sysconf(_SC_PAGE_SIZE);
>>>> +#ifdef _SC_LEVEL1_DCACHE_LINESIZE
>>>> cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
>>>> +#else
>>>> + cacheline_size = 0;
>>>> +#endif
>>>
>>> Couldn't we instead fallback to:
>>>
>>> sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", &cacheline_size)
>>>
>>> ?
>>
>> I agree that in general this would be a better fallback, but in all Android
>> images I have tested so far, "devices/system/cpu/cpu0/cache" does not exist.
>> I know not know of a good way to retrieve cache line size in this case.
>>
>> I would be ok with attempting to get cacheline size using using the
>> following methods, unless you have other ideas:
>>
>> 1. attempt to use sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
>> 2. attempt to use
>> sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size",
>> &cacheline_size)
>> 3. set to zero if both of the above fail.
>
> Ok, but perhaps we should have some sort of warning in places using
> this?
>
> - Arnaldo
Such as printing a warning when cacheline_size is set to zero, or simply
adding comments to the code in areas where cacheline_size is used?
-Chris
>
>>
>>>
>>>> if (sysctl__read_int("kernel/perf_event_max_stack", &value) == 0)
>>>> sysctl_perf_event_max_stack = value;
>>>> --
>>>> 2.7.4
next prev parent reply other threads:[~2016-07-05 0:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-01 5:12 [PATCH 0/4] perf tool: Fix Android build Chris Phlipot
2016-07-01 5:12 ` [PATCH 1/4] tools lib api: Respect WERROR=0 for build Chris Phlipot
2016-07-05 10:22 ` [tip:perf/core] " tip-bot for Chris Phlipot
2016-07-01 5:12 ` [PATCH 2/4] tools lib subcmd: " Chris Phlipot
2016-07-05 10:22 ` [tip:perf/core] " tip-bot for Chris Phlipot
2016-07-01 5:12 ` [PATCH 3/4] perf tool: Fix build when sysconf doesn't support cache line size Chris Phlipot
2016-07-04 22:48 ` Arnaldo Carvalho de Melo
2016-07-05 0:19 ` Chris Phlipot
2016-07-05 0:26 ` Arnaldo Carvalho de Melo
2016-07-05 0:47 ` Chris Phlipot [this message]
2016-07-05 0:55 ` Arnaldo Carvalho de Melo
2016-07-01 5:12 ` [PATCH 4/4] perf tool: Update android build documentation Chris Phlipot
2016-07-05 10:23 ` [tip:perf/core] perf tools: " tip-bot for Chris Phlipot
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=577B0390.60602@gmail.com \
--to=cphlipot0@gmail.com \
--cc=arnaldo.melo@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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