All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Song Liu <songliubraving@fb.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH bpf-next] bpftool: add {i,d}tlb_misses support for bpftool profile
Date: Wed, 18 Nov 2020 23:18:46 -0800	[thread overview]
Message-ID: <c6c774d7-2d1f-b16b-d10a-603373f029a5@fb.com> (raw)
In-Reply-To: <3D194218-382A-48F0-AAAC-9D3C2355D61B@fb.com>



On 11/18/20 9:03 PM, Song Liu wrote:
> 
>> On Nov 18, 2020, at 8:23 PM, Yonghong Song <yhs@fb.com> wrote:
> 
> [...]
> 
>>
>> Cc: Song Liu <songliubraving@fb.com>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>> ---
>> tools/bpf/bpftool/prog.c | 32 ++++++++++++++++++++++++++++++--
>> 1 file changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
>> index acdb2c245f0a..e33f27b950a5 100644
>> --- a/tools/bpf/bpftool/prog.c
>> +++ b/tools/bpf/bpftool/prog.c
>> @@ -1717,11 +1717,39 @@ struct profile_metric {
>> 		.ratio_desc = "LLC misses per million insns",
>> 		.ratio_mul = 1e6,
>> 	},
>> +	{
>> +		.name = "itlb_misses",
>> +		.attr = {
>> +			.type = PERF_TYPE_HW_CACHE,
>> +			.config =
>> +				PERF_COUNT_HW_CACHE_ITLB |
>> +				(PERF_COUNT_HW_CACHE_OP_READ << 8) |
>> +				(PERF_COUNT_HW_CACHE_RESULT_MISS << 16),
>> +			.exclude_user = 1
>> +		},
>> +		.ratio_metric = 2,
>> +		.ratio_desc = "itlb misses per million insns",
>> +		.ratio_mul = 1e6,
>> +	},
>> +	{
>> +		.name = "dtlb_misses",
>> +		.attr = {
>> +			.type = PERF_TYPE_HW_CACHE,
>> +			.config =
>> +				PERF_COUNT_HW_CACHE_DTLB |
>> +				(PERF_COUNT_HW_CACHE_OP_READ << 8) |
>> +				(PERF_COUNT_HW_CACHE_RESULT_MISS << 16),
>> +			.exclude_user = 1
>> +		},
>> +		.ratio_metric = 2,
>> +		.ratio_desc = "dtlb misses per million insns",
>> +		.ratio_mul = 1e6,
>> +	},
>> };
>>
>> static __u64 profile_total_count;
>>
>> -#define MAX_NUM_PROFILE_METRICS 4
>> +#define MAX_NUM_PROFILE_METRICS 6
> 
> This change is not necessary. This is the max number of enabled metrics.
> We don't stop the perf counters, each enabled metric adds some error to
> the final reading. Therefore, we don't want to enable too many metrics
> in the same run. If we don't have a use case for more metrics in one run,
> let's keep the cap of 4 metrics.
> 
> If we do want to increase this, we should also increase MAX_NUM_MATRICS
> in profiler.bpf.c.

Thanks for explanation. I missed that we also need to change 
MAX_NUM_MATRICS to really make it work. Ideally it would be best if we
only need to change in one header and that header is shared by both
bpf program and non-bpf program but probably is a overkill here just
for a single macro.

Also, your concern makes sense. We do not want to enable too many
metrics as this will cause counter sharing and may sacrifice accuracy.
I will leave current max profile metrics 4 then.

Will respin v2.

> 
> Other than this,
> 
> Acked-by: Song Liu <songliubraving@fb.com>
> 
> Thanks!
> 

      reply	other threads:[~2020-11-19  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19  4:23 [PATCH bpf-next] bpftool: add {i,d}tlb_misses support for bpftool profile Yonghong Song
2020-11-19  5:03 ` Song Liu
2020-11-19  7:18   ` Yonghong Song [this message]

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=c6c774d7-2d1f-b16b-d10a-603373f029a5@fb.com \
    --to=yhs@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=songliubraving@fb.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.