Module: xenomai-forge Branch: master Commit: 604012b4baf6dc8934639614fca0bf82b36a4950 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=604012b4baf6dc8934639614fca0bf82b36a4950
Author: Philippe Gerum <[email protected]> Date: Sun Jan 1 20:31:57 2012 +0100 cobalt: drop redundant APC services --- include/cobalt/nucleus/shadow.h | 9 ++++ kernel/cobalt/Makefile | 1 - kernel/cobalt/apc.c | 83 --------------------------------------- kernel/cobalt/apc.h | 13 ------ kernel/cobalt/module.c | 8 ---- kernel/cobalt/mq.c | 3 +- kernel/cobalt/nucleus/shadow.c | 55 ++++++++++++------------- 7 files changed, 36 insertions(+), 136 deletions(-) diff --git a/include/cobalt/nucleus/shadow.h b/include/cobalt/nucleus/shadow.h index 1cf2f95..cd687ee 100644 --- a/include/cobalt/nucleus/shadow.h +++ b/include/cobalt/nucleus/shadow.h @@ -29,6 +29,13 @@ #define XNSHADOW_CLIENT_ATTACH 0 #define XNSHADOW_CLIENT_DETACH 1 +#define LO_START_REQ 0 +#define LO_WAKEUP_REQ 1 +#define LO_SIGGRP_REQ 2 +#define LO_SIGTHR_REQ 3 +#define LO_UNMAP_REQ 4 +#define LO_FREEMEM_REQ 5 + struct xnthread; struct xnmutex; struct pt_regs; @@ -115,4 +122,6 @@ void xnshadow_kick(struct xnthread *thread); void xnshadow_demote(struct xnthread *thread); +void xnshadow_post_linux(int type, void *ptr, size_t val); + #endif /* !_XENO_NUCLEUS_SHADOW_H */ diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile index d54803c..729bbe3 100644 --- a/kernel/cobalt/Makefile +++ b/kernel/cobalt/Makefile @@ -12,7 +12,6 @@ xeno_cobalt-y := \ registry.o \ mq.o \ module.o \ - apc.o \ syscall.o \ monitor.o diff --git a/kernel/cobalt/apc.c b/kernel/cobalt/apc.c deleted file mode 100644 index fc9121f..0000000 --- a/kernel/cobalt/apc.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the Xenomai project. - * - * Copyright (C) 2008 Gilles Chanteperdrix <[email protected]> - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "thread.h" -#include "apc.h" - -#define COBALT_LO_MAX_REQUESTS 64 /* Must be a ^2 */ - -static int cobalt_lostage_apc; - -static struct cobalt_lostageq_t { - int in, out; - struct cobalt_lostage_req_t { - int type; - void *arg; - size_t size; - } req[COBALT_LO_MAX_REQUESTS]; -} cobalt_lostageq[XNARCH_NR_CPUS]; - -void cobalt_schedule_lostage(int request, void *arg, size_t size) -{ - int cpuid = ipipe_processor_id(), reqnum; - struct cobalt_lostageq_t *rq = &cobalt_lostageq[cpuid]; - spl_t s; - - /* Signal the APC, to have it delegate signals to Linux. */ - splhigh(s); - reqnum = rq->in; - rq->req[reqnum].type = request; - rq->req[reqnum].arg = arg; - rq->req[reqnum].size = size; - rq->in = (reqnum + 1) & (COBALT_LO_MAX_REQUESTS - 1); - __rthal_apc_schedule(cobalt_lostage_apc); - splexit(s); -} - -static void cobalt_lostage_handle_request(void *cookie) -{ - int cpuid = smp_processor_id(), reqnum; - struct cobalt_lostageq_t *rq = &cobalt_lostageq[cpuid]; - - while ((reqnum = rq->out) != rq->in) { - struct cobalt_lostage_req_t *req = &rq->req[reqnum]; - - rq->out = (reqnum + 1) & (COBALT_LO_MAX_REQUESTS - 1); - - if (req->type == COBALT_LO_FREE_REQ) - xnarch_free_pages(req->arg, req->size); - } -} - -int cobalt_apc_pkg_init(void) -{ - cobalt_lostage_apc = rthal_apc_alloc("cobalt_lostage_handler", - &cobalt_lostage_handle_request, NULL); - - if (cobalt_lostage_apc < 0) - printk("Unable to allocate APC: %d !\n", cobalt_lostage_apc); - - return cobalt_lostage_apc < 0; -} - -void cobalt_apc_pkg_cleanup(void) -{ - rthal_apc_free(cobalt_lostage_apc); -} diff --git a/kernel/cobalt/apc.h b/kernel/cobalt/apc.h deleted file mode 100644 index c4c3a30..0000000 --- a/kernel/cobalt/apc.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef APC_H -#define APC_H - -#define COBALT_LO_SIGNAL_REQ 0 -#define COBALT_LO_FREE_REQ 1 - -void cobalt_schedule_lostage(int request, void *arg, size_t size); - -int cobalt_apc_pkg_init(void); - -void cobalt_apc_pkg_cleanup(void); - -#endif /* APC_H */ diff --git a/kernel/cobalt/module.c b/kernel/cobalt/module.c index 12f8025..9e1a74d 100644 --- a/kernel/cobalt/module.c +++ b/kernel/cobalt/module.c @@ -46,7 +46,6 @@ */ #include <cobalt/syscall.h> -#include "apc.h" #include <cobalt/posix.h> #include "internal.h" #include "cond.h" @@ -73,7 +72,6 @@ static void cobalt_shutdown(int xtype) cobalt_mutex_pkg_cleanup(); cobalt_reg_pkg_cleanup(); cobalt_syscall_cleanup(); - cobalt_apc_pkg_cleanup(); xnpod_shutdown(xtype); } @@ -87,14 +85,8 @@ int SKIN_INIT(posix) if (ret) goto fail; - ret = cobalt_apc_pkg_init(); - if (ret) - goto fail_shutdown_pod; - ret = cobalt_syscall_init(); if (ret) { - cobalt_apc_pkg_cleanup(); - fail_shutdown_pod: xnpod_shutdown(ret); fail: xnlogerr("POSIX skin init failed, code %d.\n", ret); diff --git a/kernel/cobalt/mq.c b/kernel/cobalt/mq.c index bfd5646..9b35d97 100644 --- a/kernel/cobalt/mq.c +++ b/kernel/cobalt/mq.c @@ -34,7 +34,6 @@ #include "registry.h" #include "internal.h" /* Magics, time conversion */ #include "thread.h" /* errno. */ -#include "apc.h" #include "mq.h" /* Temporary definitions. */ @@ -152,7 +151,7 @@ static inline void cobalt_mq_destroy(cobalt_mq_t *mq) xnselect_destroy(&mq->read_select); xnselect_destroy(&mq->write_select); if (!xnpod_root_p()) - cobalt_schedule_lostage(COBALT_LO_FREE_REQ, mq->mem, mq->memsize); + xnshadow_post_linux(LO_FREEMEM_REQ, mq->mem, mq->memsize); else xnarch_free_pages(mq->mem, mq->memsize); diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c index ec6dc4d..e25b336 100644 --- a/kernel/cobalt/nucleus/shadow.c +++ b/kernel/cobalt/nucleus/shadow.c @@ -74,21 +74,13 @@ struct xnskin_slot { static int lostage_apc; static struct __lostagerq { - int in, out; - struct { -#define LO_START_REQ 0 -#define LO_WAKEUP_REQ 1 -#define LO_SIGGRP_REQ 2 -#define LO_SIGTHR_REQ 3 -#define LO_UNMAP_REQ 4 int type; - struct task_struct *task; - int arg; + void *ptr; + size_t val; #define LO_MAX_REQUESTS 64 /* Must be a ^2 */ } req[LO_MAX_REQUESTS]; - } lostagerq[XNARCH_NR_CPUS]; #define xnshadow_sig_mux(sig, arg) ((sig) | ((arg) << 8)) @@ -315,17 +307,17 @@ static inline void unlock_timers(void) static void lostage_handler(void *cookie) { - int cpu, reqnum, type, arg, sig, sigarg; + int cpu, reqnum, type, sig, sigarg; struct __lostagerq *rq; struct task_struct *p; + size_t val; cpu = smp_processor_id(); rq = &lostagerq[cpu]; while ((reqnum = rq->out) != rq->in) { type = rq->req[reqnum].type; - p = rq->req[reqnum].task; - arg = rq->req[reqnum].arg; + val = rq->req[reqnum].val; /* make sure we read the request before releasing its slot */ barrier(); @@ -343,11 +335,12 @@ static void lostage_handler(void *cookie) xnpod_schedule(); /* fall through */ case LO_START_REQ: + p = rq->req[reqnum].ptr; wake_up_process(p); break; - case LO_SIGTHR_REQ: - xnshadow_sig_demux(arg, sig, sigarg); + p = rq->req[reqnum].ptr; + xnshadow_sig_demux(val, sig, sigarg); if (sig == SIGSHADOW || sig == SIGDEBUG) { siginfo_t si; memset(&si, '\0', sizeof(si)); @@ -358,28 +351,32 @@ static void lostage_handler(void *cookie) } else send_sig(sig, p, 1); break; - case LO_SIGGRP_REQ: - kill_proc_info(arg, SEND_SIG_PRIV, p->pid); + p = rq->req[reqnum].ptr; + kill_proc_info(val, SEND_SIG_PRIV, p->pid); + break; + case LO_FREEMEM_REQ: + xnarch_free_pages(rq->req[reqnum].ptr, val); break; } } } -static void schedule_linux_call(int type, struct task_struct *p, int arg) +void xnshadow_post_linux(int type, void *ptr, size_t val) { - int cpu = ipipe_processor_id(), reqnum; struct __lostagerq *rq; + int cpu, reqnum; spl_t s; - XENO_ASSERT(NUCLEUS, p, - xnpod_fatal("schedule_linux_call() invoked " - "with NULL task pointer (req=%d, arg=%d)?!", type, - arg); + XENO_ASSERT(NUCLEUS, ptr, + xnpod_fatal("%s() invoked " + "with NULL arg pointer (req=%d, arg=%Zu)?!", + __FUNCTION__, type, val); ); splhigh(s); + cpu = ipipe_processor_id(); rq = &lostagerq[cpu]; reqnum = rq->in; rq->in = (reqnum + 1) & (LO_MAX_REQUESTS - 1); @@ -387,8 +384,8 @@ static void schedule_linux_call(int type, struct task_struct *p, int arg) xnpod_fatal("lostage queue overflow on CPU %d! " "Increase LO_MAX_REQUESTS", cpu); rq->req[reqnum].type = type; - rq->req[reqnum].task = p; - rq->req[reqnum].arg = arg; + rq->req[reqnum].ptr = ptr; + rq->req[reqnum].val = val; __rthal_apc_schedule(lostage_apc); @@ -673,7 +670,7 @@ void xnshadow_relax(int notify, int reason) * xnpod_suspend_thread() has an interrupts-on section built in. */ splmax(); - schedule_linux_call(LO_WAKEUP_REQ, p, 0); + xnshadow_post_linux(LO_WAKEUP_REQ, p, 0); /* * Task nklock to synchronize the Linux task state manipulation with @@ -1077,7 +1074,7 @@ void xnshadow_unmap(xnthread_t *thread) destroy_threadinfo(); - schedule_linux_call(LO_UNMAP_REQ, p, xnthread_get_magic(thread)); + xnshadow_post_linux(LO_UNMAP_REQ, p, xnthread_get_magic(thread)); } EXPORT_SYMBOL_GPL(xnshadow_unmap); @@ -1091,7 +1088,7 @@ void xnshadow_start(struct xnthread *thread) if (p->state == TASK_INTERRUPTIBLE) /* Wakeup the Linux mate waiting on the barrier. */ - schedule_linux_call(LO_START_REQ, p, 0); + xnshadow_post_linux(LO_START_REQ, p, 0); } EXPORT_SYMBOL_GPL(xnshadow_start); @@ -1864,7 +1861,7 @@ substitute_linux_syscall(struct pt_regs *regs) void xnshadow_send_sig(xnthread_t *thread, int sig, int arg, int specific) { - schedule_linux_call(specific ? LO_SIGTHR_REQ : LO_SIGGRP_REQ, + xnshadow_post_linux(specific ? LO_SIGTHR_REQ : LO_SIGGRP_REQ, xnthread_user_task(thread), xnshadow_sig_mux(sig, specific ? arg : 0)); } _______________________________________________ Xenomai-git mailing list [email protected] https://mail.gna.org/listinfo/xenomai-git
