Commit 0ef01f36 authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/home/acme/BK/llc-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents ad2bce43 a5d2bf7b
......@@ -608,16 +608,17 @@ static inline void free_vm86_irq(int irqnumber)
static inline int task_valid(struct task_struct *tsk)
{
struct task_struct *p;
struct task_struct *g, *p;
int ret = 0;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p)
if ((p == tsk) && (p->sig)) {
ret = 1;
break;
}
goto out;
}
while_each_thread(g, p);
out:
read_unlock(&tasklist_lock);
return ret;
}
......
......@@ -299,7 +299,7 @@ static void send_sig_all(int sig)
{
struct task_struct *p;
for_each_task(p) {
for_each_process(p) {
if (p->mm && p->pid != 1)
/* Not swapper, init nor kernel thread */
force_sig(sig, p);
......
......@@ -496,7 +496,7 @@ void do_tty_hangup(void *data)
}
read_lock(&tasklist_lock);
for_each_task(p) {
for_each_process(p) {
if ((tty->session > 0) && (p->session == tty->session) &&
p->leader) {
send_sig(SIGHUP,p,1);
......@@ -598,7 +598,7 @@ void disassociate_ctty(int on_exit)
tty->pgrp = -1;
read_lock(&tasklist_lock);
for_each_task(p)
for_each_process(p)
if (p->session == current->session)
p->tty = NULL;
read_unlock(&tasklist_lock);
......@@ -1223,7 +1223,7 @@ static void release_dev(struct file * filp)
struct task_struct *p;
read_lock(&tasklist_lock);
for_each_task(p) {
for_each_process(p) {
if (p->tty == tty || (o_tty && p->tty == o_tty))
p->tty = NULL;
}
......@@ -1561,7 +1561,7 @@ static int tiocsctty(struct tty_struct *tty, int arg)
struct task_struct *p;
read_lock(&tasklist_lock);
for_each_task(p)
for_each_process(p)
if (p->tty == tty)
p->tty = NULL;
read_unlock(&tasklist_lock);
......@@ -1834,7 +1834,7 @@ static void __do_SAK(void *arg)
if (tty->driver.flush_buffer)
tty->driver.flush_buffer(tty);
read_lock(&tasklist_lock);
for_each_task(p) {
for_each_process(p) {
if ((p->tty == tty) ||
((session > 0) && (p->session == session))) {
printk(KERN_NOTICE "SAK: killed process %d"
......
......@@ -493,7 +493,7 @@ void send_sigio(struct fown_struct *fown, int fd, int band)
send_sigio_to_task(p, fown, fd, band);
goto out_unlock_task;
}
for_each_task(p) {
for_each_process(p) {
int match = p->pid;
if (pid < 0)
match = -p->pgrp;
......@@ -531,7 +531,7 @@ int send_sigurg(struct fown_struct *fown)
send_sigurg_to_task(p, fown);
goto out_unlock_task;
}
for_each_task(p) {
for_each_process(p) {
int match = p->pid;
if (pid < 0)
match = -p->pgrp;
......
......@@ -1588,7 +1588,7 @@ int fcntl_setlk64(struct file *filp, unsigned int cmd, struct flock64 *l)
for (;;) {
error = posix_lock_file(filp, file_lock);
if ((error != -EAGAIN) || (cmd == F_SETLK))
if ((error != -EAGAIN) || (cmd == F_SETLK64))
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
......
......@@ -883,11 +883,11 @@ asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type,
static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
{
struct task_struct *p;
struct task_struct *g, *p;
struct fs_struct *fs;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
task_lock(p);
fs = p->fs;
if (fs) {
......@@ -900,7 +900,7 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
put_fs_struct(fs);
} else
task_unlock(p);
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
}
......@@ -1012,7 +1012,7 @@ static void __init init_mount_tree(void)
{
struct vfsmount *mnt;
struct namespace *namespace;
struct task_struct *p;
struct task_struct *g, *p;
mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
if (IS_ERR(mnt))
......@@ -1028,10 +1028,10 @@ static void __init init_mount_tree(void)
init_task.namespace = namespace;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
get_namespace(namespace);
p->namespace = namespace;
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root);
......
......@@ -251,7 +251,7 @@ static void check_partition(struct gendisk *hd, struct block_device *bdev)
p[j-1].start_sect = state->parts[j].from;
p[j-1].nr_sects = state->parts[j].size;
#if CONFIG_BLK_DEV_MD
if (!state->parts[j-1].flags)
if (!state->parts[j].flags)
continue;
md_autodetect_dev(bdev->bd_dev+j);
#endif
......
......@@ -1136,7 +1136,7 @@ static int get_pid_list(int index, unsigned int *pids)
index--;
read_lock(&tasklist_lock);
for_each_task(p) {
for_each_process(p) {
int pid = p->pid;
if (!pid)
continue;
......
......@@ -235,7 +235,9 @@ int proc_fill_super(struct super_block *s, void *data, int silent)
* Fixup the root inode's nlink value
*/
read_lock(&tasklist_lock);
for_each_task(p) if (p->pid) root_inode->i_nlink++;
for_each_process(p)
if (p->pid)
root_inode->i_nlink++;
read_unlock(&tasklist_lock);
s->s_root = d_alloc_root(root_inode);
if (!s->s_root)
......
......@@ -761,11 +761,13 @@ static inline void remove_wait_queue_locked(wait_queue_head_t *q,
#define add_parent(p, parent) list_add_tail(&(p)->sibling,&(parent)->children)
#define REMOVE_LINKS(p) do { \
if (thread_group_leader(p)) \
list_del_init(&(p)->tasks); \
remove_parent(p); \
} while (0)
#define SET_LINKS(p) do { \
if (thread_group_leader(p)) \
list_add_tail(&(p)->tasks,&init_task.tasks); \
add_parent(p, (p)->parent); \
} while (0)
......@@ -797,11 +799,18 @@ static inline struct task_struct *younger_sibling(struct task_struct *p)
#define next_task(p) list_entry((p)->tasks.next, struct task_struct, tasks)
#define prev_task(p) list_entry((p)->tasks.prev, struct task_struct, tasks)
#define for_each_task(p) \
#define for_each_process(p) \
for (p = &init_task ; (p = next_task(p)) != &init_task ; )
#define for_each_thread(task) \
for (task = next_thread(current) ; task != current ; task = next_thread(task))
/*
* Careful: do_each_thread/while_each_thread is a double loop so
* 'break' will not work as expected - use goto instead.
*/
#define do_each_thread(g, t) \
for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
#define while_each_thread(g, t) \
while ((t = next_thread(t)) != g)
static inline task_t *next_thread(task_t *p)
{
......
......@@ -83,13 +83,13 @@ static inline void cap_set_pg(int pgrp, kernel_cap_t *effective,
kernel_cap_t *inheritable,
kernel_cap_t *permitted)
{
task_t *target;
task_t *g, *target;
for_each_task(target) {
do_each_thread(g, target) {
if (target->pgrp != pgrp)
continue;
security_ops->capset_set(target, effective, inheritable, permitted);
}
} while_each_thread(g, target);
}
/*
......@@ -100,13 +100,13 @@ static inline void cap_set_all(kernel_cap_t *effective,
kernel_cap_t *inheritable,
kernel_cap_t *permitted)
{
task_t *target;
task_t *g, *target;
for_each_task(target) {
do_each_thread(g, target) {
if (target == current || target->pid == 1)
continue;
security_ops->capset_set(target, effective, inheritable, permitted);
}
} while_each_thread(g, target);
}
/*
......
......@@ -115,7 +115,7 @@ int session_of_pgrp(int pgrp)
fallback = -1;
read_lock(&tasklist_lock);
for_each_task(p) {
for_each_process(p) {
if (p->session <= 0)
continue;
if (p->pgrp == pgrp) {
......@@ -141,7 +141,7 @@ static int __will_become_orphaned_pgrp(int pgrp, struct task_struct * ignored_ta
{
struct task_struct *p;
for_each_task(p) {
for_each_process(p) {
if ((p == ignored_task) || (p->pgrp != pgrp) ||
(p->state == TASK_ZOMBIE) ||
(p->parent->pid == 1))
......@@ -175,7 +175,7 @@ static inline int __has_stopped_jobs(int pgrp)
int retval = 0;
struct task_struct * p;
for_each_task(p) {
for_each_process(p) {
if (p->pgrp != pgrp)
continue;
if (p->state != TASK_STOPPED)
......
......@@ -161,7 +161,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
static int get_pid(unsigned long flags)
{
struct task_struct *p;
struct task_struct *g, *p;
int pid;
if (flags & CLONE_IDLETASK)
......@@ -178,7 +178,7 @@ static int get_pid(unsigned long flags)
next_safe = pid_max;
read_lock(&tasklist_lock);
repeat:
for_each_task(p) {
do_each_thread(g, p) {
if (p->pid == last_pid ||
p->pgrp == last_pid ||
p->session == last_pid) {
......@@ -195,7 +195,8 @@ static int get_pid(unsigned long flags)
next_safe = p->pgrp;
if (p->session > last_pid && next_safe > p->session)
next_safe = p->session;
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
}
pid = last_pid;
......
......@@ -1838,7 +1838,7 @@ char * render_sigset_t(sigset_t *set, char *buffer)
void show_state(void)
{
task_t *p;
task_t *g, *p;
#if (BITS_PER_LONG == 32)
printk("\n"
......@@ -1850,14 +1850,15 @@ void show_state(void)
printk(" task PC stack pid father child younger older\n");
#endif
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
/*
* reset the NMI-timeout, listing all files on a slow
* console might take alot of time:
*/
touch_nmi_watchdog();
show_task(p);
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
}
......
......@@ -118,14 +118,18 @@ int max_queued_signals = 1024;
#define T(sig, mask) \
((1UL << (sig)) & mask)
#define sig_user_specific(sig) T(sig, SIG_USER_SPECIFIC_MASK)
#define sig_user_specific(sig) \
(((sig) < SIGRTMIN) && T(sig, SIG_USER_SPECIFIC_MASK))
#define sig_user_load_balance(sig) \
(T(sig, SIG_USER_LOAD_BALANCE_MASK) || ((sig) >= SIGRTMIN))
#define sig_kernel_specific(sig) T(sig, SIG_KERNEL_SPECIFIC_MASK)
(((sig) >= SIGRTMIN) || T(sig, SIG_USER_LOAD_BALANCE_MASK))
#define sig_kernel_specific(sig) \
(((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_SPECIFIC_MASK))
#define sig_kernel_broadcast(sig) \
(T(sig, SIG_KERNEL_BROADCAST_MASK) || ((sig) >= SIGRTMIN))
#define sig_kernel_only(sig) T(sig, SIG_KERNEL_ONLY_MASK)
#define sig_kernel_coredump(sig) T(sig, SIG_KERNEL_COREDUMP_MASK)
(((sig) >= SIGRTMIN) || T(sig, SIG_KERNEL_BROADCAST_MASK))
#define sig_kernel_only(sig) \
(((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_ONLY_MASK))
#define sig_kernel_coredump(sig) \
(((sig) < SIGRTMIN) && T(sig, SIG_KERNEL_COREDUMP_MASK))
#define sig_user_defined(t, sig) \
(((t)->sig->action[(sig)-1].sa.sa_handler != SIG_DFL) && \
......@@ -280,11 +284,13 @@ void __exit_sighand(struct task_struct *tsk)
if (atomic_read(&sig->count) == 1 &&
leader->state == TASK_ZOMBIE) {
__remove_thread_group(tsk, sig);
spin_unlock(&sig->siglock);
do_notify_parent(leader, leader->exit_signal);
} else
} else {
__remove_thread_group(tsk, sig);
spin_unlock(&sig->siglock);
}
}
clear_tsk_thread_flag(tsk,TIF_SIGPENDING);
flush_sigqueue(&tsk->pending);
......@@ -932,8 +938,8 @@ int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
struct task_struct *p;
retval = -ESRCH;
for_each_task(p) {
if (p->pgrp == pgrp && thread_group_leader(p)) {
for_each_process(p) {
if (p->pgrp == pgrp) {
int err = send_sig_info(sig, info, p);
if (retval)
retval = err;
......@@ -970,7 +976,7 @@ kill_sl_info(int sig, struct siginfo *info, pid_t sess)
retval = -ESRCH;
read_lock(&tasklist_lock);
for_each_task(p) {
for_each_process(p) {
if (p->leader && p->session == sess) {
int err = send_sig_info(sig, info, p);
if (retval)
......@@ -1014,8 +1020,8 @@ static int kill_something_info(int sig, struct siginfo *info, int pid)
struct task_struct * p;
read_lock(&tasklist_lock);
for_each_task(p) {
if (p->pid > 1 && p != current && thread_group_leader(p)) {
for_each_process(p) {
if (p->pid > 1 && p != current) {
int err = send_sig_info(sig, info, p);
++count;
if (err != -EPERM)
......
......@@ -204,14 +204,14 @@ void refrigerator(unsigned long flag)
int freeze_processes(void)
{
int todo, start_time;
struct task_struct *p;
struct task_struct *g, *p;
printk( "Stopping tasks: " );
start_time = jiffies;
do {
todo = 0;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
unsigned long flags;
INTERESTING(p);
if (p->flags & PF_FROZEN)
......@@ -224,7 +224,7 @@ int freeze_processes(void)
signal_wake_up(p);
spin_unlock_irqrestore(&p->sigmask_lock, flags);
todo++;
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
yield();
if (time_after(jiffies, start_time + TIMEOUT)) {
......@@ -240,18 +240,19 @@ int freeze_processes(void)
void thaw_processes(void)
{
struct task_struct *p;
struct task_struct *g, *p;
printk( "Restarting tasks..." );
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
INTERESTING(p);
if (p->flags & PF_FROZEN) p->flags &= ~PF_FROZEN;
else
printk(KERN_INFO " Strange, %s not stopped\n", p->comm );
wake_up_process(p);
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
printk( " done\n" );
MDELAY(500);
......
......@@ -227,7 +227,7 @@ static int proc_sel(struct task_struct *p, int which, int who)
asmlinkage long sys_setpriority(int which, int who, int niceval)
{
struct task_struct *p;
struct task_struct *g, *p;
int error;
if (which > 2 || which < 0)
......@@ -241,7 +241,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
niceval = 19;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
int no_nice;
if (!proc_sel(p, which, who))
continue;
......@@ -262,8 +262,8 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
continue;
}
set_user_nice(p, niceval);
} while_each_thread(g, p);
}
read_unlock(&tasklist_lock);
return error;
......@@ -277,21 +277,21 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
*/
asmlinkage long sys_getpriority(int which, int who)
{
struct task_struct *p;
struct task_struct *g, *p;
long retval = -ESRCH;
if (which > 2 || which < 0)
return -EINVAL;
read_lock(&tasklist_lock);
for_each_task (p) {
do_each_thread(g, p) {
long niceval;
if (!proc_sel(p, which, who))
continue;
niceval = 20 - task_nice(p);
if (niceval > retval)
retval = niceval;
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
return retval;
......@@ -882,12 +882,12 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
if (p->leader)
goto out;
if (pgid != pid) {
struct task_struct * tmp;
for_each_task (tmp) {
struct task_struct *g, *tmp;
do_each_thread(g, tmp) {
if (tmp->pgrp == pgid &&
tmp->session == current->session)
goto ok_pgid;
}
} while_each_thread(g, tmp);
goto out;
}
......@@ -956,14 +956,14 @@ asmlinkage long sys_getsid(pid_t pid)
asmlinkage long sys_setsid(void)
{
struct task_struct * p;
struct task_struct *g, *p;
int err = -EPERM;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p)
if (p->pgrp == current->pid)
goto out;
}
while_each_thread(g, p);
current->leader = 1;
current->session = current->pgrp = current->pid;
......
......@@ -116,10 +116,10 @@ static int badness(struct task_struct *p)
static struct task_struct * select_bad_process(void)
{
int maxpoints = 0;
struct task_struct *p = NULL;
struct task_struct *g, *p;
struct task_struct *chosen = NULL;
for_each_task(p) {
do_each_thread(g, p)
if (p->pid) {
int points = badness(p);
if (points > maxpoints) {
......@@ -127,7 +127,7 @@ static struct task_struct * select_bad_process(void)
maxpoints = points;
}
}
}
while_each_thread(g, p);
return chosen;
}
......@@ -166,7 +166,7 @@ void oom_kill_task(struct task_struct *p)
*/
static void oom_kill(void)
{
struct task_struct *p, *q;
struct task_struct *g, *p, *q;
read_lock(&tasklist_lock);
p = select_bad_process();
......@@ -176,9 +176,11 @@ static void oom_kill(void)
panic("Out of memory and no killable processes...\n");
/* kill all processes that share the ->mm (i.e. all threads) */
for_each_task(q) {
if(q->mm == p->mm) oom_kill_task(q);
}
do_each_thread(g, q)
if (q->mm == p->mm)
oom_kill_task(q);
while_each_thread(g, q);
read_unlock(&tasklist_lock);
/*
......
......@@ -14,12 +14,12 @@
static int
match_comm(const struct sk_buff *skb, const char *comm)
{
struct task_struct *p;
struct task_struct *g, *p;
struct files_struct *files;
int i;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
if(strncmp(p->comm, comm, sizeof(p->comm)))
continue;
......@@ -38,7 +38,7 @@ match_comm(const struct sk_buff *skb, const char *comm)
read_unlock(&files->file_lock);
}
task_unlock(p);
}
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
return 0;
}
......@@ -77,12 +77,12 @@ match_pid(const struct sk_buff *skb, pid_t pid)
static int
match_sid(const struct sk_buff *skb, pid_t sid)
{
struct task_struct *p;
struct task_struct *g, *p;
struct file *file = skb->sk->socket->file;
int i, found=0;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
struct files_struct *files;
if (p->session != sid)
continue;
......@@ -100,9 +100,10 @@ match_sid(const struct sk_buff *skb, pid_t sid)
read_unlock(&files->file_lock);
}
task_unlock(p);
if(found)
break;
}
if (found)
goto out;
} while_each_thread(g, p);
out:
read_unlock(&tasklist_lock);
return found;
......
......@@ -49,12 +49,12 @@ match_pid(const struct sk_buff *skb, pid_t pid)
static int
match_sid(const struct sk_buff *skb, pid_t sid)
{
struct task_struct *p;
struct task_struct *g, *p;
struct file *file = skb->sk->socket->file;
int i, found=0;
read_lock(&tasklist_lock);
for_each_task(p) {
do_each_thread(g, p) {
struct files_struct *files;
if (p->session != sid)
continue;
......@@ -72,9 +72,10 @@ match_sid(const struct sk_buff *skb, pid_t sid)
read_unlock(&files->file_lock);
}
task_unlock(p);
if(found)
break;
}
if (found)
goto out;
} while_each_thread(g, p);
out:
read_unlock(&tasklist_lock);
return found;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment