History

Merge branch 'perf/urgent' into perf/core

Conflicts: tools/perf/builtin-record.c tools/perf/builtin-top.c tools/perf/perf.h tools/perf/util/top.h Merge reason: resolve these cherry-picking conflicts.

Ingo Molnar committed 14 years ago

Commit 737f24b2 parents 8eedce9 b7c9242920 files · +7205 −46120Browse files

Showing the changes to kernel (16 of 920 files). Show all

Unified · Split

16 files
  1. kernel/events/core.c +14 −5
  2. kernel/events/hw_breakpoint.c +2 −2
  3. kernel/fork.c +5 −2
  4. kernel/irq/autoprobe.c +2 −2
  5. kernel/irq/chip.c +33 −9
  6. kernel/irq/internals.h +1 −1
  7. kernel/irq/manage.c +1 −1
  8. kernel/kprobes.c +5 −1
  9. kernel/params.c +2 −1
  10. kernel/pid.c +2 −2
  11. kernel/power/power.h +22 −2
  12. kernel/power/process.c +5 −2
  13. kernel/power/user.c +4 −2
  14. kernel/relay.c +8 −2
  15. kernel/sched/core.c +0 −1
  16. kernel/sched/fair.c +2 −0
kernel/events/core.c+14−5
@@ -2303,7 +2303,7 @@ do { \ · 2302 unmodified lines
23032303 static DEFINE_PER_CPU(int, perf_throttled_count);
23042304 static DEFINE_PER_CPU(u64, perf_throttled_seq);
23052305
2306−static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
2306+static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count, bool disable)
23072307 {
23082308 struct hw_perf_event *hwc = &event->hw;
23092309 s64 period, sample_period;
@@ -2322,9 +2322,13 @@ static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count) · 12 unmodified lines
23222322 hwc->sample_period = sample_period;
23232323
23242324 if (local64_read(&hwc->period_left) > 8*sample_period) {
2325− event->pmu->stop(event, PERF_EF_UPDATE);
2325+ if (disable)
2326+ event->pmu->stop(event, PERF_EF_UPDATE);
2327+
23262328 local64_set(&hwc->period_left, 0);
2327− event->pmu->start(event, PERF_EF_RELOAD);
2329+
2330+ if (disable)
2331+ event->pmu->start(event, PERF_EF_RELOAD);
23282332 }
23292333 }
23302334
@@ -2350,6 +2354,7 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, · 19 unmodified lines
23502354 return;
23512355
23522356 raw_spin_lock(&ctx->lock);
2357+ perf_pmu_disable(ctx->pmu);
23532358
23542359 list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
23552360 if (event->state != PERF_EVENT_STATE_ACTIVE)
@@ -2381,13 +2386,17 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, · 25 unmodified lines
23812386 /*
23822387 * restart the event
23832388 * reload only if value has changed
2389+ * we have stopped the event so tell that
2390+ * to perf_adjust_period() to avoid stopping it
2391+ * twice.
23842392 */
23852393 if (delta > 0)
2386− perf_adjust_period(event, period, delta);
2394+ perf_adjust_period(event, period, delta, false);
23872395
23882396 event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0);
23892397 }
23902398
2399+ perf_pmu_enable(ctx->pmu);
23912400 raw_spin_unlock(&ctx->lock);
23922401 }
23932402
@@ -4567,7 +4576,7 @@ static int __perf_event_overflow(struct perf_event *event, · 2173 unmodified lines
45674576 hwc->freq_time_stamp = now;
45684577
45694578 if (delta > 0 && delta < 2*TICK_NSEC)
4570− perf_adjust_period(event, delta, hwc->last_period);
4579+ perf_adjust_period(event, delta, hwc->last_period, true);
45714580 }
45724581
45734582 /*
kernel/events/hw_breakpoint.c+2−2
@@ -658,10 +658,10 @@ int __init init_hw_breakpoint(void) · 657 unmodified lines
658658
659659 err_alloc:
660660 for_each_possible_cpu(err_cpu) {
661− if (err_cpu == cpu)
662− break;
663661 for (i = 0; i < TYPE_MAX; i++)
664662 kfree(per_cpu(nr_task_bp_pinned[i], cpu));
663+ if (err_cpu == cpu)
664+ break;
665665 }
666666
667667 return -ENOMEM;
kernel/fork.c+5−2
@@ -66,6 +66,7 @@ · 65 unmodified lines
6666 #include <linux/user-return-notifier.h>
6767 #include <linux/oom.h>
6868 #include <linux/khugepaged.h>
69+#include <linux/signalfd.h>
6970
7071 #include <asm/pgtable.h>
7172 #include <asm/pgalloc.h>
@@ -910,7 +911,7 @@ static int copy_io(unsigned long clone_flags, struct task_struct *tsk) · 838 unmodified lines
910911 return -ENOMEM;
911912
912913 new_ioc->ioprio = ioc->ioprio;
913− put_io_context(new_ioc, NULL);
914+ put_io_context(new_ioc);
914915 }
915916 #endif
916917 return 0;
@@ -935,8 +936,10 @@ static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk) · 18 unmodified lines
935936
936937 void __cleanup_sighand(struct sighand_struct *sighand)
937938 {
938− if (atomic_dec_and_test(&sighand->count))
939+ if (atomic_dec_and_test(&sighand->count)) {
940+ signalfd_cleanup(sighand);
939941 kmem_cache_free(sighand_cachep, sighand);
942+ }
940943 }
941944
942945
kernel/irq/autoprobe.c+2−2
@@ -53,7 +53,7 @@ unsigned long probe_irq_on(void) · 52 unmodified lines
5353 if (desc->irq_data.chip->irq_set_type)
5454 desc->irq_data.chip->irq_set_type(&desc->irq_data,
5555 IRQ_TYPE_PROBE);
56− irq_startup(desc);
56+ irq_startup(desc, false);
5757 }
5858 raw_spin_unlock_irq(&desc->lock);
5959 }
@@ -70,7 +70,7 @@ unsigned long probe_irq_on(void) · 10 unmodified lines
7070 raw_spin_lock_irq(&desc->lock);
7171 if (!desc->action && irq_settings_can_probe(desc)) {
7272 desc->istate |= IRQS_AUTODETECT | IRQS_WAITING;
73− if (irq_startup(desc))
73+ if (irq_startup(desc, false))
7474 desc->istate |= IRQS_PENDING;
7575 }
7676 raw_spin_unlock_irq(&desc->lock);
kernel/irq/chip.c+33−9
@@ -159,19 +159,22 @@ static void irq_state_set_masked(struct irq_desc *desc) · 158 unmodified lines
159159 irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
160160 }
161161
162−int irq_startup(struct irq_desc *desc)
162+int irq_startup(struct irq_desc *desc, bool resend)
163163 {
164+ int ret = 0;
165+
164166 irq_state_clr_disabled(desc);
165167 desc->depth = 0;
166168
167169 if (desc->irq_data.chip->irq_startup) {
168− int ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
170+ ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
169171 irq_state_clr_masked(desc);
170− return ret;
172+ } else {
173+ irq_enable(desc);
171174 }
172−
173− irq_enable(desc);
174− return 0;
175+ if (resend)
176+ check_irq_resend(desc, desc->irq_data.irq);
177+ return ret;
175178 }
176179
177180 void irq_shutdown(struct irq_desc *desc)
@@ -332,6 +335,24 @@ out_unlock: · 154 unmodified lines
332335 }
333336 EXPORT_SYMBOL_GPL(handle_simple_irq);
334337
338+/*
339+ * Called unconditionally from handle_level_irq() and only for oneshot
340+ * interrupts from handle_fasteoi_irq()
341+ */
342+static void cond_unmask_irq(struct irq_desc *desc)
343+{
344+ /*
345+ * We need to unmask in the following cases:
346+ * - Standard level irq (IRQF_ONESHOT is not set)
347+ * - Oneshot irq which did not wake the thread (caused by a
348+ * spurious interrupt or a primary handler handling it
349+ * completely).
350+ */
351+ if (!irqd_irq_disabled(&desc->irq_data) &&
352+ irqd_irq_masked(&desc->irq_data) && !desc->threads_oneshot)
353+ unmask_irq(desc);
354+}
355+
335356 /**
336357 * handle_level_irq - Level type irq handler
337358 * @irq: the interrupt number
@@ -364,8 +385,8 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc) · 26 unmodified lines
364385
365386 handle_irq_event(desc);
366387
367− if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT))
368− unmask_irq(desc);
388+ cond_unmask_irq(desc);
389+
369390 out_unlock:
370391 raw_spin_unlock(&desc->lock);
371392 }
@@ -419,6 +440,9 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) · 47 unmodified lines
419440 preflow_handler(desc);
420441 handle_irq_event(desc);
421442
443+ if (desc->istate & IRQS_ONESHOT)
444+ cond_unmask_irq(desc);
445+
422446 out_eoi:
423447 desc->irq_data.chip->irq_eoi(&desc->irq_data);
424448 out_unlock:
@@ -627,7 +651,7 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, · 202 unmodified lines
627651 irq_settings_set_noprobe(desc);
628652 irq_settings_set_norequest(desc);
629653 irq_settings_set_nothread(desc);
630− irq_startup(desc);
654+ irq_startup(desc, true);
631655 }
632656 out:
633657 irq_put_desc_busunlock(desc, flags);
kernel/irq/internals.h+1−1
@@ -67,7 +67,7 @@ extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, · 66 unmodified lines
6767 extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
6868 extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
6969
70−extern int irq_startup(struct irq_desc *desc);
70+extern int irq_startup(struct irq_desc *desc, bool resend);
7171 extern void irq_shutdown(struct irq_desc *desc);
7272 extern void irq_enable(struct irq_desc *desc);
7373 extern void irq_disable(struct irq_desc *desc);
kernel/irq/manage.c+1−1
@@ -1027,7 +1027,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) · 1026 unmodified lines
10271027 desc->istate |= IRQS_ONESHOT;
10281028
10291029 if (irq_settings_can_autoenable(desc))
1030− irq_startup(desc);
1030+ irq_startup(desc, true);
10311031 else
10321032 /* Undo nested disables: */
10331033 desc->depth = 1;
kernel/kprobes.c+5−1
@@ -1673,8 +1673,12 @@ static int __kprobes pre_handler_kretprobe(struct kprobe *p, · 1672 unmodified lines
16731673 ri->rp = rp;
16741674 ri->task = current;
16751675
1676− if (rp->entry_handler && rp->entry_handler(ri, regs))
1676+ if (rp->entry_handler && rp->entry_handler(ri, regs)) {
1677+ raw_spin_lock_irqsave(&rp->lock, flags);
1678+ hlist_add_head(&ri->hlist, &rp->free_instances);
1679+ raw_spin_unlock_irqrestore(&rp->lock, flags);
16771680 return 0;
1681+ }
16781682
16791683 arch_prepare_kretprobe(ri, regs);
16801684
kernel/params.c+2−1
@@ -97,7 +97,8 @@ static int parse_one(char *param, · 96 unmodified lines
9797 for (i = 0; i < num_params; i++) {
9898 if (parameq(param, params[i].name)) {
9999 /* No one handled NULL, so do it here. */
100− if (!val && params[i].ops->set != param_set_bool)
100+ if (!val && params[i].ops->set != param_set_bool
101+ && params[i].ops->set != param_set_bint)
101102 return -EINVAL;
102103 pr_debug("They are equal! Calling %p\n",
103104 params[i].ops->set);
kernel/pid.c+2−2
@@ -543,12 +543,12 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) · 542 unmodified lines
543543 */
544544 void __init pidhash_init(void)
545545 {
546− int i, pidhash_size;
546+ unsigned int i, pidhash_size;
547547
548548 pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18,
549549 HASH_EARLY | HASH_SMALL,
550550 &pidhash_shift, NULL, 4096);
551− pidhash_size = 1 << pidhash_shift;
551+ pidhash_size = 1U << pidhash_shift;
552552
553553 for (i = 0; i < pidhash_size; i++)
554554 INIT_HLIST_HEAD(&pid_hash[i]);
kernel/power/power.h+22−2
@@ -231,8 +231,28 @@ extern int pm_test_level; · 230 unmodified lines
231231 #ifdef CONFIG_SUSPEND_FREEZER
232232 static inline int suspend_freeze_processes(void)
233233 {
234− int error = freeze_processes();
235− return error ? : freeze_kernel_threads();
234+ int error;
235+
236+ error = freeze_processes();
237+
238+ /*
239+ * freeze_processes() automatically thaws every task if freezing
240+ * fails. So we need not do anything extra upon error.
241+ */
242+ if (error)
243+ goto Finish;
244+
245+ error = freeze_kernel_threads();
246+
247+ /*
248+ * freeze_kernel_threads() thaws only kernel threads upon freezing
249+ * failure. So we have to thaw the userspace tasks ourselves.
250+ */
251+ if (error)
252+ thaw_processes();
253+
254+ Finish:
255+ return error;
236256 }
237257
238258 static inline void suspend_thaw_processes(void)
kernel/power/process.c+5−2
@@ -143,7 +143,10 @@ int freeze_processes(void) · 142 unmodified lines
143143 /**
144144 * freeze_kernel_threads - Make freezable kernel threads go to the refrigerator.
145145 *
146− * On success, returns 0. On failure, -errno and system is fully thawed.
146+ * On success, returns 0. On failure, -errno and only the kernel threads are
147+ * thawed, so as to give a chance to the caller to do additional cleanups
148+ * (if any) before thawing the userspace tasks. So, it is the responsibility
149+ * of the caller to thaw the userspace tasks, when the time is right.
147150 */
148151 int freeze_kernel_threads(void)
149152 {
@@ -159,7 +162,7 @@ int freeze_kernel_threads(void) · 9 unmodified lines
159162 BUG_ON(in_atomic());
160163
161164 if (error)
162− thaw_processes();
165+ thaw_kernel_threads();
163166 return error;
164167 }
165168
kernel/power/user.c+4−2
@@ -249,13 +249,15 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, · 248 unmodified lines
249249 }
250250 pm_restore_gfp_mask();
251251 error = hibernation_snapshot(data->platform_support);
252− if (!error) {
252+ if (error) {
253+ thaw_kernel_threads();
254+ } else {
253255 error = put_user(in_suspend, (int __user *)arg);
254256 if (!error && !freezer_test_done)
255257 data->ready = 1;
256258 if (freezer_test_done) {
257259 freezer_test_done = false;
258− thaw_processes();
260+ thaw_kernel_threads();
259261 }
260262 }
261263 break;
kernel/relay.c+8−2
@@ -164,10 +164,14 @@ depopulate: · 163 unmodified lines
164164 */
165165 static struct rchan_buf *relay_create_buf(struct rchan *chan)
166166 {
167− struct rchan_buf *buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
168− if (!buf)
167+ struct rchan_buf *buf;
168+
169+ if (chan->n_subbufs > UINT_MAX / sizeof(size_t *))
169170 return NULL;
170171
172+ buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
173+ if (!buf)
174+ return NULL;
171175 buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL);
172176 if (!buf->padding)
173177 goto free_buf;
@@ -574,6 +578,8 @@ struct rchan *relay_open(const char *base_filename, · 400 unmodified lines
574578
575579 if (!(subbuf_size && n_subbufs))
576580 return NULL;
581+ if (subbuf_size > UINT_MAX / n_subbufs)
582+ return NULL;
577583
578584 chan = kzalloc(sizeof(struct rchan), GFP_KERNEL);
579585 if (!chan)
kernel/sched/core.c+0−1
@@ -1932,7 +1932,6 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev) · 1931 unmodified lines
19321932 local_irq_enable();
19331933 #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
19341934 finish_lock_switch(rq, prev);
1935− trace_sched_stat_sleeptime(current, rq->clock);
19361935
19371936 fire_sched_in_preempt_notifiers(current);
19381937 if (mm)
kernel/sched/fair.c+2−0
@@ -1003,6 +1003,7 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) · 1002 unmodified lines
10031003 if (unlikely(delta > se->statistics.sleep_max))
10041004 se->statistics.sleep_max = delta;
10051005
1006+ se->statistics.sleep_start = 0;
10061007 se->statistics.sum_sleep_runtime += delta;
10071008
10081009 if (tsk) {
@@ -1019,6 +1020,7 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) · 10 unmodified lines
10191020 if (unlikely(delta > se->statistics.block_max))
10201021 se->statistics.block_max = delta;
10211022
1023+ se->statistics.block_start = 0;
10221024 se->statistics.sum_sleep_runtime += delta;
10231025
10241026 if (tsk) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t