From fd0f349bffdf61fda8a8085b435ec40d9ddfba33 Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Wed, 1 Feb 2012 17:02:59 -0800 Subject: [PATCH 3/5] test: ipicost test routine Silly test to measure ipicost. $ taskset 0x1 cat /proc/ipicost; dmesg | tail -$(($(grep processor /proc/cpuinfo | wc -l)*2)) Signed-off-by: Venkatesh Pallipadi --- fs/proc/Makefile | 2 +- fs/proc/ipicost.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletions(-) create mode 100644 fs/proc/ipicost.c diff --git a/fs/proc/Makefile b/fs/proc/Makefile index c1c7293..4407c6f 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile @@ -8,7 +8,7 @@ proc-y := nommu.o task_nommu.o proc-$(CONFIG_MMU) := mmu.o task_mmu.o proc-y += inode.o root.o base.o generic.o array.o \ - proc_tty.o + proc_tty.o ipicost.o proc-y += cmdline.o proc-y += consoles.o proc-y += cpuinfo.o diff --git a/fs/proc/ipicost.c b/fs/proc/ipicost.c new file mode 100644 index 0000000..967201d --- /dev/null +++ b/fs/proc/ipicost.c @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include + +#define REP_COUNT 100 + +static int dummy_count; +static u64 recv_sum; + +static void dummy_ipi(void *intime) +{ + u64 start, curr; + start = (u64)intime; + rdtscll(curr); + recv_sum += (curr - start); + dummy_count++; +} + +static int show_ipicost(struct seq_file *m, void *v) +{ + int i; + int count; + struct call_single_data csd; + + csd.flags = 0; + csd.func = &dummy_ipi; + csd.info = NULL; + + for_each_online_cpu(i) { + u64 start, stop, sum; + + sum = 0; + recv_sum = 0; + dummy_count = 0; + for (count = 0; count < REP_COUNT; count++) { + rdtscll(start); + csd.info = (void *)start; + __smp_call_function_single(i, &csd, 0); + rdtscll(stop); + sum += (stop - start); + msleep(1); + } + printk("0 CPU %d, time %Lu, recv %Lu, count %d\n", i, sum / REP_COUNT, recv_sum / REP_COUNT, dummy_count); + } + + for_each_online_cpu(i) { + u64 start, stop, sum; + + sum = 0; + recv_sum = 0; + dummy_count = 0; + for (count = 0; count < REP_COUNT; count++) { + rdtscll(start); + csd.info = (void *)start; + __smp_call_function_single(i, &csd, 1); + rdtscll(stop); + sum += (stop - start); + msleep(1); + } + printk("1 CPU %d, time %Lu, recv %Lu, count %d\n", i, sum / REP_COUNT, recv_sum / REP_COUNT, dummy_count); + } + return 0; +} + +static void *c_start(struct seq_file *m, loff_t *pos) +{ + return (void *)1; +} + +static void *c_next(struct seq_file *m, void *v, loff_t *pos) +{ + return NULL; +} + +static void c_stop(struct seq_file *m, void *v) +{ +} + +static const struct seq_operations ipicost_op = { + .start = c_start, + .next = c_next, + .stop = c_stop, + .show = show_ipicost, +}; + +static int ipicost_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &ipicost_op); +} + +static const struct file_operations proc_ipicost_operations = { + .open = ipicost_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int __init proc_ipicost_init(void) +{ + proc_create("ipicost", 0, NULL, &proc_ipicost_operations); + return 0; +} +module_init(proc_ipicost_init); -- 1.7.7.3