Whamcloud - gitweb
LU-9859 libcfs: delete libcfs/linux/libcfs.h
[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  *
26  * Copyright (c) 2012, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  *
32  * libcfs/include/libcfs/linux/linux-mem.h
33  *
34  * Basic library routines.
35  *
36  * Author: liang@whamcloud.com
37  */
38
39 #ifndef __LIBCFS_LINUX_CPU_H__
40 #define __LIBCFS_LINUX_CPU_H__
41
42 #include <linux/cpu.h>
43 #include <linux/cpuset.h>
44 #include <linux/topology.h>
45 #include <linux/version.h>
46
47 #ifdef CONFIG_SMP
48
49 #define HAVE_LIBCFS_CPT
50
51 /** virtual processing unit */
52 struct cfs_cpu_partition {
53         /* CPUs mask for this partition */
54         cpumask_t                       *cpt_cpumask;
55         /* nodes mask for this partition */
56         nodemask_t                      *cpt_nodemask;
57         /* NUMA distance between CPTs */
58         unsigned                        *cpt_distance;
59         /* spread rotor for NUMA allocator */
60         int                              cpt_spread_rotor;
61         /* NUMA node if cpt_nodemask is empty */
62         int                              cpt_node;
63 };
64
65 /** descriptor for CPU partitions */
66 struct cfs_cpt_table {
67         /* spread rotor for NUMA allocator */
68         int                             ctb_spread_rotor;
69         /* maximum NUMA distance between all nodes in table */
70         unsigned                        ctb_distance;
71         /* # of CPU partitions */
72         int                              ctb_nparts;
73         /* partitions tables */
74         struct cfs_cpu_partition        *ctb_parts;
75         /* shadow HW CPU to CPU partition ID */
76         int                             *ctb_cpu2cpt;
77         /* all cpus in this partition table */
78         cpumask_t                       *ctb_cpumask;
79         /* shadow HW node to CPU partition ID */
80         int                             *ctb_node2cpt;
81         /* all nodes in this partition table */
82         nodemask_t                      *ctb_nodemask;
83 };
84
85 void cfs_cpu_core_siblings(int cpu, cpumask_t *mask);
86
87 #endif /* CONFIG_SMP */
88
89 #ifndef HAVE_TOPOLOGY_SIBLING_CPUMASK
90 # define topology_sibling_cpumask(cpu)  topology_thread_cpumask(cpu)
91 #endif /* HAVE_TOPOLOGY_SIBLING_CPUMASK */
92
93 #endif /* __LIBCFS_LINUX_CPU_H__ */