/* * Test null syscall performance * * Copyright (C) 2009-2015 Anton Blanchard, IBM * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #define NR_LOOPS 10000000 #include #include #include #include #include #include #include #include static volatile int soak_done; unsigned long long clock_frequency; unsigned long long timebase_frequency; double timebase_multiplier; static inline unsigned long long mftb(void) { unsigned long low; asm volatile("mftb %0" : "=r" (low)); return low; } static void sigalrm_handler(int unused) { soak_done = 1; } /* * Use a timer instead of busy looping on clock_gettime() so we don't * pollute profiles with glibc and VDSO hits. */ static void cpu_soak_usecs(unsigned long usecs) { struct itimerval val; memset(&val, 0, sizeof(val)); val.it_value.tv_usec = usecs; signal(SIGALRM, sigalrm_handler); setitimer(ITIMER_REAL, &val, NULL); while (1) { if (soak_done) break; } signal(SIGALRM, SIG_DFL); } /* * This only works with recent kernels where cpufreq modifies * /proc/cpuinfo dynamically. */ static void get_proc_frequency(void) { FILE *f; char line[128]; char *p, *end; unsigned long v; double d; char *override; /* Try to get out of low power/low frequency mode */ cpu_soak_usecs(0.25 * 1000000); f = fopen("/proc/cpuinfo", "r"); if (f == NULL) return; timebase_frequency = 0; while (fgets(line, sizeof(line), f) != NULL) { if (strncmp(line, "timebase", 8) == 0) { p = strchr(line, ':'); if (p != NULL) { v = strtoull(p + 1, &end, 0); if (end != p + 1) timebase_frequency = v; } } if (((strncmp(line, "clock", 5) == 0) || (strncmp(line, "cpu MHz", 7) == 0))) { p = strchr(line, ':'); if (p != NULL) { d = strtod(p + 1, &end); if (end != p + 1) { /* Find fastest clock frequency */ if ((d * 1000000ULL) > clock_frequency) clock_frequency = d * 1000000ULL; } } } } fclose(f); override = getenv("FREQUENCY"); if (override) clock_frequency = strtoull(override, NULL, 10); if (timebase_frequency) timebase_multiplier = (double)clock_frequency / timebase_frequency; else timebase_multiplier = 1; } static void do_null_syscall(unsigned long nr) { unsigned long i; for (i = 0; i < nr; i++) getppid(); } #define TIME(A, STR) \ int main(void) { unsigned long tb_start, tb_now; struct timespec tv_start, tv_now; unsigned long long elapsed_ns, elapsed_tb; get_proc_frequency(); clock_gettime(CLOCK_MONOTONIC, &tv_start); tb_start = mftb(); do_null_syscall(NR_LOOPS); clock_gettime(CLOCK_MONOTONIC, &tv_now); tb_now = mftb(); elapsed_ns = (tv_now.tv_sec - tv_start.tv_sec) * 1000000000ULL + (tv_now.tv_nsec - tv_start.tv_nsec); elapsed_tb = tb_now - tb_start; printf("%10.2f ns %10.2f cycles\n", (float)elapsed_ns / NR_LOOPS, (float)elapsed_tb * timebase_multiplier / NR_LOOPS); return 0; } href='/cgit.cgi/linux/net-next.git/commit/drivers/usb?h=nds-private-remove&id=d7df2443cd5f67fc6ee7c05a88e4996e8177f91b'>usb/chipidea/Makefile
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2017-02-03 17:10:28 +1100
committerMichael Ellerman <mpe@ellerman.id.au>2017-02-08 23:36:29 +1100
commitd7df2443cd5f67fc6ee7c05a88e4996e8177f91b (patch)
tree098a7c0ca4fceb8a65cb1f693c9d71990388933d /drivers/usb/chipidea/Makefile
parenta0615a16f7d0ceb5804d295203c302d496d8ee91 (diff)
powerpc/mm: Fix spurrious segfaults on radix with autonuma
When autonuma (Automatic NUMA balancing) marks a PTE inaccessible it clears all the protection bits but leave the PTE valid. With the Radix MMU, an attempt at executing from such a PTE will take a fault with bit 35 of SRR1 set "SRR1_ISI_N_OR_G". It is thus incorrect to treat all such faults as errors. We should pass them to handle_mm_fault() for autonuma to deal with. The case of pages that are really not executable is handled by the existing test for VM_EXEC further down. That leaves us with catching the kernel attempts at executing user pages. We can catch that earlier, even before we do find_vma. It is never valid on powerpc for the kernel to take an exec fault to begin with. So fold that test with the existing test for the kernel faulting on kernel addresses to bail out early. Fixes: 1d18ad026844 ("powerpc/mm: Detect instruction fetch denied and report") Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Acked-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/usb/chipidea/Makefile')