Skip to content

Commit ce61cdc

Browse files
tile: make __write_once a synonym for __read_mostly
This was really only useful for TILE64 when we mapped the kernel data with small pages. Now we use a huge page and we really don't want to map different parts of the kernel data in different ways. We retain the __write_once name in case we want to bring it back to life at some point in the future. Note that this change uncovered a latent bug where the "smp_topology" variable happened to always be aligned mod 8 so we could store two "int" values at once, but when we eliminated __write_once it ended up only aligned mod 4. Fix with an explicit annotation. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
1 parent d7c9661 commit ce61cdc

4 files changed

Lines changed: 17 additions & 27 deletions

File tree

‎arch/tile/include/asm/cache.h‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@
4949
#define __read_mostly __attribute__((__section__(".data..read_mostly")))
5050

5151
/*
52-
* Attribute for data that is kept read/write coherent until the end of
53-
* initialization, then bumped to read/only incoherent for performance.
52+
* Originally we used small TLB pages for kernel data and grouped some
53+
* things together as "write once", enforcing the property at the end
54+
* of initialization by making those pages read-only and non-coherent.
55+
* This allowed better cache utilization since cache inclusion did not
56+
* need to be maintained. However, to do this requires an extra TLB
57+
* entry, which on balance is more of a performance hit than the
58+
* non-coherence is a performance gain, so we now just make "read
59+
* mostly" and "write once" be synonyms. We keep the attribute
60+
* separate in case we change our minds at a future date.
5461
*/
55-
#define __write_once __attribute__((__section__(".w1data")))
62+
#define __write_once __read_mostly
5663

5764
#endif /* _ASM_TILE_CACHE_H */

‎arch/tile/kernel/smp.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#include <asm/cacheflush.h>
2323
#include <asm/homecache.h>
2424

25-
HV_Topology smp_topology __write_once;
25+
/*
26+
* We write to width and height with a single store in head_NN.S,
27+
* so make the variable aligned to "long".
28+
*/
29+
HV_Topology smp_topology __write_once __aligned(sizeof(long));
2630
EXPORT_SYMBOL(smp_topology);
2731

2832
#if CHIP_HAS_IPI()

‎arch/tile/kernel/vmlinux.lds.S‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,8 @@ SECTIONS
7474
__init_end = .;
7575

7676
_sdata = .; /* Start of data section */
77-
7877
RO_DATA_SECTION(PAGE_SIZE)
79-
80-
/* initially writeable, then read-only */
81-
. = ALIGN(PAGE_SIZE);
82-
__w1data_begin = .;
83-
.w1data : AT(ADDR(.w1data) - LOAD_OFFSET) {
84-
VMLINUX_SYMBOL(__w1data_begin) = .;
85-
*(.w1data)
86-
VMLINUX_SYMBOL(__w1data_end) = .;
87-
}
88-
8978
RW_DATA_SECTION(L2_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
90-
9179
_edata = .;
9280

9381
EXCEPTION_TABLE(L2_CACHE_BYTES)

‎arch/tile/mm/init.c‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,14 @@ static pgprot_t __init init_pgprot(ulong address)
270270
if (kdata_hash)
271271
return construct_pgprot(PAGE_KERNEL, PAGE_HOME_HASH);
272272

273-
/*
274-
* Make the w1data homed like heap to start with, to avoid
275-
* making it part of the page-striped data area when we're just
276-
* going to convert it to read-only soon anyway.
277-
*/
278-
if (address >= (ulong)__w1data_begin && address < (ulong)__w1data_end)
279-
return construct_pgprot(PAGE_KERNEL, initial_heap_home());
280-
281273
/*
282274
* Otherwise we just hand out consecutive cpus. To avoid
283275
* requiring this function to hold state, we just walk forward from
284276
* _sdata by PAGE_SIZE, skipping the readonly and init data, to reach
285277
* the requested address, while walking cpu home around kdata_mask.
286278
* This is typically no more than a dozen or so iterations.
287279
*/
288-
page = (((ulong)__w1data_end) + PAGE_SIZE - 1) & PAGE_MASK;
280+
page = (((ulong)__end_rodata) + PAGE_SIZE - 1) & PAGE_MASK;
289281
BUG_ON(address < page || address >= (ulong)_end);
290282
cpu = cpumask_first(&kdata_mask);
291283
for (; page < address; page += PAGE_SIZE) {
@@ -980,8 +972,7 @@ void free_initmem(void)
980972
const unsigned long text_delta = MEM_SV_START - PAGE_OFFSET;
981973

982974
/*
983-
* Evict the dirty initdata on the boot cpu, evict the w1data
984-
* wherever it's homed, and evict all the init code everywhere.
975+
* Evict the cache on all cores to avoid incoherence.
985976
* We are guaranteed that no one will touch the init pages any more.
986977
*/
987978
homecache_evict(&cpu_cacheable_map);

0 commit comments

Comments
 (0)