[ofa-general] [PATCH] suppress RLIMIT warning for root user (was Re: there is a warning message in every use of the library libibverbs)

Michael S. Tsirkin mst at dev.mellanox.co.il
Tue May 29 02:12:46 PDT 2007


root can register as much memory as he likes, so the rlimit
value shouldn't matter in this case. Do not print a warning
about RLIMIT being too low in this case.

Signed-off-by: Michael S. Tsirkin <mst at dev.mellanox.co.il>

---

> Quoting Roland Dreier <rdreier at cisco.com>:
> Subject: Re: there is a warning message in every use of the library libibverbs
> 
>  > In every test/application that uses the libibverbs (i think when the
>  > libibverbs init function is being called)
>  > i see the following warning:
>  > 
>  > <-start->
>  > libibverbs: Warning: RLIMIT_MEMLOCK is 32768 bytes.
>  >    This will severely limit memory registrations.
>  > <-end->
>  > 
>  > Why did you add this warning message?
> 
> To avoid the FAQ of "memory registration / CQ creation fails and I
> don't know why".

OK, but kernel side actually ignores the rlimit value for the root user,
so let's not print a warning in this case?

diff --git a/src/init.c b/src/init.c
index a17ae16..de485cb 100644
--- a/src/init.c
+++ b/src/init.c
@@ -417,10 +417,15 @@ static void check_memlock_limit(void)
 		return;
 	}
 
-	if (rlim.rlim_cur <= 32768)
-		fprintf(stderr, PFX "Warning: RLIMIT_MEMLOCK is %lu bytes.\n"
-			"    This will severely limit memory registrations.\n",
-			rlim.rlim_cur);
+	if (rlim.rlim_cur > 32768)
+		return;
+
+	if (!getuid())
+		return;
+
+	fprintf(stderr, PFX "Warning: RLIMIT_MEMLOCK is %lu bytes.\n"
+		"    This will severely limit memory registrations.\n",
+		rlim.rlim_cur);
 }
 
 static void add_device(struct ibv_device *dev,

-- 
MST



More information about the general mailing list