Whamcloud - gitweb
LU-3963 libcfs: remove last cfs wrappers for cpu node handling
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-cpu.h
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  * 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
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25  * Copyright (c) 2012, Intel Corporation.
26  */
27 /*
28  * This file is part of Lustre, http://www.lustre.org/
29  * Lustre is a trademark of Sun Microsystems, Inc.
30  *
31  * libcfs/include/libcfs/linux/linux-mem.h
32  *
33  * Basic library routines.
34  *
35  * Author: liang@whamcloud.com
36  */
37
38 #ifndef __LIBCFS_LINUX_CPU_H__
39 #define __LIBCFS_LINUX_CPU_H__
40
41 #ifndef __LIBCFS_LIBCFS_H__
42 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
43 #endif
44
45 #ifndef __KERNEL__
46 #error This include is only for kernel use.
47 #endif
48
49 #include <linux/cpu.h>
50 #include <linux/cpuset.h>
51 #include <linux/topology.h>
52 #include <linux/version.h>
53
54 #ifdef CONFIG_SMP
55
56 #define HAVE_LIBCFS_CPT
57
58 /** virtual processing unit */
59 struct cfs_cpu_partition {
60         /* CPUs mask for this partition */
61         cpumask_t                       *cpt_cpumask;
62         /* nodes mask for this partition */
63         nodemask_t                      *cpt_nodemask;
64         /* spread rotor for NUMA allocator */
65         unsigned                        cpt_spread_rotor;
66 };
67
68 /** descriptor for CPU partitions */
69 struct cfs_cpt_table {
70         /* version, reserved for hotplug */
71         unsigned                        ctb_version;
72         /* spread rotor for NUMA allocator */
73         unsigned                        ctb_spread_rotor;
74         /* # of CPU partitions */
75         unsigned                        ctb_nparts;
76         /* partitions tables */
77         struct cfs_cpu_partition        *ctb_parts;
78         /* shadow HW CPU to CPU partition ID */
79         int                             *ctb_cpu2cpt;
80         /* all cpus in this partition table */
81         cpumask_t                       *ctb_cpumask;
82         /* all nodes in this partition table */
83         nodemask_t                      *ctb_nodemask;
84 };
85
86 void cfs_cpu_core_siblings(int cpu, cpumask_t *mask);
87 void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask);
88 void cfs_node_to_cpumask(int node, cpumask_t *mask);
89 int cfs_cpu_core_nsiblings(int cpu);
90 int cfs_cpu_ht_nsiblings(int cpu);
91
92 #endif /* CONFIG_SMP */
93 #endif /* __LIBCFS_LINUX_CPU_H__ */