forked from Minki/linux
6065a244a0
__get_cpu_var() is used for multiple purposes in the kernel source. One of them is address calculation via the form &__get_cpu_var(x). This calculates the address for the instance of the percpu variable of the current processor based on an offset. Other use cases are for storing and retrieving data from the current processors percpu area. __get_cpu_var() can be used as an lvalue when writing data or on the right side of an assignment. __get_cpu_var() is defined as : #define __get_cpu_var(var) (*this_cpu_ptr(&(var))) __get_cpu_var() always only does an address determination. However, store and retrieve operations could use a segment prefix (or global register on other platforms) to avoid the address calculation. this_cpu_write() and this_cpu_read() can directly take an offset into a percpu area and use optimized assembly code to read and write per cpu variables. This patch converts __get_cpu_var into either an explicit address calculation using this_cpu_ptr() or into a use of this_cpu operations that use the offset. Thereby address calculations are avoided and less registers are used when code is generated. At the end of the patch set all uses of __get_cpu_var have been removed so the macro is removed too. The patch set includes passes over all arches as well. Once these operations are used throughout then specialized macros can be defined in non -x86 arches as well in order to optimize per cpu access by f.e. using a global register that may be set to the per cpu base. Transformations done to __get_cpu_var() 1. Determine the address of the percpu instance of the current processor. DEFINE_PER_CPU(int, y); int *x = &__get_cpu_var(y); Converts to int *x = this_cpu_ptr(&y); 2. Same as #1 but this time an array structure is involved. DEFINE_PER_CPU(int, y[20]); int *x = __get_cpu_var(y); Converts to int *x = this_cpu_ptr(y); 3. Retrieve the content of the current processors instance of a per cpu variable. DEFINE_PER_CPU(int, y); int x = __get_cpu_var(y) Converts to int x = __this_cpu_read(y); 4. Retrieve the content of a percpu struct DEFINE_PER_CPU(struct mystruct, y); struct mystruct x = __get_cpu_var(y); Converts to memcpy(&x, this_cpu_ptr(&y), sizeof(x)); 5. Assignment to a per cpu variable DEFINE_PER_CPU(int, y) __get_cpu_var(y) = x; Converts to __this_cpu_write(y, x); 6. Increment/Decrement etc of a per cpu variable DEFINE_PER_CPU(int, y); __get_cpu_var(y)++ Converts to __this_cpu_inc(y) Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: linux-ia64@vger.kernel.org Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Tejun Heo <tj@kernel.org>
87 lines
2.7 KiB
C
87 lines
2.7 KiB
C
/*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*
|
|
* SGI specific setup.
|
|
*
|
|
* Copyright (C) 1995-1997,1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
|
|
* Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
|
|
*/
|
|
#ifndef _ASM_IA64_SN_ARCH_H
|
|
#define _ASM_IA64_SN_ARCH_H
|
|
|
|
#include <linux/numa.h>
|
|
#include <asm/types.h>
|
|
#include <asm/percpu.h>
|
|
#include <asm/sn/types.h>
|
|
#include <asm/sn/sn_cpuid.h>
|
|
|
|
/*
|
|
* This is the maximum number of NUMALINK nodes that can be part of a single
|
|
* SSI kernel. This number includes C-brick, M-bricks, and TIOs. Nodes in
|
|
* remote partitions are NOT included in this number.
|
|
* The number of compact nodes cannot exceed size of a coherency domain.
|
|
* The purpose of this define is to specify a node count that includes
|
|
* all C/M/TIO nodes in an SSI system.
|
|
*
|
|
* SGI system can currently support up to 256 C/M nodes plus additional TIO nodes.
|
|
*
|
|
* Note: ACPI20 has an architectural limit of 256 nodes. When we upgrade
|
|
* to ACPI3.0, this limit will be removed. The notion of "compact nodes"
|
|
* should be deleted and TIOs should be included in MAX_NUMNODES.
|
|
*/
|
|
#define MAX_TIO_NODES MAX_NUMNODES
|
|
#define MAX_COMPACT_NODES (MAX_NUMNODES + MAX_TIO_NODES)
|
|
|
|
/*
|
|
* Maximum number of nodes in all partitions and in all coherency domains.
|
|
* This is the total number of nodes accessible in the numalink fabric. It
|
|
* includes all C & M bricks, plus all TIOs.
|
|
*
|
|
* This value is also the value of the maximum number of NASIDs in the numalink
|
|
* fabric.
|
|
*/
|
|
#define MAX_NUMALINK_NODES 16384
|
|
|
|
/*
|
|
* The following defines attributes of the HUB chip. These attributes are
|
|
* frequently referenced. They are kept in the per-cpu data areas of each cpu.
|
|
* They are kept together in a struct to minimize cache misses.
|
|
*/
|
|
struct sn_hub_info_s {
|
|
u8 shub2;
|
|
u8 nasid_shift;
|
|
u8 as_shift;
|
|
u8 shub_1_1_found;
|
|
u16 nasid_bitmask;
|
|
};
|
|
DECLARE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
|
|
#define sn_hub_info this_cpu_ptr(&__sn_hub_info)
|
|
#define is_shub2() (sn_hub_info->shub2)
|
|
#define is_shub1() (sn_hub_info->shub2 == 0)
|
|
|
|
/*
|
|
* Use this macro to test if shub 1.1 wars should be enabled
|
|
*/
|
|
#define enable_shub_wars_1_1() (sn_hub_info->shub_1_1_found)
|
|
|
|
|
|
/*
|
|
* Compact node ID to nasid mappings kept in the per-cpu data areas of each
|
|
* cpu.
|
|
*/
|
|
DECLARE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_COMPACT_NODES]);
|
|
#define sn_cnodeid_to_nasid this_cpu_ptr(&__sn_cnodeid_to_nasid[0])
|
|
|
|
|
|
extern u8 sn_partition_id;
|
|
extern u8 sn_system_size;
|
|
extern u8 sn_sharing_domain_size;
|
|
extern u8 sn_region_size;
|
|
|
|
extern void sn_flush_all_caches(long addr, long bytes);
|
|
extern bool sn_cpu_disable_allowed(int cpu);
|
|
|
|
#endif /* _ASM_IA64_SN_ARCH_H */
|