at v4.12 4.3 kB view raw
1/* 2 * RCU node combining tree definitions. These are used to compute 3 * global attributes while avoiding common-case global contention. A key 4 * property that these computations rely on is a tournament-style approach 5 * where only one of the tasks contending a lower level in the tree need 6 * advance to the next higher level. If properly configured, this allows 7 * unlimited scalability while maintaining a constant level of contention 8 * on the root node. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, you can access it online at 22 * http://www.gnu.org/licenses/gpl-2.0.html. 23 * 24 * Copyright IBM Corporation, 2017 25 * 26 * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com> 27 */ 28 29#ifndef __LINUX_RCU_NODE_TREE_H 30#define __LINUX_RCU_NODE_TREE_H 31 32/* 33 * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and 34 * CONFIG_RCU_FANOUT_LEAF. 35 * In theory, it should be possible to add more levels straightforwardly. 36 * In practice, this did work well going from three levels to four. 37 * Of course, your mileage may vary. 38 */ 39 40#ifdef CONFIG_RCU_FANOUT 41#define RCU_FANOUT CONFIG_RCU_FANOUT 42#else /* #ifdef CONFIG_RCU_FANOUT */ 43# ifdef CONFIG_64BIT 44# define RCU_FANOUT 64 45# else 46# define RCU_FANOUT 32 47# endif 48#endif /* #else #ifdef CONFIG_RCU_FANOUT */ 49 50#ifdef CONFIG_RCU_FANOUT_LEAF 51#define RCU_FANOUT_LEAF CONFIG_RCU_FANOUT_LEAF 52#else /* #ifdef CONFIG_RCU_FANOUT_LEAF */ 53#define RCU_FANOUT_LEAF 16 54#endif /* #else #ifdef CONFIG_RCU_FANOUT_LEAF */ 55 56#define RCU_FANOUT_1 (RCU_FANOUT_LEAF) 57#define RCU_FANOUT_2 (RCU_FANOUT_1 * RCU_FANOUT) 58#define RCU_FANOUT_3 (RCU_FANOUT_2 * RCU_FANOUT) 59#define RCU_FANOUT_4 (RCU_FANOUT_3 * RCU_FANOUT) 60 61#if NR_CPUS <= RCU_FANOUT_1 62# define RCU_NUM_LVLS 1 63# define NUM_RCU_LVL_0 1 64# define NUM_RCU_NODES NUM_RCU_LVL_0 65# define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0 } 66# define RCU_NODE_NAME_INIT { "rcu_node_0" } 67# define RCU_FQS_NAME_INIT { "rcu_node_fqs_0" } 68#elif NR_CPUS <= RCU_FANOUT_2 69# define RCU_NUM_LVLS 2 70# define NUM_RCU_LVL_0 1 71# define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 72# define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1) 73# define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1 } 74# define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1" } 75# define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1" } 76#elif NR_CPUS <= RCU_FANOUT_3 77# define RCU_NUM_LVLS 3 78# define NUM_RCU_LVL_0 1 79# define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 80# define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 81# define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2) 82# define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2 } 83# define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1", "rcu_node_2" } 84# define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2" } 85#elif NR_CPUS <= RCU_FANOUT_4 86# define RCU_NUM_LVLS 4 87# define NUM_RCU_LVL_0 1 88# define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3) 89# define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 90# define NUM_RCU_LVL_3 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 91# define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3) 92# define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2, NUM_RCU_LVL_3 } 93# define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1", "rcu_node_2", "rcu_node_3" } 94# define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2", "rcu_node_fqs_3" } 95#else 96# error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" 97#endif /* #if (NR_CPUS) <= RCU_FANOUT_1 */ 98 99#endif /* __LINUX_RCU_NODE_TREE_H */