When "pollute_cache" is specified as command line parameter of the
apic-demo, the demo will fill each cache line with a pattern in each
measurement loop. Up to 512 KB of cache can be polluted this way.
This allows to test L3 cache partitioning features of recent Intel CPUs:
The cache pollution will dirty the L1 and L2 data caches so that the
next loop iteration will access L3. If that cache is shared, latencies
will rise as other cells use the cache as well.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013-2016
*
* Authors:
* Jan Kiszka <jan.kiszka@siemens.com>
*
* Authors:
* Jan Kiszka <jan.kiszka@siemens.com>
+#define CMDLINE_BUFFER_SIZE 256
+CMDLINE_BUFFER(CMDLINE_BUFFER_SIZE);
+
+#define POLLUTE_CACHE_SIZE (512 * 1024)
+
#ifdef CONFIG_UART_OXPCIE952
#define UART_BASE 0xe010
#else
#ifdef CONFIG_UART_OXPCIE952
#define UART_BASE 0xe010
#else
+static void pollute_cache(void)
+{
+ char *mem = (char *)HEAP_BASE;
+ unsigned long cpu_cache_line_size, ebx;
+ unsigned long n;
+
+ asm volatile("cpuid" : "=b" (ebx) : "a" (1)
+ : "rcx", "rdx", "memory");
+ cpu_cache_line_size = (ebx & 0xff00) >> 5;
+
+ for (n = 0; n < POLLUTE_CACHE_SIZE; n += cpu_cache_line_size)
+ mem[n] ^= 0xAA;
+}
+
void inmate_main(void)
{
bool allow_terminate = false;
bool terminate = false;
unsigned long tsc_freq;
void inmate_main(void)
{
bool allow_terminate = false;
bool terminate = false;
unsigned long tsc_freq;
unsigned int n;
printk_uart_base = UART_BASE;
unsigned int n;
printk_uart_base = UART_BASE;
comm_region->cell_state = JAILHOUSE_CELL_RUNNING_LOCKED;
comm_region->cell_state = JAILHOUSE_CELL_RUNNING_LOCKED;
+ cache_pollution = cmdline_parse_bool("pollute_cache");
+ if (cache_pollution)
+ printk("Cache pollution enabled\n");
+
tsc_freq = tsc_init();
printk("Calibrated TSC frequency: %lu.%03u kHz\n", tsc_freq / 1000,
tsc_freq % 1000);
tsc_freq = tsc_init();
printk("Calibrated TSC frequency: %lu.%03u kHz\n", tsc_freq / 1000,
tsc_freq % 1000);
while (!terminate) {
asm volatile("hlt");
while (!terminate) {
asm volatile("hlt");
+ if (cache_pollution)
+ pollute_cache();
+
switch (comm_region->msg_to_cell) {
case JAILHOUSE_MSG_SHUTDOWN_REQUEST:
if (!allow_terminate) {
switch (comm_region->msg_to_cell) {
case JAILHOUSE_MSG_SHUTDOWN_REQUEST:
if (!allow_terminate) {