]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Print warning if memlock limit is low
authorRoland Dreier <rolandd@cisco.com>
Thu, 29 Mar 2007 17:48:54 +0000 (10:48 -0700)
committerRoland Dreier <rolandd@cisco.com>
Thu, 29 Mar 2007 17:51:58 +0000 (10:51 -0700)
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>
src/init.c

index 664c5845a6fd00b0f88019645851794bfc3c7c40..5319e864a1e151ca85eaf03c255fa0b1579d1927 100644 (file)
@@ -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();