bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joanne Koong <joannekoong@fb.com>
To: Yonghong Song <yhs@fb.com>, <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<kafai@fb.com>, <Kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: Add bloom map success test for userspace calls
Date: Fri, 29 Oct 2021 15:30:59 -0700	[thread overview]
Message-ID: <e0b8bc63-c330-4d6a-ca49-6315648dd815@fb.com> (raw)
In-Reply-To: <d2de3cf7-7f0f-dbdc-63e3-c91478b16ae7@fb.com>

On 10/29/21 3:04 PM, Yonghong Song wrote:

> On 10/29/21 10:01 AM, Joanne Koong wrote:
>> This patch has two changes:
>> 1) Adds a new function "test_success_cases" to test
>> successfully creating + adding + looking up a value
>> in a bloom filter map from the userspace side.
>>
>> 2) Use bpf_create_map instead of bpf_create_map_xattr in
>> the "test_fail_cases" to make the code look cleaner.
>>
>> Signed-off-by: Joanne Koong <joannekoong@fb.com>
>
> LGTM with one minor comment below.
>
> Acked-by: Yonghong Song <yhs@fb.com>
>
>> ---
>>   .../bpf/prog_tests/bloom_filter_map.c         | 53 ++++++++++++-------
>>   1 file changed, 33 insertions(+), 20 deletions(-)
>>
>> diff --git 
>> a/tools/testing/selftests/bpf/prog_tests/bloom_filter_map.c 
>> b/tools/testing/selftests/bpf/prog_tests/bloom_filter_map.c
>> index 9aa3fbed918b..dbc0035e43e5 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/bloom_filter_map.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/bloom_filter_map.c
>> @@ -7,44 +7,32 @@
>>     static void test_fail_cases(void)
>>   {
>> -    struct bpf_create_map_attr xattr = {
>> -        .name = "bloom_filter_map",
>> -        .map_type = BPF_MAP_TYPE_BLOOM_FILTER,
>> -        .max_entries = 100,
>> -        .value_size = 11,
>> -    };
>>       __u32 value;
>>       int fd, err;
>>         /* Invalid key size */
>> -    xattr.key_size = 4;
>> -    fd = bpf_create_map_xattr(&xattr);
>> +    fd = bpf_create_map(BPF_MAP_TYPE_BLOOM_FILTER, 4, sizeof(value), 
>> 100, 0);
>>       if (!ASSERT_LT(fd, 0, "bpf_create_map bloom filter invalid key 
>> size"))
>>           close(fd);
>> -    xattr.key_size = 0;
>>         /* Invalid value size */
>> -    xattr.value_size = 0;
>> -    fd = bpf_create_map_xattr(&xattr);
>> +    fd = bpf_create_map(BPF_MAP_TYPE_BLOOM_FILTER, 0, 0, 100, 0);
>>       if (!ASSERT_LT(fd, 0, "bpf_create_map bloom filter invalid 
>> value size 0"))
>>           close(fd);
>> -    xattr.value_size = 11;
>>         /* Invalid max entries size */
>> -    xattr.max_entries = 0;
>> -    fd = bpf_create_map_xattr(&xattr);
>> -    if (!ASSERT_LT(fd, 0, "bpf_create_map bloom filter invalid max 
>> entries size"))
>> +    fd = bpf_create_map(BPF_MAP_TYPE_BLOOM_FILTER, 0, sizeof(value), 
>> 0, 0);
>> +    if (!ASSERT_LT(fd, 0,
>> +               "bpf_create_map bloom filter invalid max entries size"))
>
> It is OK to have "bpf_create_map ..." in the same line as ASSERT_LT
> for better readability and consistent with other ASSERT_LT. It is over 
> 80 but less than 100 char's per line.
>
Great, I will send out v2 of this patchset where this line break is 
removed.
Thanks for reviewing the patchset!
>>           close(fd);
>> -    xattr.max_entries = 100;
>>         /* Bloom filter maps do not support BPF_F_NO_PREALLOC */
>> -    xattr.map_flags = BPF_F_NO_PREALLOC;
>> -    fd = bpf_create_map_xattr(&xattr);
>> +    fd = bpf_create_map(BPF_MAP_TYPE_BLOOM_FILTER, 0, sizeof(value), 
>> 100,
>> +                BPF_F_NO_PREALLOC);
>>       if (!ASSERT_LT(fd, 0, "bpf_create_map bloom filter invalid 
>> flags"))
>>           close(fd);
>> -    xattr.map_flags = 0;
>>   -    fd = bpf_create_map_xattr(&xattr);
>> +    fd = bpf_create_map(BPF_MAP_TYPE_BLOOM_FILTER, 0, sizeof(value), 
>> 100, 0);
>>       if (!ASSERT_GE(fd, 0, "bpf_create_map bloom filter"))
>>           return;
>>   @@ -67,6 +55,30 @@ static void test_fail_cases(void)
>>       close(fd);
>>   }
> [...]

  reply	other threads:[~2021-10-29 22:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 17:01 [PATCH bpf-next 0/3] "map_extra" and bloom filter fixups Joanne Koong
2021-10-29 17:01 ` [PATCH bpf-next 1/3] bpf: Bloom filter map naming fixups Joanne Koong
2021-10-29 21:28   ` Yonghong Song
2021-10-29 17:01 ` [PATCH bpf-next 2/3] bpf: Add alignment padding for "map_extra" + consolidate holes Joanne Koong
2021-10-29 21:29   ` Yonghong Song
2021-10-29 17:01 ` [PATCH bpf-next 3/3] selftests/bpf: Add bloom map success test for userspace calls Joanne Koong
2021-10-29 22:04   ` Yonghong Song
2021-10-29 22:30     ` Joanne Koong [this message]
2021-10-29 22:49 [PATCH bpf-next 0/3] "map_extra" and bloom filter fixups Joanne Koong
2021-10-29 22:49 ` [PATCH bpf-next 3/3] selftests/bpf: Add bloom map success test for userspace calls Joanne Koong

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=e0b8bc63-c330-4d6a-ca49-6315648dd815@fb.com \
    --to=joannekoong@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=yhs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).