Skip to content

Commit fb5924f

Browse files
bsingharorampe
authored andcommitted
powerpc/mm: Flush cache on memory hot(un)plug
This patch adds support for flushing potentially dirty cache lines when memory is hot-plugged/hot-un-plugged. The support is currently limited to 64 bit systems. The bug was exposed when mappings for a device were actually hot-unplugged and plugged in back later. A similar issue was observed during the development of memtrace, but memtrace does it's own flushing of region via a custom routine. These patches do a flush both on hotplug/unplug to clear any stale data in the cache w.r.t mappings, there is a small race window where a clean cache line may be created again just prior to tearing down the mapping. The patches were tested by disabling the flush routines in memtrace and doing I/O on the trace file. The system immediately checkstops (quite reliablly if prior to the hot-unplug of the memtrace region, we memset the regions we are about to hot unplug). After these patches no custom flushing is needed in the memtrace code. Fixes: 9d5171a ("powerpc/powernv: Enable removal of memory for in memory tracing") Cc: [email protected] # v4.14+ Signed-off-by: Balbir Singh <[email protected]> Acked-by: Reza Arbab <[email protected]> Reviewed-by: Rashmica Gupta <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 6d08b06 commit fb5924f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/powerpc/mm/mem.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *
133133
start, start + size, rc);
134134
return -EFAULT;
135135
}
136+
flush_inval_dcache_range(start, start + size);
136137

137138
return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
138139
}
@@ -159,6 +160,7 @@ int __meminit arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap
159160

160161
/* Remove htab bolted mappings for this section of memory */
161162
start = (unsigned long)__va(start);
163+
flush_inval_dcache_range(start, start + size);
162164
ret = remove_section_mapping(start, start + size);
163165

164166
/* Ensure all vmalloc mappings are flushed in case they also

0 commit comments

Comments
 (0)