Whamcloud - gitweb
8bef92295a03e6640c7034d81a315858956c499a
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd_modparams.c
1 /*
2  * Copyright (C) 2004 Cluster File Systems, Inc.
3  *
4  * Copyright (C) 2009-2012 Cray, Inc.
5  *
6  *   Derived from work by: Eric Barton <eric@bartonsoftware.com>
7  *   Author: Nic Henke <nic@cray.com>
8  *
9  *   This file is part of Lustre, http://www.lustre.org.
10  *
11  *   Lustre is free software; you can redistribute it and/or
12  *   modify it under the terms of version 2 of the GNU General Public
13  *   License as published by the Free Software Foundation.
14  *
15  *   Lustre is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with Lustre; if not, write to the Free Software
22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  */
25
26 #include "gnilnd.h"
27
28 static int credits = 256;
29 CFS_MODULE_PARM(credits, "i", int, 0444,
30                 "# concurrent sends");
31
32 static int eager_credits = 256 * 1024;
33 CFS_MODULE_PARM(eager_credits, "i", int, 0444,
34                 "# eager buffers");
35
36 static int peer_credits = 16;
37 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
38                 "# LNet peer credits");
39
40 /* NB - we'll not actually limit sends to this, we just size the mailbox buffer
41  * such that at most we'll have concurrent_sends * max_immediate messages
42  * in the mailbox */
43 static int concurrent_sends = 0;
44 CFS_MODULE_PARM(concurrent_sends, "i", int, 0444,
45                 "# concurrent HW sends to 1 peer");
46
47 /* default for 2k nodes @ 16 peer credits */
48 static int fma_cq_size = 32768;
49 CFS_MODULE_PARM(fma_cq_size, "i", int, 0444,
50                 "size of the completion queue");
51
52 static int timeout = GNILND_BASE_TIMEOUT;
53 /* can't change @ runtime because LNet gets NI data at startup from
54  * this value */
55 CFS_MODULE_PARM(timeout, "i", int, 0444,
56                 "communications timeout (seconds)");
57
58 /* time to wait between datagram timeout and sending of next dgram */
59 static int min_reconnect_interval = GNILND_MIN_RECONNECT_TO;
60 CFS_MODULE_PARM(min_reconnect_interval, "i", int, 0644,
61                 "minimum connection retry interval (seconds)");
62
63 /* if this goes longer than timeout, we'll timeout the TX before
64  * the dgram */
65 static int max_reconnect_interval = GNILND_MAX_RECONNECT_TO;
66 CFS_MODULE_PARM(max_reconnect_interval, "i", int, 0644,
67                 "maximum connection retry interval (seconds)");
68
69 static int max_immediate = (2<<10);
70 CFS_MODULE_PARM(max_immediate, "i", int, 0644,
71                 "immediate/RDMA breakpoint");
72
73 static int checksum = GNILND_CHECKSUM_DEFAULT;
74 CFS_MODULE_PARM(checksum, "i", int, 0644,
75                 "0: None, 1: headers, 2: short msg, 3: all traffic");
76
77 static int checksum_dump = 0;
78 CFS_MODULE_PARM(checksum_dump, "i", int, 0644,
79                 "0: None, 1: dump log on failure, 2: payload data to D_INFO log");
80
81 static int bte_dlvr_mode = GNILND_RDMA_DLVR_OPTION;
82 CFS_MODULE_PARM(bte_dlvr_mode, "i", int, 0644,
83                 "enable hashing for BTE (RDMA) transfers");
84
85 static int bte_relaxed_ordering = 1;
86 CFS_MODULE_PARM(bte_relaxed_ordering, "i", int, 0644,
87                 "enable relaxed ordering (PASSPW) for BTE (RDMA) transfers");
88
89 #ifdef CONFIG_MK1OM
90 static int ptag = GNI_PTAG_LND_KNC;
91 #else
92 static int ptag = GNI_PTAG_LND;
93 #endif
94 CFS_MODULE_PARM(ptag, "i", int, 0444,
95                 "ptag for Gemini CDM");
96
97 static int max_retransmits = 1024;
98 CFS_MODULE_PARM(max_retransmits, "i", int, 0444,
99                 "max retransmits for FMA");
100
101 static int nwildcard = 4;
102 CFS_MODULE_PARM(nwildcard, "i", int, 0444,
103                 "# wildcard datagrams to post per net (interface)");
104
105 static int nice = -20;
106 CFS_MODULE_PARM(nice, "i", int, 0444,
107                 "nice value for kgnilnd threads, default -20");
108
109 static int rdmaq_intervals = 4;
110 CFS_MODULE_PARM(rdmaq_intervals, "i", int, 0644,
111                 "# intervals per second for rdmaq throttling, default 4, 0 to disable");
112
113 static int loops = 100;
114 CFS_MODULE_PARM(loops, "i", int, 0644,
115                 "# of loops before scheduler is friendly, default 100");
116
117 static int hash_size = 503;
118 CFS_MODULE_PARM(hash_size, "i", int, 0444,
119                 "prime number for peer/conn hash sizing, default 503");
120
121 static int peer_health = 0;
122 CFS_MODULE_PARM(peer_health, "i", int, 0444,
123                 "Disable peer timeout for LNet peer health, default off, > 0 to enable");
124
125 static int peer_timeout = -1;
126 CFS_MODULE_PARM(peer_timeout, "i", int, 0444,
127                 "Peer timeout used for peer_health, default based on gnilnd timeout, > -1 to manually set");
128
129 static int vmap_cksum = 0;
130 CFS_MODULE_PARM(vmap_cksum, "i", int, 0644,
131                 "use vmap for all kiov checksumming, default off");
132
133 static int mbox_per_block = GNILND_FMABLK;
134 CFS_MODULE_PARM(mbox_per_block, "i", int, 0644,
135                 "mailboxes per block");
136
137 static int nphys_mbox = 0;
138 CFS_MODULE_PARM(nphys_mbox, "i", int, 0444,
139                 "# mbox to preallocate from physical memory, default 0");
140
141 static int mbox_credits = GNILND_MBOX_CREDITS;
142 CFS_MODULE_PARM(mbox_credits, "i", int, 0644,
143                 "number of credits per mailbox");
144
145 static int sched_threads = GNILND_SCHED_THREADS;
146 CFS_MODULE_PARM(sched_threads, "i", int, 0444,
147                 "number of threads for moving data");
148
149 static int net_hash_size = 11;
150 CFS_MODULE_PARM(net_hash_size, "i", int, 0444,
151                 "prime number for net hash sizing, default 11");
152
153 static int hardware_timeout = GNILND_HARDWARE_TIMEOUT;
154 CFS_MODULE_PARM(hardware_timeout, "i", int, 0444,
155                 "maximum time for traffic to get from one node to another");
156
157 static int mdd_timeout = GNILND_MDD_TIMEOUT;
158 CFS_MODULE_PARM(mdd_timeout, "i", int, 0644,
159                 "maximum time (in minutes) for mdd to be held");
160
161 static int sched_timeout = GNILND_SCHED_TIMEOUT;
162 CFS_MODULE_PARM(sched_timeout, "i", int, 0644,
163                 "scheduler aliveness in seconds max time");
164
165 static int sched_nice = GNILND_SCHED_NICE;
166 CFS_MODULE_PARM(sched_nice, "i", int, 0444,
167                 "scheduler's nice setting, default compute 0 service -20");
168
169 static int reverse_rdma = GNILND_REVERSE_RDMA;
170 CFS_MODULE_PARM(reverse_rdma, "i", int, 0644,
171                 "Normal 0: Reverse GET: 1 Reverse Put: 2 Reverse Both: 3");
172
173 static int dgram_timeout = GNILND_DGRAM_TIMEOUT;
174 CFS_MODULE_PARM(dgram_timeout, "i", int, 0644,
175                 "dgram thread aliveness seconds max time");
176
177 static int efault_lbug = 0;
178 CFS_MODULE_PARM(efault_lbug, "i", int, 0644,
179                 "If a compute receives an EFAULT in"
180                 " a message should it LBUG. 0 off 1 on");
181
182 static int fast_reconn = GNILND_FAST_RECONNECT;
183 CFS_MODULE_PARM(fast_reconn, "i", int, 0644,
184                 "fast reconnect on connection timeout");
185
186 static int max_conn_purg = GNILND_PURGATORY_MAX;
187 CFS_MODULE_PARM(max_conn_purg, "i", int, 0644,
188                 "Max number of connections per peer in purgatory");
189
190 kgn_tunables_t kgnilnd_tunables = {
191         .kgn_min_reconnect_interval = &min_reconnect_interval,
192         .kgn_max_reconnect_interval = &max_reconnect_interval,
193         .kgn_credits                = &credits,
194         .kgn_peer_credits           = &peer_credits,
195         .kgn_concurrent_sends       = &concurrent_sends,
196         .kgn_fma_cq_size            = &fma_cq_size,
197         .kgn_timeout                = &timeout,
198         .kgn_max_immediate          = &max_immediate,
199         .kgn_checksum               = &checksum,
200         .kgn_checksum_dump          = &checksum_dump,
201         .kgn_bte_dlvr_mode          = &bte_dlvr_mode,
202         .kgn_bte_relaxed_ordering   = &bte_relaxed_ordering,
203         .kgn_ptag                   = &ptag,
204         .kgn_max_retransmits        = &max_retransmits,
205         .kgn_nwildcard              = &nwildcard,
206         .kgn_nice                   = &nice,
207         .kgn_rdmaq_intervals        = &rdmaq_intervals,
208         .kgn_loops                  = &loops,
209         .kgn_peer_hash_size         = &hash_size,
210         .kgn_peer_health            = &peer_health,
211         .kgn_peer_timeout           = &peer_timeout,
212         .kgn_vmap_cksum             = &vmap_cksum,
213         .kgn_mbox_per_block         = &mbox_per_block,
214         .kgn_nphys_mbox             = &nphys_mbox,
215         .kgn_mbox_credits           = &mbox_credits,
216         .kgn_sched_threads          = &sched_threads,
217         .kgn_net_hash_size          = &net_hash_size,
218         .kgn_hardware_timeout       = &hardware_timeout,
219         .kgn_mdd_timeout            = &mdd_timeout,
220         .kgn_sched_timeout          = &sched_timeout,
221         .kgn_sched_nice             = &sched_nice,
222         .kgn_reverse_rdma           = &reverse_rdma,
223         .kgn_dgram_timeout          = &dgram_timeout,
224         .kgn_eager_credits          = &eager_credits,
225         .kgn_fast_reconn            = &fast_reconn,
226         .kgn_efault_lbug            = &efault_lbug,
227         .kgn_max_purgatory          = &max_conn_purg
228 };
229
230 #if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM
231 static struct ctl_table kgnilnd_ctl_table[] = {
232         {
233                 INIT_CTL_NAME
234                 .procname = "min_reconnect_interval",
235                 .data     = &min_reconnect_interval,
236                 .maxlen   = sizeof(int),
237                 .mode     = 0644,
238                 .proc_handler = &proc_dointvec
239         },
240         {
241                 INIT_CTL_NAME
242                 .procname = "max_reconnect_interval",
243                 .data     = &max_reconnect_interval,
244                 .maxlen   = sizeof(int),
245                 .mode     = 0644,
246                 .proc_handler = &proc_dointvec
247         },
248         {
249                 INIT_CTL_NAME
250                 .procname = "credits",
251                 .data     = &credits,
252                 .maxlen   = sizeof(int),
253                 .mode     = 0444,
254                 .proc_handler = &proc_dointvec
255         },
256         {
257                 INIT_CTL_NAME
258                 .procname = "peer_credits",
259                 .data     = &peer_credits,
260                 .maxlen   = sizeof(int),
261                 .mode     = 0444,
262                 .proc_handler = &proc_dointvec
263         },
264         {
265                 INIT_CTL_NAME
266                 .procname = "fma_cq_size",
267                 .data     = &fma_cq_size,
268                 .maxlen   = sizeof(int),
269                 .mode     = 0444,
270                 .proc_handler = &proc_dointvec
271         },
272         {
273                 INIT_CTL_NAME
274                 .procname = "timeout",
275                 .data     = &timeout,
276                 .maxlen   = sizeof(int),
277                 .mode     = 0444,
278                 .proc_handler = &proc_dointvec
279         },
280         {
281                 INIT_CTL_NAME
282                 .procname = "max_immediate",
283                 .data     = &max_immediate,
284                 .maxlen   = sizeof(int),
285                 .mode     = 0444,
286                 .proc_handler = &proc_dointvec
287         },
288         {
289                 INIT_CTL_NAME
290                 .procname = "checksum",
291                 .data     = &checksum,
292                 .maxlen   = sizeof(int),
293                 .mode     = 0644,
294                 .proc_handler = &proc_dointvec
295         },
296         {
297                 INIT_CTL_NAME
298                 .procname = "bte_dlvr_mode",
299                 .data     = &bte_dlvr_mode,
300                 .maxlen   = sizeof(int),
301                 .mode     = 0644,
302                 .proc_handler = &proc_dointvec
303         },
304         {
305                 INIT_CTL_NAME
306                 .procname = "ptag",
307                 .data     = &ptag,
308                 .maxlen   = sizeof(int),
309                 .mode     = 0444,
310                 .proc_handler = &proc_dointvec
311         },
312         {
313                 INIT_CTL_NAME
314                 .procname = "nwildcard",
315                 .data     = &nwildcard,
316                 .maxlen   = sizeof(int),
317                 .mode     = 0444,
318                 .proc_handler = &proc_dointvec
319         },
320         {
321                 INIT_CTL_NAME
322                 .procname = "bte_relaxed_ordering",
323                 .data     = &bte_relaxed_ordering,
324                 .maxlen   = sizeof(int),
325                 .mode     = 0644,
326                 .proc_handler = &proc_dointvec
327         },
328         {
329                 INIT_CTL_NAME
330                 .procname = "checksum_dump",
331                 .data     = &checksum_dump,
332                 .maxlen   = sizeof(int),
333                 .mode     = 0644,
334                 .proc_handler = &proc_dointvec
335         },
336         {
337                 INIT_CTL_NAME
338                 .procname = "nice",
339                 .data     = &nice,
340                 .maxlen   = sizeof(int),
341                 .mode     = 0444,
342                 .proc_handler = &proc_dointvec
343         },
344         {
345                 INIT_CTL_NAME
346                 .procname = "rdmaq_intervals",
347                 .data     = &rdmaq_intervals,
348                 .maxlen   = sizeof(int),
349                 .mode     = 0644,
350                 .proc_handler = &proc_dointvec
351         },
352         {
353                 INIT_CTL_NAME
354                 .procname = "loops",
355                 .data     = &loops,
356                 .maxlen   = sizeof(int),
357                 .mode     = 0644,
358                 .proc_handler = &proc_dointvec
359         },
360         {
361                 INIT_CTL_NAME
362                 .procname = "hash_size",
363                 .data     = &hash_size,
364                 .maxlen   = sizeof(int),
365                 .mode     = 0444,
366                 .proc_handler = &proc_dointvec
367         },
368         {
369                 INIT_CTL_NAME
370                 .procname = "peer_health",
371                 .data     = &peer_health,
372                 .maxlen   = sizeof(int),
373                 .mode     = 0444,
374                 .proc_handler = &proc_dointvec
375         },
376         {
377                 INIT_CTL_NAME
378                 .procname = "vmap_cksum",
379                 .data     = &vmap_cksum,
380                 .maxlen   = sizeof(int),
381                 .mode     = 0644,
382                 .proc_handler = &proc_dointvec
383         },
384         {
385                 INIT_CTL_NAME
386                 .procname = "mbox_per_block",
387                 .data     = &mbox_per_block,
388                 .maxlen   = sizeof(int),
389                 .mode     = 0644,
390                 .proc_handler = &proc_dointvec
391         },
392         {
393                 INIT_CTL_NAME
394                 .procname = "mbox_credits"
395                 .data     = &mbox_credits,
396                 .maxlen   = sizeof(int),
397                 .mode     = 0644,
398                 .proc_handler = &proc_dointvec
399         },
400         {
401                 INIT_CTL_NAME
402                 .procname = "sched_threads"
403                 .data     = &sched_threads,
404                 .maxlen   = sizeof(int),
405                 .mode     = 0444,
406                 .proc_handler = &proc_dointvec
407         },
408         {
409                 INIT_CTL_NAME
410                 .procname = "net_hash_size",
411                 .data     = &net_hash_size,
412                 .maxlen   = sizeof(int),
413                 .mode     = 0444,
414                 .proc_handler = &proc_dointvec
415         },
416         {
417                 INIT_CTL_NAME
418                 .procname = "hardware_timeout",
419                 .data     = &hardware_timeout,
420                 .maxlen   = sizeof(int),
421                 .mode     = 0444,
422                 .proc_handler = &proc_dointvec
423         },
424         {
425                 INIT_CTL_NAME
426                 .procname = "mdd_timeout",
427                 .data     = &mdd_timeout,
428                 .maxlen   = sizeof(int),
429                 .mode     = 0644,
430                 .proc_handler = &proc_dointvec
431         },
432         {
433                 INIT_CTL_NAME
434                 .procname = "max_retransmits"
435                 .data     = &max_retransmits,
436                 .maxlen   = sizeof(int),
437                 .mode     = 0444,
438                 .proc_handler = &proc_dointvec
439         },
440         {
441                 INIT_CTL_NAME
442                 .procname = "concurrent_sends",
443                 .data     = &concurrent_sends,
444                 .maxlen   = sizeof(int),
445                 .mode     = 0444,
446                 .proc_handler = &proc_dointvec
447         },
448         {
449                 INIT_CTL_NAME
450                 .procname = "nphys_mbox",
451                 .data     = &nphys_mbox,
452                 .maxlen   = sizeof(int),
453                 .mode     = 0444,
454                 .proc_handler = &proc_dointvec
455         },
456         {
457                 INIT_CTL_NAME
458                 .procname = "sched_timeout",
459                 .data     = &sched_timeout,
460                 .maxlen   = sizeof(int),
461                 .mode     = 0644,
462                 .proc_handler = &proc_dointvec
463         },
464         {
465                 INIT_CTL_NAME
466                 .procname = "sched_nice",
467                 .data     = &sched_nice,
468                 .maxlen   = sizeof(int),
469                 .mode     = 0444,
470                 .proc_handler = &proc_dointvec
471         },
472         {
473                 INIT_CTL_NAME
474                 .procname = "reverse_rdma",
475                 .data     = &reverse_rdma,
476                 .maxlen   = sizeof(int),
477                 .mode     = 0644,
478                 .proc_handler = &proc_dointvec
479         },
480                 INIT_CTL_NAME
481                 .procname = "dgram_timeout"
482                 .data     = &dgram_timeout,
483                 .maxlen   = sizeof(int),
484                 .mode     = 0644,
485                 .proc_handler = &proc_dointvec
486         },
487         {
488                 INIT_CTL_NAME
489                 .procname = "peer_timeout"
490                 .data     = &peer_timeout,
491                 .maxlen   = sizeof(int),
492                 .mode     = 0444,
493                 .proc_handler = &proc_dointvec
494         },
495         {
496                 INIT_CTL_NAME
497                 .procname = "eager_credits",
498                 .data     = &eager_credits,
499                 .maxlen   = sizeof(int),
500                 .mode     = 0644,
501                 .proc_handler = &proc_dointvec
502         },
503         {
504                 INIT_CTL_NAME
505                 .procname = "efault_lbug"
506                 .data     = &efault_lbug,
507                 .maxlen   = sizeof(int),
508                 .mode     = 0644,
509                 .proc_handler = &proc_dointvec
510         },
511         {
512                 INIT_CTL_NAME
513                 .procname = "max_conn_purg"
514                 .data     = &max_conn_purg,
515                 .maxlen   = sizeof(int),
516                 .mode     = 0644,
517                 .proc_handler = &proc_dointvec
518         },
519         { 0 }
520 };
521
522 static struct ctl_table kgnilnd_top_ctl_table[] = {
523         {
524                 INIT_CTL_NAME
525                 .procname = "gnilnd",
526                 .data     = NULL,
527                 .maxlen   = 0,
528                 .mode     = 0555,
529                 .child    = kgnilnd_ctl_table
530         },
531         { 0 }
532 };
533 #endif
534
535 int
536 kgnilnd_tunables_init()
537 {
538         int rc = 0;
539
540 #if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM
541         kgnilnd_tunables.kgn_sysctl =
542                 cfs_register_sysctl_table(kgnilnd_top_ctl_table, 0);
543
544         if (kgnilnd_tunables.kgn_sysctl == NULL)
545                 CWARN("Can't setup /proc tunables\n");
546 #endif
547         switch (*kgnilnd_tunables.kgn_checksum) {
548         default:
549                 CERROR("Invalid checksum module parameter: %d\n",
550                        *kgnilnd_tunables.kgn_checksum);
551                 rc = -EINVAL;
552                 GOTO(out, rc);
553         case GNILND_CHECKSUM_OFF:
554                 /* no checksumming */
555                 break;
556         case GNILND_CHECKSUM_SMSG_HEADER:
557                 LCONSOLE_INFO("SMSG header only checksumming enabled\n");
558                 break;
559         case GNILND_CHECKSUM_SMSG:
560                 LCONSOLE_INFO("SMSG checksumming enabled\n");
561                 break;
562         case GNILND_CHECKSUM_SMSG_BTE:
563                 LCONSOLE_INFO("SMSG + BTE checksumming enabled\n");
564                 break;
565         }
566
567         if (*kgnilnd_tunables.kgn_max_immediate > GNILND_MAX_IMMEDIATE) {
568                 LCONSOLE_ERROR("kgnilnd module parameter 'max_immediate' too large %d > %d\n",
569                 *kgnilnd_tunables.kgn_max_immediate, GNILND_MAX_IMMEDIATE);
570                 rc = -EINVAL;
571                 GOTO(out, rc);
572         }
573
574         if (*kgnilnd_tunables.kgn_mbox_per_block < 1) {
575                 *kgnilnd_tunables.kgn_mbox_per_block = 1;
576         }
577
578         if (*kgnilnd_tunables.kgn_concurrent_sends == 0) {
579                 *kgnilnd_tunables.kgn_concurrent_sends = *kgnilnd_tunables.kgn_peer_credits;
580         } else if (*kgnilnd_tunables.kgn_concurrent_sends > *kgnilnd_tunables.kgn_peer_credits) {
581                 LCONSOLE_ERROR("kgnilnd parameter 'concurrent_sends' too large: %d > %d (peer_credits)\n",
582                                *kgnilnd_tunables.kgn_concurrent_sends, *kgnilnd_tunables.kgn_peer_credits);
583                 rc = -EINVAL;
584         }
585 out:
586         return rc;
587 }
588
589 void
590 kgnilnd_tunables_fini()
591 {
592 #if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM
593         if (kgnilnd_tunables.kgn_sysctl != NULL)
594                 cfs_unregister_sysctl_table(kgnilnd_tunables.kgn_sysctl);
595 #endif
596 }