syslets: core code
PATCH 5/14 syslets: core code
From: Ingo Molnar <[email protected]>
the core syslet / async system calls infrastructure code.
Is built only if CONFIG_ASYNC_SUPPORT is enabled.
--- kernel/Makefile | 1 kernel/async.c | 897 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 898 insertions(+)
kernel/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-y = sched.o fork.o exec_domain.o kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o latency.o nsproxy.o srcu.o +obj-$(CONFIG_ASYNC_SUPPORT) += async.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += time/ obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
kernel/async.c new file +897 -0
897 lines not on this page · raw message
kernel/async.c line 65
Quoted 13 lines
(quoted diff) +2
-0+static void +__mark_async_thread_ready(struct async_thread *at, struct
async_head*ah)kernel/async.c new file +4
-0+{ +list_del (&at->entry); +list_add_tail (&at->entry, &ah->ready_async_threads); +__mark_async_thread_busy(struct async_thread *at, struct
async_head*ah)kernel/async.c new file +3
-0+{ +list_del (&at->entry); +list_add_tail (&at->entry, &ah->busy_async_threads);
list_move_tail()?
- z
kernel/async.c line 418
Quoted 9 lines · Ingo Molnar
From: Ingo Molnar <[email protected]>
kernel/async.c new file +8
-0+static struct syslet_uatom __user * +exec_atom (struct async_head *ah,struct task_struct *t, +struct syslet_uatom __user *uatom) +{ +struct syslet_uatom __user *last_uatom; +struct syslet_atom atom; +long ret; +
- run_next:
+ do {
kernel/async.c line 425
Quoted 6 lines
kernel/async.c new file +6
-0+if (unlikely (copy_uatom (&atom, uatom))) +return ERR_PTR (-EFAULT ); + + last_uatom = uatom; + ret =__exec_atom (t, &atom); +if (unlikely (signal_pending (t) ||need_resched ()))
+ break;
- goto stop;
kernel/async.c line 428
Quoted 2 lines
kernel/async.c new file +2
-0+ + uatom =next_uatom (&atom, uatom, ret);
+ } while(uatom);
- if (uatom)
- goto run_next;
- stop:
kernel/async.c line 439
Quoted 8 lines
kernel/async.c new file +8
-0+/* +* We do completion only in async context: +*/ +if (t->at &&complete_uatom (ah, t, &atom, last_uatom)) +return ERR_PTR (-EFAULT ); + +return last_uatom; +}
Goto's are cool granted :), but IMO the "do {} while()" is more natural here.
kernel/async.c line 707
Quoted 9 lines
kernel/async.c new file +9
-0+asmlinkage long +sys_async_register (struct async_head_user __user *ahu,unsigned int len) +{ +struct task_struct *t = current; + +/* +* This 'len' check enables future extension of +* the async_head ABI: +*/
I'm not sure I understand why this isn't a '>' check. If you want to extend the ABI, you'll add members to async_head_user. So you just need to check that you understand all the information that userspace passes to you, or did I missed something?
kernel/async.c line 718
Quoted 11 lines
kernel/async.c new file +11
-0+if (len !=sizeof (struct async_head_user )) +return -EINVAL ; +/* +* Already registered? +*/ +if (t->ah) +return -EEXIST ; + +return async_head_init (t, ahu); +} +
Regards,
Frederik
kernel/async.c line 150
Quoted 13 lines · Ingo Molnar
kernel/async.c new file +13
-0+spin_lock (&ah->lock); + + new_async_thread =pick_ready_cachemiss_thread (ah); +if (!new_async_thread) + goto out_unlock; + + async_ready = t->async_ready; +WARN_ON (!async_ready); + t->async_ready =NULL ; + + new_task = new_async_thread->task; + +move_user_context (new_task, t);
Since I lost the email where you were describing the todo list, I'll hook into this one.
I haven't seen you mentioning it, but at least TID and signal handling need to be swapped to. So it'd be better to have a generic move_user_context() that does system independent work, and an arch_move_user_context() that takes care of system dependent stuff (that is called by move_user_context()).
- Davide