4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA
24 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright (c) 2012, Intel Corporation.
28 * This file is part of Lustre, http://www.lustre.org/
29 * Lustre is a trademark of Sun Microsystems, Inc.
31 * Please see comments in libcfs/include/libcfs/libcfs_cpu.h for introduction
33 * Author: liang@whamcloud.com
36 #define DEBUG_SUBSYSTEM S_LNET
38 #include "../../include/linux/libcfs/libcfs.h"
40 /** Global CPU partition table */
41 struct cfs_cpt_table *cfs_cpt_table __read_mostly;
42 EXPORT_SYMBOL(cfs_cpt_table);
44 #ifndef HAVE_LIBCFS_CPT
46 #define CFS_CPU_VERSION_MAGIC 0xbabecafe
48 struct cfs_cpt_table *
49 cfs_cpt_table_alloc(unsigned int ncpt)
51 struct cfs_cpt_table *cptab;
54 CERROR("Can't support cpu partition number %d\n", ncpt);
58 LIBCFS_ALLOC(cptab, sizeof(*cptab));
60 cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
61 cptab->ctb_nparts = ncpt;
66 EXPORT_SYMBOL(cfs_cpt_table_alloc);
69 cfs_cpt_table_free(struct cfs_cpt_table *cptab)
71 LASSERT(cptab->ctb_version == CFS_CPU_VERSION_MAGIC);
73 LIBCFS_FREE(cptab, sizeof(*cptab));
75 EXPORT_SYMBOL(cfs_cpt_table_free);
79 cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
83 rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
90 EXPORT_SYMBOL(cfs_cpt_table_print);
91 #endif /* CONFIG_SMP */
94 cfs_cpt_number(struct cfs_cpt_table *cptab)
98 EXPORT_SYMBOL(cfs_cpt_number);
101 cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
105 EXPORT_SYMBOL(cfs_cpt_weight);
108 cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
112 EXPORT_SYMBOL(cfs_cpt_online);
115 cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
119 EXPORT_SYMBOL(cfs_cpt_set_cpu);
122 cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
125 EXPORT_SYMBOL(cfs_cpt_unset_cpu);
128 cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
132 EXPORT_SYMBOL(cfs_cpt_set_cpumask);
135 cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
138 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
141 cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
145 EXPORT_SYMBOL(cfs_cpt_set_node);
148 cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
151 EXPORT_SYMBOL(cfs_cpt_unset_node);
154 cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
158 EXPORT_SYMBOL(cfs_cpt_set_nodemask);
161 cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt, nodemask_t *mask)
164 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
167 cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
170 EXPORT_SYMBOL(cfs_cpt_clear);
173 cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
177 EXPORT_SYMBOL(cfs_cpt_spread_node);
180 cfs_cpu_ht_nsiblings(int cpu)
184 EXPORT_SYMBOL(cfs_cpu_ht_nsiblings);
187 cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
191 EXPORT_SYMBOL(cfs_cpt_current);
194 cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
198 EXPORT_SYMBOL(cfs_cpt_of_cpu);
201 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
205 EXPORT_SYMBOL(cfs_cpt_bind);
210 if (cfs_cpt_table != NULL) {
211 cfs_cpt_table_free(cfs_cpt_table);
212 cfs_cpt_table = NULL;
219 cfs_cpt_table = cfs_cpt_table_alloc(1);
221 return cfs_cpt_table != NULL ? 0 : -1;
224 #endif /* HAVE_LIBCFS_CPT */