Hi Alexei,

Thank you, I've sent the patch to netdev.

Regards,
William

On Tue, Jun 21, 2016 at 6:45 PM, Alexei Starovoitov
<[email protected]> wrote:
> On Tue, Jun 21, 2016 at 11:03 AM, William Tu via iovisor-dev
> <[email protected]> wrote:
>> Hi,
>>
>> I'm trying to run sockex2 and sockex3 but got the error:
>> [root@vm-dev bpf]# ./sockex2
>> failed to create a map: 1 Operation not permitted
>>
>> Then I found that I have max locked memory set to 64K, after reconfig
>> to unlimited then the bpf map is created and sockex2/3 works fine.
>> The hash_map created in sockex2_kern.c should be less than 64k (1024
>> entry * (sizeof (__be32) + sizeof(struct pair)), so I don't understand
>> why increasing max locked memory solves the error.
>
> kernel counts the real cost of the map including kernel internal fields.
> See htab_map_alloc()
>
>>
>> Or should we increase the lock memory in the beginning?
>>
>> --- a/samples/bpf/sockex2_user.c
>> +++ b/samples/bpf/sockex2_user.c
>> @@ -1,4 +1,5 @@
>>  #include <stdio.h>
>> +#include <sys/resource.h>
>>  #include <assert.h>
>>  #include <linux/bpf.h>
>>  #include "libbpf.h"
>> @@ -13,11 +14,13 @@ struct pair {
>>
>>  int main(int ac, char **argv)
>>  {
>> +       struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
>>         char filename[256];
>>         FILE *f;
>>         int i, sock;
>>
>>         snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
>> +       setrlimit(RLIMIT_MEMLOCK, &r);
>
> yes. we started to use that it most of the new tests.
> pls send the official patch to netdev.
_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

Reply via email to