1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5 * Use is subject to license terms.
7 * Copyright (c) 2012, 2015, Intel Corporation.
11 * This file is part of Lustre, http://www.lustre.org/
14 #define DEBUG_SUBSYSTEM S_LNET
28 static int lst_init_step = LST_INIT_NONE;
30 struct workqueue_struct *lst_serial_wq;
31 struct workqueue_struct **lst_test_wq;
34 lnet_selftest_exit(void)
38 switch (lst_init_step) {
39 case LST_INIT_CONSOLE:
40 lstcon_console_fini();
48 case LST_INIT_WI_TEST:
50 i < cfs_cpt_number(lnet_cpt_table()); i++) {
53 destroy_workqueue(lst_test_wq[i]);
55 CFS_FREE_PTR_ARRAY(lst_test_wq,
56 cfs_cpt_number(lnet_cpt_table()));
59 case LST_INIT_WI_SERIAL:
60 destroy_workqueue(lst_serial_wq);
71 lnet_selftest_structure_assertion(void)
73 BUILD_BUG_ON(sizeof(struct srpc_msg) != 160);
74 BUILD_BUG_ON(sizeof(struct srpc_test_reqst) != 70);
75 BUILD_BUG_ON(offsetof(struct srpc_msg, msg_body.tes_reqst.tsr_concur) !=
77 BUILD_BUG_ON(offsetof(struct srpc_msg, msg_body.tes_reqst.tsr_ndest) !=
79 BUILD_BUG_ON(sizeof(struct srpc_stat_reply) != 136);
80 BUILD_BUG_ON(sizeof(struct srpc_stat_reqst) != 28);
84 lnet_selftest_init(void)
90 /* This assertion checks that struct sizes do not drift
91 * inadvertently and induce crashes when different nodes
92 * running LNet Selftest have mismatched structures.
94 lnet_selftest_structure_assertion();
100 lst_serial_wq = alloc_ordered_workqueue("lst_s", 0);
101 if (!lst_serial_wq) {
102 CERROR("Failed to create serial WI scheduler for LST\n");
105 lst_init_step = LST_INIT_WI_SERIAL;
107 nscheds = cfs_cpt_number(lnet_cpt_table());
108 CFS_ALLOC_PTR_ARRAY(lst_test_wq, nscheds);
114 lst_init_step = LST_INIT_WI_TEST;
115 for (i = 0; i < nscheds; i++) {
116 int nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
118 /* reserve at least one CPU for LND */
119 nthrs = max(nthrs - 1, 1);
120 lst_test_wq[i] = cfs_cpt_bind_workqueue("lst_t",
123 if (IS_ERR(lst_test_wq[i])) {
124 rc = PTR_ERR(lst_test_wq[i]);
125 CERROR("Failed to create CPU partition affinity WI scheduler %d for LST: rc = %d\n",
127 lst_test_wq[i] = NULL;
134 CERROR("LST can't startup rpc\n");
137 lst_init_step = LST_INIT_RPC;
141 CERROR("LST can't startup framework\n");
144 lst_init_step = LST_INIT_FW;
146 rc = lstcon_console_init();
148 CERROR("LST can't startup console\n");
151 lst_init_step = LST_INIT_CONSOLE;
154 lnet_selftest_exit();
158 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
159 MODULE_DESCRIPTION("LNet Selftest");
160 MODULE_VERSION("2.8.0");
161 MODULE_LICENSE("GPL");
163 module_init(lnet_selftest_init);
164 module_exit(lnet_selftest_exit);