Sat Dec 3 01:44:04 2011 UTC ()
Add __cacheline_aligned and __read_mostly from -HEAD.


(matt)
diff -r1.5.78.1 -r1.5.78.2 src/sys/arch/mips/conf/kern.ldscript
diff -r1.23.78.7 -r1.23.78.8 src/sys/arch/mips/include/mips_param.h
diff -r1.39 -r1.39.12.1 src/sys/net/if_gre.h
diff -r1.30 -r1.30.12.1 src/sys/sys/cdefs_elf.h

cvs diff -r1.5.78.1 -r1.5.78.2 src/sys/arch/mips/conf/kern.ldscript (expand / switch to unified diff)

--- src/sys/arch/mips/conf/kern.ldscript 2010/12/22 06:13:36 1.5.78.1
+++ src/sys/arch/mips/conf/kern.ldscript 2011/12/03 01:44:04 1.5.78.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern.ldscript,v 1.5.78.1 2010/12/22 06:13:36 matt Exp $ */ 1/* $NetBSD: kern.ldscript,v 1.5.78.2 2011/12/03 01:44:04 matt Exp $ */
2 2
3/* ldscript for NetBSD/mips kernels and LKMs */ 3/* ldscript for NetBSD/mips kernels and LKMs */
4OUTPUT_ARCH(mips) 4OUTPUT_ARCH(mips)
5ENTRY(_start) 5ENTRY(_start)
6SEARCH_DIR(/lib); 6SEARCH_DIR(/lib);
7/* Do we need any of these? 7/* Do we need any of these?
8 __DYNAMIC = 0; */ 8 __DYNAMIC = 0; */
9_DYNAMIC_LINK = 0; 9_DYNAMIC_LINK = 0;
10SECTIONS 10SECTIONS
11{ 11{
12 /* Read-only sections, merged into text segment. Assumes the 12 /* Read-only sections, merged into text segment. Assumes the
13 kernel Makefile sets the start address via -Ttext. */ 13 kernel Makefile sets the start address via -Ttext. */
14 .text : 14 .text :
@@ -20,26 +20,31 @@ SECTIONS @@ -20,26 +20,31 @@ SECTIONS
20 __stub_end = . ; 20 __stub_end = . ;
21 *(.gnu.warning) 21 *(.gnu.warning)
22 } =0 22 } =0
23 _etext = .; 23 _etext = .;
24 PROVIDE (etext = .); 24 PROVIDE (etext = .);
25 .rodata : { *(.rodata) *(.rodata.*) } 25 .rodata : { *(.rodata) *(.rodata.*) }
26 .reginfo : { *(.reginfo) } 26 .reginfo : { *(.reginfo) }
27/* . = . + 0x1000; */ 27/* . = . + 0x1000; */
28 .data : 28 .data :
29 { 29 {
30 _fdata = . ; 30 _fdata = . ;
31 *(.data) 31 *(.data)
32 CONSTRUCTORS 32 CONSTRUCTORS
 33 . = ALIGN(32); /* COHERENCY_UNIT */
 34 *(.data.cacheline_aligned)
 35 . = ALIGN(32); /* COHERENCY_UNIT */
 36 *(.data.read_mostly)
 37 . = ALIGN(32); /* COHERENCY_UNIT */
33 } 38 }
34 _gp = ALIGN(16) + 0x7ff0; 39 _gp = ALIGN(16) + 0x7ff0;
35 .lit8 : { *(.lit8) } 40 .lit8 : { *(.lit8) }
36 .lit4 : { *(.lit4) } 41 .lit4 : { *(.lit4) }
37 .sdata : { *(.sdata) } 42 .sdata : { *(.sdata) }
38 _edata = .; 43 _edata = .;
39 PROVIDE (edata = .); 44 PROVIDE (edata = .);
40 __bss_start = .; 45 __bss_start = .;
41 _fbss = .; 46 _fbss = .;
42 .sbss : { *(.sbss) *(.scommon) } 47 .sbss : { *(.sbss) *(.scommon) }
43 .bss : 48 .bss :
44 { 49 {
45 *(.bss) 50 *(.bss)

cvs diff -r1.23.78.7 -r1.23.78.8 src/sys/arch/mips/include/mips_param.h (expand / switch to unified diff)

--- src/sys/arch/mips/include/mips_param.h 2011/12/02 00:01:37 1.23.78.7
+++ src/sys/arch/mips/include/mips_param.h 2011/12/03 01:44:04 1.23.78.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mips_param.h,v 1.23.78.7 2011/12/02 00:01:37 matt Exp $ */ 1/* $NetBSD: mips_param.h,v 1.23.78.8 2011/12/03 01:44:04 matt Exp $ */
2 2
3#ifdef _KERNEL 3#ifdef _KERNEL
4#include <machine/cpu.h> 4#include <machine/cpu.h>
5#endif 5#endif
6 6
7/* 7/*
8 * No reason this can't be common 8 * No reason this can't be common
9 */ 9 */
10#if defined(__MIPSEB__) 10#if defined(__MIPSEB__)
11# if defined(__mips_n32) || defined(__mips_n64) 11# if defined(__mips_n32) || defined(__mips_n64)
12# define _MACHINE_ARCH mips64eb 12# define _MACHINE_ARCH mips64eb
13# define MACHINE_ARCH "mips64eb" 13# define MACHINE_ARCH "mips64eb"
14# define _MACHINE32_ARCH mipseb 14# define _MACHINE32_ARCH mipseb
@@ -44,26 +44,30 @@ @@ -44,26 +44,30 @@
44#define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 44#define USPACE (UPAGES*NBPG) /* size of u-area in bytes */
45#elif defined(ENABLE_MIPS_4KB_PAGE) || 1 45#elif defined(ENABLE_MIPS_4KB_PAGE) || 1
46#define UPAGES 2 /* pages of u-area */ 46#define UPAGES 2 /* pages of u-area */
47#define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 47#define USPACE (UPAGES*NBPG) /* size of u-area in bytes */
48#define USPACE_ALIGN USPACE /* make sure it starts on a even VA */ 48#define USPACE_ALIGN USPACE /* make sure it starts on a even VA */
49#else 49#else
50#error ENABLE_MIPS_xKB_PAGE not defined 50#error ENABLE_MIPS_xKB_PAGE not defined
51#endif 51#endif
52 52
53#ifndef MSGBUFSIZE 53#ifndef MSGBUFSIZE
54#define MSGBUFSIZE NBPG /* default message buffer size */ 54#define MSGBUFSIZE NBPG /* default message buffer size */
55#endif 55#endif
56 56
 57#ifndef COHERENCY_UNIT
 58#define COHERENCY_UNIT 32 /* MIPS cachelines are usually 32 bytes */
 59#endif
 60
57/* 61/*
58 * Round p (pointer or byte index) up to a correctly-aligned value for all 62 * Round p (pointer or byte index) up to a correctly-aligned value for all
59 * data types (int, long, ...). The result is u_int and must be cast to 63 * data types (int, long, ...). The result is u_int and must be cast to
60 * any desired pointer type. 64 * any desired pointer type.
61 * 65 *
62 * ALIGNED_POINTER is a boolean macro that checks whether an address 66 * ALIGNED_POINTER is a boolean macro that checks whether an address
63 * is valid to fetch data elements of type t from on this architecture. 67 * is valid to fetch data elements of type t from on this architecture.
64 * This does not reflect the optimal alignment, just the possibility 68 * This does not reflect the optimal alignment, just the possibility
65 * (within reasonable limits). 69 * (within reasonable limits).
66 * 70 *
67 */ 71 */
68#define ALIGNBYTES 7 72#define ALIGNBYTES 7
69#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) 73#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)

cvs diff -r1.39 -r1.39.12.1 src/sys/net/if_gre.h (expand / switch to unified diff)

--- src/sys/net/if_gre.h 2008/09/08 23:36:55 1.39
+++ src/sys/net/if_gre.h 2011/12/03 01:44:03 1.39.12.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_gre.h,v 1.39 2008/09/08 23:36:55 gmcgarry Exp $ */ 1/* $NetBSD: if_gre.h,v 1.39.12.1 2011/12/03 01:44:03 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Heiko W.Rupp <hwr@pilhuhn.de> 8 * by Heiko W.Rupp <hwr@pilhuhn.de>
9 * 9 *
10 * This code is derived from software contributed to The NetBSD Foundation 10 * This code is derived from software contributed to The NetBSD Foundation
11 * by David Young <dyoung@NetBSD.org> 11 * by David Young <dyoung@NetBSD.org>
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -53,32 +53,32 @@ struct gre_soparm { @@ -53,32 +53,32 @@ struct gre_soparm {
53 int sp_type; /* encapsulating socket type */ 53 int sp_type; /* encapsulating socket type */
54 int sp_proto; /* encapsulating protocol */ 54 int sp_proto; /* encapsulating protocol */
55 bool sp_bysock; /* encapsulation configured by passing 55 bool sp_bysock; /* encapsulation configured by passing
56 * socket, not by SIOCSLIFPHYADDR 56 * socket, not by SIOCSLIFPHYADDR
57 */ 57 */
58}; 58};
59 59
60enum gre_state { 60enum gre_state {
61 GRE_S_IDLE = 0 61 GRE_S_IDLE = 0
62 , GRE_S_IOCTL 62 , GRE_S_IOCTL
63 , GRE_S_DIE 63 , GRE_S_DIE
64}; 64};
65 65
66#define __cacheline_aligned __aligned(CACHE_LINE_SIZE) 66#define __xcacheline_aligned __aligned(CACHE_LINE_SIZE)
67 67
68struct gre_bufq { 68struct gre_bufq {
69 volatile int bq_prodidx; 69 volatile int bq_prodidx;
70 volatile int bq_considx; 70 volatile int bq_considx;
71 size_t bq_len __cacheline_aligned; 71 size_t bq_len __xcacheline_aligned;
72 size_t bq_lenmask; 72 size_t bq_lenmask;
73 volatile int bq_drops; 73 volatile int bq_drops;
74 struct mbuf **bq_buf; 74 struct mbuf **bq_buf;
75}; 75};
76 76
77MALLOC_DECLARE(M_GRE_BUFQ); 77MALLOC_DECLARE(M_GRE_BUFQ);
78 78
79enum gre_msg { 79enum gre_msg {
80 GRE_M_NONE = 0 80 GRE_M_NONE = 0
81 , GRE_M_SETFP 81 , GRE_M_SETFP
82 , GRE_M_DELFP 82 , GRE_M_DELFP
83 , GRE_M_STOP 83 , GRE_M_STOP
84 , GRE_M_OK 84 , GRE_M_OK

cvs diff -r1.30 -r1.30.12.1 src/sys/sys/cdefs_elf.h (expand / switch to unified diff)

--- src/sys/sys/cdefs_elf.h 2008/07/21 15:22:19 1.30
+++ src/sys/sys/cdefs_elf.h 2011/12/03 01:44:04 1.30.12.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cdefs_elf.h,v 1.30 2008/07/21 15:22:19 lukem Exp $ */ 1/* $NetBSD: cdefs_elf.h,v 1.30.12.1 2011/12/03 01:44:04 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -146,14 +146,52 @@ @@ -146,14 +146,52 @@
146#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n) 146#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n)
147#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n) 147#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n)
148 148
149#define __link_set_decl(set, ptype) \ 149#define __link_set_decl(set, ptype) \
150 extern ptype * const __start_link_set_##set[]; \ 150 extern ptype * const __start_link_set_##set[]; \
151 extern ptype * const __stop_link_set_##set[] \ 151 extern ptype * const __stop_link_set_##set[] \
152 152
153#define __link_set_start(set) (__start_link_set_##set) 153#define __link_set_start(set) (__start_link_set_##set)
154#define __link_set_end(set) (__stop_link_set_##set) 154#define __link_set_end(set) (__stop_link_set_##set)
155 155
156#define __link_set_count(set) \ 156#define __link_set_count(set) \
157 (__link_set_end(set) - __link_set_start(set)) 157 (__link_set_end(set) - __link_set_start(set))
158 158
 159#ifdef _KERNEL
 160
 161/*
 162 * On multiprocessor systems we can gain an improvement in performance
 163 * by being mindful of which cachelines data is placed in.
 164 *
 165 * __read_mostly:
 166 *
 167 * It makes sense to ensure that rarely modified data is not
 168 * placed in the same cacheline as frequently modified data.
 169 * To mitigate the phenomenon known as "false-sharing" we
 170 * can annotate rarely modified variables with __read_mostly.
 171 * All such variables are placed into the .data.read_mostly
 172 * section in the kernel ELF.
 173 *
 174 * Prime candidates for __read_mostly annotation are variables
 175 * which are hardly ever modified and which are used in code
 176 * hot-paths, e.g. pmap_initialized.
 177 *
 178 * __cacheline_aligned:
 179 *
 180 * Some data structures (mainly locks) benefit from being aligned
 181 * on a cacheline boundary, and having a cacheline to themselves.
 182 * This way, the modification of other data items cannot adversely
 183 * affect the lock and vice versa.
 184 *
 185 * Any variables annotated with __cacheline_aligned will be
 186 * placed into the .data.cacheline_aligned ELF section.
 187 */
 188#define __read_mostly \
 189 __attribute__((__section__(".data.read_mostly")))
 190
 191#define __cacheline_aligned \
 192 __attribute__((__aligned__(COHERENCY_UNIT), \
 193 __section__(".data.cacheline_aligned")))
 194
 195#endif /* _KERNEL */
 196
159#endif /* !_SYS_CDEFS_ELF_H_ */ 197#endif /* !_SYS_CDEFS_ELF_H_ */