Merge commit 'v2.6.31-rc8' into core/locking
Merge reason: we were on -rc4, move to -rc8 before applying a new batch of locking infrastructure changes. Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
151
kernel/cgroup.c
151
kernel/cgroup.c
@@ -47,6 +47,7 @@
|
||||
#include <linux/hash.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <linux/pid_namespace.h>
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
@@ -734,16 +735,28 @@ static void cgroup_d_remove_dir(struct dentry *dentry)
|
||||
* reference to css->refcnt. In general, this refcnt is expected to goes down
|
||||
* to zero, soon.
|
||||
*
|
||||
* CGRP_WAIT_ON_RMDIR flag is modified under cgroup's inode->i_mutex;
|
||||
* CGRP_WAIT_ON_RMDIR flag is set under cgroup's inode->i_mutex;
|
||||
*/
|
||||
DECLARE_WAIT_QUEUE_HEAD(cgroup_rmdir_waitq);
|
||||
|
||||
static void cgroup_wakeup_rmdir_waiters(const struct cgroup *cgrp)
|
||||
static void cgroup_wakeup_rmdir_waiter(struct cgroup *cgrp)
|
||||
{
|
||||
if (unlikely(test_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags)))
|
||||
if (unlikely(test_and_clear_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags)))
|
||||
wake_up_all(&cgroup_rmdir_waitq);
|
||||
}
|
||||
|
||||
void cgroup_exclude_rmdir(struct cgroup_subsys_state *css)
|
||||
{
|
||||
css_get(css);
|
||||
}
|
||||
|
||||
void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css)
|
||||
{
|
||||
cgroup_wakeup_rmdir_waiter(css->cgroup);
|
||||
css_put(css);
|
||||
}
|
||||
|
||||
|
||||
static int rebind_subsystems(struct cgroupfs_root *root,
|
||||
unsigned long final_bits)
|
||||
{
|
||||
@@ -960,6 +973,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
|
||||
INIT_LIST_HEAD(&cgrp->children);
|
||||
INIT_LIST_HEAD(&cgrp->css_sets);
|
||||
INIT_LIST_HEAD(&cgrp->release_list);
|
||||
INIT_LIST_HEAD(&cgrp->pids_list);
|
||||
init_rwsem(&cgrp->pids_mutex);
|
||||
}
|
||||
static void init_cgroup_root(struct cgroupfs_root *root)
|
||||
@@ -1357,7 +1371,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
|
||||
* wake up rmdir() waiter. the rmdir should fail since the cgroup
|
||||
* is no longer empty.
|
||||
*/
|
||||
cgroup_wakeup_rmdir_waiters(cgrp);
|
||||
cgroup_wakeup_rmdir_waiter(cgrp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2201,12 +2215,30 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cache pids for all threads in the same pid namespace that are
|
||||
* opening the same "tasks" file.
|
||||
*/
|
||||
struct cgroup_pids {
|
||||
/* The node in cgrp->pids_list */
|
||||
struct list_head list;
|
||||
/* The cgroup those pids belong to */
|
||||
struct cgroup *cgrp;
|
||||
/* The namepsace those pids belong to */
|
||||
struct pid_namespace *ns;
|
||||
/* Array of process ids in the cgroup */
|
||||
pid_t *tasks_pids;
|
||||
/* How many files are using the this tasks_pids array */
|
||||
int use_count;
|
||||
/* Length of the current tasks_pids array */
|
||||
int length;
|
||||
};
|
||||
|
||||
static int cmppid(const void *a, const void *b)
|
||||
{
|
||||
return *(pid_t *)a - *(pid_t *)b;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* seq_file methods for the "tasks" file. The seq_file position is the
|
||||
* next pid to display; the seq_file iterator is a pointer to the pid
|
||||
@@ -2221,45 +2253,47 @@ static void *cgroup_tasks_start(struct seq_file *s, loff_t *pos)
|
||||
* after a seek to the start). Use a binary-search to find the
|
||||
* next pid to display, if any
|
||||
*/
|
||||
struct cgroup *cgrp = s->private;
|
||||
struct cgroup_pids *cp = s->private;
|
||||
struct cgroup *cgrp = cp->cgrp;
|
||||
int index = 0, pid = *pos;
|
||||
int *iter;
|
||||
|
||||
down_read(&cgrp->pids_mutex);
|
||||
if (pid) {
|
||||
int end = cgrp->pids_length;
|
||||
int end = cp->length;
|
||||
|
||||
while (index < end) {
|
||||
int mid = (index + end) / 2;
|
||||
if (cgrp->tasks_pids[mid] == pid) {
|
||||
if (cp->tasks_pids[mid] == pid) {
|
||||
index = mid;
|
||||
break;
|
||||
} else if (cgrp->tasks_pids[mid] <= pid)
|
||||
} else if (cp->tasks_pids[mid] <= pid)
|
||||
index = mid + 1;
|
||||
else
|
||||
end = mid;
|
||||
}
|
||||
}
|
||||
/* If we're off the end of the array, we're done */
|
||||
if (index >= cgrp->pids_length)
|
||||
if (index >= cp->length)
|
||||
return NULL;
|
||||
/* Update the abstract position to be the actual pid that we found */
|
||||
iter = cgrp->tasks_pids + index;
|
||||
iter = cp->tasks_pids + index;
|
||||
*pos = *iter;
|
||||
return iter;
|
||||
}
|
||||
|
||||
static void cgroup_tasks_stop(struct seq_file *s, void *v)
|
||||
{
|
||||
struct cgroup *cgrp = s->private;
|
||||
struct cgroup_pids *cp = s->private;
|
||||
struct cgroup *cgrp = cp->cgrp;
|
||||
up_read(&cgrp->pids_mutex);
|
||||
}
|
||||
|
||||
static void *cgroup_tasks_next(struct seq_file *s, void *v, loff_t *pos)
|
||||
{
|
||||
struct cgroup *cgrp = s->private;
|
||||
struct cgroup_pids *cp = s->private;
|
||||
int *p = v;
|
||||
int *end = cgrp->tasks_pids + cgrp->pids_length;
|
||||
int *end = cp->tasks_pids + cp->length;
|
||||
|
||||
/*
|
||||
* Advance to the next pid in the array. If this goes off the
|
||||
@@ -2286,26 +2320,33 @@ static struct seq_operations cgroup_tasks_seq_operations = {
|
||||
.show = cgroup_tasks_show,
|
||||
};
|
||||
|
||||
static void release_cgroup_pid_array(struct cgroup *cgrp)
|
||||
static void release_cgroup_pid_array(struct cgroup_pids *cp)
|
||||
{
|
||||
struct cgroup *cgrp = cp->cgrp;
|
||||
|
||||
down_write(&cgrp->pids_mutex);
|
||||
BUG_ON(!cgrp->pids_use_count);
|
||||
if (!--cgrp->pids_use_count) {
|
||||
kfree(cgrp->tasks_pids);
|
||||
cgrp->tasks_pids = NULL;
|
||||
cgrp->pids_length = 0;
|
||||
BUG_ON(!cp->use_count);
|
||||
if (!--cp->use_count) {
|
||||
list_del(&cp->list);
|
||||
put_pid_ns(cp->ns);
|
||||
kfree(cp->tasks_pids);
|
||||
kfree(cp);
|
||||
}
|
||||
up_write(&cgrp->pids_mutex);
|
||||
}
|
||||
|
||||
static int cgroup_tasks_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent);
|
||||
struct seq_file *seq;
|
||||
struct cgroup_pids *cp;
|
||||
|
||||
if (!(file->f_mode & FMODE_READ))
|
||||
return 0;
|
||||
|
||||
release_cgroup_pid_array(cgrp);
|
||||
seq = file->private_data;
|
||||
cp = seq->private;
|
||||
|
||||
release_cgroup_pid_array(cp);
|
||||
return seq_release(inode, file);
|
||||
}
|
||||
|
||||
@@ -2324,6 +2365,8 @@ static struct file_operations cgroup_tasks_operations = {
|
||||
static int cgroup_tasks_open(struct inode *unused, struct file *file)
|
||||
{
|
||||
struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent);
|
||||
struct pid_namespace *ns = current->nsproxy->pid_ns;
|
||||
struct cgroup_pids *cp;
|
||||
pid_t *pidarray;
|
||||
int npids;
|
||||
int retval;
|
||||
@@ -2350,20 +2393,37 @@ static int cgroup_tasks_open(struct inode *unused, struct file *file)
|
||||
* array if necessary
|
||||
*/
|
||||
down_write(&cgrp->pids_mutex);
|
||||
kfree(cgrp->tasks_pids);
|
||||
cgrp->tasks_pids = pidarray;
|
||||
cgrp->pids_length = npids;
|
||||
cgrp->pids_use_count++;
|
||||
|
||||
list_for_each_entry(cp, &cgrp->pids_list, list) {
|
||||
if (ns == cp->ns)
|
||||
goto found;
|
||||
}
|
||||
|
||||
cp = kzalloc(sizeof(*cp), GFP_KERNEL);
|
||||
if (!cp) {
|
||||
up_write(&cgrp->pids_mutex);
|
||||
kfree(pidarray);
|
||||
return -ENOMEM;
|
||||
}
|
||||
cp->cgrp = cgrp;
|
||||
cp->ns = ns;
|
||||
get_pid_ns(ns);
|
||||
list_add(&cp->list, &cgrp->pids_list);
|
||||
found:
|
||||
kfree(cp->tasks_pids);
|
||||
cp->tasks_pids = pidarray;
|
||||
cp->length = npids;
|
||||
cp->use_count++;
|
||||
up_write(&cgrp->pids_mutex);
|
||||
|
||||
file->f_op = &cgroup_tasks_operations;
|
||||
|
||||
retval = seq_open(file, &cgroup_tasks_seq_operations);
|
||||
if (retval) {
|
||||
release_cgroup_pid_array(cgrp);
|
||||
release_cgroup_pid_array(cp);
|
||||
return retval;
|
||||
}
|
||||
((struct seq_file *)file->private_data)->private = cgrp;
|
||||
((struct seq_file *)file->private_data)->private = cp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2695,34 +2755,43 @@ again:
|
||||
}
|
||||
mutex_unlock(&cgroup_mutex);
|
||||
|
||||
/*
|
||||
* In general, subsystem has no css->refcnt after pre_destroy(). But
|
||||
* in racy cases, subsystem may have to get css->refcnt after
|
||||
* pre_destroy() and it makes rmdir return with -EBUSY. This sometimes
|
||||
* make rmdir return -EBUSY too often. To avoid that, we use waitqueue
|
||||
* for cgroup's rmdir. CGRP_WAIT_ON_RMDIR is for synchronizing rmdir
|
||||
* and subsystem's reference count handling. Please see css_get/put
|
||||
* and css_tryget() and cgroup_wakeup_rmdir_waiter() implementation.
|
||||
*/
|
||||
set_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags);
|
||||
|
||||
/*
|
||||
* Call pre_destroy handlers of subsys. Notify subsystems
|
||||
* that rmdir() request comes.
|
||||
*/
|
||||
ret = cgroup_call_pre_destroy(cgrp);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
clear_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
mutex_lock(&cgroup_mutex);
|
||||
parent = cgrp->parent;
|
||||
if (atomic_read(&cgrp->count) || !list_empty(&cgrp->children)) {
|
||||
clear_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags);
|
||||
mutex_unlock(&cgroup_mutex);
|
||||
return -EBUSY;
|
||||
}
|
||||
/*
|
||||
* css_put/get is provided for subsys to grab refcnt to css. In typical
|
||||
* case, subsystem has no reference after pre_destroy(). But, under
|
||||
* hierarchy management, some *temporal* refcnt can be hold.
|
||||
* To avoid returning -EBUSY to a user, waitqueue is used. If subsys
|
||||
* is really busy, it should return -EBUSY at pre_destroy(). wake_up
|
||||
* is called when css_put() is called and refcnt goes down to 0.
|
||||
*/
|
||||
set_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags);
|
||||
prepare_to_wait(&cgroup_rmdir_waitq, &wait, TASK_INTERRUPTIBLE);
|
||||
|
||||
if (!cgroup_clear_css_refs(cgrp)) {
|
||||
mutex_unlock(&cgroup_mutex);
|
||||
schedule();
|
||||
/*
|
||||
* Because someone may call cgroup_wakeup_rmdir_waiter() before
|
||||
* prepare_to_wait(), we need to check this flag.
|
||||
*/
|
||||
if (test_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags))
|
||||
schedule();
|
||||
finish_wait(&cgroup_rmdir_waitq, &wait);
|
||||
clear_bit(CGRP_WAIT_ON_RMDIR, &cgrp->flags);
|
||||
if (signal_pending(current))
|
||||
@@ -3294,7 +3363,7 @@ void __css_put(struct cgroup_subsys_state *css)
|
||||
set_bit(CGRP_RELEASABLE, &cgrp->flags);
|
||||
check_for_release(cgrp);
|
||||
}
|
||||
cgroup_wakeup_rmdir_waiters(cgrp);
|
||||
cgroup_wakeup_rmdir_waiter(cgrp);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
@@ -567,18 +567,18 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
|
||||
* the value intact in a core dump, and to save the unnecessary
|
||||
* trouble otherwise. Userland only wants this done for a sys_exit.
|
||||
*/
|
||||
if (tsk->clear_child_tid
|
||||
&& !(tsk->flags & PF_SIGNALED)
|
||||
&& atomic_read(&mm->mm_users) > 1) {
|
||||
u32 __user * tidptr = tsk->clear_child_tid;
|
||||
if (tsk->clear_child_tid) {
|
||||
if (!(tsk->flags & PF_SIGNALED) &&
|
||||
atomic_read(&mm->mm_users) > 1) {
|
||||
/*
|
||||
* We don't check the error code - if userspace has
|
||||
* not set up a proper pointer then tough luck.
|
||||
*/
|
||||
put_user(0, tsk->clear_child_tid);
|
||||
sys_futex(tsk->clear_child_tid, FUTEX_WAKE,
|
||||
1, NULL, NULL, 0);
|
||||
}
|
||||
tsk->clear_child_tid = NULL;
|
||||
|
||||
/*
|
||||
* We don't check the error code - if userspace has
|
||||
* not set up a proper pointer then tough luck.
|
||||
*/
|
||||
put_user(0, tidptr);
|
||||
sys_futex(tidptr, FUTEX_WAKE, 1, NULL, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,11 +815,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
|
||||
{
|
||||
struct signal_struct *sig;
|
||||
|
||||
if (clone_flags & CLONE_THREAD) {
|
||||
atomic_inc(¤t->signal->count);
|
||||
atomic_inc(¤t->signal->live);
|
||||
if (clone_flags & CLONE_THREAD)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
|
||||
tsk->signal = sig;
|
||||
@@ -877,16 +874,6 @@ void __cleanup_signal(struct signal_struct *sig)
|
||||
kmem_cache_free(signal_cachep, sig);
|
||||
}
|
||||
|
||||
static void cleanup_signal(struct task_struct *tsk)
|
||||
{
|
||||
struct signal_struct *sig = tsk->signal;
|
||||
|
||||
atomic_dec(&sig->live);
|
||||
|
||||
if (atomic_dec_and_test(&sig->count))
|
||||
__cleanup_signal(sig);
|
||||
}
|
||||
|
||||
static void copy_flags(unsigned long clone_flags, struct task_struct *p)
|
||||
{
|
||||
unsigned long new_flags = p->flags;
|
||||
@@ -1239,6 +1226,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
|
||||
}
|
||||
|
||||
if (clone_flags & CLONE_THREAD) {
|
||||
atomic_inc(¤t->signal->count);
|
||||
atomic_inc(¤t->signal->live);
|
||||
p->group_leader = current->group_leader;
|
||||
list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group);
|
||||
}
|
||||
@@ -1268,6 +1257,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
|
||||
write_unlock_irq(&tasklist_lock);
|
||||
proc_fork_connector(p);
|
||||
cgroup_post_fork(p);
|
||||
perf_counter_fork(p);
|
||||
return p;
|
||||
|
||||
bad_fork_free_pid:
|
||||
@@ -1281,7 +1271,8 @@ bad_fork_cleanup_mm:
|
||||
if (p->mm)
|
||||
mmput(p->mm);
|
||||
bad_fork_cleanup_signal:
|
||||
cleanup_signal(p);
|
||||
if (!(clone_flags & CLONE_THREAD))
|
||||
__cleanup_signal(p->signal);
|
||||
bad_fork_cleanup_sighand:
|
||||
__cleanup_sighand(p->sighand);
|
||||
bad_fork_cleanup_fs:
|
||||
@@ -1409,9 +1400,6 @@ long do_fork(unsigned long clone_flags,
|
||||
init_completion(&vfork);
|
||||
}
|
||||
|
||||
if (!(clone_flags & CLONE_THREAD))
|
||||
perf_counter_fork(p);
|
||||
|
||||
audit_finish_fork(p);
|
||||
tracehook_report_clone(regs, clone_flags, nr, p);
|
||||
|
||||
|
@@ -1010,15 +1010,19 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
|
||||
* requeue_pi_wake_futex() - Wake a task that acquired the lock during requeue
|
||||
* q: the futex_q
|
||||
* key: the key of the requeue target futex
|
||||
* hb: the hash_bucket of the requeue target futex
|
||||
*
|
||||
* During futex_requeue, with requeue_pi=1, it is possible to acquire the
|
||||
* target futex if it is uncontended or via a lock steal. Set the futex_q key
|
||||
* to the requeue target futex so the waiter can detect the wakeup on the right
|
||||
* futex, but remove it from the hb and NULL the rt_waiter so it can detect
|
||||
* atomic lock acquisition. Must be called with the q->lock_ptr held.
|
||||
* atomic lock acquisition. Set the q->lock_ptr to the requeue target hb->lock
|
||||
* to protect access to the pi_state to fixup the owner later. Must be called
|
||||
* with both q->lock_ptr and hb->lock held.
|
||||
*/
|
||||
static inline
|
||||
void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key)
|
||||
void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
|
||||
struct futex_hash_bucket *hb)
|
||||
{
|
||||
drop_futex_key_refs(&q->key);
|
||||
get_futex_key_refs(key);
|
||||
@@ -1030,6 +1034,11 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key)
|
||||
WARN_ON(!q->rt_waiter);
|
||||
q->rt_waiter = NULL;
|
||||
|
||||
q->lock_ptr = &hb->lock;
|
||||
#ifdef CONFIG_DEBUG_PI_LIST
|
||||
q->list.plist.lock = &hb->lock;
|
||||
#endif
|
||||
|
||||
wake_up_state(q->task, TASK_NORMAL);
|
||||
}
|
||||
|
||||
@@ -1088,7 +1097,7 @@ static int futex_proxy_trylock_atomic(u32 __user *pifutex,
|
||||
ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task,
|
||||
set_waiters);
|
||||
if (ret == 1)
|
||||
requeue_pi_wake_futex(top_waiter, key2);
|
||||
requeue_pi_wake_futex(top_waiter, key2, hb2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1247,8 +1256,15 @@ retry_private:
|
||||
if (!match_futex(&this->key, &key1))
|
||||
continue;
|
||||
|
||||
WARN_ON(!requeue_pi && this->rt_waiter);
|
||||
WARN_ON(requeue_pi && !this->rt_waiter);
|
||||
/*
|
||||
* FUTEX_WAIT_REQEUE_PI and FUTEX_CMP_REQUEUE_PI should always
|
||||
* be paired with each other and no other futex ops.
|
||||
*/
|
||||
if ((requeue_pi && !this->rt_waiter) ||
|
||||
(!requeue_pi && this->rt_waiter)) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wake nr_wake waiters. For requeue_pi, if we acquired the
|
||||
@@ -1273,7 +1289,7 @@ retry_private:
|
||||
this->task, 1);
|
||||
if (ret == 1) {
|
||||
/* We got the lock. */
|
||||
requeue_pi_wake_futex(this, &key2);
|
||||
requeue_pi_wake_futex(this, &key2, hb2);
|
||||
continue;
|
||||
} else if (ret) {
|
||||
/* -EDEADLK */
|
||||
|
@@ -180,7 +180,8 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
|
||||
int cmd = op & FUTEX_CMD_MASK;
|
||||
|
||||
if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI ||
|
||||
cmd == FUTEX_WAIT_BITSET)) {
|
||||
cmd == FUTEX_WAIT_BITSET ||
|
||||
cmd == FUTEX_WAIT_REQUEUE_PI)) {
|
||||
if (get_compat_timespec(&ts, utime))
|
||||
return -EFAULT;
|
||||
if (!timespec_valid(&ts))
|
||||
@@ -191,7 +192,8 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
|
||||
t = ktime_add_safe(ktime_get(), t);
|
||||
tp = &t;
|
||||
}
|
||||
if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE)
|
||||
if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
|
||||
cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP)
|
||||
val2 = (int) (unsigned long) utime;
|
||||
|
||||
return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
|
||||
|
@@ -607,7 +607,6 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
|
||||
*/
|
||||
get_task_struct(t);
|
||||
new->thread = t;
|
||||
wake_up_process(t);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -690,6 +689,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
|
||||
(int)(new->flags & IRQF_TRIGGER_MASK));
|
||||
}
|
||||
|
||||
new->irq = irq;
|
||||
*old_ptr = new;
|
||||
|
||||
/* Reset broken irq detection when installing new handler */
|
||||
@@ -707,7 +707,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
|
||||
|
||||
spin_unlock_irqrestore(&desc->lock, flags);
|
||||
|
||||
new->irq = irq;
|
||||
/*
|
||||
* Strictly no need to wake it up, but hung_task complains
|
||||
* when no hard interrupt wakes the thread up.
|
||||
*/
|
||||
if (new->thread)
|
||||
wake_up_process(new->thread);
|
||||
|
||||
register_irq_proc(irq, desc);
|
||||
new->dir = NULL;
|
||||
register_handler_proc(irq, new);
|
||||
@@ -761,7 +767,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
|
||||
{
|
||||
struct irq_desc *desc = irq_to_desc(irq);
|
||||
struct irqaction *action, **action_ptr;
|
||||
struct task_struct *irqthread;
|
||||
unsigned long flags;
|
||||
|
||||
WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq);
|
||||
@@ -809,9 +814,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
|
||||
desc->chip->disable(irq);
|
||||
}
|
||||
|
||||
irqthread = action->thread;
|
||||
action->thread = NULL;
|
||||
|
||||
spin_unlock_irqrestore(&desc->lock, flags);
|
||||
|
||||
unregister_handler_proc(irq, action);
|
||||
@@ -819,12 +821,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
|
||||
/* Make sure it's not being used on another CPU: */
|
||||
synchronize_irq(irq);
|
||||
|
||||
if (irqthread) {
|
||||
if (!test_bit(IRQTF_DIED, &action->thread_flags))
|
||||
kthread_stop(irqthread);
|
||||
put_task_struct(irqthread);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_SHIRQ
|
||||
/*
|
||||
* It's a shared IRQ -- the driver ought to be prepared for an IRQ
|
||||
@@ -840,6 +836,13 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (action->thread) {
|
||||
if (!test_bit(IRQTF_DIED, &action->thread_flags))
|
||||
kthread_stop(action->thread);
|
||||
put_task_struct(action->thread);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@@ -107,8 +107,8 @@ out_unlock:
|
||||
|
||||
struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
|
||||
{
|
||||
/* those all static, do move them */
|
||||
if (desc->irq < NR_IRQS_LEGACY)
|
||||
/* those static or target node is -1, do not move them */
|
||||
if (desc->irq < NR_IRQS_LEGACY || node == -1)
|
||||
return desc;
|
||||
|
||||
if (desc->node != node)
|
||||
|
@@ -1228,7 +1228,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
|
||||
} while (*cur++ == ',');
|
||||
|
||||
if (*crash_size > 0) {
|
||||
while (*cur != ' ' && *cur != '@')
|
||||
while (*cur && *cur != ' ' && *cur != '@')
|
||||
cur++;
|
||||
if (*cur == '@') {
|
||||
cur++;
|
||||
|
@@ -694,7 +694,7 @@ int __kprobes register_kprobe(struct kprobe *p)
|
||||
p->addr = addr;
|
||||
|
||||
preempt_disable();
|
||||
if (!__kernel_text_address((unsigned long) p->addr) ||
|
||||
if (!kernel_text_address((unsigned long) p->addr) ||
|
||||
in_kprobes_functions((unsigned long) p->addr)) {
|
||||
preempt_enable();
|
||||
return -EINVAL;
|
||||
|
@@ -180,10 +180,12 @@ EXPORT_SYMBOL(kthread_bind);
|
||||
* @k: thread created by kthread_create().
|
||||
*
|
||||
* Sets kthread_should_stop() for @k to return true, wakes it, and
|
||||
* waits for it to exit. Your threadfn() must not call do_exit()
|
||||
* itself if you use this function! This can also be called after
|
||||
* kthread_create() instead of calling wake_up_process(): the thread
|
||||
* will exit without calling threadfn().
|
||||
* waits for it to exit. This can also be called after kthread_create()
|
||||
* instead of calling wake_up_process(): the thread will exit without
|
||||
* calling threadfn().
|
||||
*
|
||||
* If threadfn() may call do_exit() itself, the caller must ensure
|
||||
* task_struct can't go away.
|
||||
*
|
||||
* Returns the result of threadfn(), or %-EINTR if wake_up_process()
|
||||
* was never called.
|
||||
|
@@ -680,7 +680,8 @@ static int __init lockdep_proc_init(void)
|
||||
&proc_lockdep_stats_operations);
|
||||
|
||||
#ifdef CONFIG_LOCK_STAT
|
||||
proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations);
|
||||
proc_create("lock_stat", S_IRUSR | S_IWUSR, NULL,
|
||||
&proc_lock_stat_operations);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@@ -909,16 +909,18 @@ void __symbol_put(const char *symbol)
|
||||
}
|
||||
EXPORT_SYMBOL(__symbol_put);
|
||||
|
||||
/* Note this assumes addr is a function, which it currently always is. */
|
||||
void symbol_put_addr(void *addr)
|
||||
{
|
||||
struct module *modaddr;
|
||||
unsigned long a = (unsigned long)dereference_function_descriptor(addr);
|
||||
|
||||
if (core_kernel_text((unsigned long)addr))
|
||||
if (core_kernel_text(a))
|
||||
return;
|
||||
|
||||
/* module_text_address is safe here: we're supposed to have reference
|
||||
* to module from symbol_get, so it can't go away. */
|
||||
modaddr = __module_text_address((unsigned long)addr);
|
||||
modaddr = __module_text_address(a);
|
||||
BUG_ON(!modaddr);
|
||||
module_put(modaddr);
|
||||
}
|
||||
@@ -1068,7 +1070,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
|
||||
{
|
||||
const unsigned long *crc;
|
||||
|
||||
if (!find_symbol("module_layout", NULL, &crc, true, false))
|
||||
if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
|
||||
&crc, true, false))
|
||||
BUG();
|
||||
return check_version(sechdrs, versindex, "module_layout", mod, crc);
|
||||
}
|
||||
@@ -2352,7 +2355,8 @@ static noinline struct module *load_module(void __user *umod,
|
||||
if (err < 0)
|
||||
goto unlink;
|
||||
add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
|
||||
add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
|
||||
if (mod->sect_attrs)
|
||||
add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
|
||||
|
||||
/* Get rid of temporary copy */
|
||||
vfree(hdr);
|
||||
|
@@ -301,6 +301,7 @@ int oops_may_print(void)
|
||||
*/
|
||||
void oops_enter(void)
|
||||
{
|
||||
tracing_off();
|
||||
/* can't trust the integrity of the kernel anymore: */
|
||||
debug_locks_off();
|
||||
do_oops_enter_exit();
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -521,11 +521,12 @@ void posix_cpu_timers_exit(struct task_struct *tsk)
|
||||
}
|
||||
void posix_cpu_timers_exit_group(struct task_struct *tsk)
|
||||
{
|
||||
struct task_cputime cputime;
|
||||
struct signal_struct *const sig = tsk->signal;
|
||||
|
||||
thread_group_cputimer(tsk, &cputime);
|
||||
cleanup_timers(tsk->signal->cpu_timers,
|
||||
cputime.utime, cputime.stime, cputime.sum_exec_runtime);
|
||||
cputime_add(tsk->utime, sig->utime),
|
||||
cputime_add(tsk->stime, sig->stime),
|
||||
tsk->se.sum_exec_runtime + sig->sum_sched_runtime);
|
||||
}
|
||||
|
||||
static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now)
|
||||
|
@@ -202,6 +202,12 @@ static int no_timer_create(struct k_itimer *new_timer)
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int no_nsleep(const clockid_t which_clock, int flags,
|
||||
struct timespec *tsave, struct timespec __user *rmtp)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return nonzero if we know a priori this clockid_t value is bogus.
|
||||
*/
|
||||
@@ -254,6 +260,7 @@ static __init int init_posix_timers(void)
|
||||
.clock_get = posix_get_monotonic_raw,
|
||||
.clock_set = do_posix_clock_nosettime,
|
||||
.timer_create = no_timer_create,
|
||||
.nsleep = no_nsleep,
|
||||
};
|
||||
|
||||
register_posix_clock(CLOCK_REALTIME, &clock_realtime);
|
||||
|
@@ -117,11 +117,12 @@ int __ref profile_init(void)
|
||||
|
||||
cpumask_copy(prof_cpu_mask, cpu_possible_mask);
|
||||
|
||||
prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL);
|
||||
prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL|__GFP_NOWARN);
|
||||
if (prof_buffer)
|
||||
return 0;
|
||||
|
||||
prof_buffer = alloc_pages_exact(buffer_bytes, GFP_KERNEL|__GFP_ZERO);
|
||||
prof_buffer = alloc_pages_exact(buffer_bytes,
|
||||
GFP_KERNEL|__GFP_ZERO|__GFP_NOWARN);
|
||||
if (prof_buffer)
|
||||
return 0;
|
||||
|
||||
|
@@ -1039,16 +1039,14 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
|
||||
if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) {
|
||||
/* We got the lock for task. */
|
||||
debug_rt_mutex_lock(lock);
|
||||
|
||||
rt_mutex_set_owner(lock, task, 0);
|
||||
|
||||
spin_unlock(&lock->wait_lock);
|
||||
rt_mutex_deadlock_account_lock(lock, task);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock);
|
||||
|
||||
|
||||
if (ret && !waiter->task) {
|
||||
/*
|
||||
* Reset the return value. We might have
|
||||
|
@@ -81,8 +81,21 @@ int cpupri_find(struct cpupri *cp, struct task_struct *p,
|
||||
if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids)
|
||||
continue;
|
||||
|
||||
if (lowest_mask)
|
||||
if (lowest_mask) {
|
||||
cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask);
|
||||
|
||||
/*
|
||||
* We have to ensure that we have at least one bit
|
||||
* still set in the array, since the map could have
|
||||
* been concurrently emptied between the first and
|
||||
* second reads of vec->mask. If we hit this
|
||||
* condition, simply act as though we never hit this
|
||||
* priority level and continue on.
|
||||
*/
|
||||
if (cpumask_any(lowest_mask) >= nr_cpu_ids)
|
||||
continue;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -611,9 +611,13 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
|
||||
static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
|
||||
{
|
||||
#ifdef CONFIG_SCHEDSTATS
|
||||
struct task_struct *tsk = NULL;
|
||||
|
||||
if (entity_is_task(se))
|
||||
tsk = task_of(se);
|
||||
|
||||
if (se->sleep_start) {
|
||||
u64 delta = rq_of(cfs_rq)->clock - se->sleep_start;
|
||||
struct task_struct *tsk = task_of(se);
|
||||
|
||||
if ((s64)delta < 0)
|
||||
delta = 0;
|
||||
@@ -624,11 +628,11 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
|
||||
se->sleep_start = 0;
|
||||
se->sum_sleep_runtime += delta;
|
||||
|
||||
account_scheduler_latency(tsk, delta >> 10, 1);
|
||||
if (tsk)
|
||||
account_scheduler_latency(tsk, delta >> 10, 1);
|
||||
}
|
||||
if (se->block_start) {
|
||||
u64 delta = rq_of(cfs_rq)->clock - se->block_start;
|
||||
struct task_struct *tsk = task_of(se);
|
||||
|
||||
if ((s64)delta < 0)
|
||||
delta = 0;
|
||||
@@ -639,17 +643,19 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
|
||||
se->block_start = 0;
|
||||
se->sum_sleep_runtime += delta;
|
||||
|
||||
/*
|
||||
* Blocking time is in units of nanosecs, so shift by 20 to
|
||||
* get a milliseconds-range estimation of the amount of
|
||||
* time that the task spent sleeping:
|
||||
*/
|
||||
if (unlikely(prof_on == SLEEP_PROFILING)) {
|
||||
|
||||
profile_hits(SLEEP_PROFILING, (void *)get_wchan(tsk),
|
||||
delta >> 20);
|
||||
if (tsk) {
|
||||
/*
|
||||
* Blocking time is in units of nanosecs, so shift by
|
||||
* 20 to get a milliseconds-range estimation of the
|
||||
* amount of time that the task spent sleeping:
|
||||
*/
|
||||
if (unlikely(prof_on == SLEEP_PROFILING)) {
|
||||
profile_hits(SLEEP_PROFILING,
|
||||
(void *)get_wchan(tsk),
|
||||
delta >> 20);
|
||||
}
|
||||
account_scheduler_latency(tsk, delta >> 10, 0);
|
||||
}
|
||||
account_scheduler_latency(tsk, delta >> 10, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -2454,11 +2454,9 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
|
||||
stack_t oss;
|
||||
int error;
|
||||
|
||||
if (uoss) {
|
||||
oss.ss_sp = (void __user *) current->sas_ss_sp;
|
||||
oss.ss_size = current->sas_ss_size;
|
||||
oss.ss_flags = sas_ss_flags(sp);
|
||||
}
|
||||
oss.ss_sp = (void __user *) current->sas_ss_sp;
|
||||
oss.ss_size = current->sas_ss_size;
|
||||
oss.ss_flags = sas_ss_flags(sp);
|
||||
|
||||
if (uss) {
|
||||
void __user *ss_sp;
|
||||
@@ -2466,10 +2464,12 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
|
||||
int ss_flags;
|
||||
|
||||
error = -EFAULT;
|
||||
if (!access_ok(VERIFY_READ, uss, sizeof(*uss))
|
||||
|| __get_user(ss_sp, &uss->ss_sp)
|
||||
|| __get_user(ss_flags, &uss->ss_flags)
|
||||
|| __get_user(ss_size, &uss->ss_size))
|
||||
if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
|
||||
goto out;
|
||||
error = __get_user(ss_sp, &uss->ss_sp) |
|
||||
__get_user(ss_flags, &uss->ss_flags) |
|
||||
__get_user(ss_size, &uss->ss_size);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
error = -EPERM;
|
||||
@@ -2501,13 +2501,16 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
|
||||
current->sas_ss_size = ss_size;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
if (uoss) {
|
||||
error = -EFAULT;
|
||||
if (copy_to_user(uoss, &oss, sizeof(oss)))
|
||||
if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
|
||||
goto out;
|
||||
error = __put_user(oss.ss_sp, &uoss->ss_sp) |
|
||||
__put_user(oss.ss_size, &uoss->ss_size) |
|
||||
__put_user(oss.ss_flags, &uoss->ss_flags);
|
||||
}
|
||||
|
||||
error = 0;
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
|
||||
return NOTIFY_BAD;
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_CPU_HOTPLUG
|
||||
#ifdef CONFIG_HOTPLUG_CPU
|
||||
case CPU_UP_CANCELED:
|
||||
case CPU_UP_CANCELED_FROZEN:
|
||||
|
||||
|
@@ -49,6 +49,7 @@
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/ftrace.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/slow-work.h>
|
||||
#include <linux/perf_counter.h>
|
||||
|
||||
@@ -1306,10 +1307,10 @@ static struct ctl_table vm_table[] = {
|
||||
{
|
||||
.ctl_name = CTL_UNNUMBERED,
|
||||
.procname = "mmap_min_addr",
|
||||
.data = &mmap_min_addr,
|
||||
.maxlen = sizeof(unsigned long),
|
||||
.data = &dac_mmap_min_addr,
|
||||
.maxlen = sizeof(unsigned long),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_doulongvec_minmax,
|
||||
.proc_handler = &mmap_min_addr_handler,
|
||||
},
|
||||
#ifdef CONFIG_NUMA
|
||||
{
|
||||
|
@@ -137,11 +137,12 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
|
||||
*/
|
||||
int clockevents_register_notifier(struct notifier_block *nb)
|
||||
{
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
spin_lock(&clockevents_lock);
|
||||
spin_lock_irqsave(&clockevents_lock, flags);
|
||||
ret = raw_notifier_chain_register(&clockevents_chain, nb);
|
||||
spin_unlock(&clockevents_lock);
|
||||
spin_unlock_irqrestore(&clockevents_lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -178,16 +179,18 @@ static void clockevents_notify_released(void)
|
||||
*/
|
||||
void clockevents_register_device(struct clock_event_device *dev)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
|
||||
BUG_ON(!dev->cpumask);
|
||||
|
||||
spin_lock(&clockevents_lock);
|
||||
spin_lock_irqsave(&clockevents_lock, flags);
|
||||
|
||||
list_add(&dev->list, &clockevent_devices);
|
||||
clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
|
||||
clockevents_notify_released();
|
||||
|
||||
spin_unlock(&clockevents_lock);
|
||||
spin_unlock_irqrestore(&clockevents_lock, flags);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(clockevents_register_device);
|
||||
|
||||
@@ -235,8 +238,9 @@ void clockevents_exchange_device(struct clock_event_device *old,
|
||||
void clockevents_notify(unsigned long reason, void *arg)
|
||||
{
|
||||
struct list_head *node, *tmp;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock(&clockevents_lock);
|
||||
spin_lock_irqsave(&clockevents_lock, flags);
|
||||
clockevents_do_notify(reason, arg);
|
||||
|
||||
switch (reason) {
|
||||
@@ -251,7 +255,7 @@ void clockevents_notify(unsigned long reason, void *arg)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
spin_unlock(&clockevents_lock);
|
||||
spin_unlock_irqrestore(&clockevents_lock, flags);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(clockevents_notify);
|
||||
#endif
|
||||
|
@@ -205,11 +205,11 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
|
||||
* Powerstate information: The system enters/leaves a state, where
|
||||
* affected devices might stop
|
||||
*/
|
||||
static void tick_do_broadcast_on_off(void *why)
|
||||
static void tick_do_broadcast_on_off(unsigned long *reason)
|
||||
{
|
||||
struct clock_event_device *bc, *dev;
|
||||
struct tick_device *td;
|
||||
unsigned long flags, *reason = why;
|
||||
unsigned long flags;
|
||||
int cpu, bc_stopped;
|
||||
|
||||
spin_lock_irqsave(&tick_broadcast_lock, flags);
|
||||
@@ -276,8 +276,7 @@ void tick_broadcast_on_off(unsigned long reason, int *oncpu)
|
||||
printk(KERN_ERR "tick-broadcast: ignoring broadcast for "
|
||||
"offline CPU #%d\n", *oncpu);
|
||||
else
|
||||
smp_call_function_single(*oncpu, tick_do_broadcast_on_off,
|
||||
&reason, 1);
|
||||
tick_do_broadcast_on_off(&reason);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -286,7 +286,7 @@ static int __init init_timer_list_procfs(void)
|
||||
{
|
||||
struct proc_dir_entry *pe;
|
||||
|
||||
pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
|
||||
pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
|
||||
if (!pe)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
|
@@ -267,8 +267,8 @@ static void blk_trace_free(struct blk_trace *bt)
|
||||
{
|
||||
debugfs_remove(bt->msg_file);
|
||||
debugfs_remove(bt->dropped_file);
|
||||
debugfs_remove(bt->dir);
|
||||
relay_close(bt->rchan);
|
||||
debugfs_remove(bt->dir);
|
||||
free_percpu(bt->sequence);
|
||||
free_percpu(bt->msg_data);
|
||||
kfree(bt);
|
||||
@@ -378,18 +378,8 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
|
||||
|
||||
static int blk_remove_buf_file_callback(struct dentry *dentry)
|
||||
{
|
||||
struct dentry *parent = dentry->d_parent;
|
||||
debugfs_remove(dentry);
|
||||
|
||||
/*
|
||||
* this will fail for all but the last file, but that is ok. what we
|
||||
* care about is the top level buts->name directory going away, when
|
||||
* the last trace file is gone. Then we don't have to rmdir() that
|
||||
* manually on trace stop, so it nicely solves the issue with
|
||||
* force killing of running traces.
|
||||
*/
|
||||
|
||||
debugfs_remove(parent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1662,7 +1662,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
|
||||
|
||||
mutex_lock(&ftrace_regex_lock);
|
||||
if ((file->f_mode & FMODE_WRITE) &&
|
||||
!(file->f_flags & O_APPEND))
|
||||
(file->f_flags & O_TRUNC))
|
||||
ftrace_filter_reset(enable);
|
||||
|
||||
if (file->f_mode & FMODE_READ) {
|
||||
@@ -2278,7 +2278,11 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
|
||||
read++;
|
||||
cnt--;
|
||||
|
||||
if (!(iter->flags & ~FTRACE_ITER_CONT)) {
|
||||
/*
|
||||
* If the parser haven't finished with the last write,
|
||||
* continue reading the user input without skipping spaces.
|
||||
*/
|
||||
if (!(iter->flags & FTRACE_ITER_CONT)) {
|
||||
/* skip white space */
|
||||
while (cnt && isspace(ch)) {
|
||||
ret = get_user(ch, ubuf++);
|
||||
@@ -2288,8 +2292,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
|
||||
cnt--;
|
||||
}
|
||||
|
||||
/* only spaces were written */
|
||||
if (isspace(ch)) {
|
||||
file->f_pos += read;
|
||||
*ppos += read;
|
||||
ret = read;
|
||||
goto out;
|
||||
}
|
||||
@@ -2319,12 +2324,12 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
|
||||
if (ret)
|
||||
goto out;
|
||||
iter->buffer_idx = 0;
|
||||
} else
|
||||
} else {
|
||||
iter->flags |= FTRACE_ITER_CONT;
|
||||
iter->buffer[iter->buffer_idx++] = ch;
|
||||
}
|
||||
|
||||
|
||||
file->f_pos += read;
|
||||
|
||||
*ppos += read;
|
||||
ret = read;
|
||||
out:
|
||||
mutex_unlock(&ftrace_regex_lock);
|
||||
@@ -2577,7 +2582,7 @@ ftrace_graph_open(struct inode *inode, struct file *file)
|
||||
|
||||
mutex_lock(&graph_lock);
|
||||
if ((file->f_mode & FMODE_WRITE) &&
|
||||
!(file->f_flags & O_APPEND)) {
|
||||
(file->f_flags & O_TRUNC)) {
|
||||
ftrace_graph_count = 0;
|
||||
memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs));
|
||||
}
|
||||
@@ -2595,6 +2600,14 @@ ftrace_graph_open(struct inode *inode, struct file *file)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
ftrace_graph_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
if (file->f_mode & FMODE_READ)
|
||||
seq_release(inode, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ftrace_set_func(unsigned long *array, int *idx, char *buffer)
|
||||
{
|
||||
@@ -2724,9 +2737,10 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
|
||||
}
|
||||
|
||||
static const struct file_operations ftrace_graph_fops = {
|
||||
.open = ftrace_graph_open,
|
||||
.read = seq_read,
|
||||
.write = ftrace_graph_write,
|
||||
.open = ftrace_graph_open,
|
||||
.read = seq_read,
|
||||
.write = ftrace_graph_write,
|
||||
.release = ftrace_graph_release,
|
||||
};
|
||||
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
||||
|
||||
|
@@ -735,6 +735,7 @@ ring_buffer_free(struct ring_buffer *buffer)
|
||||
|
||||
put_online_cpus();
|
||||
|
||||
kfree(buffer->buffers);
|
||||
free_cpumask_var(buffer->cpumask);
|
||||
|
||||
kfree(buffer);
|
||||
@@ -1785,7 +1786,7 @@ void ring_buffer_discard_commit(struct ring_buffer *buffer,
|
||||
*/
|
||||
RB_WARN_ON(buffer, !local_read(&cpu_buffer->committing));
|
||||
|
||||
if (!rb_try_to_discard(cpu_buffer, event))
|
||||
if (rb_try_to_discard(cpu_buffer, event))
|
||||
goto out;
|
||||
|
||||
/*
|
||||
@@ -2383,7 +2384,6 @@ rb_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
|
||||
* the box. Return the padding, and we will release
|
||||
* the current locks, and try again.
|
||||
*/
|
||||
rb_advance_reader(cpu_buffer);
|
||||
return event;
|
||||
|
||||
case RINGBUF_TYPE_TIME_EXTEND:
|
||||
@@ -2486,7 +2486,7 @@ static inline int rb_ok_to_lock(void)
|
||||
* buffer too. A one time deal is all you get from reading
|
||||
* the ring buffer from an NMI.
|
||||
*/
|
||||
if (likely(!in_nmi() && !oops_in_progress))
|
||||
if (likely(!in_nmi()))
|
||||
return 1;
|
||||
|
||||
tracing_off_permanent();
|
||||
@@ -2519,6 +2519,8 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
|
||||
if (dolock)
|
||||
spin_lock(&cpu_buffer->reader_lock);
|
||||
event = rb_buffer_peek(buffer, cpu, ts);
|
||||
if (event && event->type_len == RINGBUF_TYPE_PADDING)
|
||||
rb_advance_reader(cpu_buffer);
|
||||
if (dolock)
|
||||
spin_unlock(&cpu_buffer->reader_lock);
|
||||
local_irq_restore(flags);
|
||||
@@ -2590,12 +2592,9 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)
|
||||
spin_lock(&cpu_buffer->reader_lock);
|
||||
|
||||
event = rb_buffer_peek(buffer, cpu, ts);
|
||||
if (!event)
|
||||
goto out_unlock;
|
||||
if (event)
|
||||
rb_advance_reader(cpu_buffer);
|
||||
|
||||
rb_advance_reader(cpu_buffer);
|
||||
|
||||
out_unlock:
|
||||
if (dolock)
|
||||
spin_unlock(&cpu_buffer->reader_lock);
|
||||
local_irq_restore(flags);
|
||||
|
@@ -848,6 +848,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags,
|
||||
((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) |
|
||||
(need_resched() ? TRACE_FLAG_NEED_RESCHED : 0);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tracing_generic_entry_update);
|
||||
|
||||
struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr,
|
||||
int type,
|
||||
@@ -2031,7 +2032,7 @@ static int tracing_open(struct inode *inode, struct file *file)
|
||||
|
||||
/* If this file was open for write, then erase contents */
|
||||
if ((file->f_mode & FMODE_WRITE) &&
|
||||
!(file->f_flags & O_APPEND)) {
|
||||
(file->f_flags & O_TRUNC)) {
|
||||
long cpu = (long) inode->i_private;
|
||||
|
||||
if (cpu == TRACE_PIPE_ALL_CPU)
|
||||
@@ -3085,7 +3086,8 @@ tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter)
|
||||
break;
|
||||
}
|
||||
|
||||
trace_consume(iter);
|
||||
if (ret != TRACE_TYPE_NO_CONSUME)
|
||||
trace_consume(iter);
|
||||
rem -= count;
|
||||
if (!find_next_entry_inc(iter)) {
|
||||
rem = 0;
|
||||
@@ -3894,17 +3896,9 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
switch (val) {
|
||||
case 0:
|
||||
trace_flags &= ~(1 << index);
|
||||
break;
|
||||
case 1:
|
||||
trace_flags |= 1 << index;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (val != 0 && val != 1)
|
||||
return -EINVAL;
|
||||
}
|
||||
set_tracer_flags(1 << index, val);
|
||||
|
||||
*ppos += cnt;
|
||||
|
||||
@@ -4233,8 +4227,11 @@ static void __ftrace_dump(bool disable_tracing)
|
||||
iter.pos = -1;
|
||||
|
||||
if (find_next_entry_inc(&iter) != NULL) {
|
||||
print_trace_line(&iter);
|
||||
trace_consume(&iter);
|
||||
int ret;
|
||||
|
||||
ret = print_trace_line(&iter);
|
||||
if (ret != TRACE_TYPE_NO_CONSUME)
|
||||
trace_consume(&iter);
|
||||
}
|
||||
|
||||
trace_printk_seq(&iter.seq);
|
||||
|
@@ -438,10 +438,6 @@ struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
|
||||
struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
|
||||
int *ent_cpu, u64 *ent_ts);
|
||||
|
||||
void tracing_generic_entry_update(struct trace_entry *entry,
|
||||
unsigned long flags,
|
||||
int pc);
|
||||
|
||||
void default_wait_pipe(struct trace_iterator *iter);
|
||||
void poll_wait_pipe(struct trace_iterator *iter);
|
||||
|
||||
|
@@ -14,7 +14,7 @@ int ftrace_profile_enable(int event_id)
|
||||
|
||||
mutex_lock(&event_mutex);
|
||||
list_for_each_entry(event, &ftrace_events, list) {
|
||||
if (event->id == event_id) {
|
||||
if (event->id == event_id && event->profile_enable) {
|
||||
ret = event->profile_enable(event);
|
||||
break;
|
||||
}
|
||||
|
@@ -376,7 +376,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file)
|
||||
const struct seq_operations *seq_ops;
|
||||
|
||||
if ((file->f_mode & FMODE_WRITE) &&
|
||||
!(file->f_flags & O_APPEND))
|
||||
(file->f_flags & O_TRUNC))
|
||||
ftrace_clear_events();
|
||||
|
||||
seq_ops = inode->i_private;
|
||||
@@ -940,7 +940,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
|
||||
entry = trace_create_file("enable", 0644, call->dir, call,
|
||||
enable);
|
||||
|
||||
if (call->id)
|
||||
if (call->id && call->profile_enable)
|
||||
entry = trace_create_file("id", 0444, call->dir, call,
|
||||
id);
|
||||
|
||||
|
@@ -624,9 +624,6 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
filter->preds[filter->n_preds] = pred;
|
||||
filter->n_preds++;
|
||||
|
||||
list_for_each_entry(call, &ftrace_events, list) {
|
||||
|
||||
if (!call->define_fields)
|
||||
@@ -643,6 +640,9 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
|
||||
}
|
||||
replace_filter_string(call->filter, filter_string);
|
||||
}
|
||||
|
||||
filter->preds[filter->n_preds] = pred;
|
||||
filter->n_preds++;
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
@@ -1029,12 +1029,17 @@ static int replace_preds(struct event_subsystem *system,
|
||||
|
||||
if (elt->op == OP_AND || elt->op == OP_OR) {
|
||||
pred = create_logical_pred(elt->op);
|
||||
if (!pred)
|
||||
return -ENOMEM;
|
||||
if (call) {
|
||||
err = filter_add_pred(ps, call, pred);
|
||||
filter_free_pred(pred);
|
||||
} else
|
||||
} else {
|
||||
err = filter_add_subsystem_pred(ps, system,
|
||||
pred, filter_string);
|
||||
if (err)
|
||||
filter_free_pred(pred);
|
||||
}
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -1048,12 +1053,17 @@ static int replace_preds(struct event_subsystem *system,
|
||||
}
|
||||
|
||||
pred = create_pred(elt->op, operand1, operand2);
|
||||
if (!pred)
|
||||
return -ENOMEM;
|
||||
if (call) {
|
||||
err = filter_add_pred(ps, call, pred);
|
||||
filter_free_pred(pred);
|
||||
} else
|
||||
} else {
|
||||
err = filter_add_subsystem_pred(ps, system, pred,
|
||||
filter_string);
|
||||
if (err)
|
||||
filter_free_pred(pred);
|
||||
}
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@@ -843,9 +843,16 @@ print_graph_function(struct trace_iterator *iter)
|
||||
|
||||
switch (entry->type) {
|
||||
case TRACE_GRAPH_ENT: {
|
||||
struct ftrace_graph_ent_entry *field;
|
||||
/*
|
||||
* print_graph_entry() may consume the current event,
|
||||
* thus @field may become invalid, so we need to save it.
|
||||
* sizeof(struct ftrace_graph_ent_entry) is very small,
|
||||
* it can be safely saved at the stack.
|
||||
*/
|
||||
struct ftrace_graph_ent_entry *field, saved;
|
||||
trace_assign_type(field, entry);
|
||||
return print_graph_entry(field, s, iter);
|
||||
saved = *field;
|
||||
return print_graph_entry(&saved, s, iter);
|
||||
}
|
||||
case TRACE_GRAPH_RET: {
|
||||
struct ftrace_graph_ret_entry *field;
|
||||
|
@@ -176,7 +176,7 @@ static int t_show(struct seq_file *m, void *v)
|
||||
const char *str = *fmt;
|
||||
int i;
|
||||
|
||||
seq_printf(m, "0x%lx : \"", (unsigned long)fmt);
|
||||
seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt);
|
||||
|
||||
/*
|
||||
* Tabs and new lines need to be converted.
|
||||
|
@@ -301,17 +301,14 @@ static const struct seq_operations stack_trace_seq_ops = {
|
||||
|
||||
static int stack_trace_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = seq_open(file, &stack_trace_seq_ops);
|
||||
|
||||
return ret;
|
||||
return seq_open(file, &stack_trace_seq_ops);
|
||||
}
|
||||
|
||||
static const struct file_operations stack_trace_fops = {
|
||||
.open = stack_trace_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = seq_release,
|
||||
};
|
||||
|
||||
int
|
||||
|
@@ -73,7 +73,7 @@ static struct rb_node *release_next(struct rb_node *node)
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_stat_session(struct stat_session *session)
|
||||
static void __reset_stat_session(struct stat_session *session)
|
||||
{
|
||||
struct rb_node *node = session->stat_root.rb_node;
|
||||
|
||||
@@ -83,10 +83,17 @@ static void reset_stat_session(struct stat_session *session)
|
||||
session->stat_root = RB_ROOT;
|
||||
}
|
||||
|
||||
static void reset_stat_session(struct stat_session *session)
|
||||
{
|
||||
mutex_lock(&session->stat_mutex);
|
||||
__reset_stat_session(session);
|
||||
mutex_unlock(&session->stat_mutex);
|
||||
}
|
||||
|
||||
static void destroy_session(struct stat_session *session)
|
||||
{
|
||||
debugfs_remove(session->file);
|
||||
reset_stat_session(session);
|
||||
__reset_stat_session(session);
|
||||
mutex_destroy(&session->stat_mutex);
|
||||
kfree(session);
|
||||
}
|
||||
@@ -150,7 +157,7 @@ static int stat_seq_init(struct stat_session *session)
|
||||
int i;
|
||||
|
||||
mutex_lock(&session->stat_mutex);
|
||||
reset_stat_session(session);
|
||||
__reset_stat_session(session);
|
||||
|
||||
if (!ts->stat_cmp)
|
||||
ts->stat_cmp = dummy_cmp;
|
||||
@@ -183,7 +190,7 @@ exit:
|
||||
return ret;
|
||||
|
||||
exit_free_rbtree:
|
||||
reset_stat_session(session);
|
||||
__reset_stat_session(session);
|
||||
mutex_unlock(&session->stat_mutex);
|
||||
return ret;
|
||||
}
|
||||
@@ -250,16 +257,21 @@ static const struct seq_operations trace_stat_seq_ops = {
|
||||
static int tracing_stat_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct seq_file *m;
|
||||
struct stat_session *session = inode->i_private;
|
||||
|
||||
ret = stat_seq_init(session);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = seq_open(file, &trace_stat_seq_ops);
|
||||
if (!ret) {
|
||||
struct seq_file *m = file->private_data;
|
||||
m->private = session;
|
||||
ret = stat_seq_init(session);
|
||||
if (ret) {
|
||||
reset_stat_session(session);
|
||||
return ret;
|
||||
}
|
||||
|
||||
m = file->private_data;
|
||||
m->private = session;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -270,11 +282,9 @@ static int tracing_stat_release(struct inode *i, struct file *f)
|
||||
{
|
||||
struct stat_session *session = i->i_private;
|
||||
|
||||
mutex_lock(&session->stat_mutex);
|
||||
reset_stat_session(session);
|
||||
mutex_unlock(&session->stat_mutex);
|
||||
|
||||
return 0;
|
||||
return seq_release(i, f);
|
||||
}
|
||||
|
||||
static const struct file_operations tracing_stat_fops = {
|
||||
|
@@ -10,13 +10,14 @@
|
||||
#include <linux/wait.h>
|
||||
#include <linux/hash.h>
|
||||
|
||||
void init_waitqueue_head(wait_queue_head_t *q)
|
||||
void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *key)
|
||||
{
|
||||
spin_lock_init(&q->lock);
|
||||
lockdep_set_class(&q->lock, key);
|
||||
INIT_LIST_HEAD(&q->task_list);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(init_waitqueue_head);
|
||||
EXPORT_SYMBOL(__init_waitqueue_head);
|
||||
|
||||
void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
|
||||
{
|
||||
|
Reference in New Issue
Block a user