cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler
PATCH 1/1 cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler
create and register RESCHEDULE_OOB_IPI interrupt handler
kernel/cobalt/sched.c +33 -1
@@ -30,6 +30,13 @@#define CREATE_TRACE_POINTS #include <trace/events/cobalt-core.h> +struct xn_machine_cpudata { +}; + +DEFINE_PER_CPU(struct xn_machine_cpudata, xn_machine_cpudata); + +static void xnsched_destroy (struct xnsched *sched); +/** * @ingroup cobalt_core * @defgroup cobalt_core_sched Thread scheduling control
@@ -224,10 +231,18 @@ static void xnsched_init(struct xnsched *sched, int cpu)#endif /* CONFIG_XENO_OPT_WATCHDOG */ } +static irqreturn_t reschedule_interrupt (int irq,void *dev_id) +{ +__xnsched_run_handler (); + +return IRQ_HANDLED ; +} +void xnsched_init_all (void ) {struct xnsched *sched;int cpu; +int ret;for_each_online_cpu (cpu) { sched = &per_cpu (nksched, cpu);
@@ -235,12 +250,28 @@ void xnsched_init_all(void) }#ifdef CONFIG_SMP -#warning TODO/* ipipe_request_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI, (ipipe_irq_handler_t)__xnsched_run_handler, NULL, NULL);*/ + ret =__request_percpu_irq (RESCHEDULE_OOB_IPI , + reschedule_interrupt, +IRQF_OOB , +"Xenomai reschedule" , + &xn_machine_cpudata); +if (ret) + goto cleanup_sched;#endif +return ; + +cleanup_sched: +for_each_online_cpu (cpu) { + sched =xnsched_struct (cpu); +xnsched_destroy (sched); + } + +return ; + }static void xnsched_destroy (struct xnsched *sched)
@@ -264,6 +295,7 @@ void xnsched_destroy_all(void)#ifdef CONFIG_SMP #warning TODO// ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI); +free_percpu_irq (RESCHEDULE_OOB_IPI , &xn_machine_cpudata);#endif xnlock_get_irqsave (&nklock, s);
Signature · 1 line
2.17.1
Quoted 54 lines · On 15.10.20 07:02, hongzha1 wrote:
create and register
RESCHEDULE_OOB_IPIinterrupt handlerSigned-off-by hongzha1 <[email protected]>kernel/cobalt/sched.c +19
-1@@ -30,6 +30,13 @@#define CREATE_TRACE_POINTS #include <trace/events/cobalt-core.h> +struct xn_machine_cpudata { +}; + +DEFINE_PER_CPU(struct xn_machine_cpudata, xn_machine_cpudata); + +static void xnsched_destroy (struct xnsched *sched); +/** * @ingroup cobalt_core * @defgroup cobalt_core_sched Thread scheduling control @@ -224,10 +231,18 @@ static void xnsched_init(struct xnsched *sched, int cpu)#endif /* CONFIG_XENO_OPT_WATCHDOG */ } +static irqreturn_t reschedule_interrupt (int irq,void *dev_id) +{ +__xnsched_run_handler (); + +return IRQ_HANDLED ; +} +void xnsched_init_all (void ) {struct xnsched *sched;int cpu; +int ret;for_each_online_cpu (cpu) { sched = &per_cpu (nksched, cpu);@@ -235,12 +250,28 @@ void xnsched_init_all(void) }#ifdef CONFIG_SMP -#warning TODO/* ipipe_request_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI, (ipipe_irq_handler_t)__xnsched_run_handler, NULL, NULL);*/ + ret = __request_percpu_irq(RESCHEDULE_OOB_IPI, + reschedule_interrupt, + IRQF_OOB, + "Xenomai reschedule",
kernel/cobalt/sched.c void xnsched_init_all(void) · line 270
Quoted 10 lines
kernel/cobalt/sched.c +9
-0+ &xn_machine_cpudata); +if (ret) + goto cleanup_sched;#endif +return ; + +cleanup_sched: +for_each_online_cpu (cpu) { + sched =xnsched_struct (cpu); +xnsched_destroy (sched);
That will run for all cpus, also for those possibly not yet initialized at this stage. Did you check if that is ok?
kernel/cobalt/sched.c void xnsched_init_all(void) · line 273
Quoted 3 lines
kernel/cobalt/sched.c +3
-0+ } + +return ;
Unneeded "return" statement.
kernel/cobalt/sched.c void xnsched_destroy_all(void) · line 301
Quoted 13 lines
kernel/cobalt/sched.c +2
-0+ }static void xnsched_destroy (struct xnsched *sched)@@ -264,6 +295,7 @@ void xnsched_destroy_all(void)#ifdef CONFIG_SMP #warning TODO// ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI); +free_percpu_irq (RESCHEDULE_OOB_IPI , &xn_machine_cpudata);#endif xnlock_get_irqsave (&nklock, s);
Looks good otherwise. Another step forward.
Thanks,
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 41 lines
Quoted 41 lines
create and register
RESCHEDULE_OOB_IPIinterrupt handlerSigned-off-by hongzha1 <[email protected]>kernel/cobalt/sched.c +15
-0@@ -30,6 +30,13 @@#define CREATE_TRACE_POINTS #include <trace/events/cobalt-core.h> +struct xn_machine_cpudata { +}; + +DEFINE_PER_CPU(struct xn_machine_cpudata, xn_machine_cpudata); + +static void xnsched_destroy (struct xnsched *sched); +/** * @ingroup cobalt_core * @defgroup cobalt_core_sched Thread scheduling control @@ -224,10 +231,18 @@ static void xnsched_init(struct xnsched *sched, int cpu)#endif /* CONFIG_XENO_OPT_WATCHDOG */ } +static irqreturn_t reschedule_interrupt (int irq,void *dev_id) +{ +__xnsched_run_handler (); + +return IRQ_HANDLED ; +} +void xnsched_init_all (void ) {struct xnsched *sched;int cpu; +int ret;
Quoted 2 lines
kernel/cobalt/sched.c static void xnsched_init(struct xnsched *sched, int cpu) · line 248
Quoted 2 lines
kernel/cobalt/sched.c +0
-0for_each_online_cpu (cpu) { sched = &per_cpu (nksched, cpu);
Step 1: these code is to do initialization.
Quoted 18 lines
Quoted 18 lines
kernel/cobalt/sched.c +8
-1@@ -235,12 +250,28 @@ void xnsched_init_all(void) }#ifdef CONFIG_SMP -#warning TODO/* ipipe_request_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI, (ipipe_irq_handler_t)__xnsched_run_handler, NULL, NULL);*/ + ret =__request_percpu_irq (RESCHEDULE_OOB_IPI , + reschedule_interrupt, +IRQF_OOB , +"Xenomai reschedule" , + &xn_machine_cpudata); +if (ret) + goto cleanup_sched;#endif +return ;
Quoted 9 lines
kernel/cobalt/sched.c void xnsched_init_all(void) · line 270
Quoted 5 lines
kernel/cobalt/sched.c +5
-0+ +cleanup_sched: +for_each_online_cpu (cpu) { + sched =xnsched_struct (cpu); +xnsched_destroy (sched);TThat will run for all cpus, also for those possibly not yet initialized aat this stage. Did you check if that is ok?
Hi Yan,
Thanks for your comments. Yes , it was already initialized from the start of current function, please check code where I comment at step 1 in original code. cleanup_sched is to recall the initialization if fail to request irq before return current function.
Quoted 17 lines
Quoted 3 lines
kernel/cobalt/sched.c +0
-0> + }Review
Quoted 2 lines
(quoted diff) +2
-0+ + return;UUnneeded "return" statement.
Quoted 11 lines
Quoted 11 lines
kernel/cobalt/sched.c +2
-0+ }static void xnsched_destroy (struct xnsched *sched)@@ -264,6 +295,7 @@ void xnsched_destroy_all(void)#ifdef CONFIG_SMP #warning TODO// ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI); +free_percpu_irq (RESCHEDULE_OOB_IPI , &xn_machine_cpudata);#endif
Quoted 11 lines
Quoted 2 lines
kernel/cobalt/sched.c void xnsched_destroy_all(void) · line 301
Quoted 2 lines
kernel/cobalt/sched.c +0
-0xnlock_get_irqsave (&nklock, s);Looks good otherwise. Another step forward.
Thanks,
JanSignature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Regards
Hongzhan Chen