aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-03-29 10:48:54 -0700
committerRoland Dreier <rolandd@cisco.com>2007-03-29 10:51:58 -0700
commit707de5ef26930436242ced850e6fe81e4deb059c (patch)
treeed213c16287f1ce92fbb6e6cfc274edbb46f7c4a
parent66cab911bbfa63a3cb7a8600a27bfe41dc7546b1 (diff)
downloadlibibverbs-707de5ef26930436242ced850e6fe81e4deb059c.tar.gz
Print warning if memlock limit is low
Check RLIMIT_MEMLOCK, and if it is 32 KB or less, print a warning. This should help with support requests for systems that set this limit too low. Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--src/init.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/init.c b/src/init.c
index 664c584..5319e86 100644
--- a/src/init.c
+++ b/src/init.c
@@ -43,6 +43,8 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <dirent.h>
#include "ibverbs.h"
@@ -406,6 +408,21 @@ static int check_abi_version(const char *path)
return 0;
}
+static void check_memlock_limit(void)
+{
+ struct rlimit rlim;
+
+ if (getrlimit(RLIMIT_MEMLOCK, &rlim)) {
+ fprintf(stderr, PFX "Warning: getrlimit(RLIMIT_MEMLOCK) failed.");
+ return;
+ }
+
+ if (rlim.rlim_cur <= 32768)
+ fprintf(stderr, PFX "Warning: RLIMIT_MEMLOCK is %lu bytes.\n"
+ " This will severely limit memory registrations.",
+ rlim.rlim_cur);
+}
+
static void add_device(struct ibv_device *dev,
struct ibv_device ***dev_list,
int *num_devices,
@@ -450,6 +467,8 @@ HIDDEN int ibverbs_init(struct ibv_device ***list)
if (check_abi_version(sysfs_path))
return 0;
+ check_memlock_limit();
+
read_config();
find_sysfs_devs();