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_init(void)
81 lst_serial_wq = alloc_ordered_workqueue("lst_s", 0);
83 CERROR("Failed to create serial WI scheduler for LST\n");
86 lst_init_step = LST_INIT_WI_SERIAL;
88 nscheds = cfs_cpt_number(lnet_cpt_table());
89 CFS_ALLOC_PTR_ARRAY(lst_test_wq, nscheds);
95 lst_init_step = LST_INIT_WI_TEST;
96 for (i = 0; i < nscheds; i++) {
97 int nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
99 /* reserve at least one CPU for LND */
100 nthrs = max(nthrs - 1, 1);
101 lst_test_wq[i] = cfs_cpt_bind_workqueue("lst_t",
104 if (IS_ERR(lst_test_wq[i])) {
105 rc = PTR_ERR(lst_test_wq[i]);
106 CERROR("Failed to create CPU partition affinity WI scheduler %d for LST: rc = %d\n",
108 lst_test_wq[i] = NULL;
115 CERROR("LST can't startup rpc\n");
118 lst_init_step = LST_INIT_RPC;
122 CERROR("LST can't startup framework\n");
125 lst_init_step = LST_INIT_FW;
127 rc = lstcon_console_init();
129 CERROR("LST can't startup console\n");
132 lst_init_step = LST_INIT_CONSOLE;
135 lnet_selftest_exit();
139 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
140 MODULE_DESCRIPTION("LNet Selftest");
141 MODULE_VERSION("2.8.0");
142 MODULE_LICENSE("GPL");
144 module_init(lnet_selftest_init);
145 module_exit(lnet_selftest_exit);