diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/futex.c | 28 | ||||
| -rw-r--r-- | kernel/futex_compat.c | 6 | ||||
| -rw-r--r-- | kernel/irq/manage.c | 17 | ||||
| -rw-r--r-- | kernel/irq/numa_migrate.c | 4 | ||||
| -rw-r--r-- | kernel/lockdep_proc.c | 3 | ||||
| -rw-r--r-- | kernel/perf_counter.c | 581 | ||||
| -rw-r--r-- | kernel/posix-cpu-timers.c | 7 | ||||
| -rw-r--r-- | kernel/rtmutex.c | 4 | ||||
| -rw-r--r-- | kernel/trace/blktrace.c | 12 | ||||
| -rw-r--r-- | kernel/trace/ring_buffer.c | 15 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 1 | ||||
| -rw-r--r-- | kernel/trace/trace.h | 4 | ||||
| -rw-r--r-- | kernel/trace/trace_events_filter.c | 20 | ||||
| -rw-r--r-- | kernel/wait.c | 5 |
14 files changed, 460 insertions, 247 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index 0672ff88f159..e18cfbdc7190 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -1010,15 +1010,19 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1, | |||
| 1010 | * requeue_pi_wake_futex() - Wake a task that acquired the lock during requeue | 1010 | * requeue_pi_wake_futex() - Wake a task that acquired the lock during requeue |
| 1011 | * q: the futex_q | 1011 | * q: the futex_q |
| 1012 | * key: the key of the requeue target futex | 1012 | * key: the key of the requeue target futex |
| 1013 | * hb: the hash_bucket of the requeue target futex | ||
| 1013 | * | 1014 | * |
| 1014 | * During futex_requeue, with requeue_pi=1, it is possible to acquire the | 1015 | * During futex_requeue, with requeue_pi=1, it is possible to acquire the |
| 1015 | * target futex if it is uncontended or via a lock steal. Set the futex_q key | 1016 | * target futex if it is uncontended or via a lock steal. Set the futex_q key |
| 1016 | * to the requeue target futex so the waiter can detect the wakeup on the right | 1017 | * to the requeue target futex so the waiter can detect the wakeup on the right |
| 1017 | * futex, but remove it from the hb and NULL the rt_waiter so it can detect | 1018 | * futex, but remove it from the hb and NULL the rt_waiter so it can detect |
| 1018 | * atomic lock acquisition. Must be called with the q->lock_ptr held. | 1019 | * atomic lock acquisition. Set the q->lock_ptr to the requeue target hb->lock |
| 1020 | * to protect access to the pi_state to fixup the owner later. Must be called | ||
| 1021 | * with both q->lock_ptr and hb->lock held. | ||
| 1019 | */ | 1022 | */ |
| 1020 | static inline | 1023 | static inline |
| 1021 | void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key) | 1024 | void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key, |
| 1025 | struct futex_hash_bucket *hb) | ||
| 1022 | { | 1026 | { |
| 1023 | drop_futex_key_refs(&q->key); | 1027 | drop_futex_key_refs(&q->key); |
| 1024 | get_futex_key_refs(key); | 1028 | get_futex_key_refs(key); |
| @@ -1030,6 +1034,11 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key) | |||
| 1030 | WARN_ON(!q->rt_waiter); | 1034 | WARN_ON(!q->rt_waiter); |
| 1031 | q->rt_waiter = NULL; | 1035 | q->rt_waiter = NULL; |
| 1032 | 1036 | ||
| 1037 | q->lock_ptr = &hb->lock; | ||
| 1038 | #ifdef CONFIG_DEBUG_PI_LIST | ||
| 1039 | q->list.plist.lock = &hb->lock; | ||
| 1040 | #endif | ||
| 1041 | |||
| 1033 | wake_up_state(q->task, TASK_NORMAL); | 1042 | wake_up_state(q->task, TASK_NORMAL); |
| 1034 | } | 1043 | } |
| 1035 | 1044 | ||
| @@ -1088,7 +1097,7 @@ static int futex_proxy_trylock_atomic(u32 __user *pifutex, | |||
| 1088 | ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task, | 1097 | ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task, |
| 1089 | set_waiters); | 1098 | set_waiters); |
| 1090 | if (ret == 1) | 1099 | if (ret == 1) |
| 1091 | requeue_pi_wake_futex(top_waiter, key2); | 1100 | requeue_pi_wake_futex(top_waiter, key2, hb2); |
| 1092 | 1101 | ||
| 1093 | return ret; | 1102 | return ret; |
| 1094 | } | 1103 | } |
| @@ -1247,8 +1256,15 @@ retry_private: | |||
| 1247 | if (!match_futex(&this->key, &key1)) | 1256 | if (!match_futex(&this->key, &key1)) |
| 1248 | continue; | 1257 | continue; |
| 1249 | 1258 | ||
| 1250 | WARN_ON(!requeue_pi && this->rt_waiter); | 1259 | /* |
| 1251 | WARN_ON(requeue_pi && !this->rt_waiter); | 1260 | * FUTEX_WAIT_REQEUE_PI and FUTEX_CMP_REQUEUE_PI should always |
| 1261 | * be paired with each other and no other futex ops. | ||
| 1262 | */ | ||
| 1263 | if ((requeue_pi && !this->rt_waiter) || | ||
| 1264 | (!requeue_pi && this->rt_waiter)) { | ||
| 1265 | ret = -EINVAL; | ||
| 1266 | break; | ||
| 1267 | } | ||
| 1252 | 1268 | ||
| 1253 | /* | 1269 | /* |
| 1254 | * Wake nr_wake waiters. For requeue_pi, if we acquired the | 1270 | * Wake nr_wake waiters. For requeue_pi, if we acquired the |
| @@ -1273,7 +1289,7 @@ retry_private: | |||
| 1273 | this->task, 1); | 1289 | this->task, 1); |
| 1274 | if (ret == 1) { | 1290 | if (ret == 1) { |
| 1275 | /* We got the lock. */ | 1291 | /* We got the lock. */ |
| 1276 | requeue_pi_wake_futex(this, &key2); | 1292 | requeue_pi_wake_futex(this, &key2, hb2); |
| 1277 | continue; | 1293 | continue; |
| 1278 | } else if (ret) { | 1294 | } else if (ret) { |
| 1279 | /* -EDEADLK */ | 1295 | /* -EDEADLK */ |
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c index d607a5b9ee29..235716556bf1 100644 --- a/kernel/futex_compat.c +++ b/kernel/futex_compat.c | |||
| @@ -180,7 +180,8 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val, | |||
| 180 | int cmd = op & FUTEX_CMD_MASK; | 180 | int cmd = op & FUTEX_CMD_MASK; |
| 181 | 181 | ||
| 182 | if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || | 182 | if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || |
| 183 | cmd == FUTEX_WAIT_BITSET)) { | 183 | cmd == FUTEX_WAIT_BITSET || |
| 184 | cmd == FUTEX_WAIT_REQUEUE_PI)) { | ||
| 184 | if (get_compat_timespec(&ts, utime)) | 185 | if (get_compat_timespec(&ts, utime)) |
| 185 | return -EFAULT; | 186 | return -EFAULT; |
| 186 | if (!timespec_valid(&ts)) | 187 | if (!timespec_valid(&ts)) |
| @@ -191,7 +192,8 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val, | |||
| 191 | t = ktime_add_safe(ktime_get(), t); | 192 | t = ktime_add_safe(ktime_get(), t); |
| 192 | tp = &t; | 193 | tp = &t; |
| 193 | } | 194 | } |
| 194 | if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE) | 195 | if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || |
| 196 | cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) | ||
| 195 | val2 = (int) (unsigned long) utime; | 197 | val2 = (int) (unsigned long) utime; |
| 196 | 198 | ||
| 197 | return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); | 199 | return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 61c679db4687..d222515a5a06 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
| @@ -761,7 +761,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
| 761 | { | 761 | { |
| 762 | struct irq_desc *desc = irq_to_desc(irq); | 762 | struct irq_desc *desc = irq_to_desc(irq); |
| 763 | struct irqaction *action, **action_ptr; | 763 | struct irqaction *action, **action_ptr; |
| 764 | struct task_struct *irqthread; | ||
| 765 | unsigned long flags; | 764 | unsigned long flags; |
| 766 | 765 | ||
| 767 | WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); | 766 | WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); |
| @@ -809,9 +808,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
| 809 | desc->chip->disable(irq); | 808 | desc->chip->disable(irq); |
| 810 | } | 809 | } |
| 811 | 810 | ||
| 812 | irqthread = action->thread; | ||
| 813 | action->thread = NULL; | ||
| 814 | |||
| 815 | spin_unlock_irqrestore(&desc->lock, flags); | 811 | spin_unlock_irqrestore(&desc->lock, flags); |
| 816 | 812 | ||
| 817 | unregister_handler_proc(irq, action); | 813 | unregister_handler_proc(irq, action); |
| @@ -819,12 +815,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
| 819 | /* Make sure it's not being used on another CPU: */ | 815 | /* Make sure it's not being used on another CPU: */ |
| 820 | synchronize_irq(irq); | 816 | synchronize_irq(irq); |
| 821 | 817 | ||
| 822 | if (irqthread) { | ||
| 823 | if (!test_bit(IRQTF_DIED, &action->thread_flags)) | ||
| 824 | kthread_stop(irqthread); | ||
| 825 | put_task_struct(irqthread); | ||
| 826 | } | ||
| 827 | |||
| 828 | #ifdef CONFIG_DEBUG_SHIRQ | 818 | #ifdef CONFIG_DEBUG_SHIRQ |
| 829 | /* | 819 | /* |
| 830 | * It's a shared IRQ -- the driver ought to be prepared for an IRQ | 820 | * It's a shared IRQ -- the driver ought to be prepared for an IRQ |
| @@ -840,6 +830,13 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
| 840 | local_irq_restore(flags); | 830 | local_irq_restore(flags); |
| 841 | } | 831 | } |
| 842 | #endif | 832 | #endif |
| 833 | |||
| 834 | if (action->thread) { | ||
| 835 | if (!test_bit(IRQTF_DIED, &action->thread_flags)) | ||
| 836 | kthread_stop(action->thread); | ||
| 837 | put_task_struct(action->thread); | ||
| 838 | } | ||
| 839 | |||
| 843 | return action; | 840 | return action; |
| 844 | } | 841 | } |
| 845 | 842 | ||
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c index 2f69bee57bf2..3fd30197da2e 100644 --- a/kernel/irq/numa_migrate.c +++ b/kernel/irq/numa_migrate.c | |||
| @@ -107,8 +107,8 @@ out_unlock: | |||
| 107 | 107 | ||
| 108 | struct irq_desc *move_irq_desc(struct irq_desc *desc, int node) | 108 | struct irq_desc *move_irq_desc(struct irq_desc *desc, int node) |
| 109 | { | 109 | { |
| 110 | /* those all static, do move them */ | 110 | /* those static or target node is -1, do not move them */ |
| 111 | if (desc->irq < NR_IRQS_LEGACY) | 111 | if (desc->irq < NR_IRQS_LEGACY || node == -1) |
| 112 | return desc; | 112 | return desc; |
| 113 | 113 | ||
| 114 | if (desc->node != node) | 114 | if (desc->node != node) |
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c index d7135aa2d2c4..e94caa666dba 100644 --- a/kernel/lockdep_proc.c +++ b/kernel/lockdep_proc.c | |||
| @@ -758,7 +758,8 @@ static int __init lockdep_proc_init(void) | |||
| 758 | &proc_lockdep_stats_operations); | 758 | &proc_lockdep_stats_operations); |
| 759 | 759 | ||
| 760 | #ifdef CONFIG_LOCK_STAT | 760 | #ifdef CONFIG_LOCK_STAT |
| 761 | proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations); | 761 | proc_create("lock_stat", S_IRUSR | S_IWUSR, NULL, |
| 762 | &proc_lock_stat_operations); | ||
| 762 | #endif | 763 | #endif |
| 763 | 764 | ||
| 764 | return 0; | 765 | return 0; |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 673c1aaf7332..534e20d14d63 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
| @@ -88,6 +88,7 @@ void __weak hw_perf_disable(void) { barrier(); } | |||
| 88 | void __weak hw_perf_enable(void) { barrier(); } | 88 | void __weak hw_perf_enable(void) { barrier(); } |
| 89 | 89 | ||
| 90 | void __weak hw_perf_counter_setup(int cpu) { barrier(); } | 90 | void __weak hw_perf_counter_setup(int cpu) { barrier(); } |
| 91 | void __weak hw_perf_counter_setup_online(int cpu) { barrier(); } | ||
| 91 | 92 | ||
| 92 | int __weak | 93 | int __weak |
| 93 | hw_perf_group_sched_in(struct perf_counter *group_leader, | 94 | hw_perf_group_sched_in(struct perf_counter *group_leader, |
| @@ -306,6 +307,10 @@ counter_sched_out(struct perf_counter *counter, | |||
| 306 | return; | 307 | return; |
| 307 | 308 | ||
| 308 | counter->state = PERF_COUNTER_STATE_INACTIVE; | 309 | counter->state = PERF_COUNTER_STATE_INACTIVE; |
| 310 | if (counter->pending_disable) { | ||
| 311 | counter->pending_disable = 0; | ||
| 312 | counter->state = PERF_COUNTER_STATE_OFF; | ||
| 313 | } | ||
| 309 | counter->tstamp_stopped = ctx->time; | 314 | counter->tstamp_stopped = ctx->time; |
| 310 | counter->pmu->disable(counter); | 315 | counter->pmu->disable(counter); |
| 311 | counter->oncpu = -1; | 316 | counter->oncpu = -1; |
| @@ -1691,7 +1696,32 @@ static int perf_release(struct inode *inode, struct file *file) | |||
| 1691 | return 0; | 1696 | return 0; |
| 1692 | } | 1697 | } |
| 1693 | 1698 | ||
| 1694 | static u64 perf_counter_read_tree(struct perf_counter *counter) | 1699 | static int perf_counter_read_size(struct perf_counter *counter) |
| 1700 | { | ||
| 1701 | int entry = sizeof(u64); /* value */ | ||
| 1702 | int size = 0; | ||
| 1703 | int nr = 1; | ||
| 1704 | |||
| 1705 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) | ||
| 1706 | size += sizeof(u64); | ||
| 1707 | |||
| 1708 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) | ||
| 1709 | size += sizeof(u64); | ||
| 1710 | |||
| 1711 | if (counter->attr.read_format & PERF_FORMAT_ID) | ||
| 1712 | entry += sizeof(u64); | ||
| 1713 | |||
| 1714 | if (counter->attr.read_format & PERF_FORMAT_GROUP) { | ||
| 1715 | nr += counter->group_leader->nr_siblings; | ||
| 1716 | size += sizeof(u64); | ||
| 1717 | } | ||
| 1718 | |||
| 1719 | size += entry * nr; | ||
| 1720 | |||
| 1721 | return size; | ||
| 1722 | } | ||
| 1723 | |||
| 1724 | static u64 perf_counter_read_value(struct perf_counter *counter) | ||
| 1695 | { | 1725 | { |
| 1696 | struct perf_counter *child; | 1726 | struct perf_counter *child; |
| 1697 | u64 total = 0; | 1727 | u64 total = 0; |
| @@ -1703,14 +1733,96 @@ static u64 perf_counter_read_tree(struct perf_counter *counter) | |||
| 1703 | return total; | 1733 | return total; |
| 1704 | } | 1734 | } |
| 1705 | 1735 | ||
| 1736 | static int perf_counter_read_entry(struct perf_counter *counter, | ||
| 1737 | u64 read_format, char __user *buf) | ||
| 1738 | { | ||
| 1739 | int n = 0, count = 0; | ||
| 1740 | u64 values[2]; | ||
| 1741 | |||
| 1742 | values[n++] = perf_counter_read_value(counter); | ||
| 1743 | if (read_format & PERF_FORMAT_ID) | ||
| 1744 | values[n++] = primary_counter_id(counter); | ||
| 1745 | |||
| 1746 | count = n * sizeof(u64); | ||
| 1747 | |||
| 1748 | if (copy_to_user(buf, values, count)) | ||
| 1749 | return -EFAULT; | ||
| 1750 | |||
| 1751 | return count; | ||
| 1752 | } | ||
| 1753 | |||
| 1754 | static int perf_counter_read_group(struct perf_counter *counter, | ||
| 1755 | u64 read_format, char __user *buf) | ||
| 1756 | { | ||
| 1757 | struct perf_counter *leader = counter->group_leader, *sub; | ||
| 1758 | int n = 0, size = 0, err = -EFAULT; | ||
| 1759 | u64 values[3]; | ||
| 1760 | |||
| 1761 | values[n++] = 1 + leader->nr_siblings; | ||
| 1762 | if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) { | ||
| 1763 | values[n++] = leader->total_time_enabled + | ||
| 1764 | atomic64_read(&leader->child_total_time_enabled); | ||
| 1765 | } | ||
| 1766 | if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) { | ||
| 1767 | values[n++] = leader->total_time_running + | ||
| 1768 | atomic64_read(&leader->child_total_time_running); | ||
| 1769 | } | ||
| 1770 | |||
| 1771 | size = n * sizeof(u64); | ||
| 1772 | |||
| 1773 | if (copy_to_user(buf, values, size)) | ||
| 1774 | return -EFAULT; | ||
| 1775 | |||
| 1776 | err = perf_counter_read_entry(leader, read_format, buf + size); | ||
| 1777 | if (err < 0) | ||
| 1778 | return err; | ||
| 1779 | |||
| 1780 | size += err; | ||
| 1781 | |||
| 1782 | list_for_each_entry(sub, &leader->sibling_list, list_entry) { | ||
| 1783 | err = perf_counter_read_entry(counter, read_format, | ||
| 1784 | buf + size); | ||
| 1785 | if (err < 0) | ||
| 1786 | return err; | ||
| 1787 | |||
| 1788 | size += err; | ||
| 1789 | } | ||
| 1790 | |||
| 1791 | return size; | ||
| 1792 | } | ||
| 1793 | |||
| 1794 | static int perf_counter_read_one(struct perf_counter *counter, | ||
| 1795 | u64 read_format, char __user *buf) | ||
| 1796 | { | ||
| 1797 | u64 values[4]; | ||
| 1798 | int n = 0; | ||
| 1799 | |||
| 1800 | values[n++] = perf_counter_read_value(counter); | ||
| 1801 | if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) { | ||
| 1802 | values[n++] = counter->total_time_enabled + | ||
| 1803 | atomic64_read(&counter->child_total_time_enabled); | ||
| 1804 | } | ||
| 1805 | if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) { | ||
| 1806 | values[n++] = counter->total_time_running + | ||
| 1807 | atomic64_read(&counter->child_total_time_running); | ||
| 1808 | } | ||
| 1809 | if (read_format & PERF_FORMAT_ID) | ||
| 1810 | values[n++] = primary_counter_id(counter); | ||
| 1811 | |||
| 1812 | if (copy_to_user(buf, values, n * sizeof(u64))) | ||
| 1813 | return -EFAULT; | ||
| 1814 | |||
| 1815 | return n * sizeof(u64); | ||
| 1816 | } | ||
| 1817 | |||
| 1706 | /* | 1818 | /* |
| 1707 | * Read the performance counter - simple non blocking version for now | 1819 | * Read the performance counter - simple non blocking version for now |
| 1708 | */ | 1820 | */ |
| 1709 | static ssize_t | 1821 | static ssize_t |
| 1710 | perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count) | 1822 | perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count) |
| 1711 | { | 1823 | { |
| 1712 | u64 values[4]; | 1824 | u64 read_format = counter->attr.read_format; |
| 1713 | int n; | 1825 | int ret; |
| 1714 | 1826 | ||
| 1715 | /* | 1827 | /* |
| 1716 | * Return end-of-file for a read on a counter that is in | 1828 | * Return end-of-file for a read on a counter that is in |
| @@ -1720,28 +1832,18 @@ perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count) | |||
| 1720 | if (counter->state == PERF_COUNTER_STATE_ERROR) | 1832 | if (counter->state == PERF_COUNTER_STATE_ERROR) |
| 1721 | return 0; | 1833 | return 0; |
| 1722 | 1834 | ||
| 1835 | if (count < perf_counter_read_size(counter)) | ||
| 1836 | return -ENOSPC; | ||
| 1837 | |||
| 1723 | WARN_ON_ONCE(counter->ctx->parent_ctx); | 1838 | WARN_ON_ONCE(counter->ctx->parent_ctx); |
| 1724 | mutex_lock(&counter->child_mutex); | 1839 | mutex_lock(&counter->child_mutex); |
| 1725 | values[0] = perf_counter_read_tree(counter); | 1840 | if (read_format & PERF_FORMAT_GROUP) |
| 1726 | n = 1; | 1841 | ret = perf_counter_read_group(counter, read_format, buf); |
| 1727 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) | 1842 | else |
| 1728 | values[n++] = counter->total_time_enabled + | 1843 | ret = perf_counter_read_one(counter, read_format, buf); |
| 1729 | atomic64_read(&counter->child_total_time_enabled); | ||
| 1730 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) | ||
| 1731 | values[n++] = counter->total_time_running + | ||
| 1732 | atomic64_read(&counter->child_total_time_running); | ||
| 1733 | if (counter->attr.read_format & PERF_FORMAT_ID) | ||
| 1734 | values[n++] = primary_counter_id(counter); | ||
| 1735 | mutex_unlock(&counter->child_mutex); | 1844 | mutex_unlock(&counter->child_mutex); |
| 1736 | 1845 | ||
| 1737 | if (count < n * sizeof(u64)) | 1846 | return ret; |
| 1738 | return -EINVAL; | ||
| 1739 | count = n * sizeof(u64); | ||
| 1740 | |||
| 1741 | if (copy_to_user(buf, values, count)) | ||
| 1742 | return -EFAULT; | ||
| 1743 | |||
| 1744 | return count; | ||
| 1745 | } | 1847 | } |
| 1746 | 1848 | ||
| 1747 | static ssize_t | 1849 | static ssize_t |
| @@ -2245,7 +2347,7 @@ static void perf_pending_counter(struct perf_pending_entry *entry) | |||
| 2245 | 2347 | ||
| 2246 | if (counter->pending_disable) { | 2348 | if (counter->pending_disable) { |
| 2247 | counter->pending_disable = 0; | 2349 | counter->pending_disable = 0; |
| 2248 | perf_counter_disable(counter); | 2350 | __perf_counter_disable(counter); |
| 2249 | } | 2351 | } |
| 2250 | 2352 | ||
| 2251 | if (counter->pending_wakeup) { | 2353 | if (counter->pending_wakeup) { |
| @@ -2630,7 +2732,80 @@ static u32 perf_counter_tid(struct perf_counter *counter, struct task_struct *p) | |||
| 2630 | return task_pid_nr_ns(p, counter->ns); | 2732 | return task_pid_nr_ns(p, counter->ns); |
| 2631 | } | 2733 | } |
| 2632 | 2734 | ||
| 2633 | static void perf_counter_output(struct perf_counter *counter, int nmi, | 2735 | static void perf_output_read_one(struct perf_output_handle *handle, |
| 2736 | struct perf_counter *counter) | ||
| 2737 | { | ||
| 2738 | u64 read_format = counter->attr.read_format; | ||
| 2739 | u64 values[4]; | ||
| 2740 | int n = 0; | ||
| 2741 | |||
| 2742 | values[n++] = atomic64_read(&counter->count); | ||
| 2743 | if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) { | ||
| 2744 | values[n++] = counter->total_time_enabled + | ||
| 2745 | atomic64_read(&counter->child_total_time_enabled); | ||
| 2746 | } | ||
| 2747 | if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) { | ||
| 2748 | values[n++] = counter->total_time_running + | ||
| 2749 | atomic64_read(&counter->child_total_time_running); | ||
| 2750 | } | ||
| 2751 | if (read_format & PERF_FORMAT_ID) | ||
| 2752 | values[n++] = primary_counter_id(counter); | ||
| 2753 | |||
| 2754 | perf_output_copy(handle, values, n * sizeof(u64)); | ||
| 2755 | } | ||
| 2756 | |||
| 2757 | /* | ||
| 2758 | * XXX PERF_FORMAT_GROUP vs inherited counters seems difficult. | ||
| 2759 | */ | ||
| 2760 | static void perf_output_read_group(struct perf_output_handle *handle, | ||
| 2761 | struct perf_counter *counter) | ||
| 2762 | { | ||
| 2763 | struct perf_counter *leader = counter->group_leader, *sub; | ||
| 2764 | u64 read_format = counter->attr.read_format; | ||
| 2765 | u64 values[5]; | ||
| 2766 | int n = 0; | ||
| 2767 | |||
| 2768 | values[n++] = 1 + leader->nr_siblings; | ||
| 2769 | |||
| 2770 | if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) | ||
| 2771 | values[n++] = leader->total_time_enabled; | ||
| 2772 | |||
| 2773 | if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) | ||
| 2774 | values[n++] = leader->total_time_running; | ||
| 2775 | |||
| 2776 | if (leader != counter) | ||
| 2777 | leader->pmu->read(leader); | ||
| 2778 | |||
| 2779 | values[n++] = atomic64_read(&leader->count); | ||
| 2780 | if (read_format & PERF_FORMAT_ID) | ||
| 2781 | values[n++] = primary_counter_id(leader); | ||
| 2782 | |||
| 2783 | perf_output_copy(handle, values, n * sizeof(u64)); | ||
| 2784 | |||
| 2785 | list_for_each_entry(sub, &leader->sibling_list, list_entry) { | ||
| 2786 | n = 0; | ||
| 2787 | |||
| 2788 | if (sub != counter) | ||
| 2789 | sub->pmu->read(sub); | ||
| 2790 | |||
| 2791 | values[n++] = atomic64_read(&sub->count); | ||
| 2792 | if (read_format & PERF_FORMAT_ID) | ||
| 2793 | values[n++] = primary_counter_id(sub); | ||
| 2794 | |||
| 2795 | perf_output_copy(handle, values, n * sizeof(u64)); | ||
| 2796 | } | ||
| 2797 | } | ||
| 2798 | |||
| 2799 | static void perf_output_read(struct perf_output_handle *handle, | ||
| 2800 | struct perf_counter *counter) | ||
| 2801 | { | ||
| 2802 | if (counter->attr.read_format & PERF_FORMAT_GROUP) | ||
| 2803 | perf_output_read_group(handle, counter); | ||
| 2804 | else | ||
| 2805 | perf_output_read_one(handle, counter); | ||
| 2806 | } | ||
| 2807 | |||
| 2808 | void perf_counter_output(struct perf_counter *counter, int nmi, | ||
| 2634 | struct perf_sample_data *data) | 2809 | struct perf_sample_data *data) |
| 2635 | { | 2810 | { |
| 2636 | int ret; | 2811 | int ret; |
| @@ -2641,10 +2816,6 @@ static void perf_counter_output(struct perf_counter *counter, int nmi, | |||
| 2641 | struct { | 2816 | struct { |
| 2642 | u32 pid, tid; | 2817 | u32 pid, tid; |
| 2643 | } tid_entry; | 2818 | } tid_entry; |
| 2644 | struct { | ||
| 2645 | u64 id; | ||
| 2646 | u64 counter; | ||
| 2647 | } group_entry; | ||
| 2648 | struct perf_callchain_entry *callchain = NULL; | 2819 | struct perf_callchain_entry *callchain = NULL; |
| 2649 | int callchain_size = 0; | 2820 | int callchain_size = 0; |
| 2650 | u64 time; | 2821 | u64 time; |
| @@ -2699,10 +2870,8 @@ static void perf_counter_output(struct perf_counter *counter, int nmi, | |||
| 2699 | if (sample_type & PERF_SAMPLE_PERIOD) | 2870 | if (sample_type & PERF_SAMPLE_PERIOD) |
| 2700 | header.size += sizeof(u64); | 2871 | header.size += sizeof(u64); |
| 2701 | 2872 | ||
| 2702 | if (sample_type & PERF_SAMPLE_GROUP) { | 2873 | if (sample_type & PERF_SAMPLE_READ) |
| 2703 | header.size += sizeof(u64) + | 2874 | header.size += perf_counter_read_size(counter); |
| 2704 | counter->nr_siblings * sizeof(group_entry); | ||
| 2705 | } | ||
| 2706 | 2875 | ||
| 2707 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { | 2876 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { |
| 2708 | callchain = perf_callchain(data->regs); | 2877 | callchain = perf_callchain(data->regs); |
| @@ -2714,6 +2883,18 @@ static void perf_counter_output(struct perf_counter *counter, int nmi, | |||
| 2714 | header.size += sizeof(u64); | 2883 | header.size += sizeof(u64); |
| 2715 | } | 2884 | } |
| 2716 | 2885 | ||
| 2886 | if (sample_type & PERF_SAMPLE_RAW) { | ||
| 2887 | int size = sizeof(u32); | ||
| 2888 | |||
| 2889 | if (data->raw) | ||
| 2890 | size += data->raw->size; | ||
| 2891 | else | ||
| 2892 | size += sizeof(u32); | ||
| 2893 | |||
| 2894 | WARN_ON_ONCE(size & (sizeof(u64)-1)); | ||
| 2895 | header.size += size; | ||
| 2896 | } | ||
| 2897 | |||
| 2717 | ret = perf_output_begin(&handle, counter, header.size, nmi, 1); | 2898 | ret = perf_output_begin(&handle, counter, header.size, nmi, 1); |
| 2718 | if (ret) | 2899 | if (ret) |
| 2719 | return; | 2900 | return; |
| @@ -2747,26 +2928,8 @@ static void perf_counter_output(struct perf_counter *counter, int nmi, | |||
| 2747 | if (sample_type & PERF_SAMPLE_PERIOD) | 2928 | if (sample_type & PERF_SAMPLE_PERIOD) |
| 2748 | perf_output_put(&handle, data->period); | 2929 | perf_output_put(&handle, data->period); |
| 2749 | 2930 | ||
| 2750 | /* | 2931 | if (sample_type & PERF_SAMPLE_READ) |
| 2751 | * XXX PERF_SAMPLE_GROUP vs inherited counters seems difficult. | 2932 | perf_output_read(&handle, counter); |
| 2752 | */ | ||
| 2753 | if (sample_type & PERF_SAMPLE_GROUP) { | ||
| 2754 | struct perf_counter *leader, *sub; | ||
| 2755 | u64 nr = counter->nr_siblings; | ||
| 2756 | |||
| 2757 | perf_output_put(&handle, nr); | ||
| 2758 | |||
| 2759 | leader = counter->group_leader; | ||
| 2760 | list_for_each_entry(sub, &leader->sibling_list, list_entry) { | ||
| 2761 | if (sub != counter) | ||
| 2762 | sub->pmu->read(sub); | ||
| 2763 | |||
| 2764 | group_entry.id = primary_counter_id(sub); | ||
| 2765 | group_entry.counter = atomic64_read(&sub->count); | ||
| 2766 | |||
| 2767 | perf_output_put(&handle, group_entry); | ||
| 2768 | } | ||
| 2769 | } | ||
| 2770 | 2933 | ||
| 2771 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { | 2934 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { |
| 2772 | if (callchain) | 2935 | if (callchain) |
| @@ -2777,6 +2940,22 @@ static void perf_counter_output(struct perf_counter *counter, int nmi, | |||
| 2777 | } | 2940 | } |
| 2778 | } | 2941 | } |
| 2779 | 2942 | ||
| 2943 | if (sample_type & PERF_SAMPLE_RAW) { | ||
| 2944 | if (data->raw) { | ||
| 2945 | perf_output_put(&handle, data->raw->size); | ||
| 2946 | perf_output_copy(&handle, data->raw->data, data->raw->size); | ||
| 2947 | } else { | ||
| 2948 | struct { | ||
| 2949 | u32 size; | ||
| 2950 | u32 data; | ||
| 2951 | } raw = { | ||
| 2952 | .size = sizeof(u32), | ||
| 2953 | .data = 0, | ||
| 2954 | }; | ||
| 2955 | perf_output_put(&handle, raw); | ||
| 2956 | } | ||
| 2957 | } | ||
| 2958 | |||
| 2780 | perf_output_end(&handle); | 2959 | perf_output_end(&handle); |
| 2781 | } | 2960 | } |
| 2782 | 2961 | ||
| @@ -2789,8 +2968,6 @@ struct perf_read_event { | |||
| 2789 | 2968 | ||
| 2790 | u32 pid; | 2969 | u32 pid; |
| 2791 | u32 tid; | 2970 | u32 tid; |
| 2792 | u64 value; | ||
| 2793 | u64 format[3]; | ||
| 2794 | }; | 2971 | }; |
| 2795 | 2972 | ||
| 2796 | static void | 2973 | static void |
| @@ -2802,34 +2979,20 @@ perf_counter_read_event(struct perf_counter *counter, | |||
| 2802 | .header = { | 2979 | .header = { |
| 2803 | .type = PERF_EVENT_READ, | 2980 | .type = PERF_EVENT_READ, |
| 2804 | .misc = 0, | 2981 | .misc = 0, |
| 2805 | .size = sizeof(event) - sizeof(event.format), | 2982 | .size = sizeof(event) + perf_counter_read_size(counter), |
| 2806 | }, | 2983 | }, |
| 2807 | .pid = perf_counter_pid(counter, task), | 2984 | .pid = perf_counter_pid(counter, task), |
| 2808 | .tid = perf_counter_tid(counter, task), | 2985 | .tid = perf_counter_tid(counter, task), |
| 2809 | .value = atomic64_read(&counter->count), | ||
| 2810 | }; | 2986 | }; |
| 2811 | int ret, i = 0; | 2987 | int ret; |
| 2812 | |||
| 2813 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) { | ||
| 2814 | event.header.size += sizeof(u64); | ||
| 2815 | event.format[i++] = counter->total_time_enabled; | ||
| 2816 | } | ||
| 2817 | |||
| 2818 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) { | ||
| 2819 | event.header.size += sizeof(u64); | ||
| 2820 | event.format[i++] = counter->total_time_running; | ||
| 2821 | } | ||
| 2822 | |||
| 2823 | if (counter->attr.read_format & PERF_FORMAT_ID) { | ||
| 2824 | event.header.size += sizeof(u64); | ||
| 2825 | event.format[i++] = primary_counter_id(counter); | ||
| 2826 | } | ||
| 2827 | 2988 | ||
| 2828 | ret = perf_output_begin(&handle, counter, event.header.size, 0, 0); | 2989 | ret = perf_output_begin(&handle, counter, event.header.size, 0, 0); |
| 2829 | if (ret) | 2990 | if (ret) |
| 2830 | return; | 2991 | return; |
| 2831 | 2992 | ||
| 2832 | perf_output_copy(&handle, &event, event.header.size); | 2993 | perf_output_put(&handle, event); |
| 2994 | perf_output_read(&handle, counter); | ||
| 2995 | |||
| 2833 | perf_output_end(&handle); | 2996 | perf_output_end(&handle); |
| 2834 | } | 2997 | } |
| 2835 | 2998 | ||
| @@ -2840,7 +3003,8 @@ perf_counter_read_event(struct perf_counter *counter, | |||
| 2840 | */ | 3003 | */ |
| 2841 | 3004 | ||
| 2842 | struct perf_task_event { | 3005 | struct perf_task_event { |
| 2843 | struct task_struct *task; | 3006 | struct task_struct *task; |
| 3007 | struct perf_counter_context *task_ctx; | ||
| 2844 | 3008 | ||
| 2845 | struct { | 3009 | struct { |
| 2846 | struct perf_event_header header; | 3010 | struct perf_event_header header; |
| @@ -2864,10 +3028,10 @@ static void perf_counter_task_output(struct perf_counter *counter, | |||
| 2864 | return; | 3028 | return; |
| 2865 | 3029 | ||
| 2866 | task_event->event.pid = perf_counter_pid(counter, task); | 3030 | task_event->event.pid = perf_counter_pid(counter, task); |
| 2867 | task_event->event.ppid = perf_counter_pid(counter, task->real_parent); | 3031 | task_event->event.ppid = perf_counter_pid(counter, current); |
| 2868 | 3032 | ||
| 2869 | task_event->event.tid = perf_counter_tid(counter, task); | 3033 | task_event->event.tid = perf_counter_tid(counter, task); |
| 2870 | task_event->event.ptid = perf_counter_tid(counter, task->real_parent); | 3034 | task_event->event.ptid = perf_counter_tid(counter, current); |
| 2871 | 3035 | ||
| 2872 | perf_output_put(&handle, task_event->event); | 3036 | perf_output_put(&handle, task_event->event); |
| 2873 | perf_output_end(&handle); | 3037 | perf_output_end(&handle); |
| @@ -2900,24 +3064,23 @@ static void perf_counter_task_ctx(struct perf_counter_context *ctx, | |||
| 2900 | static void perf_counter_task_event(struct perf_task_event *task_event) | 3064 | static void perf_counter_task_event(struct perf_task_event *task_event) |
| 2901 | { | 3065 | { |
| 2902 | struct perf_cpu_context *cpuctx; | 3066 | struct perf_cpu_context *cpuctx; |
| 2903 | struct perf_counter_context *ctx; | 3067 | struct perf_counter_context *ctx = task_event->task_ctx; |
| 2904 | 3068 | ||
| 2905 | cpuctx = &get_cpu_var(perf_cpu_context); | 3069 | cpuctx = &get_cpu_var(perf_cpu_context); |
| 2906 | perf_counter_task_ctx(&cpuctx->ctx, task_event); | 3070 | perf_counter_task_ctx(&cpuctx->ctx, task_event); |
| 2907 | put_cpu_var(perf_cpu_context); | 3071 | put_cpu_var(perf_cpu_context); |
| 2908 | 3072 | ||
| 2909 | rcu_read_lock(); | 3073 | rcu_read_lock(); |
| 2910 | /* | 3074 | if (!ctx) |
| 2911 | * doesn't really matter which of the child contexts the | 3075 | ctx = rcu_dereference(task_event->task->perf_counter_ctxp); |
| 2912 | * events ends up in. | ||
| 2913 | */ | ||
| 2914 | ctx = rcu_dereference(current->perf_counter_ctxp); | ||
| 2915 | if (ctx) | 3076 | if (ctx) |
| 2916 | perf_counter_task_ctx(ctx, task_event); | 3077 | perf_counter_task_ctx(ctx, task_event); |
| 2917 | rcu_read_unlock(); | 3078 | rcu_read_unlock(); |
| 2918 | } | 3079 | } |
| 2919 | 3080 | ||
| 2920 | static void perf_counter_task(struct task_struct *task, int new) | 3081 | static void perf_counter_task(struct task_struct *task, |
| 3082 | struct perf_counter_context *task_ctx, | ||
| 3083 | int new) | ||
| 2921 | { | 3084 | { |
| 2922 | struct perf_task_event task_event; | 3085 | struct perf_task_event task_event; |
| 2923 | 3086 | ||
| @@ -2927,8 +3090,9 @@ static void perf_counter_task(struct task_struct *task, int new) | |||
| 2927 | return; | 3090 | return; |
| 2928 | 3091 | ||
| 2929 | task_event = (struct perf_task_event){ | 3092 | task_event = (struct perf_task_event){ |
| 2930 | .task = task, | 3093 | .task = task, |
| 2931 | .event = { | 3094 | .task_ctx = task_ctx, |
| 3095 | .event = { | ||
| 2932 | .header = { | 3096 | .header = { |
| 2933 | .type = new ? PERF_EVENT_FORK : PERF_EVENT_EXIT, | 3097 | .type = new ? PERF_EVENT_FORK : PERF_EVENT_EXIT, |
| 2934 | .misc = 0, | 3098 | .misc = 0, |
| @@ -2946,7 +3110,7 @@ static void perf_counter_task(struct task_struct *task, int new) | |||
| 2946 | 3110 | ||
| 2947 | void perf_counter_fork(struct task_struct *task) | 3111 | void perf_counter_fork(struct task_struct *task) |
| 2948 | { | 3112 | { |
| 2949 | perf_counter_task(task, 1); | 3113 | perf_counter_task(task, NULL, 1); |
| 2950 | } | 3114 | } |
| 2951 | 3115 | ||
| 2952 | /* | 3116 | /* |
| @@ -3335,125 +3499,111 @@ int perf_counter_overflow(struct perf_counter *counter, int nmi, | |||
| 3335 | * Generic software counter infrastructure | 3499 | * Generic software counter infrastructure |
| 3336 | */ | 3500 | */ |
| 3337 | 3501 | ||
| 3338 | static void perf_swcounter_update(struct perf_counter *counter) | 3502 | /* |
| 3503 | * We directly increment counter->count and keep a second value in | ||
| 3504 | * counter->hw.period_left to count intervals. This period counter | ||
| 3505 | * is kept in the range [-sample_period, 0] so that we can use the | ||
| 3506 | * sign as trigger. | ||
| 3507 | */ | ||
| 3508 | |||
| 3509 | static u64 perf_swcounter_set_period(struct perf_counter *counter) | ||
| 3339 | { | 3510 | { |
| 3340 | struct hw_perf_counter *hwc = &counter->hw; | 3511 | struct hw_perf_counter *hwc = &counter->hw; |
| 3341 | u64 prev, now; | 3512 | u64 period = hwc->last_period; |
| 3342 | s64 delta; | 3513 | u64 nr, offset; |
| 3514 | s64 old, val; | ||
| 3515 | |||
| 3516 | hwc->last_period = hwc->sample_period; | ||
| 3343 | 3517 | ||
| 3344 | again: | 3518 | again: |
| 3345 | prev = atomic64_read(&hwc->prev_count); | 3519 | old = val = atomic64_read(&hwc->period_left); |
| 3346 | now = atomic64_read(&hwc->count); | 3520 | if (val < 0) |
| 3347 | if (atomic64_cmpxchg(&hwc->prev_count, prev, now) != prev) | 3521 | return 0; |
| 3348 | goto again; | ||
| 3349 | 3522 | ||
| 3350 | delta = now - prev; | 3523 | nr = div64_u64(period + val, period); |
| 3524 | offset = nr * period; | ||
| 3525 | val -= offset; | ||
| 3526 | if (atomic64_cmpxchg(&hwc->period_left, old, val) != old) | ||
| 3527 | goto again; | ||
| 3351 | 3528 | ||
| 3352 | atomic64_add(delta, &counter->count); | 3529 | return nr; |
| 3353 | atomic64_sub(delta, &hwc->period_left); | ||
| 3354 | } | 3530 | } |
| 3355 | 3531 | ||
| 3356 | static void perf_swcounter_set_period(struct perf_counter *counter) | 3532 | static void perf_swcounter_overflow(struct perf_counter *counter, |
| 3533 | int nmi, struct perf_sample_data *data) | ||
| 3357 | { | 3534 | { |
| 3358 | struct hw_perf_counter *hwc = &counter->hw; | 3535 | struct hw_perf_counter *hwc = &counter->hw; |
| 3359 | s64 left = atomic64_read(&hwc->period_left); | 3536 | u64 overflow; |
| 3360 | s64 period = hwc->sample_period; | ||
| 3361 | 3537 | ||
| 3362 | if (unlikely(left <= -period)) { | 3538 | data->period = counter->hw.last_period; |
| 3363 | left = period; | 3539 | overflow = perf_swcounter_set_period(counter); |
| 3364 | atomic64_set(&hwc->period_left, left); | ||
| 3365 | hwc->last_period = period; | ||
| 3366 | } | ||
| 3367 | 3540 | ||
| 3368 | if (unlikely(left <= 0)) { | 3541 | if (hwc->interrupts == MAX_INTERRUPTS) |
| 3369 | left += period; | 3542 | return; |
| 3370 | atomic64_add(period, &hwc->period_left); | ||
| 3371 | hwc->last_period = period; | ||
| 3372 | } | ||
| 3373 | 3543 | ||
| 3374 | atomic64_set(&hwc->prev_count, -left); | 3544 | for (; overflow; overflow--) { |
| 3375 | atomic64_set(&hwc->count, -left); | 3545 | if (perf_counter_overflow(counter, nmi, data)) { |
| 3546 | /* | ||
| 3547 | * We inhibit the overflow from happening when | ||
| 3548 | * hwc->interrupts == MAX_INTERRUPTS. | ||
| 3549 | */ | ||
| 3550 | break; | ||
| 3551 | } | ||
| 3552 | } | ||
| 3376 | } | 3553 | } |
| 3377 | 3554 | ||
| 3378 | static enum hrtimer_restart perf_swcounter_hrtimer(struct hrtimer *hrtimer) | 3555 | static void perf_swcounter_unthrottle(struct perf_counter *counter) |
| 3379 | { | 3556 | { |
| 3380 | enum hrtimer_restart ret = HRTIMER_RESTART; | ||
| 3381 | struct perf_sample_data data; | ||
| 3382 | struct perf_counter *counter; | ||
| 3383 | u64 period; | ||
| 3384 | |||
| 3385 | counter = container_of(hrtimer, struct perf_counter, hw.hrtimer); | ||
| 3386 | counter->pmu->read(counter); | ||
| 3387 | |||
| 3388 | data.addr = 0; | ||
| 3389 | data.regs = get_irq_regs(); | ||
| 3390 | /* | 3557 | /* |
| 3391 | * In case we exclude kernel IPs or are somehow not in interrupt | 3558 | * Nothing to do, we already reset hwc->interrupts. |
| 3392 | * context, provide the next best thing, the user IP. | ||
| 3393 | */ | 3559 | */ |
| 3394 | if ((counter->attr.exclude_kernel || !data.regs) && | 3560 | } |
| 3395 | !counter->attr.exclude_user) | ||
| 3396 | data.regs = task_pt_regs(current); | ||
| 3397 | 3561 | ||
| 3398 | if (data.regs) { | 3562 | static void perf_swcounter_add(struct perf_counter *counter, u64 nr, |
| 3399 | if (perf_counter_overflow(counter, 0, &data)) | 3563 | int nmi, struct perf_sample_data *data) |
| 3400 | ret = HRTIMER_NORESTART; | 3564 | { |
| 3401 | } | 3565 | struct hw_perf_counter *hwc = &counter->hw; |
| 3402 | 3566 | ||
| 3403 | period = max_t(u64, 10000, counter->hw.sample_period); | 3567 | atomic64_add(nr, &counter->count); |
| 3404 | hrtimer_forward_now(hrtimer, ns_to_ktime(period)); | ||
| 3405 | 3568 | ||
| 3406 | return ret; | 3569 | if (!hwc->sample_period) |
| 3407 | } | 3570 | return; |
| 3408 | 3571 | ||
| 3409 | static void perf_swcounter_overflow(struct perf_counter *counter, | 3572 | if (!data->regs) |
| 3410 | int nmi, struct perf_sample_data *data) | 3573 | return; |
| 3411 | { | ||
| 3412 | data->period = counter->hw.last_period; | ||
| 3413 | 3574 | ||
| 3414 | perf_swcounter_update(counter); | 3575 | if (!atomic64_add_negative(nr, &hwc->period_left)) |
| 3415 | perf_swcounter_set_period(counter); | 3576 | perf_swcounter_overflow(counter, nmi, data); |
| 3416 | if (perf_counter_overflow(counter, nmi, data)) | ||
| 3417 | /* soft-disable the counter */ | ||
| 3418 | ; | ||
| 3419 | } | 3577 | } |
| 3420 | 3578 | ||
| 3421 | static int perf_swcounter_is_counting(struct perf_counter *counter) | 3579 | static int perf_swcounter_is_counting(struct perf_counter *counter) |
| 3422 | { | 3580 | { |
| 3423 | struct perf_counter_context *ctx; | 3581 | /* |
| 3424 | unsigned long flags; | 3582 | * The counter is active, we're good! |
| 3425 | int count; | 3583 | */ |
| 3426 | |||
| 3427 | if (counter->state == PERF_COUNTER_STATE_ACTIVE) | 3584 | if (counter->state == PERF_COUNTER_STATE_ACTIVE) |
| 3428 | return 1; | 3585 | return 1; |
| 3429 | 3586 | ||
| 3587 | /* | ||
| 3588 | * The counter is off/error, not counting. | ||
| 3589 | */ | ||
| 3430 | if (counter->state != PERF_COUNTER_STATE_INACTIVE) | 3590 | if (counter->state != PERF_COUNTER_STATE_INACTIVE) |
| 3431 | return 0; | 3591 | return 0; |
| 3432 | 3592 | ||
| 3433 | /* | 3593 | /* |
| 3434 | * If the counter is inactive, it could be just because | 3594 | * The counter is inactive, if the context is active |
| 3435 | * its task is scheduled out, or because it's in a group | 3595 | * we're part of a group that didn't make it on the 'pmu', |
| 3436 | * which could not go on the PMU. We want to count in | 3596 | * not counting. |
| 3437 | * the first case but not the second. If the context is | ||
| 3438 | * currently active then an inactive software counter must | ||
| 3439 | * be the second case. If it's not currently active then | ||
| 3440 | * we need to know whether the counter was active when the | ||
| 3441 | * context was last active, which we can determine by | ||
| 3442 | * comparing counter->tstamp_stopped with ctx->time. | ||
| 3443 | * | ||
| 3444 | * We are within an RCU read-side critical section, | ||
| 3445 | * which protects the existence of *ctx. | ||
| 3446 | */ | 3597 | */ |
| 3447 | ctx = counter->ctx; | 3598 | if (counter->ctx->is_active) |
| 3448 | spin_lock_irqsave(&ctx->lock, flags); | 3599 | return 0; |
| 3449 | count = 1; | 3600 | |
| 3450 | /* Re-check state now we have the lock */ | 3601 | /* |
| 3451 | if (counter->state < PERF_COUNTER_STATE_INACTIVE || | 3602 | * We're inactive and the context is too, this means the |
| 3452 | counter->ctx->is_active || | 3603 | * task is scheduled out, we're counting events that happen |
| 3453 | counter->tstamp_stopped < ctx->time) | 3604 | * to us, like migration events. |
| 3454 | count = 0; | 3605 | */ |
| 3455 | spin_unlock_irqrestore(&ctx->lock, flags); | 3606 | return 1; |
| 3456 | return count; | ||
| 3457 | } | 3607 | } |
| 3458 | 3608 | ||
| 3459 | static int perf_swcounter_match(struct perf_counter *counter, | 3609 | static int perf_swcounter_match(struct perf_counter *counter, |
| @@ -3479,15 +3629,6 @@ static int perf_swcounter_match(struct perf_counter *counter, | |||
| 3479 | return 1; | 3629 | return 1; |
| 3480 | } | 3630 | } |
| 3481 | 3631 | ||
| 3482 | static void perf_swcounter_add(struct perf_counter *counter, u64 nr, | ||
| 3483 | int nmi, struct perf_sample_data *data) | ||
| 3484 | { | ||
| 3485 | int neg = atomic64_add_negative(nr, &counter->hw.count); | ||
| 3486 | |||
| 3487 | if (counter->hw.sample_period && !neg && data->regs) | ||
| 3488 | perf_swcounter_overflow(counter, nmi, data); | ||
| 3489 | } | ||
| 3490 | |||
| 3491 | static void perf_swcounter_ctx_event(struct perf_counter_context *ctx, | 3632 | static void perf_swcounter_ctx_event(struct perf_counter_context *ctx, |
| 3492 | enum perf_type_id type, | 3633 | enum perf_type_id type, |
| 3493 | u32 event, u64 nr, int nmi, | 3634 | u32 event, u64 nr, int nmi, |
| @@ -3566,27 +3707,66 @@ void __perf_swcounter_event(u32 event, u64 nr, int nmi, | |||
| 3566 | 3707 | ||
| 3567 | static void perf_swcounter_read(struct perf_counter *counter) | 3708 | static void perf_swcounter_read(struct perf_counter *counter) |
| 3568 | { | 3709 | { |
| 3569 | perf_swcounter_update(counter); | ||
| 3570 | } | 3710 | } |
| 3571 | 3711 | ||
| 3572 | static int perf_swcounter_enable(struct perf_counter *counter) | 3712 | static int perf_swcounter_enable(struct perf_counter *counter) |
| 3573 | { | 3713 | { |
| 3574 | perf_swcounter_set_period(counter); | 3714 | struct hw_perf_counter *hwc = &counter->hw; |
| 3715 | |||
| 3716 | if (hwc->sample_period) { | ||
| 3717 | hwc->last_period = hwc->sample_period; | ||
| 3718 | perf_swcounter_set_period(counter); | ||
| 3719 | } | ||
| 3575 | return 0; | 3720 | return 0; |
| 3576 | } | 3721 | } |
| 3577 | 3722 | ||
| 3578 | static void perf_swcounter_disable(struct perf_counter *counter) | 3723 | static void perf_swcounter_disable(struct perf_counter *counter) |
| 3579 | { | 3724 | { |
| 3580 | perf_swcounter_update(counter); | ||
| 3581 | } | 3725 | } |
| 3582 | 3726 | ||
| 3583 | static const struct pmu perf_ops_generic = { | 3727 | static const struct pmu perf_ops_generic = { |
| 3584 | .enable = perf_swcounter_enable, | 3728 | .enable = perf_swcounter_enable, |
| 3585 | .disable = perf_swcounter_disable, | 3729 | .disable = perf_swcounter_disable, |
| 3586 | .read = perf_swcounter_read, | 3730 | .read = perf_swcounter_read, |
| 3731 | .unthrottle = perf_swcounter_unthrottle, | ||
| 3587 | }; | 3732 | }; |
| 3588 | 3733 | ||
| 3589 | /* | 3734 | /* |
| 3735 | * hrtimer based swcounter callback | ||
| 3736 | */ | ||
| 3737 | |||
| 3738 | static enum hrtimer_restart perf_swcounter_hrtimer(struct hrtimer *hrtimer) | ||
| 3739 | { | ||
| 3740 | enum hrtimer_restart ret = HRTIMER_RESTART; | ||
| 3741 | struct perf_sample_data data; | ||
| 3742 | struct perf_counter *counter; | ||
| 3743 | u64 period; | ||
| 3744 | |||
| 3745 | counter = container_of(hrtimer, struct perf_counter, hw.hrtimer); | ||
| 3746 | counter->pmu->read(counter); | ||
| 3747 | |||
| 3748 | data.addr = 0; | ||
| 3749 | data.regs = get_irq_regs(); | ||
| 3750 | /* | ||
| 3751 | * In case we exclude kernel IPs or are somehow not in interrupt | ||
| 3752 | * context, provide the next best thing, the user IP. | ||
| 3753 | */ | ||
| 3754 | if ((counter->attr.exclude_kernel || !data.regs) && | ||
| 3755 | !counter->attr.exclude_user) | ||
| 3756 | data.regs = task_pt_regs(current); | ||
| 3757 | |||
| 3758 | if (data.regs) { | ||
| 3759 | if (perf_counter_overflow(counter, 0, &data)) | ||
| 3760 | ret = HRTIMER_NORESTART; | ||
| 3761 | } | ||
| 3762 | |||
| 3763 | period = max_t(u64, 10000, counter->hw.sample_period); | ||
| 3764 | hrtimer_forward_now(hrtimer, ns_to_ktime(period)); | ||
| 3765 | |||
| 3766 | return ret; | ||
| 3767 | } | ||
| 3768 | |||
| 3769 | /* | ||
| 3590 | * Software counter: cpu wall time clock | 3770 | * Software counter: cpu wall time clock |
| 3591 | */ | 3771 | */ |
| 3592 | 3772 | ||
| @@ -3703,17 +3883,24 @@ static const struct pmu perf_ops_task_clock = { | |||
| 3703 | }; | 3883 | }; |
| 3704 | 3884 | ||
| 3705 | #ifdef CONFIG_EVENT_PROFILE | 3885 | #ifdef CONFIG_EVENT_PROFILE |
| 3706 | void perf_tpcounter_event(int event_id) | 3886 | void perf_tpcounter_event(int event_id, u64 addr, u64 count, void *record, |
| 3887 | int entry_size) | ||
| 3707 | { | 3888 | { |
| 3889 | struct perf_raw_record raw = { | ||
| 3890 | .size = entry_size, | ||
| 3891 | .data = record, | ||
| 3892 | }; | ||
| 3893 | |||
| 3708 | struct perf_sample_data data = { | 3894 | struct perf_sample_data data = { |
| 3709 | .regs = get_irq_regs(), | 3895 | .regs = get_irq_regs(), |
| 3710 | .addr = 0, | 3896 | .addr = addr, |
| 3897 | .raw = &raw, | ||
| 3711 | }; | 3898 | }; |
| 3712 | 3899 | ||
| 3713 | if (!data.regs) | 3900 | if (!data.regs) |
| 3714 | data.regs = task_pt_regs(current); | 3901 | data.regs = task_pt_regs(current); |
| 3715 | 3902 | ||
| 3716 | do_perf_swcounter_event(PERF_TYPE_TRACEPOINT, event_id, 1, 1, &data); | 3903 | do_perf_swcounter_event(PERF_TYPE_TRACEPOINT, event_id, count, 1, &data); |
| 3717 | } | 3904 | } |
| 3718 | EXPORT_SYMBOL_GPL(perf_tpcounter_event); | 3905 | EXPORT_SYMBOL_GPL(perf_tpcounter_event); |
| 3719 | 3906 | ||
| @@ -3727,6 +3914,14 @@ static void tp_perf_counter_destroy(struct perf_counter *counter) | |||
| 3727 | 3914 | ||
| 3728 | static const struct pmu *tp_perf_counter_init(struct perf_counter *counter) | 3915 | static const struct pmu *tp_perf_counter_init(struct perf_counter *counter) |
| 3729 | { | 3916 | { |
| 3917 | /* | ||
| 3918 | * Raw tracepoint data is a severe data leak, only allow root to | ||
| 3919 | * have these. | ||
| 3920 | */ | ||
| 3921 | if ((counter->attr.sample_type & PERF_SAMPLE_RAW) && | ||
| 3922 | !capable(CAP_SYS_ADMIN)) | ||
| 3923 | return ERR_PTR(-EPERM); | ||
| 3924 | |||
| 3730 | if (ftrace_profile_enable(counter->attr.config)) | 3925 | if (ftrace_profile_enable(counter->attr.config)) |
| 3731 | return NULL; | 3926 | return NULL; |
| 3732 | 3927 | ||
| @@ -3860,9 +4055,9 @@ perf_counter_alloc(struct perf_counter_attr *attr, | |||
| 3860 | atomic64_set(&hwc->period_left, hwc->sample_period); | 4055 | atomic64_set(&hwc->period_left, hwc->sample_period); |
| 3861 | 4056 | ||
| 3862 | /* | 4057 | /* |
| 3863 | * we currently do not support PERF_SAMPLE_GROUP on inherited counters | 4058 | * we currently do not support PERF_FORMAT_GROUP on inherited counters |
| 3864 | */ | 4059 | */ |
| 3865 | if (attr->inherit && (attr->sample_type & PERF_SAMPLE_GROUP)) | 4060 | if (attr->inherit && (attr->read_format & PERF_FORMAT_GROUP)) |
| 3866 | goto done; | 4061 | goto done; |
| 3867 | 4062 | ||
| 3868 | switch (attr->type) { | 4063 | switch (attr->type) { |
| @@ -4269,7 +4464,7 @@ void perf_counter_exit_task(struct task_struct *child) | |||
| 4269 | unsigned long flags; | 4464 | unsigned long flags; |
| 4270 | 4465 | ||
| 4271 | if (likely(!child->perf_counter_ctxp)) { | 4466 | if (likely(!child->perf_counter_ctxp)) { |
| 4272 | perf_counter_task(child, 0); | 4467 | perf_counter_task(child, NULL, 0); |
| 4273 | return; | 4468 | return; |
| 4274 | } | 4469 | } |
| 4275 | 4470 | ||
| @@ -4289,6 +4484,7 @@ void perf_counter_exit_task(struct task_struct *child) | |||
| 4289 | * incremented the context's refcount before we do put_ctx below. | 4484 | * incremented the context's refcount before we do put_ctx below. |
| 4290 | */ | 4485 | */ |
| 4291 | spin_lock(&child_ctx->lock); | 4486 | spin_lock(&child_ctx->lock); |
| 4487 | child->perf_counter_ctxp = NULL; | ||
| 4292 | /* | 4488 | /* |
| 4293 | * If this context is a clone; unclone it so it can't get | 4489 | * If this context is a clone; unclone it so it can't get |
| 4294 | * swapped to another process while we're removing all | 4490 | * swapped to another process while we're removing all |
| @@ -4302,9 +4498,7 @@ void perf_counter_exit_task(struct task_struct *child) | |||
| 4302 | * won't get any samples after PERF_EVENT_EXIT. We can however still | 4498 | * won't get any samples after PERF_EVENT_EXIT. We can however still |
| 4303 | * get a few PERF_EVENT_READ events. | 4499 | * get a few PERF_EVENT_READ events. |
| 4304 | */ | 4500 | */ |
| 4305 | perf_counter_task(child, 0); | 4501 | perf_counter_task(child, child_ctx, 0); |
| 4306 | |||
| 4307 | child->perf_counter_ctxp = NULL; | ||
| 4308 | 4502 | ||
| 4309 | /* | 4503 | /* |
| 4310 | * We can recurse on the same lock type through: | 4504 | * We can recurse on the same lock type through: |
| @@ -4525,6 +4719,11 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) | |||
| 4525 | perf_counter_init_cpu(cpu); | 4719 | perf_counter_init_cpu(cpu); |
| 4526 | break; | 4720 | break; |
| 4527 | 4721 | ||
| 4722 | case CPU_ONLINE: | ||
| 4723 | case CPU_ONLINE_FROZEN: | ||
| 4724 | hw_perf_counter_setup_online(cpu); | ||
| 4725 | break; | ||
| 4726 | |||
| 4528 | case CPU_DOWN_PREPARE: | 4727 | case CPU_DOWN_PREPARE: |
| 4529 | case CPU_DOWN_PREPARE_FROZEN: | 4728 | case CPU_DOWN_PREPARE_FROZEN: |
| 4530 | perf_counter_exit_cpu(cpu); | 4729 | perf_counter_exit_cpu(cpu); |
| @@ -4549,6 +4748,8 @@ void __init perf_counter_init(void) | |||
| 4549 | { | 4748 | { |
| 4550 | perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE, | 4749 | perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE, |
| 4551 | (void *)(long)smp_processor_id()); | 4750 | (void *)(long)smp_processor_id()); |
| 4751 | perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_ONLINE, | ||
| 4752 | (void *)(long)smp_processor_id()); | ||
| 4552 | register_cpu_notifier(&perf_cpu_nb); | 4753 | register_cpu_notifier(&perf_cpu_nb); |
| 4553 | } | 4754 | } |
| 4554 | 4755 | ||
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index bece7c0b67b2..e33a21cb9407 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
| @@ -521,11 +521,12 @@ void posix_cpu_timers_exit(struct task_struct *tsk) | |||
| 521 | } | 521 | } |
| 522 | void posix_cpu_timers_exit_group(struct task_struct *tsk) | 522 | void posix_cpu_timers_exit_group(struct task_struct *tsk) |
| 523 | { | 523 | { |
| 524 | struct task_cputime cputime; | 524 | struct signal_struct *const sig = tsk->signal; |
| 525 | 525 | ||
| 526 | thread_group_cputimer(tsk, &cputime); | ||
| 527 | cleanup_timers(tsk->signal->cpu_timers, | 526 | cleanup_timers(tsk->signal->cpu_timers, |
| 528 | cputime.utime, cputime.stime, cputime.sum_exec_runtime); | 527 | cputime_add(tsk->utime, sig->utime), |
| 528 | cputime_add(tsk->stime, sig->stime), | ||
| 529 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); | ||
| 529 | } | 530 | } |
| 530 | 531 | ||
| 531 | static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now) | 532 | static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now) |
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c index fcd107a78c5a..29bd4baf9e75 100644 --- a/kernel/rtmutex.c +++ b/kernel/rtmutex.c | |||
| @@ -1039,16 +1039,14 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock, | |||
| 1039 | if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) { | 1039 | if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) { |
| 1040 | /* We got the lock for task. */ | 1040 | /* We got the lock for task. */ |
| 1041 | debug_rt_mutex_lock(lock); | 1041 | debug_rt_mutex_lock(lock); |
| 1042 | |||
| 1043 | rt_mutex_set_owner(lock, task, 0); | 1042 | rt_mutex_set_owner(lock, task, 0); |
| 1044 | 1043 | spin_unlock(&lock->wait_lock); | |
| 1045 | rt_mutex_deadlock_account_lock(lock, task); | 1044 | rt_mutex_deadlock_account_lock(lock, task); |
| 1046 | return 1; | 1045 | return 1; |
| 1047 | } | 1046 | } |
| 1048 | 1047 | ||
| 1049 | ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock); | 1048 | ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock); |
| 1050 | 1049 | ||
| 1051 | |||
| 1052 | if (ret && !waiter->task) { | 1050 | if (ret && !waiter->task) { |
| 1053 | /* | 1051 | /* |
| 1054 | * Reset the return value. We might have | 1052 | * Reset the return value. We might have |
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 1090b0aed9ba..7a34cb563fec 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
| @@ -267,8 +267,8 @@ static void blk_trace_free(struct blk_trace *bt) | |||
| 267 | { | 267 | { |
| 268 | debugfs_remove(bt->msg_file); | 268 | debugfs_remove(bt->msg_file); |
| 269 | debugfs_remove(bt->dropped_file); | 269 | debugfs_remove(bt->dropped_file); |
| 270 | debugfs_remove(bt->dir); | ||
| 271 | relay_close(bt->rchan); | 270 | relay_close(bt->rchan); |
| 271 | debugfs_remove(bt->dir); | ||
| 272 | free_percpu(bt->sequence); | 272 | free_percpu(bt->sequence); |
| 273 | free_percpu(bt->msg_data); | 273 | free_percpu(bt->msg_data); |
| 274 | kfree(bt); | 274 | kfree(bt); |
| @@ -378,18 +378,8 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf, | |||
| 378 | 378 | ||
| 379 | static int blk_remove_buf_file_callback(struct dentry *dentry) | 379 | static int blk_remove_buf_file_callback(struct dentry *dentry) |
| 380 | { | 380 | { |
| 381 | struct dentry *parent = dentry->d_parent; | ||
| 382 | debugfs_remove(dentry); | 381 | debugfs_remove(dentry); |
| 383 | 382 | ||
| 384 | /* | ||
| 385 | * this will fail for all but the last file, but that is ok. what we | ||
| 386 | * care about is the top level buts->name directory going away, when | ||
| 387 | * the last trace file is gone. Then we don't have to rmdir() that | ||
| 388 | * manually on trace stop, so it nicely solves the issue with | ||
| 389 | * force killing of running traces. | ||
| 390 | */ | ||
| 391 | |||
| 392 | debugfs_remove(parent); | ||
| 393 | return 0; | 383 | return 0; |
| 394 | } | 384 | } |
| 395 | 385 | ||
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index bf27bb7a63e2..a330513d96ce 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
| @@ -735,6 +735,7 @@ ring_buffer_free(struct ring_buffer *buffer) | |||
| 735 | 735 | ||
| 736 | put_online_cpus(); | 736 | put_online_cpus(); |
| 737 | 737 | ||
| 738 | kfree(buffer->buffers); | ||
| 738 | free_cpumask_var(buffer->cpumask); | 739 | free_cpumask_var(buffer->cpumask); |
| 739 | 740 | ||
| 740 | kfree(buffer); | 741 | kfree(buffer); |
| @@ -1785,7 +1786,7 @@ void ring_buffer_discard_commit(struct ring_buffer *buffer, | |||
| 1785 | */ | 1786 | */ |
| 1786 | RB_WARN_ON(buffer, !local_read(&cpu_buffer->committing)); | 1787 | RB_WARN_ON(buffer, !local_read(&cpu_buffer->committing)); |
| 1787 | 1788 | ||
| 1788 | if (!rb_try_to_discard(cpu_buffer, event)) | 1789 | if (rb_try_to_discard(cpu_buffer, event)) |
| 1789 | goto out; | 1790 | goto out; |
| 1790 | 1791 | ||
| 1791 | /* | 1792 | /* |
| @@ -2383,7 +2384,6 @@ rb_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts) | |||
| 2383 | * the box. Return the padding, and we will release | 2384 | * the box. Return the padding, and we will release |
| 2384 | * the current locks, and try again. | 2385 | * the current locks, and try again. |
| 2385 | */ | 2386 | */ |
| 2386 | rb_advance_reader(cpu_buffer); | ||
| 2387 | return event; | 2387 | return event; |
| 2388 | 2388 | ||
| 2389 | case RINGBUF_TYPE_TIME_EXTEND: | 2389 | case RINGBUF_TYPE_TIME_EXTEND: |
| @@ -2486,7 +2486,7 @@ static inline int rb_ok_to_lock(void) | |||
| 2486 | * buffer too. A one time deal is all you get from reading | 2486 | * buffer too. A one time deal is all you get from reading |
| 2487 | * the ring buffer from an NMI. | 2487 | * the ring buffer from an NMI. |
| 2488 | */ | 2488 | */ |
| 2489 | if (likely(!in_nmi() && !oops_in_progress)) | 2489 | if (likely(!in_nmi())) |
| 2490 | return 1; | 2490 | return 1; |
| 2491 | 2491 | ||
| 2492 | tracing_off_permanent(); | 2492 | tracing_off_permanent(); |
| @@ -2519,6 +2519,8 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts) | |||
| 2519 | if (dolock) | 2519 | if (dolock) |
| 2520 | spin_lock(&cpu_buffer->reader_lock); | 2520 | spin_lock(&cpu_buffer->reader_lock); |
| 2521 | event = rb_buffer_peek(buffer, cpu, ts); | 2521 | event = rb_buffer_peek(buffer, cpu, ts); |
| 2522 | if (event && event->type_len == RINGBUF_TYPE_PADDING) | ||
| 2523 | rb_advance_reader(cpu_buffer); | ||
| 2522 | if (dolock) | 2524 | if (dolock) |
| 2523 | spin_unlock(&cpu_buffer->reader_lock); | 2525 | spin_unlock(&cpu_buffer->reader_lock); |
| 2524 | local_irq_restore(flags); | 2526 | local_irq_restore(flags); |
| @@ -2590,12 +2592,9 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts) | |||
| 2590 | spin_lock(&cpu_buffer->reader_lock); | 2592 | spin_lock(&cpu_buffer->reader_lock); |
| 2591 | 2593 | ||
| 2592 | event = rb_buffer_peek(buffer, cpu, ts); | 2594 | event = rb_buffer_peek(buffer, cpu, ts); |
| 2593 | if (!event) | 2595 | if (event) |
| 2594 | goto out_unlock; | 2596 | rb_advance_reader(cpu_buffer); |
| 2595 | |||
| 2596 | rb_advance_reader(cpu_buffer); | ||
| 2597 | 2597 | ||
| 2598 | out_unlock: | ||
| 2599 | if (dolock) | 2598 | if (dolock) |
| 2600 | spin_unlock(&cpu_buffer->reader_lock); | 2599 | spin_unlock(&cpu_buffer->reader_lock); |
| 2601 | local_irq_restore(flags); | 2600 | local_irq_restore(flags); |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8930e39b9d8c..c22b40f8f576 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -848,6 +848,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags, | |||
| 848 | ((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) | | 848 | ((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) | |
| 849 | (need_resched() ? TRACE_FLAG_NEED_RESCHED : 0); | 849 | (need_resched() ? TRACE_FLAG_NEED_RESCHED : 0); |
| 850 | } | 850 | } |
| 851 | EXPORT_SYMBOL_GPL(tracing_generic_entry_update); | ||
| 851 | 852 | ||
| 852 | struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr, | 853 | struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr, |
| 853 | int type, | 854 | int type, |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 3548ae5cc780..8b9f4f6e9559 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -438,10 +438,6 @@ struct trace_entry *tracing_get_trace_entry(struct trace_array *tr, | |||
| 438 | struct trace_entry *trace_find_next_entry(struct trace_iterator *iter, | 438 | struct trace_entry *trace_find_next_entry(struct trace_iterator *iter, |
| 439 | int *ent_cpu, u64 *ent_ts); | 439 | int *ent_cpu, u64 *ent_ts); |
| 440 | 440 | ||
| 441 | void tracing_generic_entry_update(struct trace_entry *entry, | ||
| 442 | unsigned long flags, | ||
| 443 | int pc); | ||
| 444 | |||
| 445 | void default_wait_pipe(struct trace_iterator *iter); | 441 | void default_wait_pipe(struct trace_iterator *iter); |
| 446 | void poll_wait_pipe(struct trace_iterator *iter); | 442 | void poll_wait_pipe(struct trace_iterator *iter); |
| 447 | 443 | ||
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 936c621bbf46..f32dc9d1ea7b 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
| @@ -624,9 +624,6 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps, | |||
| 624 | return -ENOSPC; | 624 | return -ENOSPC; |
| 625 | } | 625 | } |
| 626 | 626 | ||
| 627 | filter->preds[filter->n_preds] = pred; | ||
| 628 | filter->n_preds++; | ||
| 629 | |||
| 630 | list_for_each_entry(call, &ftrace_events, list) { | 627 | list_for_each_entry(call, &ftrace_events, list) { |
| 631 | 628 | ||
| 632 | if (!call->define_fields) | 629 | if (!call->define_fields) |
| @@ -643,6 +640,9 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps, | |||
| 643 | } | 640 | } |
| 644 | replace_filter_string(call->filter, filter_string); | 641 | replace_filter_string(call->filter, filter_string); |
| 645 | } | 642 | } |
| 643 | |||
| 644 | filter->preds[filter->n_preds] = pred; | ||
| 645 | filter->n_preds++; | ||
| 646 | out: | 646 | out: |
| 647 | return err; | 647 | return err; |
| 648 | } | 648 | } |
| @@ -1029,12 +1029,17 @@ static int replace_preds(struct event_subsystem *system, | |||
| 1029 | 1029 | ||
| 1030 | if (elt->op == OP_AND || elt->op == OP_OR) { | 1030 | if (elt->op == OP_AND || elt->op == OP_OR) { |
| 1031 | pred = create_logical_pred(elt->op); | 1031 | pred = create_logical_pred(elt->op); |
| 1032 | if (!pred) | ||
| 1033 | return -ENOMEM; | ||
| 1032 | if (call) { | 1034 | if (call) { |
| 1033 | err = filter_add_pred(ps, call, pred); | 1035 | err = filter_add_pred(ps, call, pred); |
| 1034 | filter_free_pred(pred); | 1036 | filter_free_pred(pred); |
| 1035 | } else | 1037 | } else { |
| 1036 | err = filter_add_subsystem_pred(ps, system, | 1038 | err = filter_add_subsystem_pred(ps, system, |
| 1037 | pred, filter_string); | 1039 | pred, filter_string); |
| 1040 | if (err) | ||
| 1041 | filter_free_pred(pred); | ||
| 1042 | } | ||
| 1038 | if (err) | 1043 | if (err) |
| 1039 | return err; | 1044 | return err; |
| 1040 | 1045 | ||
| @@ -1048,12 +1053,17 @@ static int replace_preds(struct event_subsystem *system, | |||
| 1048 | } | 1053 | } |
| 1049 | 1054 | ||
| 1050 | pred = create_pred(elt->op, operand1, operand2); | 1055 | pred = create_pred(elt->op, operand1, operand2); |
| 1056 | if (!pred) | ||
| 1057 | return -ENOMEM; | ||
| 1051 | if (call) { | 1058 | if (call) { |
| 1052 | err = filter_add_pred(ps, call, pred); | 1059 | err = filter_add_pred(ps, call, pred); |
| 1053 | filter_free_pred(pred); | 1060 | filter_free_pred(pred); |
| 1054 | } else | 1061 | } else { |
| 1055 | err = filter_add_subsystem_pred(ps, system, pred, | 1062 | err = filter_add_subsystem_pred(ps, system, pred, |
| 1056 | filter_string); | 1063 | filter_string); |
| 1064 | if (err) | ||
| 1065 | filter_free_pred(pred); | ||
| 1066 | } | ||
| 1057 | if (err) | 1067 | if (err) |
| 1058 | return err; | 1068 | return err; |
| 1059 | 1069 | ||
diff --git a/kernel/wait.c b/kernel/wait.c index ea7c3b4275cf..c4bd3d825f35 100644 --- a/kernel/wait.c +++ b/kernel/wait.c | |||
| @@ -10,13 +10,14 @@ | |||
| 10 | #include <linux/wait.h> | 10 | #include <linux/wait.h> |
| 11 | #include <linux/hash.h> | 11 | #include <linux/hash.h> |
| 12 | 12 | ||
| 13 | void init_waitqueue_head(wait_queue_head_t *q) | 13 | void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *key) |
| 14 | { | 14 | { |
| 15 | spin_lock_init(&q->lock); | 15 | spin_lock_init(&q->lock); |
| 16 | lockdep_set_class(&q->lock, key); | ||
| 16 | INIT_LIST_HEAD(&q->task_list); | 17 | INIT_LIST_HEAD(&q->task_list); |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | EXPORT_SYMBOL(init_waitqueue_head); | 20 | EXPORT_SYMBOL(__init_waitqueue_head); |
| 20 | 21 | ||
| 21 | void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) | 22 | void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) |
| 22 | { | 23 | { |
