From: Feng Zhou <zhoufeng.zf@bytedance.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Network Development <netdev@vger.kernel.org>,
bpf <bpf@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Xiongchun Duan <duanxiongchun@bytedance.com>,
Muchun Song <songmuchun@bytedance.com>,
Dongdong Wang <wangdongdong.6@bytedance.com>,
Cong Wang <cong.wang@bytedance.com>,
Chengming Zhou <zhouchengming@bytedance.com>
Subject: Re: Re: Re: [PATCH v4 2/2] selftest/bpf/benchs: Add bpf_map benchmark
Date: Thu, 2 Jun 2022 11:29:09 +0800 [thread overview]
Message-ID: <6181d77a-66ed-76ff-35a4-b24134bc67fb@bytedance.com> (raw)
In-Reply-To: <CAADnVQ+cCoH=DAoyLGtJ5HvdNVgFBgTW=wCHs1wvFQuwyhcWOw@mail.gmail.com>
在 2022/6/1 下午7:37, Alexei Starovoitov 写道:
> On Wed, Jun 1, 2022 at 1:17 PM Feng Zhou <zhoufeng.zf@bytedance.com> wrote:
>> 在 2022/6/1 下午5:53, Alexei Starovoitov 写道:
>>> On Wed, Jun 1, 2022 at 10:42 AM Feng zhou <zhoufeng.zf@bytedance.com> wrote:
>>>> +struct {
>>>> + __uint(type, BPF_MAP_TYPE_HASH);
>>>> + __type(key, u32);
>>>> + __type(value, u64);
>>>> + __uint(max_entries, MAX_ENTRIES);
>>>> +} hash_map_bench SEC(".maps");
>>>> +
>>>> +u64 __attribute__((__aligned__(256))) percpu_time[256];
>>> aligned 256 ?
>>> What is the point?
>> I didn't think too much about it here, just referenced it from
>> tools/testing/selftests/bpf/progs/bloom_filter_bench.c
>>
>>>> +u64 nr_loops;
>>>> +
>>>> +static int loop_update_callback(__u32 index, u32 *key)
>>>> +{
>>>> + u64 init_val = 1;
>>>> +
>>>> + bpf_map_update_elem(&hash_map_bench, key, &init_val, BPF_ANY);
>>>> + return 0;
>>>> +}
>>>> +
>>>> +SEC("fentry/" SYS_PREFIX "sys_getpgid")
>>>> +int benchmark(void *ctx)
>>>> +{
>>>> + u32 key = bpf_get_prandom_u32() % MAX_ENTRIES + MAX_ENTRIES;
>>> What is the point of random ?
>>> just key = MAX_ENTRIES would be the same, no?
>>> or key = -1 ?
>> If all threads on different cpu trigger sys_getpgid and lookup the same
>> key, it will cause
>> "ret = htab_lock_bucket(htab, b, hash, &flags);"
>> the lock competition here is fierce, and unnecessary overhead is
>> introduced,
>> and I don't want it to interfere with the test.
> I see.
> but using random leaves it to chance.
> Use cpu+max_entries then?
Ok, will do. Thanks.
prev parent reply other threads:[~2022-06-02 3:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 8:41 [PATCH v4 0/2] Optimize performance of update hash-map when free is zero Feng zhou
2022-06-01 8:41 ` [PATCH v4 1/2] bpf: avoid grabbing spin_locks of all cpus when no free elems Feng zhou
2022-06-01 9:50 ` Alexei Starovoitov
2022-06-01 11:10 ` [External] " Feng Zhou
2022-06-01 11:35 ` Alexei Starovoitov
2022-06-02 3:27 ` Feng Zhou
2022-06-06 6:12 ` Feng Zhou
2022-06-01 8:41 ` [PATCH v4 2/2] selftest/bpf/benchs: Add bpf_map benchmark Feng zhou
2022-06-01 9:53 ` Alexei Starovoitov
2022-06-01 11:17 ` Feng Zhou
2022-06-01 11:37 ` Alexei Starovoitov
2022-06-02 3:29 ` Feng Zhou [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=6181d77a-66ed-76ff-35a4-b24134bc67fb@bytedance.com \
--to=zhoufeng.zf@bytedance.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=duanxiongchun@bytedance.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=songmuchun@bytedance.com \
--cc=wangdongdong.6@bytedance.com \
--cc=yhs@fb.com \
--cc=zhouchengming@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®