Whamcloud - gitweb
LU-10675 tests: increase default MDSSIZE
[fs/lustre-release.git] / libcfs / libcfs / libcfs_cpu.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * GPL HEADER END
17  */
18 /*
19  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
20  * Copyright (c) 2012, 2017, Intel Corporation.
21  */
22 /*
23  * This file is part of Lustre, http://www.lustre.org/
24  * Lustre is a trademark of Sun Microsystems, Inc.
25  *
26  * Please see comments in libcfs/include/libcfs/libcfs_cpu.h for introduction
27  *
28  * Author: liang@whamcloud.com
29  */
30
31 #define DEBUG_SUBSYSTEM S_LNET
32
33 #include <libcfs/linux/linux-cpu.h>
34 #include <libcfs/libcfs.h>
35
36 /** Global CPU partition table */
37 struct cfs_cpt_table *cfs_cpt_table __read_mostly;
38 EXPORT_SYMBOL(cfs_cpt_table);
39
40 #ifndef CONFIG_SMP
41
42 #define CFS_CPT_DISTANCE        1       /* Arbitrary positive value */
43
44 struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)
45 {
46         struct cfs_cpt_table *cptab;
47
48         if (ncpt != 1) {
49                 CERROR("Can't support cpu partition number %d\n", ncpt);
50                 return NULL;
51         }
52
53         LIBCFS_ALLOC(cptab, sizeof(*cptab));
54         if (cptab) {
55                 cpumask_set_cpu(0, cptab->ctb_cpumask);
56                 node_set(0, cptab->ctb_nodemask);
57         }
58
59         return cptab;
60 }
61 EXPORT_SYMBOL(cfs_cpt_table_alloc);
62
63 void cfs_cpt_table_free(struct cfs_cpt_table *cptab)
64 {
65         LIBCFS_FREE(cptab, sizeof(*cptab));
66 }
67 EXPORT_SYMBOL(cfs_cpt_table_free);
68
69 int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
70 {
71         int rc;
72
73         rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
74         len -= rc;
75         if (len <= 0)
76                 return -EFBIG;
77
78         return rc;
79 }
80 EXPORT_SYMBOL(cfs_cpt_table_print);
81
82 int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
83 {
84         int rc;
85
86         rc = snprintf(buf, len, "0\t: 0:%d\n", CFS_CPT_DISTANCE);
87         len -= rc;
88         if (len <= 0)
89                 return -EFBIG;
90
91         return rc;
92 }
93 EXPORT_SYMBOL(cfs_cpt_distance_print);
94
95 int cfs_cpt_number(struct cfs_cpt_table *cptab)
96 {
97         return 1;
98 }
99 EXPORT_SYMBOL(cfs_cpt_number);
100
101 int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
102 {
103         return 1;
104 }
105 EXPORT_SYMBOL(cfs_cpt_weight);
106
107 int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
108 {
109         return 1;
110 }
111 EXPORT_SYMBOL(cfs_cpt_online);
112
113 cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
114 {
115         return &cptab->ctb_cpumask;
116 }
117 EXPORT_SYMBOL(cfs_cpt_cpumask);
118
119 nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
120 {
121         return &cptab->ctb_nodemask;
122 }
123 EXPORT_SYMBOL(cfs_cpt_nodemask);
124
125 unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2)
126 {
127         return CFS_CPT_DISTANCE;
128 }
129 EXPORT_SYMBOL(cfs_cpt_distance);
130
131 int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
132 {
133         return 1;
134 }
135 EXPORT_SYMBOL(cfs_cpt_set_cpu);
136
137 void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
138 {
139 }
140 EXPORT_SYMBOL(cfs_cpt_unset_cpu);
141
142 int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt,
143                         const cpumask_t *mask)
144 {
145         return 1;
146 }
147 EXPORT_SYMBOL(cfs_cpt_set_cpumask);
148
149 void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
150                            const cpumask_t *mask)
151 {
152 }
153 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
154
155 int cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
156 {
157         return 1;
158 }
159 EXPORT_SYMBOL(cfs_cpt_set_node);
160
161 void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
162 {
163 }
164 EXPORT_SYMBOL(cfs_cpt_unset_node);
165
166 int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt,
167                          const nodemask_t *mask)
168 {
169         return 1;
170 }
171 EXPORT_SYMBOL(cfs_cpt_set_nodemask);
172
173 void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt,
174                             const nodemask_t *mask)
175 {
176 }
177 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
178
179 int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
180 {
181         return 0;
182 }
183 EXPORT_SYMBOL(cfs_cpt_spread_node);
184
185 int cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
186 {
187         return 0;
188 }
189 EXPORT_SYMBOL(cfs_cpt_current);
190
191 int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
192 {
193         return 0;
194 }
195 EXPORT_SYMBOL(cfs_cpt_of_cpu);
196
197 int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
198 {
199         return 0;
200 }
201 EXPORT_SYMBOL(cfs_cpt_of_node);
202
203 int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
204 {
205         return 0;
206 }
207 EXPORT_SYMBOL(cfs_cpt_bind);
208
209 void cfs_cpu_fini(void)
210 {
211         if (cfs_cpt_table) {
212                 cfs_cpt_table_free(cfs_cpt_table);
213                 cfs_cpt_table = NULL;
214         }
215 }
216
217 int cfs_cpu_init(void)
218 {
219         cfs_cpt_table = cfs_cpt_table_alloc(1);
220
221         return cfs_cpt_table ? 0 : -1;
222 }
223
224 #endif /* !CONFIG_SMP */