From 4b38febbd59fd33542a343991262119eb9860f5e Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:23:36 -0500 Subject: [ported from 2008.3] Core LITMUS^RT infrastructure Port 2008.3 Core LITMUS^RT infrastructure to Linux 2.6.32 litmus_sched_class implements 4 new methods: - prio_changed: void - switched_to: void - get_rr_interval: return infinity (i.e., 0) - select_task_rq: return current cpu --- include/linux/sched.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/linux') diff --git a/include/linux/sched.h b/include/linux/sched.h index 75e6e60bf58..bb046c0adf9 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -38,6 +38,7 @@ #define SCHED_BATCH 3 /* SCHED_ISO: reserved but not implemented yet */ #define SCHED_IDLE 5 +#define SCHED_LITMUS 6 /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */ #define SCHED_RESET_ON_FORK 0x40000000 @@ -94,6 +95,8 @@ struct sched_param { #include +#include + struct exec_domain; struct futex_pi_state; struct robust_list_head; @@ -1505,6 +1508,10 @@ struct task_struct { int make_it_fail; #endif struct prop_local_single dirties; + + /* LITMUS RT parameters and state */ + struct rt_param rt_param; + #ifdef CONFIG_LATENCYTOP int latency_record_count; struct latency_record latency_record[LT_SAVECOUNT]; -- cgit v1.2.2 From 59d8d4c53f1e9f6408b87fc22e319e78f664276f Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:29:31 -0500 Subject: [ported from 2008.3] Add complete_n() call --- include/linux/completion.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux') diff --git a/include/linux/completion.h b/include/linux/completion.h index 4a6b604ef7e..258bec13d42 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h @@ -88,6 +88,7 @@ extern bool completion_done(struct completion *x); extern void complete(struct completion *); extern void complete_all(struct completion *); +extern void complete_n(struct completion *, int n); /** * INIT_COMPLETION: - reinitialize a completion structure -- cgit v1.2.2 From 4e593e7105dec02e62ea7a1812dccb35a0d56d01 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:30:47 -0500 Subject: [ported from 2008.3] Add support for quantum alignment --- include/linux/tick.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/linux') diff --git a/include/linux/tick.h b/include/linux/tick.h index 0482229c07d..4f9ba058abd 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -71,6 +71,11 @@ extern int tick_is_oneshot_available(void); extern struct tick_device *tick_get_device(int cpu); # ifdef CONFIG_HIGH_RES_TIMERS +/* LITMUS^RT tick alignment */ +#define LINUX_DEFAULT_TICKS 0 +#define LITMUS_ALIGNED_TICKS 1 +#define LITMUS_STAGGERED_TICKS 2 + extern int tick_init_highres(void); extern int tick_program_event(ktime_t expires, int force); extern void tick_setup_sched_timer(void); -- cgit v1.2.2 From fa3c94fc9cd1619fe0dd6081a1a980c09ef3e119 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:33:26 -0500 Subject: [ported from 2008.3] Add File Descriptor Attached Shared Objects (FDSO) infrastructure --- include/linux/fs.h | 21 ++++++++++++--------- include/linux/sched.h | 10 +++++++--- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs.h b/include/linux/fs.h index 2620a8c6357..5c7e0ff370b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -15,8 +15,8 @@ * nr_file rlimit, so it's safe to set up a ridiculously high absolute * upper limit on files-per-process. * - * Some programs (notably those using select()) may have to be - * recompiled to take full advantage of the new limits.. + * Some programs (notably those using select()) may have to be + * recompiled to take full advantage of the new limits.. */ /* Fixed constants first: */ @@ -169,7 +169,7 @@ struct inodes_stat_t { #define SEL_EX 4 /* public flags for file_system_type */ -#define FS_REQUIRES_DEV 1 +#define FS_REQUIRES_DEV 1 #define FS_BINARY_MOUNTDATA 2 #define FS_HAS_SUBTYPE 4 #define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */ @@ -466,7 +466,7 @@ struct iattr { */ #include -/** +/** * enum positive_aop_returns - aop return codes with specific semantics * * @AOP_WRITEPAGE_ACTIVATE: Informs the caller that page writeback has @@ -476,7 +476,7 @@ struct iattr { * be a candidate for writeback again in the near * future. Other callers must be careful to unlock * the page if they get this return. Returned by - * writepage(); + * writepage(); * * @AOP_TRUNCATED_PAGE: The AOP method that was handed a locked page has * unlocked it and the page might have been truncated. @@ -715,6 +715,7 @@ static inline int mapping_writably_mapped(struct address_space *mapping) struct posix_acl; #define ACL_NOT_CACHED ((void *)(-1)) +struct inode_obj_id_table; struct inode { struct hlist_node i_hash; @@ -783,6 +784,8 @@ struct inode { struct posix_acl *i_acl; struct posix_acl *i_default_acl; #endif + struct list_head i_obj_list; + struct mutex i_obj_mutex; void *i_private; /* fs or device private pointer */ }; @@ -995,10 +998,10 @@ static inline int file_check_writeable(struct file *filp) #define MAX_NON_LFS ((1UL<<31) - 1) -/* Page cache limit. The filesystems should put that into their s_maxbytes - limits, otherwise bad things can happen in VM. */ +/* Page cache limit. The filesystems should put that into their s_maxbytes + limits, otherwise bad things can happen in VM. */ #if BITS_PER_LONG==32 -#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) +#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) #elif BITS_PER_LONG==64 #define MAX_LFS_FILESIZE 0x7fffffffffffffffUL #endif @@ -2139,7 +2142,7 @@ extern int may_open(struct path *, int, int); extern int kernel_read(struct file *, loff_t, char *, unsigned long); extern struct file * open_exec(const char *); - + /* fs/dcache.c -- generic fs support functions */ extern int is_subdir(struct dentry *, struct dentry *); extern ino_t find_inode_number(struct dentry *, struct qstr *); diff --git a/include/linux/sched.h b/include/linux/sched.h index bb046c0adf9..724814191fe 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1214,6 +1214,7 @@ struct sched_rt_entity { }; struct rcu_node; +struct od_table_entry; struct task_struct { volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ @@ -1296,9 +1297,9 @@ struct task_struct { unsigned long stack_canary; #endif - /* + /* * pointers to (original) parent process, youngest child, younger sibling, - * older sibling, respectively. (p->father can be replaced with + * older sibling, respectively. (p->father can be replaced with * p->real_parent->pid) */ struct task_struct *real_parent; /* real parent process */ @@ -1512,6 +1513,9 @@ struct task_struct { /* LITMUS RT parameters and state */ struct rt_param rt_param; + /* references to PI semaphores, etc. */ + struct od_table_entry *od_table; + #ifdef CONFIG_LATENCYTOP int latency_record_count; struct latency_record latency_record[LT_SAVECOUNT]; @@ -2051,7 +2055,7 @@ static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, s spin_unlock_irqrestore(&tsk->sighand->siglock, flags); return ret; -} +} extern void block_all_signals(int (*notifier)(void *priv), void *priv, sigset_t *mask); -- 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 --- include/linux/smp.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/linux') diff --git a/include/linux/smp.h b/include/linux/smp.h index 39c64bae776..76bb3e45351 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -76,6 +76,11 @@ void smp_call_function_many(const struct cpumask *mask, void __smp_call_function_single(int cpuid, struct call_single_data *data, int wait); +/* + * sends a 'pull timer' event to a remote CPU + */ +extern void smp_send_pull_timers(int cpu); + /* * Generic and arch helpers */ -- 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 --- include/linux/hrtimer.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include/linux') diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index ff037f0b1b4..b984b947f5d 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -166,6 +166,7 @@ struct hrtimer_clock_base { * event devices whether high resolution mode can be * activated. * @nr_events: Total number of timer interrupt events + * @to_pull: LITMUS^RT list of timers to be pulled on this cpu */ struct hrtimer_cpu_base { spinlock_t lock; @@ -175,6 +176,26 @@ struct hrtimer_cpu_base { int hres_active; unsigned long nr_events; #endif + struct list_head to_pull; +}; + +#define HRTIMER_START_ON_INACTIVE 0 +#define HRTIMER_START_ON_QUEUED 1 + +/* + * struct hrtimer_start_on_info - save timer info on remote cpu + * @list: list of hrtimer_start_on_info on remote cpu (to_pull) + * @timer: timer to be triggered on remote cpu + * @time: time event + * @mode: timer mode + * @state: activity flag + */ +struct hrtimer_start_on_info { + struct list_head list; + struct hrtimer *timer; + ktime_t time; + enum hrtimer_mode mode; + atomic_t state; }; static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) @@ -343,6 +364,10 @@ __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, unsigned long delta_ns, const enum hrtimer_mode mode, int wakeup); +extern int hrtimer_start_on(int cpu, struct hrtimer_start_on_info *info, + struct hrtimer *timer, ktime_t time, + const enum hrtimer_mode mode); + extern int hrtimer_cancel(struct hrtimer *timer); extern int hrtimer_try_to_cancel(struct hrtimer *timer); -- 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. --- include/linux/hrtimer.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/linux') diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index b34823755ee..370096d132d 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -184,6 +184,8 @@ struct hrtimer_cpu_base { struct list_head to_pull; }; +#ifdef CONFIG_ARCH_HAS_SEND_PULL_TIMERS + #define HRTIMER_START_ON_INACTIVE 0 #define HRTIMER_START_ON_QUEUED 1 @@ -203,6 +205,8 @@ struct hrtimer_start_on_info { atomic_t state; }; +#endif + static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) { timer->_expires = time; @@ -369,9 +373,11 @@ __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, unsigned long delta_ns, const enum hrtimer_mode mode, int wakeup); +#ifdef CONFIG_ARCH_HAS_SEND_PULL_TIMERS extern int hrtimer_start_on(int cpu, struct hrtimer_start_on_info *info, struct hrtimer *timer, ktime_t time, const enum hrtimer_mode mode); +#endif extern int hrtimer_cancel(struct hrtimer *timer); extern int hrtimer_try_to_cancel(struct hrtimer *timer); -- cgit v1.2.2 From bd6d5f1dd586a27c2082ad4d95ee58913b471f5c Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Tue, 28 Sep 2010 11:08:17 -0400 Subject: hrtimer: add init function to properly set hrtimer_start_on_info params This helper function is also useful to remind us that if we use hrtimer_pull outside the scope of triggering remote releases, we need to take care of properly set the "state" field of hrtimer_start_on_info structure. --- include/linux/hrtimer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux') diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 370096d132d..9470a9e4a8f 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -374,6 +374,7 @@ __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode, int wakeup); #ifdef CONFIG_ARCH_HAS_SEND_PULL_TIMERS +extern void hrtimer_start_on_info_init(struct hrtimer_start_on_info *info); extern int hrtimer_start_on(int cpu, struct hrtimer_start_on_info *info, struct hrtimer *timer, ktime_t time, const enum hrtimer_mode mode); -- cgit v1.2.2 From fb3df2ec261d8cd6bcb8206d9d985355214d7767 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 10 Nov 2010 12:10:49 -0500 Subject: Implement proper remote preemption support To date, Litmus has just hooked into the smp_send_reschedule() IPI handler and marked tasks as having to reschedule to implement remote preemptions. This was never particularly clean, but so far we got away with it. However, changes in the underlying Linux, and peculartities of the ARM code (interrupts enabled before context switch) break this naive approach. This patch introduces new state-machine based remote preemption support. By examining the local state before calling set_tsk_need_resched(), we avoid confusing the underlying Linux scheduler. Further, this patch avoids sending unncessary IPIs. --- include/linux/sched.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/linux') diff --git a/include/linux/sched.h b/include/linux/sched.h index 708523b0692..c9ac4fc837b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -96,6 +96,7 @@ struct sched_param { #include #include +#include struct exec_domain; struct futex_pi_state; @@ -2301,6 +2302,7 @@ static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag) static inline void set_tsk_need_resched(struct task_struct *tsk) { set_tsk_thread_flag(tsk,TIF_NEED_RESCHED); + sched_state_will_schedule(tsk); } static inline void clear_tsk_need_resched(struct task_struct *tsk) -- cgit v1.2.2 From 83b11ea1c6ad113519c488853cf06e626c95a64d Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Tue, 24 Jan 2012 09:36:12 +0100 Subject: Feather-Trace: keep track of interrupt-related interference. Increment a processor-local counter whenever an interrupt is handled. This allows Feather-Trace to include a (truncated) counter and a flag to report interference from interrupts. This could be used to filter samples that were disturbed by interrupts. --- include/linux/hardirq.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux') diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h index ba362171e8a..e6dd5a456ba 100644 --- a/include/linux/hardirq.h +++ b/include/linux/hardirq.h @@ -6,6 +6,8 @@ #include #include +#include + /* * We put the hardirq and softirq counter into the preemption * counter. The bitmask has the following meaning: @@ -186,6 +188,7 @@ extern void rcu_nmi_exit(void); account_system_vtime(current); \ add_preempt_count(HARDIRQ_OFFSET); \ trace_hardirq_enter(); \ + ft_irq_fired(); \ } while (0) /* @@ -216,6 +219,7 @@ extern void irq_exit(void); lockdep_off(); \ rcu_nmi_enter(); \ trace_hardirq_enter(); \ + ft_irq_fired(); \ } while (0) #define nmi_exit() \ -- cgit v1.2.2 From d245619060965c2f379fadf6103e7b69a2d1e951 Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Fri, 7 Sep 2012 14:28:59 +0200 Subject: Remove complete_n() API The LITMUS^RT-specific completion API complete_n() is no longer required by the synchronous release code. Let's remove it; one less modification of a core Linux file to maintain during rebasing. --- include/linux/completion.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/completion.h b/include/linux/completion.h index 9d727271c9f..51494e6b554 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h @@ -90,7 +90,6 @@ extern bool completion_done(struct completion *x); extern void complete(struct completion *); extern void complete_all(struct completion *); -extern void complete_n(struct completion *, int n); /** * INIT_COMPLETION - reinitialize a completion structure -- cgit v1.2.2 From 44123a1a3076503bef7666ffc3fdcb3f8e68e8da Mon Sep 17 00:00:00 2001 From: Bryan Ward Date: Sun, 12 Aug 2012 16:35:36 -0400 Subject: DGLock and DGUnlock implementation. These methods haven't been fully tested, but they compile and pass a few simple tests. --- include/linux/sched.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/linux') diff --git a/include/linux/sched.h b/include/linux/sched.h index 9c990d13ae3..2b094bdaafa 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -96,6 +96,7 @@ struct sched_param { #include #include +#include struct exec_domain; struct futex_pi_state; @@ -1538,6 +1539,8 @@ struct task_struct { /* references to PI semaphores, etc. */ struct od_table_entry *od_table; + resource_mask_t resources; + #ifdef CONFIG_LATENCYTOP int latency_record_count; struct latency_record latency_record[LT_SAVECOUNT]; -- cgit v1.2.2