• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, 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 "../../include/linux/libcfs/libcfs.h"
34 
35 /** Global CPU partition table */
36 struct cfs_cpt_table   *cfs_cpt_table __read_mostly;
37 EXPORT_SYMBOL(cfs_cpt_table);
38 
39 #ifndef HAVE_LIBCFS_CPT
40 
41 #define CFS_CPU_VERSION_MAGIC	   0xbabecafe
42 
43 struct cfs_cpt_table *
cfs_cpt_table_alloc(unsigned int ncpt)44 cfs_cpt_table_alloc(unsigned 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 		cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
56 		node_set(0, cptab->ctb_nodemask);
57 		cptab->ctb_nparts  = ncpt;
58 	}
59 
60 	return cptab;
61 }
62 EXPORT_SYMBOL(cfs_cpt_table_alloc);
63 
64 void
cfs_cpt_table_free(struct cfs_cpt_table * cptab)65 cfs_cpt_table_free(struct cfs_cpt_table *cptab)
66 {
67 	LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
68 
69 	LIBCFS_FREE(cptab, sizeof(*cptab));
70 }
71 EXPORT_SYMBOL(cfs_cpt_table_free);
72 
73 #ifdef CONFIG_SMP
74 int
cfs_cpt_table_print(struct cfs_cpt_table * cptab,char * buf,int len)75 cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
76 {
77 	int	rc;
78 
79 	rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
80 	len -= rc;
81 	if (len <= 0)
82 		return -EFBIG;
83 
84 	return rc;
85 }
86 EXPORT_SYMBOL(cfs_cpt_table_print);
87 #endif /* CONFIG_SMP */
88 
89 int
cfs_cpt_number(struct cfs_cpt_table * cptab)90 cfs_cpt_number(struct cfs_cpt_table *cptab)
91 {
92 	return 1;
93 }
94 EXPORT_SYMBOL(cfs_cpt_number);
95 
96 int
cfs_cpt_weight(struct cfs_cpt_table * cptab,int cpt)97 cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
98 {
99 	return 1;
100 }
101 EXPORT_SYMBOL(cfs_cpt_weight);
102 
103 int
cfs_cpt_online(struct cfs_cpt_table * cptab,int cpt)104 cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
105 {
106 	return 1;
107 }
108 EXPORT_SYMBOL(cfs_cpt_online);
109 
110 nodemask_t *
cfs_cpt_nodemask(struct cfs_cpt_table * cptab,int cpt)111 cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
112 {
113 	return &cptab->ctb_nodemask;
114 }
115 EXPORT_SYMBOL(cfs_cpt_cpumask);
116 
117 int
cfs_cpt_set_cpu(struct cfs_cpt_table * cptab,int cpt,int cpu)118 cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
119 {
120 	return 1;
121 }
122 EXPORT_SYMBOL(cfs_cpt_set_cpu);
123 
124 void
cfs_cpt_unset_cpu(struct cfs_cpt_table * cptab,int cpt,int cpu)125 cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
126 {
127 }
128 EXPORT_SYMBOL(cfs_cpt_unset_cpu);
129 
130 int
cfs_cpt_set_cpumask(struct cfs_cpt_table * cptab,int cpt,cpumask_t * mask)131 cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
132 {
133 	return 1;
134 }
135 EXPORT_SYMBOL(cfs_cpt_set_cpumask);
136 
137 void
cfs_cpt_unset_cpumask(struct cfs_cpt_table * cptab,int cpt,cpumask_t * mask)138 cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
139 {
140 }
141 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
142 
143 int
cfs_cpt_set_node(struct cfs_cpt_table * cptab,int cpt,int node)144 cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
145 {
146 	return 1;
147 }
148 EXPORT_SYMBOL(cfs_cpt_set_node);
149 
150 void
cfs_cpt_unset_node(struct cfs_cpt_table * cptab,int cpt,int node)151 cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
152 {
153 }
154 EXPORT_SYMBOL(cfs_cpt_unset_node);
155 
156 int
cfs_cpt_set_nodemask(struct cfs_cpt_table * cptab,int cpt,nodemask_t * mask)157 cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
158 {
159 	return 1;
160 }
161 EXPORT_SYMBOL(cfs_cpt_set_nodemask);
162 
163 void
cfs_cpt_unset_nodemask(struct cfs_cpt_table * cptab,int cpt,nodemask_t * mask)164 cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
165 {
166 }
167 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
168 
169 void
cfs_cpt_clear(struct cfs_cpt_table * cptab,int cpt)170 cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
171 {
172 }
173 EXPORT_SYMBOL(cfs_cpt_clear);
174 
175 int
cfs_cpt_spread_node(struct cfs_cpt_table * cptab,int cpt)176 cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
177 {
178 	return 0;
179 }
180 EXPORT_SYMBOL(cfs_cpt_spread_node);
181 
182 int
cfs_cpu_ht_nsiblings(int cpu)183 cfs_cpu_ht_nsiblings(int cpu)
184 {
185 	return 1;
186 }
187 EXPORT_SYMBOL(cfs_cpu_ht_nsiblings);
188 
189 int
cfs_cpt_current(struct cfs_cpt_table * cptab,int remap)190 cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
191 {
192 	return 0;
193 }
194 EXPORT_SYMBOL(cfs_cpt_current);
195 
196 int
cfs_cpt_of_cpu(struct cfs_cpt_table * cptab,int cpu)197 cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
198 {
199 	return 0;
200 }
201 EXPORT_SYMBOL(cfs_cpt_of_cpu);
202 
203 int
cfs_cpt_bind(struct cfs_cpt_table * cptab,int cpt)204 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
205 {
206 	return 0;
207 }
208 EXPORT_SYMBOL(cfs_cpt_bind);
209 
210 void
cfs_cpu_fini(void)211 cfs_cpu_fini(void)
212 {
213 	if (cfs_cpt_table) {
214 		cfs_cpt_table_free(cfs_cpt_table);
215 		cfs_cpt_table = NULL;
216 	}
217 }
218 
219 int
cfs_cpu_init(void)220 cfs_cpu_init(void)
221 {
222 	cfs_cpt_table = cfs_cpt_table_alloc(1);
223 
224 	return cfs_cpt_table ? 0 : -1;
225 }
226 
227 #endif /* HAVE_LIBCFS_CPT */
228