From 96979188007a0671d3f067d7edf144742d7433ee Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:26:50 -0500 Subject: [ported from 2008.3] Add tracing support and hook up Litmus KConfig for x86 - fix requesting more than 2^11 pages (MAX_ORDER) to system allocator Still to be merged: - feather-trace generic implementation --- arch/x86/Kconfig | 2 ++ arch/x86/include/asm/feather_trace.h | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 arch/x86/include/asm/feather_trace.h (limited to 'arch') diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 72ace9515a0..e2cd95ebeeb 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2092,3 +2092,5 @@ source "crypto/Kconfig" source "arch/x86/kvm/Kconfig" source "lib/Kconfig" + +source "litmus/Kconfig" diff --git a/arch/x86/include/asm/feather_trace.h b/arch/x86/include/asm/feather_trace.h new file mode 100644 index 00000000000..f60fbed07af --- /dev/null +++ b/arch/x86/include/asm/feather_trace.h @@ -0,0 +1,11 @@ +#ifndef _ARCH_FEATHER_TRACE_H +#define _ARCH_FEATHER_TRACE_H + +static inline unsigned long long ft_timestamp(void) +{ + unsigned long long ret; + __asm__ __volatile__("rdtsc" : "=A" (ret)); + return ret; +} + +#endif -- cgit v1.2.2 From 2a94c7bf9869a13e32de7a1fe94596de7b4789a8 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Fri, 28 May 2010 10:03:24 -0400 Subject: [ported from 2008.3] Add LITRMUS^RT syscalls to x86_32 --- arch/x86/include/asm/unistd_32.h | 6 +++++- arch/x86/kernel/syscall_table_32.S | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/x86/include/asm/unistd_32.h b/arch/x86/include/asm/unistd_32.h index 6fb3c209a7e..34bc4204d37 100644 --- a/arch/x86/include/asm/unistd_32.h +++ b/arch/x86/include/asm/unistd_32.h @@ -343,9 +343,13 @@ #define __NR_rt_tgsigqueueinfo 335 #define __NR_perf_event_open 336 +#define __NR_LITMUS 337 + +#include "litmus/unistd.h" + #ifdef __KERNEL__ -#define NR_syscalls 337 +#define NR_syscalls 336 + NR_litmus_syscalls #define __ARCH_WANT_IPC_PARSE_VERSION #define __ARCH_WANT_OLD_READDIR diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S index 0157cd26d7c..17fcb3abe23 100644 --- a/arch/x86/kernel/syscall_table_32.S +++ b/arch/x86/kernel/syscall_table_32.S @@ -336,3 +336,17 @@ ENTRY(sys_call_table) .long sys_pwritev .long sys_rt_tgsigqueueinfo /* 335 */ .long sys_perf_event_open + .long sys_set_rt_task_param /* LITMUS^RT 337 */ + .long sys_get_rt_task_param + .long sys_complete_job + .long sys_od_open + .long sys_od_close + .long sys_fmlp_down + .long sys_fmlp_up + .long sys_srp_down + .long sys_srp_up + .long sys_query_job_no + .long sys_wait_for_job_release + .long sys_wait_for_ts_release + .long sys_release_ts + .long sys_null_call -- cgit v1.2.2 From 50ca05ff9cc85176c3ee18bf1363d3d7c34aa355 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:39:14 -0500 Subject: [ported from 2008.3] Add GSN-EDF plugin - insert arm_release_timer() in add_relese() path - arm_release_timer() uses __hrtimer_start_range_ns() instead of hrtimer_start() to avoid deadlock on rq->lock. --- arch/x86/kernel/smp.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'arch') diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index ec1de97600e..337ce0c44f9 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -22,6 +22,9 @@ #include #include +#include +#include + #include #include #include @@ -117,6 +120,7 @@ static void native_smp_send_reschedule(int cpu) WARN_ON(1); return; } + TS_SEND_RESCHED_START(cpu); apic->send_IPI_mask(cpumask_of(cpu), RESCHEDULE_VECTOR); } @@ -197,7 +201,12 @@ static void native_smp_send_stop(void) void smp_reschedule_interrupt(struct pt_regs *regs) { ack_APIC_irq(); + /* LITMUS^RT needs this interrupt to proper reschedule + * on this cpu + */ + set_tsk_need_resched(current); inc_irq_stat(irq_resched_count); + TS_SEND_RESCHED_END; /* * KVM uses this interrupt to force a cpu out of guest mode */ -- cgit v1.2.2 From b085cafc43bc395e255626204169e20a587f28ba Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:44:47 -0500 Subject: [ported from 2008.3] Add send_pull_timers() support for x86_32 arch --- arch/x86/include/asm/entry_arch.h | 1 + arch/x86/include/asm/hw_irq.h | 2 ++ arch/x86/include/asm/irq_vectors.h | 5 +++++ arch/x86/kernel/irqinit.c | 3 +++ arch/x86/kernel/smp.c | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+) (limited to 'arch') diff --git a/arch/x86/include/asm/entry_arch.h b/arch/x86/include/asm/entry_arch.h index f5693c81a1d..19e22e3784d 100644 --- a/arch/x86/include/asm/entry_arch.h +++ b/arch/x86/include/asm/entry_arch.h @@ -13,6 +13,7 @@ BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR) +BUILD_INTERRUPT(pull_timers_interrupt,PULL_TIMERS_VECTOR) BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR) BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR) diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index ba180d93b08..162e5f9646e 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -53,6 +53,8 @@ extern void threshold_interrupt(void); extern void call_function_interrupt(void); extern void call_function_single_interrupt(void); +extern void pull_timers_interrupt(void); + /* PIC specific functions */ extern void disable_8259A_irq(unsigned int irq); extern void enable_8259A_irq(unsigned int irq); diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index 5b21f0ec3df..28c3bf3f4c8 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h @@ -103,6 +103,11 @@ */ #define LOCAL_TIMER_VECTOR 0xef +/* + * LITMUS^RT pull timers IRQ vector + */ +#define PULL_TIMERS_VECTOR 0xee + /* * Generic system vector for platform specific use */ diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c index 40f30773fb2..f5fa64c0b37 100644 --- a/arch/x86/kernel/irqinit.c +++ b/arch/x86/kernel/irqinit.c @@ -172,6 +172,9 @@ static void __init smp_intr_init(void) alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR, call_function_single_interrupt); + /* IPI for hrtimer pulling on remote cpus */ + alloc_intr_gate(PULL_TIMERS_VECTOR, pull_timers_interrupt); + /* Low priority IPI to cleanup after moving an irq */ set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt); set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors); diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index 337ce0c44f9..e83f79de863 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -150,6 +150,16 @@ void native_send_call_func_ipi(const struct cpumask *mask) free_cpumask_var(allbutself); } +/* trigger timers on remote cpu */ +void smp_send_pull_timers(int cpu) +{ + if (unlikely(cpu_is_offline(cpu))) { + WARN_ON(1); + return; + } + apic->send_IPI_mask(cpumask_of(cpu), PULL_TIMERS_VECTOR); +} + /* * this function calls the 'stop' function on all other CPUs in the system. */ @@ -230,6 +240,14 @@ void smp_call_function_single_interrupt(struct pt_regs *regs) irq_exit(); } +extern void hrtimer_pull(void); + +void smp_pull_timers_interrupt(struct pt_regs *regs) +{ + ack_APIC_irq(); + TRACE("pull timer interrupt\n"); +} + struct smp_ops smp_ops = { .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu, .smp_prepare_cpus = native_smp_prepare_cpus, -- cgit v1.2.2 From c15be843778236e9f2fdbc207ab36ba996b2bb1b Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:45:38 -0500 Subject: [ported from 2008.3] Add hrtimer_start_on() API --- arch/x86/kernel/smp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch') diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index e83f79de863..a93528bc16e 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -246,6 +246,7 @@ void smp_pull_timers_interrupt(struct pt_regs *regs) { ack_APIC_irq(); TRACE("pull timer interrupt\n"); + hrtimer_pull(); } struct smp_ops smp_ops = { -- cgit v1.2.2 From 5306b9834e9660e370fb8430ff22d4a47b4bbdf5 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:47:51 -0500 Subject: Add pull_timers_interrupt() to x86_64 Add apic interrupt vector for pull_timers() in x86_64 arch. --- arch/x86/kernel/entry_64.S | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch') diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index b5c061f8f35..5e9b0e538a1 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -1008,6 +1008,8 @@ apicinterrupt CALL_FUNCTION_VECTOR \ call_function_interrupt smp_call_function_interrupt apicinterrupt RESCHEDULE_VECTOR \ reschedule_interrupt smp_reschedule_interrupt +apicinterrupt PULL_TIMERS_VECTOR \ + pull_timers_interrupt smp_pull_timers_interrupt #endif apicinterrupt ERROR_APIC_VECTOR \ -- cgit v1.2.2 From 07ae7efcb81f95eb8e870cad21c7ba72573af7e8 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:48:38 -0500 Subject: Add support for x86_64 architecture - Add syscall on x86_64 - Refactor __NR_sleep_next_period -> __NR_complete_job for both x86_32 and x86_64 --- arch/x86/include/asm/hw_irq.h | 1 + arch/x86/include/asm/unistd_32.h | 2 +- arch/x86/include/asm/unistd_64.h | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index 162e5f9646e..68900e7dada 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -112,6 +112,7 @@ extern asmlinkage void smp_irq_move_cleanup_interrupt(void); extern void smp_reschedule_interrupt(struct pt_regs *); extern void smp_call_function_interrupt(struct pt_regs *); extern void smp_call_function_single_interrupt(struct pt_regs *); +extern void smp_pull_timers_interrupt(struct pt_regs *); #ifdef CONFIG_X86_32 extern void smp_invalidate_interrupt(struct pt_regs *); #else diff --git a/arch/x86/include/asm/unistd_32.h b/arch/x86/include/asm/unistd_32.h index 34bc4204d37..f9b507f30d6 100644 --- a/arch/x86/include/asm/unistd_32.h +++ b/arch/x86/include/asm/unistd_32.h @@ -345,7 +345,7 @@ #define __NR_LITMUS 337 -#include "litmus/unistd.h" +#include "litmus/unistd_32.h" #ifdef __KERNEL__ diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h index 8d3ad0adbc6..33b2003c045 100644 --- a/arch/x86/include/asm/unistd_64.h +++ b/arch/x86/include/asm/unistd_64.h @@ -662,6 +662,10 @@ __SYSCALL(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) #define __NR_perf_event_open 298 __SYSCALL(__NR_perf_event_open, sys_perf_event_open) +#define __NR_LITMUS 299 + +#include "litmus/unistd_64.h" + #ifndef __NO_STUBS #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_OLD_STAT -- cgit v1.2.2 From d1a840d7194fdd09c1bd9977e30fd391ef2a7526 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Tue, 19 Jan 2010 19:38:14 -0500 Subject: [ported from 2008.3] Add Feather-Trace x86_32 architecture dependent code - [ported from 2008.3] Add x86_32 architecture dependent code. - Add the infrastructure for x86_32 - x86_64 integration. --- arch/x86/include/asm/feather_trace.h | 13 +++- arch/x86/include/asm/feather_trace_32.h | 80 +++++++++++++++++++++++ arch/x86/kernel/Makefile | 2 + arch/x86/kernel/ft_event.c | 112 ++++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 arch/x86/include/asm/feather_trace_32.h create mode 100644 arch/x86/kernel/ft_event.c (limited to 'arch') diff --git a/arch/x86/include/asm/feather_trace.h b/arch/x86/include/asm/feather_trace.h index f60fbed07af..86a4303fce7 100644 --- a/arch/x86/include/asm/feather_trace.h +++ b/arch/x86/include/asm/feather_trace.h @@ -1,11 +1,18 @@ #ifndef _ARCH_FEATHER_TRACE_H #define _ARCH_FEATHER_TRACE_H +#include + static inline unsigned long long ft_timestamp(void) { - unsigned long long ret; - __asm__ __volatile__("rdtsc" : "=A" (ret)); - return ret; + return __native_read_tsc(); } +#ifdef CONFIG_X86_32 +#include "feather_trace_32.h" +#else +/* not ready for integration yet */ +//#include "feather_trace_64.h" +#endif + #endif diff --git a/arch/x86/include/asm/feather_trace_32.h b/arch/x86/include/asm/feather_trace_32.h new file mode 100644 index 00000000000..192cd09b785 --- /dev/null +++ b/arch/x86/include/asm/feather_trace_32.h @@ -0,0 +1,80 @@ +/* Do not directly include this file. Include feather_trace.h instead */ + +#define feather_callback __attribute__((regparm(0))) + +/* + * make the compiler reload any register that is not saved in + * a cdecl function call + */ +#define CLOBBER_LIST "memory", "cc", "eax", "ecx", "edx" + +#define ft_event(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " call " #callback " \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event0(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $4, %%esp \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $4, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event1(id, callback, param) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $8, %%esp \n\t" \ + " movl %0, 4(%%esp) \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $8, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : "r" (param) : CLOBBER_LIST) + +#define ft_event2(id, callback, param, param2) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $12, %%esp \n\t" \ + " movl %1, 8(%%esp) \n\t" \ + " movl %0, 4(%%esp) \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $12, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : "r" (param), "r" (param2) : CLOBBER_LIST) + + +#define ft_event3(id, callback, p, p2, p3) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " subl $16, %%esp \n\t" \ + " movl %2, 12(%%esp) \n\t" \ + " movl %1, 8(%%esp) \n\t" \ + " movl %0, 4(%%esp) \n\t" \ + " movl $" #id ", (%%esp) \n\t" \ + " call " #callback " \n\t" \ + " addl $16, %%esp \n\t" \ + ".section __event_table, \"aw\" \n\t" \ + ".long " #id ", 0, 1b, 2f \n\t" \ + ".previous \n\t" \ + "2: \n\t" \ + : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) + +#define __ARCH_HAS_FEATHER_TRACE diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index d8e5d0cdd67..a99b34d1b3b 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -117,6 +117,8 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o +obj-$(CONFIG_FEATHER_TRACE) += ft_event.o + ### # 64 bit specific files ifeq ($(CONFIG_X86_64),y) diff --git a/arch/x86/kernel/ft_event.c b/arch/x86/kernel/ft_event.c new file mode 100644 index 00000000000..e07ee30dfff --- /dev/null +++ b/arch/x86/kernel/ft_event.c @@ -0,0 +1,112 @@ +#include + +#include + +#ifdef __ARCH_HAS_FEATHER_TRACE +/* the feather trace management functions assume + * exclusive access to the event table + */ + + +#define BYTE_JUMP 0xeb +#define BYTE_JUMP_LEN 0x02 + +/* for each event, there is an entry in the event table */ +struct trace_event { + long id; + long count; + long start_addr; + long end_addr; +}; + +extern struct trace_event __start___event_table[]; +extern struct trace_event __stop___event_table[]; + +int ft_enable_event(unsigned long id) +{ + struct trace_event* te = __start___event_table; + int count = 0; + char* delta; + unsigned char* instr; + + while (te < __stop___event_table) { + if (te->id == id && ++te->count == 1) { + instr = (unsigned char*) te->start_addr; + /* make sure we don't clobber something wrong */ + if (*instr == BYTE_JUMP) { + delta = (((unsigned char*) te->start_addr) + 1); + *delta = 0; + } + } + if (te->id == id) + count++; + te++; + } + + printk(KERN_DEBUG "ft_enable_event: enabled %d events\n", count); + return count; +} + +int ft_disable_event(unsigned long id) +{ + struct trace_event* te = __start___event_table; + int count = 0; + char* delta; + unsigned char* instr; + + while (te < __stop___event_table) { + if (te->id == id && --te->count == 0) { + instr = (unsigned char*) te->start_addr; + if (*instr == BYTE_JUMP) { + delta = (((unsigned char*) te->start_addr) + 1); + *delta = te->end_addr - te->start_addr - + BYTE_JUMP_LEN; + } + } + if (te->id == id) + count++; + te++; + } + + printk(KERN_DEBUG "ft_disable_event: disabled %d events\n", count); + return count; +} + +int ft_disable_all_events(void) +{ + struct trace_event* te = __start___event_table; + int count = 0; + char* delta; + unsigned char* instr; + + while (te < __stop___event_table) { + if (te->count) { + instr = (unsigned char*) te->start_addr; + if (*instr == BYTE_JUMP) { + delta = (((unsigned char*) te->start_addr) + + 1); + *delta = te->end_addr - te->start_addr - + BYTE_JUMP_LEN; + te->count = 0; + count++; + } + } + te++; + } + return count; +} + +int ft_is_event_enabled(unsigned long id) +{ + struct trace_event* te = __start___event_table; + + while (te < __stop___event_table) { + if (te->id == id) + return te->count; + te++; + } + return 0; +} + +#endif + -- cgit v1.2.2 From 37b840336a1663a5ce62d663a702d9afefd56d23 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Mon, 1 Feb 2010 23:07:54 -0500 Subject: Add Feather-Trace x86_64 architecture dependent code --- arch/x86/include/asm/feather_trace.h | 3 +- arch/x86/include/asm/feather_trace_64.h | 69 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 arch/x86/include/asm/feather_trace_64.h (limited to 'arch') diff --git a/arch/x86/include/asm/feather_trace.h b/arch/x86/include/asm/feather_trace.h index 86a4303fce7..4fd31633405 100644 --- a/arch/x86/include/asm/feather_trace.h +++ b/arch/x86/include/asm/feather_trace.h @@ -11,8 +11,7 @@ static inline unsigned long long ft_timestamp(void) #ifdef CONFIG_X86_32 #include "feather_trace_32.h" #else -/* not ready for integration yet */ -//#include "feather_trace_64.h" +#include "feather_trace_64.h" #endif #endif diff --git a/arch/x86/include/asm/feather_trace_64.h b/arch/x86/include/asm/feather_trace_64.h new file mode 100644 index 00000000000..1cffa4eec5f --- /dev/null +++ b/arch/x86/include/asm/feather_trace_64.h @@ -0,0 +1,69 @@ +/* Do not directly include this file. Include feather_trace.h instead */ + +/* regparm is the default on x86_64 */ +#define feather_callback + +# define _EVENT_TABLE(id,from,to) \ + ".section __event_table, \"aw\"\n\t" \ + ".balign 8\n\t" \ + ".quad " #id ", 0, " #from ", " #to " \n\t" \ + ".previous \n\t" + +/* + * x86_64 callee only owns rbp, rbx, r12 -> r15 + * the called can freely modify the others + */ +#define CLOBBER_LIST "memory", "cc", "rdi", "rsi", "rdx", "rcx", \ + "r8", "r9", "r10", "r11", "rax" + +#define ft_event(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event0(id, callback) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : : CLOBBER_LIST) + +#define ft_event1(id, callback, param) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq %0, %%rsi \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : "r" (param) : CLOBBER_LIST) + +#define ft_event2(id, callback, param, param2) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq %1, %%rdx \n\t" \ + " movq %0, %%rsi \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : "r" (param), "r" (param2) : CLOBBER_LIST) + +#define ft_event3(id, callback, p, p2, p3) \ + __asm__ __volatile__( \ + "1: jmp 2f \n\t" \ + " movq %2, %%rcx \n\t" \ + " movq %1, %%rdx \n\t" \ + " movq %0, %%rsi \n\t" \ + " movq $" #id ", %%rdi \n\t" \ + " call " #callback " \n\t" \ + _EVENT_TABLE(id,1b,2f) \ + "2: \n\t" \ + : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) + +#define __ARCH_HAS_FEATHER_TRACE -- cgit v1.2.2 From 425a6b5043bcc2142804107c853f978ac2fe3040 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Fri, 28 May 2010 10:49:09 -0400 Subject: Export shared_cpu_map The cpumap of CPUs that share the same cache level is not normally available outside intel_cacheinfo.c. This commit allows to export such map. --- arch/x86/include/asm/processor.h | 2 ++ arch/x86/kernel/cpu/intel_cacheinfo.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'arch') diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index c9786480f0f..e75daac6496 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -172,6 +172,8 @@ extern void print_cpu_info(struct cpuinfo_x86 *); extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); extern unsigned short num_cache_leaves; +extern int get_shared_cpu_map(cpumask_var_t mask, + unsigned int cpu, int index); extern void detect_extended_topology(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index 804c40e2bc3..3167c3d7259 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c @@ -515,6 +515,23 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) static DEFINE_PER_CPU(struct _cpuid4_info *, cpuid4_info); #define CPUID4_INFO_IDX(x, y) (&((per_cpu(cpuid4_info, x))[y])) +/* returns CPUs that share the index cache with cpu */ +int get_shared_cpu_map(cpumask_var_t mask, unsigned int cpu, int index) +{ + int ret = 0; + struct _cpuid4_info *this_leaf; + + if (index >= num_cache_leaves) { + index = num_cache_leaves - 1; + ret = index; + } + + this_leaf = CPUID4_INFO_IDX(cpu,index); + cpumask_copy(mask, to_cpumask(this_leaf->shared_cpu_map)); + + return ret; +} + #ifdef CONFIG_SMP static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) { -- cgit v1.2.2 From 152968b15afb74a6adba6d512c5eebf0280c8f00 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sun, 30 May 2010 18:41:28 -0400 Subject: Make __ARCH_HAS_FEATHER_TRACE a proper CONFIG_ variable. The idea of the Feather-Trace default implementation is that LITMUS^RT should work without a specialized Feather-Trace implementation present. This was actually broken. Changes litmus/feather_trace.h to only include asm/feather_trace.h if actually promised by the architecture. --- arch/x86/Kconfig | 3 +++ arch/x86/include/asm/feather_trace_32.h | 1 - arch/x86/include/asm/feather_trace_64.h | 2 -- arch/x86/kernel/ft_event.c | 4 ---- 4 files changed, 3 insertions(+), 7 deletions(-) (limited to 'arch') diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 12fbd5b65f1..955ad4089a7 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2126,4 +2126,7 @@ source "arch/x86/kvm/Kconfig" source "lib/Kconfig" +config ARCH_HAS_FEATHER_TRACE + def_bool y + source "litmus/Kconfig" diff --git a/arch/x86/include/asm/feather_trace_32.h b/arch/x86/include/asm/feather_trace_32.h index 192cd09b785..70202f90f16 100644 --- a/arch/x86/include/asm/feather_trace_32.h +++ b/arch/x86/include/asm/feather_trace_32.h @@ -77,4 +77,3 @@ "2: \n\t" \ : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) -#define __ARCH_HAS_FEATHER_TRACE diff --git a/arch/x86/include/asm/feather_trace_64.h b/arch/x86/include/asm/feather_trace_64.h index 1cffa4eec5f..54ac2aeb3a2 100644 --- a/arch/x86/include/asm/feather_trace_64.h +++ b/arch/x86/include/asm/feather_trace_64.h @@ -65,5 +65,3 @@ _EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) - -#define __ARCH_HAS_FEATHER_TRACE diff --git a/arch/x86/kernel/ft_event.c b/arch/x86/kernel/ft_event.c index e07ee30dfff..da9b3ccb725 100644 --- a/arch/x86/kernel/ft_event.c +++ b/arch/x86/kernel/ft_event.c @@ -2,7 +2,6 @@ #include -#ifdef __ARCH_HAS_FEATHER_TRACE /* the feather trace management functions assume * exclusive access to the event table */ @@ -107,6 +106,3 @@ int ft_is_event_enabled(unsigned long id) } return 0; } - -#endif - -- cgit v1.2.2 From 8bf9de45b663e4b9ce889eb24929ce773f306339 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sun, 30 May 2010 19:50:52 -0400 Subject: Make smp_send_pull_timers() optional. There is currently no need to implement this in ARM. So let's make it optional instead. --- arch/x86/Kconfig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch') diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 955ad4089a7..7b2c8db45d8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2129,4 +2129,7 @@ source "lib/Kconfig" config ARCH_HAS_FEATHER_TRACE def_bool y +config ARCH_HAS_SEND_PULL_TIMERS + def_bool y + source "litmus/Kconfig" -- cgit v1.2.2 From 4382e90cf851fc1d209a466bab92e256aeb7acf1 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Mon, 31 May 2010 00:54:07 -0400 Subject: Make C-EDF depend on x86 and SYSFS C-EDF depends on intel_cacheinfo.c (for get_shared_cpu_map()) which is only available on x86 architectures. Furthermore, get_shared_cpu_map() is only available if SYSFS filesystem is present. --- arch/x86/include/asm/processor.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch') diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 91d323f4736..48426f99147 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -173,8 +173,10 @@ extern void print_cpu_info(struct cpuinfo_x86 *); extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); extern unsigned short num_cache_leaves; +#ifdef CONFIG_SYSFS extern int get_shared_cpu_map(cpumask_var_t mask, unsigned int cpu, int index); +#endif extern void detect_extended_topology(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); -- cgit v1.2.2 From 753fb14dfb0662e1d38758ffc6876c0ab1c7bd9e Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 31 May 2010 12:52:35 -0400 Subject: Make platform-specific Feather-Trace depend on !CONFIG_DEBUG_RODATA Feather-Trace rewrites instructions in the kernel's .text segment. This segment may be write-protected if CONFIG_DEBUG_RODATA is selected. In this case, fall back to the default flag-based Feather-Trace implementation. In the future, we could either adopt the ftrace method of rewriting .text addresses using non-.text mappings or we could consider replacing Feather-Trace with ftrace altogether. For now, this patch avoids unexpected runtime errors. --- arch/x86/kernel/ft_event.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch') diff --git a/arch/x86/kernel/ft_event.c b/arch/x86/kernel/ft_event.c index da9b3ccb725..6552e2741ec 100644 --- a/arch/x86/kernel/ft_event.c +++ b/arch/x86/kernel/ft_event.c @@ -6,6 +6,7 @@ * exclusive access to the event table */ +#ifndef CONFIG_DEBUG_RODATA #define BYTE_JUMP 0xeb #define BYTE_JUMP_LEN 0x02 @@ -106,3 +107,5 @@ int ft_is_event_enabled(unsigned long id) } return 0; } + +#endif -- cgit v1.2.2 From 136a08dbe8c28e751b01e932420f715edb229f6b Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Fri, 16 Jul 2010 10:30:06 -0400 Subject: Bugfix: avoid link error in Feather-Trace on x86 If no events are defined but Feater-Trace support is enabled, then the current implementation generates a link error because the __event_table sections is absent. > arch/x86/built-in.o: In function `ft_disable_all_events': > (.text+0x242af): undefined reference to `__start___event_table' As a simple work around, we force zero-element array to always be "allocated" in the __event_table section. This ensures that we end up with a zero-byte section if no events are enabled, and does not affect the layout of the section if events are present. > bbb@ludwig:~/dev/litmus2010$ nm vmlinux | grep event_table > ffffffff81950cdc D __event_table_dummy > ffffffff81950cdc A __start___event_table > ffffffff81950cdc A __stop___event_table --- arch/x86/kernel/ft_event.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'arch') diff --git a/arch/x86/kernel/ft_event.c b/arch/x86/kernel/ft_event.c index 6552e2741ec..37cc3325271 100644 --- a/arch/x86/kernel/ft_event.c +++ b/arch/x86/kernel/ft_event.c @@ -22,6 +22,13 @@ struct trace_event { extern struct trace_event __start___event_table[]; extern struct trace_event __stop___event_table[]; +/* Workaround: if no events are defined, then the event_table section does not + * exist and the above references cause linker errors. This could probably be + * fixed by adjusting the linker script, but it is easier to maintain for us if + * we simply create a dummy symbol in the event table section. + */ +int __event_table_dummy[0] __attribute__ ((section("__event_table"))); + int ft_enable_event(unsigned long id) { struct trace_event* te = __start___event_table; -- cgit v1.2.2 From b39ae3793ab590efbdb8aab63a598071782d32b8 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 31 May 2010 15:12:58 -0400 Subject: ARM: allow mach/timex.h to define get_cycles() Some platforms have access to a cycle coutner (CCNT) register in the CP15 coprocessor. This trivial change will allow such platforms to provide specialized implementations. --- arch/arm/include/asm/timex.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch') diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h index 3be8de3adab..8a102a383a3 100644 --- a/arch/arm/include/asm/timex.h +++ b/arch/arm/include/asm/timex.h @@ -16,9 +16,11 @@ typedef unsigned long cycles_t; +#ifndef get_cycles static inline cycles_t get_cycles (void) { return 0; } +#endif #endif -- cgit v1.2.2 From dd9d29e1f6ec74af4ff7df1bbe4d05829887475f Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 31 May 2010 15:19:02 -0400 Subject: ARM: provide get_cycles() for RealView PB11{MP,76} and Cortex-A8 Use the CCNT register to override the default get_cycles() implementation in arch/arm/asm/timex.h. This is useful for overhead measurements and debugging. --- arch/arm/mach-realview/include/mach/timex.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'arch') diff --git a/arch/arm/mach-realview/include/mach/timex.h b/arch/arm/mach-realview/include/mach/timex.h index 4eeb069373c..e8bcc40d1f0 100644 --- a/arch/arm/mach-realview/include/mach/timex.h +++ b/arch/arm/mach-realview/include/mach/timex.h @@ -21,3 +21,30 @@ */ #define CLOCK_TICK_RATE (50000000 / 16) + +#if defined(CONFIG_MACH_REALVIEW_PB11MP) || defined(CONFIG_MACH_REALVIEW_PB1176) + +static inline unsigned long realview_get_arm11_cp15_ccnt(void) +{ + unsigned long cycles; + /* Read CP15 CCNT register. */ + asm volatile ("mrc p15, 0, %0, c15, c12, 1" : "=r" (cycles)); + return cycles; +} + +#define get_cycles realview_get_arm11_cp15_ccnt + +#elif defined(CONFIG_MACH_REALVIEW_PBA8) + + +static inline unsigned long realview_get_a8_cp15_ccnt(void) +{ + unsigned long cycles; + /* Read CP15 CCNT register. */ + asm volatile ("mrc p15, 0, %0, c9, c13, 0" : "=r" (cycles)); + return cycles; +} + +#define get_cycles realview_get_a8_cp15_ccnt + +#endif -- cgit v1.2.2 From 9907691855fa49ec8ed317fc54a626fcd137c73b Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sun, 30 May 2010 18:52:30 -0400 Subject: ARM: Include LITMUS^RT KConfig Make the ARM built aware of the LITMUS^RT-specific options. --- arch/arm/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'arch') diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9c26ba7244f..babad6d7681 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1808,3 +1808,11 @@ source "security/Kconfig" source "crypto/Kconfig" source "lib/Kconfig" + +config ARCH_HAS_SEND_PULL_TIMERS + def_bool n + +config ARCH_HAS_FEATHER_TRACE + def_bool n + +source "litmus/Kconfig" -- cgit v1.2.2 From 8e10e1803e695a08f1fb59e90dac4ba0d8744f89 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 31 May 2010 13:06:50 -0400 Subject: ARM: hookup LITMUS^RT system calls Includes the LITMUS^RT-specifc unistd.h extension and modifies the actual syscall table. --- arch/arm/include/asm/unistd.h | 3 +++ arch/arm/kernel/calls.S | 14 ++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'arch') diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h index c891eb76c0e..625b3049062 100644 --- a/arch/arm/include/asm/unistd.h +++ b/arch/arm/include/asm/unistd.h @@ -397,6 +397,9 @@ #define __NR_fanotify_mark (__NR_SYSCALL_BASE+368) #define __NR_prlimit64 (__NR_SYSCALL_BASE+369) +#define __NR_LITMUS (__NR_SYSCALL_BASE+370) +#include + /* * The following SWIs are ARM private. */ diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index 5c26eccef99..584a68349a4 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -379,6 +379,20 @@ CALL(sys_fanotify_init) CALL(sys_fanotify_mark) CALL(sys_prlimit64) +/* 370 */ CALL(sys_set_rt_task_param) + CALL(sys_get_rt_task_param) + CALL(sys_complete_job) + CALL(sys_od_open) + CALL(sys_od_close) +/* 375 */ CALL(sys_fmlp_down) + CALL(sys_fmlp_up) + CALL(sys_srp_down) + CALL(sys_srp_up) + CALL(sys_query_job_no) +/* 380 */ CALL(sys_wait_for_job_release) + CALL(sys_wait_for_ts_release) + CALL(sys_release_ts) + CALL(sys_null_call) #ifndef syscalls_counted .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls #define syscalls_counted -- cgit v1.2.2 From 2c142d1028f276c6d5e58c553768ae32ed9bda68 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 10 Nov 2010 12:25:43 -0500 Subject: Hook up LITMUS^RT remote preemption support on x86 Call into scheduler state machine in the IPI handler. --- arch/x86/kernel/smp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'arch') diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index 97af589a5c0..74cca6014c0 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -23,7 +23,8 @@ #include #include -#include +#include +#include #include #include @@ -212,10 +213,8 @@ static void native_smp_send_stop(void) void smp_reschedule_interrupt(struct pt_regs *regs) { ack_APIC_irq(); - /* LITMUS^RT needs this interrupt to proper reschedule - * on this cpu - */ - set_tsk_need_resched(current); + /* LITMUS^RT: this IPI might need to trigger the sched state machine. */ + sched_state_ipi(); inc_irq_stat(irq_resched_count); TS_SEND_RESCHED_END; /* -- cgit v1.2.2 From f599a587e1c7446a76d7d62ed7748f3c4435acd8 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 10 Nov 2010 12:20:48 -0500 Subject: Hook up LITMUS^RT remote preemption support on ARM Call into scheduler state machine in the IPI handler. --- arch/arm/kernel/smp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch') diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 40dc74f2b27..b72fbf3d043 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -38,6 +38,8 @@ #include #include +#include + /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core @@ -533,6 +535,8 @@ asmlinkage void __exception do_IPI(struct pt_regs *regs) * nothing more to do - eveything is * done on the interrupt return path */ + /* LITMUS^RT: take action based on scheduler state */ + sched_state_ipi(); break; case IPI_CALL_FUNC: -- cgit v1.2.2 From cc602187d4466374bca031039e145aa1b89aca96 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Fri, 28 Jan 2011 16:41:16 -0500 Subject: Litmus core: replace FMLP & SRP system calls with generic syscalls This renders the FMLP and SRP unfunctional until they are ported to the new locking API. --- arch/arm/kernel/calls.S | 10 ++++------ arch/x86/kernel/syscall_table_32.S | 6 ++---- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'arch') diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index 584a68349a4..b99087ac85b 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -384,14 +384,12 @@ CALL(sys_complete_job) CALL(sys_od_open) CALL(sys_od_close) -/* 375 */ CALL(sys_fmlp_down) - CALL(sys_fmlp_up) - CALL(sys_srp_down) - CALL(sys_srp_up) +/* 375 */ CALL(sys_litmus_lock) + CALL(sys_litmus_unlock) CALL(sys_query_job_no) -/* 380 */ CALL(sys_wait_for_job_release) + CALL(sys_wait_for_job_release) CALL(sys_wait_for_ts_release) - CALL(sys_release_ts) +/* 380 */ CALL(sys_release_ts) CALL(sys_null_call) #ifndef syscalls_counted .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S index d78c5ed5aef..37702905f65 100644 --- a/arch/x86/kernel/syscall_table_32.S +++ b/arch/x86/kernel/syscall_table_32.S @@ -345,10 +345,8 @@ ENTRY(sys_call_table) .long sys_complete_job .long sys_od_open .long sys_od_close - .long sys_fmlp_down - .long sys_fmlp_up - .long sys_srp_down - .long sys_srp_up + .long sys_litmus_lock + .long sys_litmus_unlock .long sys_query_job_no .long sys_wait_for_job_release .long sys_wait_for_ts_release -- cgit v1.2.2 From 56c5c609615322bfbda5adff94ce011eb3d28fef Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Sat, 27 Aug 2011 16:10:06 +0200 Subject: Fix prototype mismatching and synch syscall numbers * Update prototypes for switched_to(), prio_changed(), select_task_rq(). * Fix missing pid field in printk output. * Synchronize syscall numbers for arm and x86. --- arch/arm/include/asm/unistd.h | 2 +- arch/x86/include/asm/unistd_64.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h index 110d113d4af..0196edf6ee5 100644 --- a/arch/arm/include/asm/unistd.h +++ b/arch/arm/include/asm/unistd.h @@ -403,7 +403,7 @@ #define __NR_sendmmsg (__NR_SYSCALL_BASE+374) #define __NR_setns (__NR_SYSCALL_BASE+375) -#define __NR_LITMUS (__NR_SYSCALL_BASE+370) +#define __NR_LITMUS (__NR_SYSCALL_BASE+376) #include /* diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h index f24806cf3a0..e347f077378 100644 --- a/arch/x86/include/asm/unistd_64.h +++ b/arch/x86/include/asm/unistd_64.h @@ -682,7 +682,7 @@ __SYSCALL(__NR_sendmmsg, sys_sendmmsg) #define __NR_setns 308 __SYSCALL(__NR_setns, sys_setns) -#define __NR_LITMUS 303 +#define __NR_LITMUS 309 #include "litmus/unistd_64.h" -- cgit v1.2.2 From ea62a6fe914f7463f89422dcb1812eb071cbd495 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Wed, 24 Aug 2011 12:06:42 +0200 Subject: Update PULL_TIMERS_VECTOR number From 2.6.39 the "0xee" vector number that we used for pull_timers low-level management is is use by invalidate_tlb_X interrupts. Move the pull_timers vector below the max size of invalidate_tlb. --- arch/x86/include/asm/irq_vectors.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'arch') diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index cf72a7060bf..99a44cf9845 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h @@ -97,11 +97,6 @@ #define THRESHOLD_APIC_VECTOR 0xf9 #define REBOOT_VECTOR 0xf8 -/* - * LITMUS^RT pull timers IRQ vector - */ -#define PULL_TIMERS_VECTOR 0xee - /* * Generic system vector for platform specific use */ @@ -140,6 +135,13 @@ #define INVALIDATE_TLB_VECTOR_START \ (INVALIDATE_TLB_VECTOR_END-NUM_INVALIDATE_TLB_VECTORS+1) +/* + * LITMUS^RT pull timers IRQ vector + * Make sure it's below the above max 32 vectors. + */ +#define PULL_TIMERS_VECTOR 0xce + + #define NR_VECTORS 256 #define FPU_IRQ 13 -- cgit v1.2.2 From 4bc55d3b64fdf0af17f4777013a74fbef7f40ced Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Wed, 30 May 2012 10:16:32 +0200 Subject: Update to improved x86 Feather-Trace triggers This patch imports recent upstream changes in Feather-Trace that reduce register pressure around Feather-Trace triggers. References: Commits 00713b8 and 225d734 in Feather-Trace. https://github.com/brandenburg/feather-trace/commit/00713b878636867ce07291c588509b38fa5bf152 https://github.com/brandenburg/feather-trace/commit/225d7348a08682cd87f72b127142bdfd6c0c7890 --- arch/x86/include/asm/feather_trace_32.h | 96 ++++++++++++++++++++---------- arch/x86/include/asm/feather_trace_64.h | 101 +++++++++++++++++++++++++------- 2 files changed, 145 insertions(+), 52 deletions(-) (limited to 'arch') diff --git a/arch/x86/include/asm/feather_trace_32.h b/arch/x86/include/asm/feather_trace_32.h index 70202f90f16..75e81a9f938 100644 --- a/arch/x86/include/asm/feather_trace_32.h +++ b/arch/x86/include/asm/feather_trace_32.h @@ -1,12 +1,45 @@ +/* Copyright (c) 2007-2012 Björn Brandenburg, + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + /* Do not directly include this file. Include feather_trace.h instead */ -#define feather_callback __attribute__((regparm(0))) +#define feather_callback __attribute__((regparm(3))) __attribute__((used)) /* - * make the compiler reload any register that is not saved in - * a cdecl function call + * Make the compiler reload any register that is not saved in a cdecl function + * call (minus the registers that we explicitly clobber as output registers). */ -#define CLOBBER_LIST "memory", "cc", "eax", "ecx", "edx" +#define __FT_CLOBBER_LIST0 "memory", "cc", "eax", "edx", "ecx" +#define __FT_CLOBBER_LIST1 "memory", "cc", "eax", "ecx" +#define __FT_CLOBBER_LIST2 "memory", "cc", "eax" +#define __FT_CLOBBER_LIST3 "memory", "cc", "eax" + +#define __FT_TMP1(x) "=d" (x) +#define __FT_ARG1(x) "0" ((long) (x)) +#define __FT_TMP2(x) "=c" (x) +#define __FT_ARG2(x) "1" ((long) (x)) + +#define __FT_ARG3(x) "r" ((long) (x)) #define ft_event(id, callback) \ __asm__ __volatile__( \ @@ -16,64 +49,67 @@ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) #define ft_event0(id, callback) \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $4, %%esp \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " movl $" #id ", %%eax \n\t" \ " call " #callback " \n\t" \ - " addl $4, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) -#define ft_event1(id, callback, param) \ +#define ft_event1(id, callback, param) \ + do { \ + long __ft_tmp1; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $8, %%esp \n\t" \ - " movl %0, 4(%%esp) \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " movl $" #id ", %%eax \n\t" \ " call " #callback " \n\t" \ - " addl $8, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : "r" (param) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1) \ + : __FT_ARG1(param) \ + : __FT_CLOBBER_LIST1); \ + } while (0); #define ft_event2(id, callback, param, param2) \ + do { \ + long __ft_tmp1, __ft_tmp2; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $12, %%esp \n\t" \ - " movl %1, 8(%%esp) \n\t" \ - " movl %0, 4(%%esp) \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " movl $" #id ", %%eax \n\t" \ " call " #callback " \n\t" \ - " addl $12, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : "r" (param), "r" (param2) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2) \ + : __FT_ARG1(param), __FT_ARG2(param2) \ + : __FT_CLOBBER_LIST2); \ + } while (0); -#define ft_event3(id, callback, p, p2, p3) \ +#define ft_event3(id, callback, param, param2, param3) \ + do { \ + long __ft_tmp1, __ft_tmp2; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " subl $16, %%esp \n\t" \ - " movl %2, 12(%%esp) \n\t" \ - " movl %1, 8(%%esp) \n\t" \ - " movl %0, 4(%%esp) \n\t" \ - " movl $" #id ", (%%esp) \n\t" \ + " subl $4, %%esp \n\t" \ + " movl $" #id ", %%eax \n\t" \ + " movl %2, (%%esp) \n\t" \ " call " #callback " \n\t" \ - " addl $16, %%esp \n\t" \ + " addl $4, %%esp \n\t" \ ".section __event_table, \"aw\" \n\t" \ ".long " #id ", 0, 1b, 2f \n\t" \ ".previous \n\t" \ "2: \n\t" \ - : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) - + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2) \ + : __FT_ARG1(param), __FT_ARG2(param2), __FT_ARG3(param3) \ + : __FT_CLOBBER_LIST3); \ + } while (0); diff --git a/arch/x86/include/asm/feather_trace_64.h b/arch/x86/include/asm/feather_trace_64.h index 54ac2aeb3a2..5ce49e2eebb 100644 --- a/arch/x86/include/asm/feather_trace_64.h +++ b/arch/x86/include/asm/feather_trace_64.h @@ -1,67 +1,124 @@ +/* Copyright (c) 2010 Andrea Bastoni, + * Copyright (c) 2012 Björn Brandenburg, + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + /* Do not directly include this file. Include feather_trace.h instead */ /* regparm is the default on x86_64 */ -#define feather_callback +#define feather_callback __attribute__((used)) -# define _EVENT_TABLE(id,from,to) \ +#define __FT_EVENT_TABLE(id,from,to) \ ".section __event_table, \"aw\"\n\t" \ ".balign 8\n\t" \ ".quad " #id ", 0, " #from ", " #to " \n\t" \ ".previous \n\t" /* - * x86_64 callee only owns rbp, rbx, r12 -> r15 - * the called can freely modify the others + * x86_64 caller only owns rbp, rbx, r12-r15; + * the callee can freely modify the others. */ -#define CLOBBER_LIST "memory", "cc", "rdi", "rsi", "rdx", "rcx", \ +#define __FT_CLOBBER_LIST0 "memory", "cc", "rdi", "rsi", "rdx", "rcx", \ + "r8", "r9", "r10", "r11", "rax" + +#define __FT_CLOBBER_LIST1 "memory", "cc", "rdi", "rdx", "rcx", \ + "r8", "r9", "r10", "r11", "rax" + +#define __FT_CLOBBER_LIST2 "memory", "cc", "rdi", "rcx", \ "r8", "r9", "r10", "r11", "rax" +#define __FT_CLOBBER_LIST3 "memory", "cc", "rdi", \ + "r8", "r9", "r10", "r11", "rax" + +/* The registers RDI, RSI, RDX, RCX, R8 and R9 are used for integer and pointer + * arguments. */ + +/* RSI */ +#define __FT_TMP1(x) "=S" (x) +#define __FT_ARG1(x) "0" ((long) (x)) + +/* RDX */ +#define __FT_TMP2(x) "=d" (x) +#define __FT_ARG2(x) "1" ((long) (x)) + +/* RCX */ +#define __FT_TMP3(x) "=c" (x) +#define __FT_ARG3(x) "2" ((long) (x)) + #define ft_event(id, callback) \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) #define ft_event0(id, callback) \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : : CLOBBER_LIST) + : : : __FT_CLOBBER_LIST0) #define ft_event1(id, callback, param) \ + do { \ + long __ft_tmp1; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " movq %0, %%rsi \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : "r" (param) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1) \ + : __FT_ARG1(param) \ + : __FT_CLOBBER_LIST1); \ + } while (0); #define ft_event2(id, callback, param, param2) \ + do { \ + long __ft_tmp1, __ft_tmp2; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " movq %1, %%rdx \n\t" \ - " movq %0, %%rsi \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : "r" (param), "r" (param2) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2) \ + : __FT_ARG1(param), __FT_ARG2(param2) \ + : __FT_CLOBBER_LIST2); \ + } while (0); -#define ft_event3(id, callback, p, p2, p3) \ +#define ft_event3(id, callback, param, param2, param3) \ + do { \ + long __ft_tmp1, __ft_tmp2, __ft_tmp3; \ __asm__ __volatile__( \ "1: jmp 2f \n\t" \ - " movq %2, %%rcx \n\t" \ - " movq %1, %%rdx \n\t" \ - " movq %0, %%rsi \n\t" \ " movq $" #id ", %%rdi \n\t" \ " call " #callback " \n\t" \ - _EVENT_TABLE(id,1b,2f) \ + __FT_EVENT_TABLE(id,1b,2f) \ "2: \n\t" \ - : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) + : __FT_TMP1(__ft_tmp1), __FT_TMP2(__ft_tmp2), __FT_TMP3(__ft_tmp3) \ + : __FT_ARG1(param), __FT_ARG2(param2), __FT_ARG3(param3) \ + : __FT_CLOBBER_LIST3); \ + } while (0); -- cgit v1.2.2 From a13904d4b6d04278deb6841020dd7dee9867745e Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Tue, 4 Sep 2012 12:45:54 +0200 Subject: Trace IPI-related IRQs with ft_irq_fired() IPIs have some special cases where irq_enter() is not called. This caused ft_irq_fired() to "miss" some rescheduling-related interrupts, which in turn may cause outliers. This patch makes sure ft_irq_fired() is called on scheduling-related IPIs. --- arch/x86/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch') diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index ed4c4f54e2a..f5e294040b1 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -251,8 +251,10 @@ extern void hrtimer_pull(void); void smp_pull_timers_interrupt(struct pt_regs *regs) { ack_APIC_irq(); + irq_enter(); TRACE("pull timer interrupt\n"); hrtimer_pull(); + irq_exit(); } struct smp_ops smp_ops = { -- cgit v1.2.2 From d940d731de7c4c98e47d526d08064035893dbeed Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Thu, 6 Sep 2012 15:14:10 +0200 Subject: Move SEND_RESCHED tracing to preempt.c The SEND_RESCHED is really only interesting if the IPI was generated by LITMUS^RT. Therefore, we don't need to trace in Linux's architecture-specific code. Instead, we hook into the preemption state machine, which is informed about incoming IPIs anyway. --- arch/x86/kernel/smp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'arch') diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index f5e294040b1..7539d84628f 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -122,7 +121,6 @@ static void native_smp_send_reschedule(int cpu) WARN_ON(1); return; } - TS_SEND_RESCHED_START(cpu); apic->send_IPI_mask(cpumask_of(cpu), RESCHEDULE_VECTOR); } @@ -214,18 +212,16 @@ static void native_stop_other_cpus(int wait) void smp_reschedule_interrupt(struct pt_regs *regs) { ack_APIC_irq(); - /* LITMUS^RT: this IPI might need to trigger the sched state machine. */ - sched_state_ipi(); inc_irq_stat(irq_resched_count); - /* - * LITMUS^RT: starting from 3.0 schedule_ipi() actually does something. - * This may increase IPI latencies compared with previous versions. - */ scheduler_ipi(); - TS_SEND_RESCHED_END; /* * KVM uses this interrupt to force a cpu out of guest mode */ + + /* LITMUS^RT: this IPI might need to trigger the sched state machine. + * Starting from 3.0 schedule_ipi() actually does something. This may + * increase IPI latencies compared with previous versions. */ + sched_state_ipi(); } void smp_call_function_interrupt(struct pt_regs *regs) -- cgit v1.2.2 From 4005b45d832a3affc6c4e1c4575d3112d188f3ee Mon Sep 17 00:00:00 2001 From: Bryan Ward Date: Tue, 7 Aug 2012 14:29:12 -0400 Subject: Chris help! --- arch/arm/kernel/calls.S | 3 +++ arch/x86/kernel/syscall_table_32.S | 3 +++ 2 files changed, 6 insertions(+) (limited to 'arch') diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index ed2ae934127..3444f32562e 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -397,6 +397,9 @@ /* 385 */ CALL(sys_wait_for_ts_release) CALL(sys_release_ts) CALL(sys_null_call) + CALL(sys_dynamic_group_lock) + CALL(sys_dynamic_group_unlock) + CALL(sys_dynamic_group_add) #ifndef syscalls_counted .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls #define syscalls_counted diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S index d0126222b39..47028d2ff1a 100644 --- a/arch/x86/kernel/syscall_table_32.S +++ b/arch/x86/kernel/syscall_table_32.S @@ -358,3 +358,6 @@ ENTRY(sys_call_table) .long sys_wait_for_ts_release .long sys_release_ts /* +10 */ .long sys_null_call + .long sys_dynamic_group_lock + .long sys_dynamic_group_unlock + .long sys_dynamic_group_add -- cgit v1.2.2 From ba3f616d900d1a8caad96d0fb8c4f168c30a8afd Mon Sep 17 00:00:00 2001 From: Bryan Ward Date: Fri, 10 Aug 2012 16:27:47 -0400 Subject: Allow one litmus_lock to control multiple fdsos. Each fdso in a resource group now points to a single litmus_lock object which will arbitrate access to each of the fdsos. --- arch/arm/kernel/calls.S | 1 - arch/x86/kernel/syscall_table_32.S | 1 - 2 files changed, 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index 3444f32562e..6a4f83eeb6b 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -399,7 +399,6 @@ CALL(sys_null_call) CALL(sys_dynamic_group_lock) CALL(sys_dynamic_group_unlock) - CALL(sys_dynamic_group_add) #ifndef syscalls_counted .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls #define syscalls_counted diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S index 47028d2ff1a..652137f34dc 100644 --- a/arch/x86/kernel/syscall_table_32.S +++ b/arch/x86/kernel/syscall_table_32.S @@ -360,4 +360,3 @@ ENTRY(sys_call_table) .long sys_null_call .long sys_dynamic_group_lock .long sys_dynamic_group_unlock - .long sys_dynamic_group_add -- cgit v1.2.2