diff mbox series

[bpf-next,04/17] selftests: xsk: set rlimit per thread

Message ID 20210727131753.10924-5-magnus.karlsson@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series selftests: xsk: various simplifications | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 9 maintainers not CCed: linux-kselftest@vger.kernel.org kpsingh@kernel.org hawk@kernel.org kafai@fb.com john.fastabend@gmail.com songliubraving@fb.com davem@davemloft.net shuah@kernel.org kuba@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Magnus Karlsson July 27, 2021, 1:17 p.m. UTC
From: Magnus Karlsson <magnus.karlsson@intel.com>

Set rlimit per thread instead of on the main thread. The main thread
does not register any umem area so do not need this.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 tools/testing/selftests/bpf/xdpxceiver.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Yonghong Song July 27, 2021, 6:39 p.m. UTC | #1
On 7/27/21 6:17 AM, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Set rlimit per thread instead of on the main thread. The main thread
> does not register any umem area so do not need this.

I think setrlimit() is per process. Did I miss anything?

> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>   tools/testing/selftests/bpf/xdpxceiver.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
> index 4d8ee636fc24..2100ab4e58b7 100644
> --- a/tools/testing/selftests/bpf/xdpxceiver.c
> +++ b/tools/testing/selftests/bpf/xdpxceiver.c
> @@ -252,6 +252,7 @@ static void gen_eth_frame(struct xsk_umem_info *umem, u64 addr)
>   
>   static void xsk_configure_umem(struct ifobject *data, void *buffer, int idx)
>   {
> +	const struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY };
>   	struct xsk_umem_config cfg = {
>   		.fill_size = XSK_RING_PROD__DEFAULT_NUM_DESCS,
>   		.comp_size = XSK_RING_CONS__DEFAULT_NUM_DESCS,
> @@ -263,6 +264,10 @@ static void xsk_configure_umem(struct ifobject *data, void *buffer, int idx)
>   	struct xsk_umem_info *umem;
>   	int ret;
>   
> +	ret = XSK_UMEM__DEFAULT_FRAME_SIZE;
> +	if (setrlimit(RLIMIT_MEMLOCK, &_rlim))
> +		exit_with_error(errno);
> +
>   	umem = calloc(1, sizeof(struct xsk_umem_info));
>   	if (!umem)
>   		exit_with_error(errno);
> @@ -1088,13 +1093,9 @@ static void run_pkt_test(int mode, int type)
>   
>   int main(int argc, char **argv)
>   {
> -	struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY };
>   	bool failure = false;
>   	int i, j;
>   
> -	if (setrlimit(RLIMIT_MEMLOCK, &_rlim))
> -		exit_with_error(errno);
> -
>   	for (int i = 0; i < MAX_INTERFACES; i++) {
>   		ifdict[i] = malloc(sizeof(struct ifobject));
>   		if (!ifdict[i])
>
Magnus Karlsson July 28, 2021, 6:13 a.m. UTC | #2
On Tue, Jul 27, 2021 at 8:39 PM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 7/27/21 6:17 AM, Magnus Karlsson wrote:
> > From: Magnus Karlsson <magnus.karlsson@intel.com>
> >
> > Set rlimit per thread instead of on the main thread. The main thread
> > does not register any umem area so do not need this.
>
> I think setrlimit() is per process. Did I miss anything?

No, you are correct. I must have gotten confused by the heat or
something. Will remove this patch from the set.

Thanks!

> >
> > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> > ---
> >   tools/testing/selftests/bpf/xdpxceiver.c | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
> > index 4d8ee636fc24..2100ab4e58b7 100644
> > --- a/tools/testing/selftests/bpf/xdpxceiver.c
> > +++ b/tools/testing/selftests/bpf/xdpxceiver.c
> > @@ -252,6 +252,7 @@ static void gen_eth_frame(struct xsk_umem_info *umem, u64 addr)
> >
> >   static void xsk_configure_umem(struct ifobject *data, void *buffer, int idx)
> >   {
> > +     const struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY };
> >       struct xsk_umem_config cfg = {
> >               .fill_size = XSK_RING_PROD__DEFAULT_NUM_DESCS,
> >               .comp_size = XSK_RING_CONS__DEFAULT_NUM_DESCS,
> > @@ -263,6 +264,10 @@ static void xsk_configure_umem(struct ifobject *data, void *buffer, int idx)
> >       struct xsk_umem_info *umem;
> >       int ret;
> >
> > +     ret = XSK_UMEM__DEFAULT_FRAME_SIZE;
> > +     if (setrlimit(RLIMIT_MEMLOCK, &_rlim))
> > +             exit_with_error(errno);
> > +
> >       umem = calloc(1, sizeof(struct xsk_umem_info));
> >       if (!umem)
> >               exit_with_error(errno);
> > @@ -1088,13 +1093,9 @@ static void run_pkt_test(int mode, int type)
> >
> >   int main(int argc, char **argv)
> >   {
> > -     struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY };
> >       bool failure = false;
> >       int i, j;
> >
> > -     if (setrlimit(RLIMIT_MEMLOCK, &_rlim))
> > -             exit_with_error(errno);
> > -
> >       for (int i = 0; i < MAX_INTERFACES; i++) {
> >               ifdict[i] = malloc(sizeof(struct ifobject));
> >               if (!ifdict[i])
> >
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
index 4d8ee636fc24..2100ab4e58b7 100644
--- a/tools/testing/selftests/bpf/xdpxceiver.c
+++ b/tools/testing/selftests/bpf/xdpxceiver.c
@@ -252,6 +252,7 @@  static void gen_eth_frame(struct xsk_umem_info *umem, u64 addr)
 
 static void xsk_configure_umem(struct ifobject *data, void *buffer, int idx)
 {
+	const struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY };
 	struct xsk_umem_config cfg = {
 		.fill_size = XSK_RING_PROD__DEFAULT_NUM_DESCS,
 		.comp_size = XSK_RING_CONS__DEFAULT_NUM_DESCS,
@@ -263,6 +264,10 @@  static void xsk_configure_umem(struct ifobject *data, void *buffer, int idx)
 	struct xsk_umem_info *umem;
 	int ret;
 
+	ret = XSK_UMEM__DEFAULT_FRAME_SIZE;
+	if (setrlimit(RLIMIT_MEMLOCK, &_rlim))
+		exit_with_error(errno);
+
 	umem = calloc(1, sizeof(struct xsk_umem_info));
 	if (!umem)
 		exit_with_error(errno);
@@ -1088,13 +1093,9 @@  static void run_pkt_test(int mode, int type)
 
 int main(int argc, char **argv)
 {
-	struct rlimit _rlim = { RLIM_INFINITY, RLIM_INFINITY };
 	bool failure = false;
 	int i, j;
 
-	if (setrlimit(RLIMIT_MEMLOCK, &_rlim))
-		exit_with_error(errno);
-
 	for (int i = 0; i < MAX_INTERFACES; i++) {
 		ifdict[i] = malloc(sizeof(struct ifobject));
 		if (!ifdict[i])