diff mbox series

[bpf-next,v7,1/2] selftests/bpf: Add min() and max() macros in bpf_util.h

Message ID 20230628115910.3817966-2-houtao@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series Add benchmark for bpf memory allocator | expand

Commit Message

Hou Tao June 28, 2023, 11:59 a.m. UTC
From: Hou Tao <houtao1@huawei.com>

max() will be used by the following htab-mem benchmark patch.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 tools/testing/selftests/bpf/bpf_util.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Alexei Starovoitov June 28, 2023, 6:02 p.m. UTC | #1
On Wed, Jun 28, 2023 at 4:41 AM Hou Tao <houtao@huaweicloud.com> wrote:
>
> From: Hou Tao <houtao1@huawei.com>
>
> max() will be used by the following htab-mem benchmark patch.
>
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
>  tools/testing/selftests/bpf/bpf_util.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
> index 10587a29b967..e87e9f8c13a7 100644
> --- a/tools/testing/selftests/bpf/bpf_util.h
> +++ b/tools/testing/selftests/bpf/bpf_util.h
> @@ -59,4 +59,11 @@ static inline void bpf_strlcpy(char *dst, const char *src, size_t sz)
>         (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
>  #endif
>
> +#ifndef min
> +#define min(x, y) ((x) < (y) ? (x) : (y))
> +#endif
> +#ifndef max
> +#define max(x, y) ((x) < (y) ? (y) : (x))
> +#endif

That's for user space only?
Just use the standard MIN/MAX macros.
Hou Tao June 29, 2023, 2:28 a.m. UTC | #2
Hi,

On 6/29/2023 2:02 AM, Alexei Starovoitov wrote:
> On Wed, Jun 28, 2023 at 4:41 AM Hou Tao <houtao@huaweicloud.com> wrote:
>> From: Hou Tao <houtao1@huawei.com>
>>
>> max() will be used by the following htab-mem benchmark patch.
>>
>> Signed-off-by: Hou Tao <houtao1@huawei.com>
>> ---
>>  tools/testing/selftests/bpf/bpf_util.h | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
>> index 10587a29b967..e87e9f8c13a7 100644
>> --- a/tools/testing/selftests/bpf/bpf_util.h
>> +++ b/tools/testing/selftests/bpf/bpf_util.h
>> @@ -59,4 +59,11 @@ static inline void bpf_strlcpy(char *dst, const char *src, size_t sz)
>>         (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
>>  #endif
>>
>> +#ifndef min
>> +#define min(x, y) ((x) < (y) ? (x) : (y))
>> +#endif
>> +#ifndef max
>> +#define max(x, y) ((x) < (y) ? (y) : (x))
>> +#endif
> That's for user space only?
> Just use the standard MIN/MAX macros.
> .
Yes. Will update and remove this prepare patch.
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
index 10587a29b967..e87e9f8c13a7 100644
--- a/tools/testing/selftests/bpf/bpf_util.h
+++ b/tools/testing/selftests/bpf/bpf_util.h
@@ -59,4 +59,11 @@  static inline void bpf_strlcpy(char *dst, const char *src, size_t sz)
 	(offsetof(TYPE, MEMBER)	+ sizeof_field(TYPE, MEMBER))
 #endif
 
+#ifndef min
+#define min(x, y) ((x) < (y) ? (x) : (y))
+#endif
+#ifndef max
+#define max(x, y) ((x) < (y) ? (y) : (x))
+#endif
+
 #endif /* __BPF_UTIL__ */