From d934eb3c4f63858245132b55363002cda722c50b Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Wed, 10 Jun 2020 15:27:23 -0700 Subject: [PATCH] LU-13662 lnet: handle undefined parameters If peer_tx_credits or peer_credits are 0, they should be defaulted to the system defaults 8 and 256 respectively Signed-off-by: Amir Shehata Change-Id: I351ff37cba0a9adaa1a6c25ff9c7da701724db2b Reviewed-on: https://review.whamcloud.com/38894 Tested-by: jenkins Reviewed-by: Serguei Smirnov Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-lnet.h | 4 +++- lnet/klnds/o2iblnd/o2iblnd_modparams.c | 4 ++-- lnet/klnds/socklnd/socklnd_modparams.c | 4 ++-- lnet/lnet/api-ni.c | 26 +++++++++++++++++++++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 8e27802..1c690cb 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -74,8 +74,10 @@ extern struct lnet the_lnet; /* THE network */ /** exclusive lock */ #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX -/* default timeout */ +/* default timeout and credits */ #define DEFAULT_PEER_TIMEOUT 180 +#define DEFAULT_PEER_CREDITS 8 +#define DEFAULT_CREDITS 256 #ifdef HAVE_KERN_SOCK_GETNAME_2ARGS #define lnet_kernel_getpeername(sock, addr, addrlen) \ diff --git a/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/lnet/klnds/o2iblnd/o2iblnd_modparams.c index 2095958..a9ac2d8 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -66,11 +66,11 @@ module_param(ntx, int, 0444); MODULE_PARM_DESC(ntx, "# of message descriptors allocated for each pool"); /* NB: this value is shared by all CPTs */ -static int credits = 256; +static int credits = DEFAULT_CREDITS; module_param(credits, int, 0444); MODULE_PARM_DESC(credits, "# concurrent sends"); -static int peer_credits = 8; +static int peer_credits = DEFAULT_PEER_CREDITS; module_param(peer_credits, int, 0444); MODULE_PARM_DESC(peer_credits, "# concurrent sends to 1 peer"); diff --git a/lnet/klnds/socklnd/socklnd_modparams.c b/lnet/klnds/socklnd/socklnd_modparams.c index fb8b95c..2204280 100644 --- a/lnet/klnds/socklnd/socklnd_modparams.c +++ b/lnet/klnds/socklnd/socklnd_modparams.c @@ -30,11 +30,11 @@ static int sock_timeout; module_param(sock_timeout, int, 0644); MODULE_PARM_DESC(sock_timeout, "dead socket timeout (seconds)"); -static int credits = 256; +static int credits = DEFAULT_CREDITS; module_param(credits, int, 0444); MODULE_PARM_DESC(credits, "# concurrent sends"); -static int peer_credits = 8; +static int peer_credits = DEFAULT_PEER_CREDITS; module_param(peer_credits, int, 0444); MODULE_PARM_DESC(peer_credits, "# concurrent sends to 1 peer"); diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 62411c6..8c97fba 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -3171,6 +3171,19 @@ failed: return rc; } +static void +lnet_set_tune_defaults(struct lnet_ioctl_config_lnd_tunables *tun) +{ + if (tun) { + if (!tun->lt_cmn.lct_peer_timeout) + tun->lt_cmn.lct_peer_timeout = DEFAULT_PEER_TIMEOUT; + if (!tun->lt_cmn.lct_peer_tx_credits) + tun->lt_cmn.lct_peer_tx_credits = DEFAULT_PEER_CREDITS; + if (!tun->lt_cmn.lct_max_tx_credits) + tun->lt_cmn.lct_max_tx_credits = DEFAULT_CREDITS; + } +} + static int lnet_handle_legacy_ip2nets(char *ip2nets, struct lnet_ioctl_config_lnd_tunables *tun) { @@ -3187,6 +3200,8 @@ static int lnet_handle_legacy_ip2nets(char *ip2nets, if (rc < 0) return rc; + lnet_set_tune_defaults(tun); + mutex_lock(&the_lnet.ln_api_mutex); while (!list_empty(&net_head)) { net = list_entry(net_head.next, struct lnet_net, net_list); @@ -3248,6 +3263,8 @@ int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf) if (!ni) return -ENOMEM; + lnet_set_tune_defaults(tun); + mutex_lock(&the_lnet.ln_api_mutex); rc = lnet_add_net_common(net, tun); @@ -3380,13 +3397,16 @@ lnet_dyn_add_net(struct lnet_ioctl_config_data *conf) memset(&tun, 0, sizeof(tun)); tun.lt_cmn.lct_peer_timeout = - conf->cfg_config_u.cfg_net.net_peer_timeout; + (!conf->cfg_config_u.cfg_net.net_peer_timeout) ? DEFAULT_PEER_TIMEOUT : + conf->cfg_config_u.cfg_net.net_peer_timeout; tun.lt_cmn.lct_peer_tx_credits = - conf->cfg_config_u.cfg_net.net_peer_tx_credits; + (!conf->cfg_config_u.cfg_net.net_peer_tx_credits) ? DEFAULT_PEER_CREDITS : + conf->cfg_config_u.cfg_net.net_peer_tx_credits; tun.lt_cmn.lct_peer_rtr_credits = conf->cfg_config_u.cfg_net.net_peer_rtr_credits; tun.lt_cmn.lct_max_tx_credits = - conf->cfg_config_u.cfg_net.net_max_tx_credits; + (!conf->cfg_config_u.cfg_net.net_max_tx_credits) ? DEFAULT_CREDITS : + conf->cfg_config_u.cfg_net.net_max_tx_credits; rc = lnet_add_net_common(net, &tun); -- 1.8.3.1