Whamcloud - gitweb
LU-7734 lnet: add lnet_max_interfaces tunable 92/21092/10
authorOlaf Weber <olaf@sgi.com>
Fri, 27 Jan 2017 15:15:07 +0000 (16:15 +0100)
committerOlaf Weber <olaf@sgi.com>
Fri, 27 Jan 2017 15:40:59 +0000 (16:40 +0100)
Add an lnet_max_interfaces tunable value, that describes the maximum
number of interfaces per node. This tunable is primarily useful for
sanity checks prior to allocating memory.

Add LNET_MIN_INTERFACES, value 16, as the minimum value.

Add LNET_MAX_INTERFACES_DEFAULT, value 200, as the default value. This
value was chosen to ensure that the size of an LNet ping message with
any associated LND overhead would fit in 4096 bytes.

(The LNET_MAX_INTERFACES name was not reused to allow for the early
detection of issues when merging code that uses it.)

Test-Parameters: trivial
Signed-off-by: Olaf Weber <olaf@sgi.com>
Change-Id: I1fd88e9e37d21614bb0af8a4fe14d9ae5ae62c1e

lnet/include/lnet/types.h
lnet/lnet/api-ni.c

index 58cee3f..e45b60f 100644 (file)
@@ -248,6 +248,11 @@ typedef struct lnet_counters {
  */
 #define LNET_NUM_INTERFACES    16
 
+/* The minimum number of interfaces per node supported by LNet. */
+#define LNET_MIN_INTERFACES    16
+/* The default - arbitrary - value of the lnet_max_interfaces tunable. */
+#define LNET_MAX_INTERFACES_DEFAULT    200
+
 /**
  * Objects maintained by the LNet are accessed through handles. Handle types
  * have names of the form lnet_handle_xx_t, where xx is one of the two letter
index 1500833..fdeb751 100644 (file)
@@ -67,6 +67,11 @@ module_param(lnet_numa_range, uint, 0444);
 MODULE_PARM_DESC(lnet_numa_range,
                "NUMA range to consider during Multi-Rail selection");
 
+static int lnet_max_interfaces = LNET_MAX_INTERFACES_DEFAULT;
+module_param(lnet_max_interfaces, int, 0444);
+MODULE_PARM_DESC(lnet_max_interfaces,
+               "Maximum number of interfaces in a node.");
+
 /*
  * This sequence number keeps track of how many times DLC was used to
  * update the local NIs. It is incremented when a NI is added or
@@ -1702,6 +1707,9 @@ int lnet_lib_init(void)
 
        lnet_assert_wire_constants();
 
+       if (lnet_max_interfaces < LNET_MIN_INTERFACES)
+               lnet_max_interfaces = LNET_MIN_INTERFACES;
+
        memset(&the_lnet, 0, sizeof(the_lnet));
 
        /* refer to global cfs_cpt_table for now */
@@ -3036,7 +3044,7 @@ static int lnet_ping(lnet_process_id_t id, signed long timeout,
        infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]);
 
        /* n_ids limit is arbitrary */
-       if (n_ids <= 0 || n_ids > 20 || id.nid == LNET_NID_ANY)
+       if (n_ids <= 0 || n_ids > lnet_max_interfaces || id.nid == LNET_NID_ANY)
                return -EINVAL;
 
        if (id.pid == LNET_PID_ANY)