[PATCH] ACPI/NVS: Not save NVS region for new machines to accelerate S3
NVS region is saved and restored unconditionally for machines without nvs_nosave quirk during S3. Tested some new machines and the operation is not necessary. Saving NVS region also affects S2RAM speed. The time of NVS saving and restoring depends on the size of NVS region and it consumes 7~10ms normally. This patch is to make machines produced from 2012 to now not saving NVS region to accelerate S3. Signed-off-by: Lan Tianyu --- drivers/acpi/sleep.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index b3e3cc7..896d8be 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -322,7 +322,12 @@ static struct dmi_system_id acpisleep_dmi_table[] __initdata = { static void acpi_sleep_dmi_check(void) { + int year; + dmi_check_system(acpisleep_dmi_table); + + if (dmi_get_date(DMI_BIOS_DATE, , NULL, NULL) && year >= 2012) + acpi_nvs_nosave_s3(); } /** -- 1.8.4.rc0.1.g8f6a3e5.dirty -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] block:bio.c Cleanup styleguide errors reported by checkpatch.pl
3 styleguide errors cleaned up from checkpatch.pl report for block/bio.c Signed-off-by: Jim Richardson --- block/bio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/bio.c b/block/bio.c index 0ec61c9..41707f0 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1337,7 +1337,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q, if (len <= 0) break; - + if (bytes > len) bytes = len; @@ -1374,7 +1374,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q, out_unmap: for (i = 0; i < nr_pages; i++) { - if(!pages[i]) + if (!pages[i]) break; page_cache_release(pages[i]); } @@ -2025,7 +2025,7 @@ static void __init biovec_init_slabs(void) size = bvs->nr_vecs * sizeof(struct bio_vec); bvs->slab = kmem_cache_create(bvs->name, size, 0, -SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); } } -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH RFCv3 08/14] arm64: introduce aarch64_insn_gen_movewide()
(resending this email in case the first one got caught in your spam filter. sorry.) On Thu, Jul 17, 2014 at 10:41:02AM +0100, Will Deacon wrote: > On Wed, Jul 16, 2014 at 11:04:22PM +0100, Zi Shen Lim wrote: > > On Wed, Jul 16, 2014 at 05:17:15PM +0100, Will Deacon wrote: > > > On Tue, Jul 15, 2014 at 07:25:06AM +0100, Zi Shen Lim wrote: > > > > Introduce function to generate move wide (immediate) instructions. [...] > > > > + switch (variant) { > > > > + case AARCH64_INSN_VARIANT_32BIT: > > > > + BUG_ON(shift != 0 && shift != 16); > > > > + break; > > > > + case AARCH64_INSN_VARIANT_64BIT: > > > > + insn |= BIT(31); > > > > + BUG_ON(shift != 0 && shift != 16 && shift != 32 && > > > > + shift != 48); > > > > > > Would be neater as a nested switch, perhaps? If you reorder the > > > outer-switch, you could probably fall-through too and combine the shift > > > checks. > > > > Not sure I picture what you had in mind... I couldn't come up with a > > neater version with the properties you described. > > > > The alternative I had was using masks instead of integer values, but > > one could argue that while neater, it could also be harder to read: > > > > switch (variant) { > > case AARCH64_INSN_VARIANT_32BIT: > > BUG_ON(shift & ~BIT(4)); > > break; > > case AARCH64_INSN_VARIANT_64BIT: > > insn |= BIT(31); > > BUG_ON(shift & ~GENMASK(5, 4)); > > ... > > I was thinking of using nested switches, but that doesn't fall out like I > hoped. How about: > > switch (variant) { > case AARCH64_INSN_VARIANT_64BIT: > BUG_ON(shift != 32 && shift != 48); Sorry this won't work. For example, on the valid case of shift==0, we'll barf right here - no fallthrough. Shall we just leave the code as is? :) > case AARCH64_INSN_VARIANT_32BIT: > BUG_ON(shift != 0 && shift != 16); > }; > > ? > > Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH RFCv3 01/14] arm64: introduce aarch64_insn_gen_comp_branch_imm()
(resending this email in case the first one got caught in your spam filter. sorry.) On Thu, Jul 17, 2014 at 06:25:26PM +0100, Will Deacon wrote: > On Thu, Jul 17, 2014 at 04:59:10PM +0100, Alexei Starovoitov wrote: > > On Thu, Jul 17, 2014 at 2:19 AM, Will Deacon wrote: > > > On Wed, Jul 16, 2014 at 10:19:31PM +0100, Zi Shen Lim wrote: > > >> > > > >> > Is a BUG_ON justifiable here? Is there not a nicer way to fail? > > >> > > >> In general, it'd be nice if we returned something like -EINVAL and > > >> have all callers handle failures. Today all code gen functions return > > >> the u32 instruction and there's no error handling by callers. > > >> I think following the precedence (aarch64_insn_gen_branch_imm()) > > >> of failing with BUG_ON is a reasonable tradeoff. > > > > > > Well, I don't necessarily agree with that BUG_ON, either :) > > > I take it eBPF doesn't have a `trap' instruction or similar? Otherwise, we > > > could generate that and avoid having to propagate errors directly to the > > > caller. > > > > > >> In this case here, when we hit the default (failure) case, that means > > >> there's a serious error of attempting to use an unsupported > > >> variant. I think we're better off failing hard here than trying to > > >> arbitrarily "fallback" on a default choice. > > > > > > It might be a serious error for BPF, but a BUG_ON brings down the entire > > > machine, which I think is unfortunate. > > > > There is some misunderstanding here. Here BUG_ON will trigger > > only on actual bug in JIT implementation, it cannot be triggered by user. > > eBPF program is verified before it reaches JIT, so all instructions are > > valid and input to JIT is proper. Two instruction are not yet > > implemented in this JIT and they trigger pr_.._once(). > > So I don't see any issue with this usage of BUG_ON > > imo living with silent bugs in JIT is more dangerous. > > > > For the same reason there is no 'trap' instruction in eBPF. > > Static verifier checks that program is valid. If there was a 'trap' > > insn the program would be rejected. Like programs with > > 'div by zero' are rejected. There is normal 'bpf_exit' insn to > > return from the program. > > Ok, so assuming that BPF doesn't have any issues, I take your point. > However, we could very easily re-use these functions for things like SMP > alternatives and kprobes, where simply failing the instruction generation > might be acceptable. > > It just feels like a bit hammer to me, when the machine is probably happily > scheduling user tasks, responding to interrupts, writing data to disk etc. Yes I agree with you Will, it'd be truly unfortunate if we inadvertently allow the entire system to be brought down. Alexei accurately pointed out that if we ever hit such a case, it'd be a bug in the BPF JIT implementation (or bug in other in-kernel implementations). Our BPF JIT implementation actually handles this, making sure that input to the codegen function is valid, or gracefully fail by not JITing and falling back on the core BPF interpreter. This way our JIT will not trigger the BUG_ON. IMO, other future users of these codegen functions should do the same. An alternative would be to throw away all the BUG_ON and have callers check for and handle error conditions. I think this is actually more dangerous as callers who don't handle the error conditions properly may end up causing system crash later with subtle (and quite possibly hard to debug) bugs. > > Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] stating/lustre: fix misuse of current->parent.
current->parent is used by ptrace to redirect some signal delivery to the ptracer. It should only be used by 'ptrace' or 'signal' code. All other users should use current->real_parent, which is the real parent. Signed-off-by: NeilBrown diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 77ee9e58cf87..5c5d2d6470f1 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -909,7 +909,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) sbi->ll_stats_track_id == current->pid) lprocfs_counter_add(sbi->ll_stats, op, count); else if (sbi->ll_stats_track_type == STATS_TRACK_PPID && -sbi->ll_stats_track_id == current->parent->pid) +sbi->ll_stats_track_id == current->real_parent->pid) lprocfs_counter_add(sbi->ll_stats, op, count); else if (sbi->ll_stats_track_type == STATS_TRACK_GID && sbi->ll_stats_track_id == signature.asc Description: PGP signature
Re: [net-next PATCH v2 0/3] Broadcast/Multicast rate limit via Ethtool Coalesce
On Thursday 17 July 2014 06:23 PM, David Laight wrote: >> From: Mugunthan V N >> On Thursday 10 July 2014 05:14 AM, David Miller wrote: >>> From: Mugunthan V N >>> Date: Wed, 9 Jul 2014 12:44:07 +0530 >>> A system/cpu can be loaded by a hacker with flooding of broadcast or multicast packets, to prevent this some Ethernet controllers like CPSW provide a mechanism to limit the broadcast/multicast packet rate via hardware limiters. This patch series enables this feature via Ethtool Coalesce. >>> This is pretty bogus if you ask me. >>> >>> What is the difference from accepting a high rate of unicast packets? >>> I say it is no different. >>> >>> Therefore, this feature makes no sense to me at all. >> Any packet storm can cause an endpoint some issues. Typically packet >> storms will cause the system CPU to thrash resulting is very low system >> performance. >> >> Unicast storms only target a single destination end station, it can be >> easily mitigated by the host adding a blocking entry in the LUT for each >> aggressor. >> >> Broadcast and multicast target multiple end stations, or an entire >> network, not only can it cause CPU thrashing, it can result in loss of >> other broadcast and multicast services. The rate limiting feature allow >> the broadcast and or multicast traffic to be dropped if the rates are >> too high. This eliminates the CPU thrashing issue. It also allows the >> system to analyze the aggressors and block them for future transgressions. > Rate limiting multicast traffic will definitely cause the loss of multicast > services. When a system apply the rate limit, the system should expect to miss some of the broadcast/multicast packet depending on the rate limit it applies. > > My experience of broadcast storms is that many of the ethernet switches > (probably especially the cheap ones) end up using a much slower software? > path for broadcasts. In a broadcast storm they start discarding normal > traffic - to point where a single ssh session becomes unusable. > This is true even when isolated from the storm by a 10M hub. > > Broadcast storms are probably mostly caused by network topology issues. > Especially is switches are sending traffic to 'all ports' while resetting > the spanning tree tables. > This is one more example where broadcast/multicast rate limit can be used. Regards Mugunthan V N -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Scheduler regression from caffcdd8d27ba78730d5540396ce72ad022aff2c
On Thu, Jul 17, 2014 at 14:35:02 +0200, Peter Zijlstra wrote: In any case, can someone who can trigger this run with the below; its 'clean' for me, but supposedly you'll trigger a FAIL somewhere. I got a couple of fail messages. dmesg output is available in the bug as the following attachment: https://bugzilla.kernel.org/attachment.cgi?id=143361 The part of interest is probably: [0.253354] build_sched_groups: got group f255b020 with cpus: [0.253436] build_sched_groups: got group f255b120 with cpus: [0.253519] build_sched_groups: got group f255b1a0 with cpus: [0.253600] build_sched_groups: got group f255b2a0 with cpus: [0.253681] build_sched_groups: got group f255b2e0 with cpus: [0.253762] build_sched_groups: got group f255b320 with cpus: [0.253843] build_sched_groups: got group f255b360 with cpus: [0.254004] build_sched_groups: got group f255b0e0 with cpus: [0.254087] build_sched_groups: got group f255b160 with cpus: [0.254170] build_sched_groups: got group f255b1e0 with cpus: [0.254252] build_sched_groups: FAIL [0.254331] build_sched_groups: got group f255b1a0 with cpus: 0 [0.255004] build_sched_groups: FAIL [0.255084] build_sched_groups: got group f255b1e0 with cpus: 1 I also booted with early printk=keepsched_debug as requested by Dietmar. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH ftrace/core v3 3/3] kprobes: Set IPMODIFY flag only if the probe can change regs->ip
Hi Masami, On Tue, 15 Jul 2014 06:00:35 +, Masami Hiramatsu wrote: > +static int __ftrace_add_filter_ip(struct ftrace_ops *ops, unsigned long ip, > + int *ref) > +{ > + int ret; > + > + /* Try to set given ip to filter */ > + ret = ftrace_set_filter_ip(ops, ip, 0, 0); > + if (ret < 0) > + return ret; > + > + (*ref)++; > + if (*ref == 1) { > + ret = register_ftrace_function(ops); > + if (ret < 0) { > + /* Rollback refcounter and filter */ > + (*ref)--; > + ftrace_set_filter_ip(ops, ip, 1, 0); > + } > + } > + > + return ret; > +} This function also can be changed in a similar way: if (*ref == 0) { ret = register_ftrace_function(ops); if (ret < 0) { /* Rollback filter if failed */ ftrace_set_filter_ip(ops, ip, 1, 0); return ret; } } (*ref)++; return 0; Thanks, Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 05/11] perf, tools: Add support for reading JSON event files
On Fri, 2014-07-11 at 16:59 -0700, Andi Kleen wrote: > From: Andi Kleen > > Add a parser for Intel style JSON event files. This allows > to use an Intel event list directly with perf. The Intel > event lists can be quite large and are too big to store > in unswappable kernel memory. ... > diff --git a/tools/perf/util/jevents.c b/tools/perf/util/jevents.c > new file mode 100644 > index 000..a23f57f > --- /dev/null > +++ b/tools/perf/util/jevents.c > @@ -0,0 +1,246 @@ ... > + > +static void fixname(char *s) > +{ > + for (; *s; s++) > + *s = tolower(*s); > +} On powerpc our event names are always uppercase, it would be nice if the perf list output honoured that. Can we instead just honour whatever case is in the input JSON ? It looks like the event lookup is already case insensitive. cheers -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] ia64: Fix me add register r8
The function user_stack_pointer was not returning the correct value \ as stated by a Fix Me message before the function declaration. I fixed the return value to add register r8 as that register stores dirty pages. Signed-off-by: Nicholas Krause --- arch/ia64/include/asm/ptrace.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/ia64/include/asm/ptrace.h b/arch/ia64/include/asm/ptrace.h index 8451439..eaef692 100644 --- a/arch/ia64/include/asm/ptrace.h +++ b/arch/ia64/include/asm/ptrace.h @@ -53,8 +53,7 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs) { - /* FIXME: should this be bspstore + nr_dirty regs? */ - return regs->ar_bspstore; + return regs->ar_bspstore + regs->r8; } static inline int is_syscall_success(struct pt_regs *regs) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
linux-next: manual merge of the irqchip tree with the trivial tree
Hi Jason, Today's linux-next merge of the irqchip tree got a conflict in drivers/irqchip/irq-gic.c between commit d31e373d0778 ("irq-gic: remove file name from heading comment") from the trivial tree and commit fe7ac63fe539 ("irqchip: gic: Restructuring ARM GIC code") from the irqchip tree. I fixed it up (I just removed the file name from the comment) and can carry the fix as necessary (no action is required). -- Cheers, Stephen Rothwells...@canb.auug.org.au signature.asc Description: PGP signature
[PATCH 2/4] ARM: add IPI tracepoints
The strings used to list IPIs in /proc/interrupts are reused for tracing purposes. Signed-off-by: Nicolas Pitre --- arch/arm/kernel/smp.c | 72 --- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 7c4fada440..daedff319b 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -47,6 +47,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core @@ -430,38 +433,19 @@ void __init smp_prepare_cpus(unsigned int max_cpus) } } -static void (*smp_cross_call)(const struct cpumask *, unsigned int); +static void (*__smp_cross_call)(const struct cpumask *, unsigned int); void __init set_smp_cross_call(void (*fn)(const struct cpumask *, unsigned int)) { - if (!smp_cross_call) - smp_cross_call = fn; -} - -void arch_send_call_function_ipi_mask(const struct cpumask *mask) -{ - smp_cross_call(mask, IPI_CALL_FUNC); -} - -void arch_send_wakeup_ipi_mask(const struct cpumask *mask) -{ - smp_cross_call(mask, IPI_WAKEUP); -} - -void arch_send_call_function_single_ipi(int cpu) -{ - smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE); + if (!__smp_cross_call) + __smp_cross_call = fn; } -#ifdef CONFIG_IRQ_WORK -void arch_irq_work_raise(void) -{ - if (is_smp()) - smp_cross_call(cpumask_of(smp_processor_id()), IPI_IRQ_WORK); -} +static const char *ipi_types[NR_IPI] +#ifdef CONFIG_TRACING +__tracepoint_string #endif - -static const char *ipi_types[NR_IPI] = { += { #define S(x,s) [x] = s S(IPI_WAKEUP, "CPU wakeup interrupts"), S(IPI_TIMER, "Timer broadcast interrupts"), @@ -473,6 +457,12 @@ static const char *ipi_types[NR_IPI] = { S(IPI_COMPLETION, "completion interrupts"), }; +static void smp_cross_call(const struct cpumask *target, unsigned int ipinr) +{ + trace_ipi_raise(target, ipi_types[ipinr]); + __smp_cross_call(target, ipinr); +} + void show_ipi_list(struct seq_file *p, int prec) { unsigned int cpu, i; @@ -499,6 +489,29 @@ u64 smp_irq_stat_cpu(unsigned int cpu) return sum; } +void arch_send_call_function_ipi_mask(const struct cpumask *mask) +{ + smp_cross_call(mask, IPI_CALL_FUNC); +} + +void arch_send_wakeup_ipi_mask(const struct cpumask *mask) +{ + smp_cross_call(mask, IPI_WAKEUP); +} + +void arch_send_call_function_single_ipi(int cpu) +{ + smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE); +} + +#ifdef CONFIG_IRQ_WORK +void arch_irq_work_raise(void) +{ + if (is_smp()) + smp_cross_call(cpumask_of(smp_processor_id()), IPI_IRQ_WORK); +} +#endif + #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST void tick_broadcast(const struct cpumask *mask) { @@ -556,8 +569,10 @@ void handle_IPI(int ipinr, struct pt_regs *regs) unsigned int cpu = smp_processor_id(); struct pt_regs *old_regs = set_irq_regs(regs); - if (ipinr < NR_IPI) + if ((unsigned)ipinr < NR_IPI) { + trace_ipi_entry(ipi_types[ipinr]); __inc_irq_stat(cpu, ipi_irqs[ipinr]); + } switch (ipinr) { case IPI_WAKEUP: @@ -612,6 +627,9 @@ void handle_IPI(int ipinr, struct pt_regs *regs) cpu, ipinr); break; } + + if ((unsigned)ipinr < NR_IPI) + trace_ipi_exit(ipi_types[ipinr]); set_irq_regs(old_regs); } -- 1.8.4.108.g55ea5f6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/4] basic IPI tracing
Part of the energy aware scheduler work is concerned by test and measurement tools such as idlestat[1]. This relies on the ability to trace wake-up events, mainly IRQs and IPIs. While IRQs are already well instrumented with tracepoints, IPIs are rather lacking on that front, and completely invisible on ARM. This series defines generic IPI tracepoints and adds them to ARM and ARM64. An attempt at adding them to X86 is also included for comments. [1] https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/Tools/Idlestat diffstat: arch/arm/kernel/smp.c | 72 arch/arm64/kernel/smp.c| 67 +++--- arch/x86/kernel/smp.c | 16 include/trace/events/ipi.h | 89 4 files changed, 192 insertions(+), 52 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/4] (RFC) X86: add IPI tracepoints
On X86 there are already tracepoints for IRQ vectors through which IPIs are handled. However this is highly X86 specific, and the IPI signaling is not currently traced. This is an attempt at adding generic IPI tracepoints to X86. Signed-off-by: Nicolas Pitre --- arch/x86/kernel/smp.c | 16 1 file changed, 16 insertions(+) diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index be8e1bde07..e154d176cf 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -31,6 +31,12 @@ #include #include #include + +#define CREATE_TRACE_POINTS +#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE +#include + /* * Some notes on x86 processor bugs affecting SMP operation: * @@ -124,11 +130,13 @@ static void native_smp_send_reschedule(int cpu) WARN_ON(1); return; } + trace_ipi_raise(cpumask_of(cpu), tracepoint_string("RESCHEDULE")); apic->send_IPI_mask(cpumask_of(cpu), RESCHEDULE_VECTOR); } void native_send_call_func_single_ipi(int cpu) { + trace_ipi_raise(cpumask_of(cpu), tracepoint_string("CALL_FUNCTION_SINGLE")); apic->send_IPI_mask(cpumask_of(cpu), CALL_FUNCTION_SINGLE_VECTOR); } @@ -136,6 +144,8 @@ void native_send_call_func_ipi(const struct cpumask *mask) { cpumask_var_t allbutself; + trace_ipi_raise(mask, tracepoint_string("CALL_FUNCTION")); + if (!alloc_cpumask_var(, GFP_ATOMIC)) { apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR); return; @@ -252,8 +262,10 @@ finish: */ static inline void __smp_reschedule_interrupt(void) { + trace_ipi_entry(tracepoint_string("RESCHEDULE")); inc_irq_stat(irq_resched_count); scheduler_ipi(); + trace_ipi_exit(tracepoint_string("RESCHEDULE")); } __visible void smp_reschedule_interrupt(struct pt_regs *regs) @@ -291,8 +303,10 @@ __visible void smp_trace_reschedule_interrupt(struct pt_regs *regs) static inline void __smp_call_function_interrupt(void) { + trace_ipi_entry(tracepoint_string("CALL_FUNCTION")); generic_smp_call_function_interrupt(); inc_irq_stat(irq_call_count); + trace_ipi_exit(tracepoint_string("CALL_FUNCTION")); } __visible void smp_call_function_interrupt(struct pt_regs *regs) @@ -313,8 +327,10 @@ __visible void smp_trace_call_function_interrupt(struct pt_regs *regs) static inline void __smp_call_function_single_interrupt(void) { + trace_ipi_entry(tracepoint_string("CALL_FUNCTION_SINGLE")); generic_smp_call_function_single_interrupt(); inc_irq_stat(irq_call_count); + trace_ipi_exit(tracepoint_string("CALL_FUNCTION_SINGLE")); } __visible void smp_call_function_single_interrupt(struct pt_regs *regs) -- 1.8.4.108.g55ea5f6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/4] tracepoint: add generic tracepoint definitions for IPI tracing
The Inter Processor Interrupt is used to make another processor do a specific action such as rescheduling tasks, signal a timer event or execute something in another CPU's context. IRQs are already traceable but IPIs were not. Tracing them is useful for monitoring IPI latency, or to verify when they are the source of CPU wake-ups with power management implications. Three trace hooks are defined: ipi_raise, ipi_entry and ipi_exit. To make them portable, a string is used to identify them and correlate related events. Additionally, ipi_raise records a bitmask representing targeted CPUs. Signed-off-by: Nicolas Pitre --- include/trace/events/ipi.h | 89 ++ 1 file changed, 89 insertions(+) create mode 100644 include/trace/events/ipi.h diff --git a/include/trace/events/ipi.h b/include/trace/events/ipi.h new file mode 100644 index 00..834a7362a6 --- /dev/null +++ b/include/trace/events/ipi.h @@ -0,0 +1,89 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ipi + +#if !defined(_TRACE_IPI_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_IPI_H + +#include + +/** + * ipi_raise - called when a smp cross call is made + * + * @mask: mask of recipient CPUs for the IPI + * @reason: string identifying the IPI purpose + * + * It is necessary for @reason to be a static string declared with + * __tracepoint_string. + */ +TRACE_EVENT(ipi_raise, + + TP_PROTO(const struct cpumask *mask, const char *reason), + + TP_ARGS(mask, reason), + + TP_STRUCT__entry( + __bitmask(target_cpus, nr_cpumask_bits) + __field(const char *, reason) + ), + + TP_fast_assign( + __assign_bitmask(target_cpus, cpumask_bits(mask), nr_cpumask_bits); + __entry->reason = reason; + ), + + TP_printk("target_mask=%s (%s)", __get_bitmask(target_cpus), __entry->reason) +); + +DECLARE_EVENT_CLASS(ipi_handler, + + TP_PROTO(const char *reason), + + TP_ARGS(reason), + + TP_STRUCT__entry( + __field(const char *, reason) + ), + + TP_fast_assign( + __entry->reason = reason; + ), + + TP_printk("(%s)", __entry->reason) +); + +/** + * ipi_entry - called immediately before the IPI handler + * + * @reason: string identifying the IPI purpose + * + * It is necessary for @reason to be a static string declared with + * __tracepoint_string, ideally the same as used with trace_ipi_raise + * for that IPI. + */ +DEFINE_EVENT(ipi_handler, ipi_entry, + + TP_PROTO(const char *reason), + + TP_ARGS(reason) +); + +/** + * ipi_exit - called immediately after the IPI handler returns + * + * @reason: string identifying the IPI purpose + * + * It is necessary for @reason to be a static string declared with + * __tracepoint_string, ideally the same as used with trace_ipi_raise for + * that IPI. + */ +DEFINE_EVENT(ipi_handler, ipi_exit, + + TP_PROTO(const char *reason), + + TP_ARGS(reason) +); + +#endif /* _TRACE_IPI_H */ + +/* This part must be outside protection */ +#include -- 1.8.4.108.g55ea5f6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/4] ARM64: add IPI tracepoints
The strings used to list IPIs in /proc/interrupts are reused for tracing purposes. While at it, the code is slightly cleaned up so the ipi_types array indices are no longer offset by IPI_RESCHEDULE whose value is 0 anyway. Signed-off-by: Nicolas Pitre --- arch/arm64/kernel/smp.c | 67 +++-- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 40f38f46c8..78a5904994 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -50,6 +50,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + /* * as from 2.5, kernels no longer have an init_tasks structure * so we need some other way of telling a new secondary core @@ -307,8 +310,6 @@ void __init smp_prepare_boot_cpu(void) set_my_cpu_offset(per_cpu_offset(smp_processor_id())); } -static void (*smp_cross_call)(const struct cpumask *, unsigned int); - /* * Enumerate the possible CPU set from the device tree and build the * cpu logical map array containing MPIDR values related to logical @@ -463,32 +464,19 @@ void __init smp_prepare_cpus(unsigned int max_cpus) } } +static void (*__smp_cross_call)(const struct cpumask *, unsigned int); void __init set_smp_cross_call(void (*fn)(const struct cpumask *, unsigned int)) { - smp_cross_call = fn; -} - -void arch_send_call_function_ipi_mask(const struct cpumask *mask) -{ - smp_cross_call(mask, IPI_CALL_FUNC); -} - -void arch_send_call_function_single_ipi(int cpu) -{ - smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE); + __smp_cross_call = fn; } -#ifdef CONFIG_IRQ_WORK -void arch_irq_work_raise(void) -{ - if (smp_cross_call) - smp_cross_call(cpumask_of(smp_processor_id()), IPI_IRQ_WORK); -} +static const char *ipi_types[NR_IPI] +#ifdef CONFIG_TRACING +__tracepoint_string #endif - -static const char *ipi_types[NR_IPI] = { -#define S(x,s) [x - IPI_RESCHEDULE] = s += { +#define S(x,s) [x] = s S(IPI_RESCHEDULE, "Rescheduling interrupts"), S(IPI_CALL_FUNC, "Function call interrupts"), S(IPI_CALL_FUNC_SINGLE, "Single function call interrupts"), @@ -497,12 +485,18 @@ static const char *ipi_types[NR_IPI] = { S(IPI_IRQ_WORK, "IRQ work interrupts"), }; +static void smp_cross_call(const struct cpumask *target, unsigned int ipinr) +{ + trace_ipi_raise(target, ipi_types[ipinr]); + __smp_cross_call(target, ipinr); +} + void show_ipi_list(struct seq_file *p, int prec) { unsigned int cpu, i; for (i = 0; i < NR_IPI; i++) { - seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i + IPI_RESCHEDULE, + seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, prec >= 4 ? " " : ""); for_each_online_cpu(cpu) seq_printf(p, "%10u ", @@ -522,6 +516,24 @@ u64 smp_irq_stat_cpu(unsigned int cpu) return sum; } +void arch_send_call_function_ipi_mask(const struct cpumask *mask) +{ + smp_cross_call(mask, IPI_CALL_FUNC); +} + +void arch_send_call_function_single_ipi(int cpu) +{ + smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE); +} + +#ifdef CONFIG_IRQ_WORK +void arch_irq_work_raise(void) +{ + if (__smp_cross_call) + smp_cross_call(cpumask_of(smp_processor_id()), IPI_IRQ_WORK); +} +#endif + static DEFINE_RAW_SPINLOCK(stop_lock); /* @@ -553,8 +565,10 @@ void handle_IPI(int ipinr, struct pt_regs *regs) unsigned int cpu = smp_processor_id(); struct pt_regs *old_regs = set_irq_regs(regs); - if (ipinr >= IPI_RESCHEDULE && ipinr < IPI_RESCHEDULE + NR_IPI) - __inc_irq_stat(cpu, ipi_irqs[ipinr - IPI_RESCHEDULE]); + if ((unsigned)ipinr < NR_IPI) { + trace_ipi_entry(ipi_types[ipinr]); + __inc_irq_stat(cpu, ipi_irqs[ipinr]); + } switch (ipinr) { case IPI_RESCHEDULE: @@ -599,6 +613,9 @@ void handle_IPI(int ipinr, struct pt_regs *regs) pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); break; } + + if ((unsigned)ipinr < NR_IPI) + trace_ipi_exit(ipi_types[ipinr]); set_irq_regs(old_regs); } -- 1.8.4.108.g55ea5f6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
linux-next: manual merge of the irqchip tree with the arm64 tree
Hi Jason, Today's linux-next merge of the irqchip tree got a conflict in arch/arm64/Kconfig between commit 875cbf3e4614 ("arm64: Add audit support") from the arm64 tree and commit 3e44358c12cc ("irqchip: gic: Add support for ARM GICv2m MSI(-X)") from the irqchip tree. I fixed it up (see below) and can carry the fix as necessary (no action is required). -- Cheers, Stephen Rothwells...@canb.auug.org.au diff --cc arch/arm64/Kconfig index 27bbdb7a5b83,0f9b11de7816.. --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@@ -11,7 -9,8 +11,9 @@@ config ARM6 select ARM_AMBA select ARM_ARCH_TIMER select ARM_GIC + select ARM_GIC_V2M if (PCI && PCI_MSI) + select ARM_GIC_V3 + select AUDIT_ARCH_COMPAT_GENERIC select BUILDTIME_EXTABLE_SORT select CLONE_BACKWARDS select COMMON_CLK signature.asc Description: PGP signature
RE: [PATCHv5 0/4] iio: adc: exynos_adc: Support Exynos3250 ADC and code clean
Jonathan Cameron wrote: > > On 27/06/14 05:30, Chanwoo Choi wrote: > > Changes from v4: > > - Use 'exynos_adc_data' structure instead of 'exynos_adc_ops' structure > >and remove enum variable of ADC version > > - Fix wrong name of special clock (sclk_tsadc -> sclk_adc) > > - Add reviewed message by Naveen Krishna Chatradhi > > - Add functions for ADC clock control > > > > Changes from v3: > > - Add new 'exynos_adc_ops' structure to improve readability according to > > Tomasz Figa comment[1] > > [1] https://lkml.org/lkml/2014/4/16/238 > > - Add new 'exynos3250-adc-v2' compatible string to support Exynos3250 ADC > > - Fix wrong compaitlbe string of ADC in Exynos3250 dtsi file > > > > Changes from v2: > > - Check return value of clock function to deal with error exception > > - Fix minor coding style to improve readability > > > > Changes from v1: > > - Add new "samsung,exynos-adc-v3" compatible to support Exynos3250 ADC > > - Add a patch about DT binding documentation > > > > Chanwoo Choi (4): > >iio: adc: exynos_adc: Add exynos_adc_data structure to improve > > readability > >iio: adc: exynos_adc: Control special clock of ADC to support Exynos3250 > > ADC > >iio: devicetree: Add DT binding documentation for Exynos3250 ADC > >ARM: dts: Fix wrong compatible string for Exynos3250 ADC > > > > .../devicetree/bindings/arm/samsung/exynos-adc.txt | 26 +- > > arch/arm/boot/dts/exynos3250.dtsi | 4 +- > > drivers/iio/adc/exynos_adc.c | 326 > > +++-- > > 3 files changed, 268 insertions(+), 88 deletions(-) > > > I am happy with this series, but given it touches some exynos bindings, I > would > like an ack from Kukjin Kim (or according to MAINTAINERS Ben Dooks) before > taking it > all through IIO. > Hi, Sorry for late response... The change looks good to me, so please go ahead with my ack on exynos stuff. Acked-by: Kukjin Kim Thanks, Kukjin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] pwm: add this series patch to support for rk-pwm and vop-pwm.
Hi Beniamino, 于 2014年07月18日 03:24, Beniamino Galvani 写道: On Thu, Jul 17, 2014 at 02:08:14PM +0800, caesar wrote: Signed-off-by: caesar Hi Caesar, just a couple of comments below. --- drivers/pwm/pwm-rockchip.c | 108 - 1 file changed, 88 insertions(+), 20 deletions(-) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index eec2145..59b0380 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -2,6 +2,7 @@ * PWM driver for Rockchip SoCs * * Copyright (C) 2014 Beniamino Galvani + * Copyright (C) 2014 Caesar Wang * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -12,6 +13,8 @@ #include #include #include +#include +#include These two should be swapped to keep the alphabetical order of the includes. ok,II will fix it. #include #include #include @@ -23,14 +26,37 @@ #define PWM_CTRL_TIMER_EN (1 << 0) #define PWM_CTRL_OUTPUT_EN(1 << 3) + [...] :-( ok,I will remove it. static int rockchip_pwm_probe(struct platform_device *pdev) { + const struct of_device_id *of_id = + of_match_device(rockchip_pwm_dt_ids, >dev); + struct device_node *np = pdev->dev.of_node; struct rockchip_pwm_chip *pc; struct resource *r; int ret; @@ -119,9 +185,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev) return -ENOMEM; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - pc->base = devm_ioremap_resource(>dev, r); - if (IS_ERR(pc->base)) - return PTR_ERR(pc->base); + pc->base = of_iomap(np, 0); + if (!pc->base) { + dev_err(>dev, "failed to map controller\n"); + ret = -ENOMEM; + goto fail_map; + } I think that this change is not needed. devm_ioremap_resource() guarantees an automatic unmapping when the device is destroyed. Moreover, when of_iomap() fails you don't need to call iounmap(). Beniamino VOP-PWM base has be requested for lcdc. When I use devm_ioremap_resource(), the vop-pwm will request region fail. Example:.931020] rockchip-pwm ff9401a0.pwm: can't request region for resource [mem 0xff9401a0-0xff9401af] /pwm@ff9401a0. So ,I have to charge it. I will be simplyfied by having: - pc->base = devm_ioremap_resource(>dev, r); + if (!strcmp(of_id->compatible, "rockchip,vop-pwm")) + pc->base = devm_ioremap(>dev, r->start, resource_size(r)); + else + pc->base = devm_ioremap_resource(>dev, r); Maybe, Could you give me better suggestions for it? Caesar pc->clk = devm_clk_get(>dev, NULL); if (IS_ERR(pc->clk)) @@ -133,6 +202,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pc); + pc->data = of_id->data; pc->chip.dev = >dev; pc->chip.ops = _pwm_ops; pc->chip.base = -1; @@ -145,6 +215,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev) } return ret; + +fail_map: + iounmap(pc->base); + return ret; } static int rockchip_pwm_remove(struct platform_device *pdev) @@ -156,12 +230,6 @@ static int rockchip_pwm_remove(struct platform_device *pdev) return pwmchip_remove(>chip); } -static const struct of_device_id rockchip_pwm_dt_ids[] = { - { .compatible = "rockchip,rk2928-pwm" }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids); - static struct platform_driver rockchip_pwm_driver = { .driver = { .name = "rockchip-pwm", -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] perf stat: Pass PERF_STAT_RUN environment variable for each run
Hi Arnaldo and Peter, On Thu, 17 Jul 2014 10:09:43 -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Jul 17, 2014 at 10:40:11AM +0200, Peter Zijlstra escreveu: >> On Thu, Jul 17, 2014 at 05:31:14PM +0900, Namhyung Kim wrote: >> > On Thu, Jul 17, 2014 at 5:26 PM, Peter Zijlstra >> > wrote: >> > > On Thu, Jul 17, 2014 at 05:21:06PM +0900, Namhyung Kim wrote: >> > >> When perf stat runs multiple times via -r option, it's sometimes >> > >> useful for a workload to know which run it executing. So pass new >> > >> PERF_STAT_RUN environment variable to the workload for each run >> > >> (starting from 1). > >> > > This seems counter intuitive, runs should be _identical_ otherwise >> > > there's no point. That means the workload should very much _not_ know >> > > these things. > >> > But I think it can be useful if a workload wants to save logfiles >> > based on the iteration number for example. If it doesn't want, it can >> > just ignore. :) > >> That's the wrong way around. Also, there's --pre and --post hooks to >> preserve logfiles if you really have to do that kind of thing. > > Agreed, one can script this using --pre or --post if needed. Hmm... okay, I'll drop this then. Thanks, Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv3 4/5] perf tools: Add --debug optionto set debug variable
Hi Jiri, On Thu, 17 Jul 2014 12:55:00 +0200, Jiri Olsa wrote: > yep, it's better, v3 attached [SNIP] > --- a/tools/perf/Documentation/perf.txt > +++ b/tools/perf/Documentation/perf.txt > @@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux > SYNOPSIS > > [verse] > -'perf' [--version] [--help] COMMAND [ARGS] > +'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS] > + > +OPTIONS > +--- > +--debug:: > + Setup debug variable (just verbose for now) in value > + range (0, 10). Use like: > + --debug verbose # sets verbose = 1 > + --debug verbose=2 # sets verbose = 2 > > DESCRIPTION > --- > diff --git a/tools/perf/perf.c b/tools/perf/perf.c > index 95c58fc15284..eed3fb2a3af0 100644 > --- a/tools/perf/perf.c > +++ b/tools/perf/perf.c > @@ -13,11 +13,12 @@ > #include "util/quote.h" > #include "util/run-command.h" > #include "util/parse-events.h" > +#include "util/debug.h" > #include > #include > > const char perf_usage_string[] = > - "perf [--version] [--help] COMMAND [ARGS]"; > + "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]"; You missed to update here.. ;-) Thanks, Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
linux-next: build warning after merge of the tip tree
Hi all, After merging the tip tree, today's linux-next build (x86_64 allmodconfig) produced these warnings: In file included from arch/x86/vdso/vdso2c.c:161:0: arch/x86/vdso/vdso2c.c: In function 'main': arch/x86/vdso/vdso2c.h:118:6: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow] In file included from arch/x86/vdso/vdso2c.c:165:0: arch/x86/vdso/vdso2c.h:118:6: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow] Probably introduced by commit e6577a7ce99a ("x86, vdso: Move the vvar area before the vdso text"). -- Cheers, Stephen Rothwells...@canb.auug.org.au signature.asc Description: PGP signature
Re: [PATCH v2] staging: android: Fixed missing blank line
On Fri, Jul 18, 2014 at 04:36:42AM +, Sharma, Sanjeev wrote: > Done ! ,Please review now. > Looks ok. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
hcd.c Fix me statements
I am assuming this is a stupid question but since I am new I will ask it anyway. Can the usb_bus structure be Null? If can I will send it a patch removing the fix mes on lines 854 and 878 of hcd.c . Cheers Nick -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] ftrace: Do not copy old hash when resetting.
Hi Steve, What's your opinion on my v2 patch ( https://lkml.org/lkml/2014/7/14/839 )? I have swapped if consitions following your suggestion. On 2014/7/14 12:10, Wang Nan wrote: > If we are going to reset hash, we don't need to duplicate old hash > and remove every entries right after allocation. > > Signed-off-by: Wang Nan > Cc: Steven Rostedt > Cc: Ingo Molnar > --- > kernel/trace/ftrace.c | 8 +--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 5b372e3..52d6931 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -3471,14 +3471,16 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char > *buf, int len, > else > orig_hash = >notrace_hash; > > - hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash); > + if (!reset) > + hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, > *orig_hash); > + else > + hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS); > + > if (!hash) { > ret = -ENOMEM; > goto out_regex_unlock; > } > > - if (reset) > - ftrace_filter_reset(hash); > if (buf && !ftrace_match_records(hash, buf, len)) { > ret = -EINVAL; > goto out_regex_unlock; > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kbuild: allow to override Python command name
The specification of Python 3 is largely different from that of Python 2. For example, arch/ia64/scripts/unwcheck.py seems to be written in Python 2, not compatible with Python 3. It is not a good idea to invoke python scripts with the hard-coded command name 'python'. The command 'python' could possibly be Python 3 on some systems. For that case, it is reasonable to allow to override the command name by giving 'PYTHON=python2' from the command line. The 'python' in arch/ia64/Makefile should be replaced with '$(PYTHON)'. Signed-off-by: Masahiro Yamada Cc: linux-i...@vger.kernel.org --- Makefile | 3 ++- arch/ia64/Makefile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f3c543d..7f5f301 100644 --- a/Makefile +++ b/Makefile @@ -372,6 +372,7 @@ GENKSYMS= scripts/genksyms/genksyms INSTALLKERNEL := installkernel DEPMOD = /sbin/depmod PERL = perl +PYTHON = python CHECK = sparse CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ @@ -422,7 +423,7 @@ KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(S export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP -export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE +export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index f37238f..5441b14 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -76,7 +76,7 @@ vmlinux.gz: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ unwcheck: vmlinux - -$(Q)READELF=$(READELF) python $(srctree)/arch/ia64/scripts/unwcheck.py $< + -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $< archclean: $(Q)$(MAKE) $(clean)=$(boot) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 00/16] BPF syscall, maps, verifier, samples
Hi All, changes V1->V2: - got rid of global id, everything now FD based (Thanks Andy!) - split type enum in verifier (as suggested by Andy and Namhyung) - switched gpl enforcement to be kmod like (as suggested by Andy and David) - addressed feedback from Namhyung, Chema, Joe - added more comments to verifier - renamed sock_filter_int -> bpf_insn - rebased on net-next FD approach made eBPF user interface much cleaner for sockets/seccomp/tracing use cases. Now socket and tracing examples (patch 15 and 16) can be Ctrl-C in the middle and kernel will auto cleanup everything including tracing filters. Small downside is eBPF programs need to include 'map fixup' section to use maps, which is similar to traditional elf relocation sections, but much simpler. First 11 patches are eBPF core which I think is ready for prime time. Patch 12 (sockets+bpf) is very useful already and it's trivial to expose more features for sockets in the future (like packet rewrite or calling flow_dissect) Patch 13 (tracing+bpf) needs more work to become dtrace like. It's a first step Todo: - manpage for new syscall - detect and reject address leaking in non-root programs Fixed V1 cover letter: 'maps' is a generic storage of different types for sharing data between kernel and userspace. Maps are referrenced by file descriptor. Root process can create multiple maps of different types where key/value are opaque bytes of data. It's up to user space and eBPF program to decide what they store in the maps. eBPF programs are similar to kernel modules. They are loaded by the user space program and unload on closing of fd. Each program is a safe run-to-completion set of instructions. eBPF verifier statically determines that the program terminates and safe to execute. During verification the program takes a hold of maps that it intends to use, so selected maps cannot be removed until program is unloaded. The program can be attached to different events. These events can be packets, tracepoint events and other types in the future. New event triggers execution of the program which may store information about the event in the maps. Beyond storing data the programs may call into in-kernel helper functions which may, for example, dump stack, do trace_printk or other forms of live kernel debugging. Same program can be attached to multiple events. Different programs can access the same map: tracepoint tracepoint tracepointsk_buffsk_buff event A event B event C on eth0on eth1 | | || | | | || | --> tracing <-- tracing socket socket prog_1 prog_2 prog_3 prog_4 | | || |--- -| |---| map_3 map_1 map_2 User space (via syscall) and eBPF programs access maps concurrently. Last two patches are sample code. 1st demonstrates stateful packet inspection. It counts tcp and udp packets on eth0. Should be easy to see how this eBPF framework can be used for network analytics. 2nd sample does simple 'drop monitor'. It attaches to kfree_skb tracepoint event and counts number of packet drops at particular $pc location. User space periodically summarizes what eBPF programs recorded. In these two samples the eBPF programs are tiny and written in 'assembler' with macroses. More complex programs can be written C (llvm backend is not part of this diff and will be upstreamed after this patchset is accepted) Since eBPF is fully JITed on x64, the cost of running eBPF program is very small even for high frequency events. Here are the numbers comparing flow_dissector in C vs eBPF: x86_64 skb_flow_dissect() same skb (all cached) - 42 nsec per call x86_64 skb_flow_dissect() different skbs (cache misses) - 141 nsec per call eBPF+jit skb_flow_dissect() same skb (all cached) - 51 nsec per call eBPF+jit skb_flow_dissect() different skbs (cache misses) - 135 nsec per call Thanks Alexei -- The following changes since commit da388973d4a15e71cada1219d625b5393c90e5ae: iw_cxgb4: fix for 64-bit integer division (2014-07-17 16:52:08 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf master for you to fetch changes up to e8c12b5d78f612a7651db9648c45999bd6fd3c1c: samples: bpf: example of tracing filters with eBPF (2014-07-17 20:08:17 -0700) Alexei Starovoitov (16): net: filter: split filter.c into two files bpf: update MAINTAINERS entry net: filter: rename struct sock_filter_int into bpf_insn net: filter: split filter.h and expose eBPF to user space bpf: introduce syscall(BPF, ...) and BPF maps bpf: enable bpf syscall on x64 bpf: add lookup/update/delete/iterate methods to BPF maps bpf: add hashtable type of BPF maps bpf: expand BPF
RE: [PATCH v2] staging: android: Fixed missing blank line
Done ! ,Please review now. Regards Sanjeev Sharma -Original Message- From: Dan Carpenter [mailto:dan.carpen...@oracle.com] Sent: Thursday, July 17, 2014 2:41 PM To: Sharma, Sanjeev Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; way...@gmail.com; swetl...@google.com; linux-kernel@vger.kernel.org; dan...@ffwll.ch Subject: Re: [PATCH v2] staging: android: Fixed missing blank line On Thu, Jul 17, 2014 at 02:43:27PM +0530, sanjeev sharma wrote: > From: sanjeevs1 Only use this if you are sending on behalf of someone else. > > This patch will add an blank line after declaration reported by > checkpatch.pl script. > > Signed-off-by: Sanjeev Sharma > --- > Changes in v2: > - Fixed frm header Send these to yourself to test. Also look at your email. Bad - From: sanjeev sharma Good - From: Sanjeev Sharma regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 02/16] bpf: update MAINTAINERS entry
Signed-off-by: Alexei Starovoitov --- MAINTAINERS |7 +++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ae8cd00215b2..32e24ff46da3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1912,6 +1912,13 @@ S: Supported F: drivers/net/bonding/ F: include/uapi/linux/if_bonding.h +BPF (Safe dynamic programs and tools) +M: Alexei Starovoitov +L: net...@vger.kernel.org +L: linux-kernel@vger.kernel.org +S: Supported +F: kernel/bpf/ + BROADCOM B44 10/100 ETHERNET DRIVER M: Gary Zambrano L: net...@vger.kernel.org -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 01/16] net: filter: split filter.c into two files
BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest kernel/bpf/core.c: eBPF interpreter net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters This patch only moves functions. Signed-off-by: Alexei Starovoitov --- kernel/Makefile |1 + kernel/bpf/Makefile |1 + kernel/bpf/core.c | 536 +++ net/core/filter.c | 511 4 files changed, 538 insertions(+), 511 deletions(-) create mode 100644 kernel/bpf/Makefile create mode 100644 kernel/bpf/core.c diff --git a/kernel/Makefile b/kernel/Makefile index f2a8b6246ce9..e7360b7c2c0e 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -87,6 +87,7 @@ obj-$(CONFIG_RING_BUFFER) += trace/ obj-$(CONFIG_TRACEPOINTS) += trace/ obj-$(CONFIG_IRQ_WORK) += irq_work.o obj-$(CONFIG_CPU_PM) += cpu_pm.o +obj-$(CONFIG_NET) += bpf/ obj-$(CONFIG_PERF_EVENTS) += events/ diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile new file mode 100644 index ..6a71145e2769 --- /dev/null +++ b/kernel/bpf/Makefile @@ -0,0 +1 @@ +obj-y := core.o diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c new file mode 100644 index ..77a240a1ce11 --- /dev/null +++ b/kernel/bpf/core.c @@ -0,0 +1,536 @@ +/* + * Linux Socket Filter - Kernel level socket filtering + * + * Based on the design of the Berkeley Packet Filter. The new + * internal format has been designed by PLUMgrid: + * + * Copyright (c) 2011 - 2014 PLUMgrid, http://plumgrid.com + * + * Authors: + * + * Jay Schulist + * Alexei Starovoitov + * Daniel Borkmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Andi Kleen - Fix a few bad bugs and races. + * Kris Katterjohn - Added many additional checks in sk_chk_filter() + */ +#include +#include +#include + +/* Registers */ +#define BPF_R0 regs[BPF_REG_0] +#define BPF_R1 regs[BPF_REG_1] +#define BPF_R2 regs[BPF_REG_2] +#define BPF_R3 regs[BPF_REG_3] +#define BPF_R4 regs[BPF_REG_4] +#define BPF_R5 regs[BPF_REG_5] +#define BPF_R6 regs[BPF_REG_6] +#define BPF_R7 regs[BPF_REG_7] +#define BPF_R8 regs[BPF_REG_8] +#define BPF_R9 regs[BPF_REG_9] +#define BPF_R10regs[BPF_REG_10] + +/* Named registers */ +#define DSTregs[insn->dst_reg] +#define SRCregs[insn->src_reg] +#define FP regs[BPF_REG_FP] +#define ARG1 regs[BPF_REG_ARG1] +#define CTXregs[BPF_REG_CTX] +#define IMMinsn->imm + +/* No hurry in this branch + * + * Exported for the bpf jit load helper. + */ +void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, unsigned int size) +{ + u8 *ptr = NULL; + + if (k >= SKF_NET_OFF) + ptr = skb_network_header(skb) + k - SKF_NET_OFF; + else if (k >= SKF_LL_OFF) + ptr = skb_mac_header(skb) + k - SKF_LL_OFF; + if (ptr >= skb->head && ptr + size <= skb_tail_pointer(skb)) + return ptr; + + return NULL; +} + +/* Base function for offset calculation. Needs to go into .text section, + * therefore keeping it non-static as well; will also be used by JITs + * anyway later on, so do not let the compiler omit it. + */ +noinline u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) +{ + return 0; +} + +/** + * __sk_run_filter - run a filter on a given context + * @ctx: buffer to run the filter on + * @insn: filter to apply + * + * Decode and apply filter instructions to the skb->data. Return length to + * keep, 0 for none. @ctx is the data we are operating on, @insn is the + * array of filter instructions. + */ +static unsigned int __sk_run_filter(void *ctx, const struct sock_filter_int *insn) +{ + u64 stack[MAX_BPF_STACK / sizeof(u64)]; + u64 regs[MAX_BPF_REG], tmp; + static const void *jumptable[256] = { + [0 ... 255] = &_label, + /* Now overwrite non-defaults ... */ + /* 32 bit ALU operations */ + [BPF_ALU | BPF_ADD | BPF_X] = &_ADD_X, + [BPF_ALU | BPF_ADD | BPF_K] = &_ADD_K, + [BPF_ALU | BPF_SUB | BPF_X] = &_SUB_X, + [BPF_ALU | BPF_SUB | BPF_K] = &_SUB_K, + [BPF_ALU | BPF_AND | BPF_X] = &_AND_X, + [BPF_ALU | BPF_AND | BPF_K] = &_AND_K, + [BPF_ALU | BPF_OR | BPF_X] = &_OR_X, + [BPF_ALU | BPF_OR | BPF_K] = &_OR_K, + [BPF_ALU | BPF_LSH | BPF_X] = &_LSH_X, + [BPF_ALU | BPF_LSH | BPF_K] = &_LSH_K, + [BPF_ALU | BPF_RSH | BPF_X] = &_RSH_X, + [BPF_ALU | BPF_RSH | BPF_K] = &_RSH_K, + [BPF_ALU | BPF_XOR | BPF_X] = &_XOR_X, + [BPF_ALU | BPF_XOR | BPF_K] =
[PATCH] staging: android: Fixed missing blank line
This patch will add an blank line after declaration reported by checkpatch.pl script. Signed-off-by: Sanjeev Sharma --- drivers/staging/android/sw_sync.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index a76db3f..863d4b1 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -97,6 +97,7 @@ static void sw_sync_pt_value_str(struct sync_pt *sync_pt, char *str, int size) { struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; + snprintf(str, size, "%d", pt->value); } @@ -156,6 +157,7 @@ static int sw_sync_open(struct inode *inode, struct file *file) static int sw_sync_release(struct inode *inode, struct file *file) { struct sw_sync_timeline *obj = file->private_data; + sync_timeline_destroy(>obj); return 0; } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 07/16] bpf: add lookup/update/delete/iterate methods to BPF maps
'maps' is a generic storage of different types for sharing data between kernel and userspace. The maps are accessed from user space via BPF syscall, which has commands: - create a map with given type and attributes fd = bpf_map_create(map_type, struct nlattr *attr, int len) returns fd or negative error - lookup key in a given map referenced by fd err = bpf_map_lookup_elem(int fd, void *key, void *value) returns zero and stores found elem into value or negative error - create or update key/value pair in a given map err = bpf_map_update_elem(int fd, void *key, void *value) returns zero or negative error - find and delete element by key in a given map err = bpf_map_delete_elem(int fd, void *key) - iterate map elements (based on input key return next_key) err = bpf_map_get_next_key(int fd, void *key, void *next_key) - close(fd) deletes the map Signed-off-by: Alexei Starovoitov --- include/linux/bpf.h |6 ++ include/uapi/linux/bpf.h | 25 ++ kernel/bpf/syscall.c | 209 ++ 3 files changed, 240 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 57af236a0eb4..91e2caf8edf9 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -18,6 +18,12 @@ struct bpf_map_ops { /* funcs callable from userspace (via syscall) */ struct bpf_map *(*map_alloc)(struct nlattr *attrs[BPF_MAP_ATTR_MAX + 1]); void (*map_free)(struct bpf_map *); + int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key); + + /* funcs callable from userspace and from eBPF programs */ + void *(*map_lookup_elem)(struct bpf_map *map, void *key); + int (*map_update_elem)(struct bpf_map *map, void *key, void *value); + int (*map_delete_elem)(struct bpf_map *map, void *key); }; struct bpf_map { diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index dcc7eb97a64a..5e1bfbc9cdc7 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -308,6 +308,31 @@ enum bpf_cmd { * map is deleted when fd is closed */ BPF_MAP_CREATE, + + /* lookup key in a given map referenced by map_id +* err = bpf_map_lookup_elem(int map_id, void *key, void *value) +* returns zero and stores found elem into value +* or negative error +*/ + BPF_MAP_LOOKUP_ELEM, + + /* create or update key/value pair in a given map +* err = bpf_map_update_elem(int map_id, void *key, void *value) +* returns zero or negative error +*/ + BPF_MAP_UPDATE_ELEM, + + /* find and delete elem by key in a given map +* err = bpf_map_delete_elem(int map_id, void *key) +* returns zero or negative error +*/ + BPF_MAP_DELETE_ELEM, + + /* lookup key in a given map and return next key +* err = bpf_map_get_elem(int map_id, void *key, void *next_key) +* returns zero and stores next key or negative error +*/ + BPF_MAP_GET_NEXT_KEY, }; enum bpf_map_attributes { diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index c4a330642653..ca2be66845b3 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -13,6 +13,7 @@ #include #include #include +#include /* mutex to protect insertion/deletion of map_id in IDR */ static DEFINE_MUTEX(bpf_map_lock); @@ -209,6 +210,202 @@ free_attr: return err; } +static int get_map_id(struct fd f) +{ + struct bpf_map *map; + + if (!f.file) + return -EBADF; + + if (f.file->f_op != _map_fops) { + fdput(f); + return -EINVAL; + } + + map = f.file->private_data; + + return map->map_id; +} + +static int map_lookup_elem(int ufd, void __user *ukey, void __user *uvalue) +{ + struct fd f = fdget(ufd); + struct bpf_map *map; + void *key, *value; + int err; + + err = get_map_id(f); + if (err < 0) + return err; + + rcu_read_lock(); + map = idr_find(_map_id_idr, err); + err = -EINVAL; + if (!map) + goto err_unlock; + + err = -ENOMEM; + key = kmalloc(map->key_size, GFP_ATOMIC); + if (!key) + goto err_unlock; + + err = -EFAULT; + if (copy_from_user(key, ukey, map->key_size) != 0) + goto free_key; + + err = -ESRCH; + value = map->ops->map_lookup_elem(map, key); + if (!value) + goto free_key; + + err = -EFAULT; + if (copy_to_user(uvalue, value, map->value_size) != 0) + goto free_key; + + err = 0; + +free_key: + kfree(key); +err_unlock: + rcu_read_unlock(); + fdput(f); + return err; +} + +static int map_update_elem(int ufd, void __user *ukey, void __user *uvalue) +{ + struct fd f = fdget(ufd); + struct bpf_map *map; + void *key, *value; + int err; + + err =
[PATCH RFC v2 net-next 04/16] net: filter: split filter.h and expose eBPF to user space
eBPF can be used from user space. uapi/linux/bpf.h: eBPF instruction set definition linux/filter.h: the rest This patch only moves macro definitions, but practically it freezes existing eBPF instruction set, though new instructions can still be added in the future. These eBPF definitions cannot go into uapi/linux/filter.h, since the names may conflict with existing applications. Signed-off-by: Alexei Starovoitov --- include/linux/filter.h| 294 +-- include/uapi/linux/Kbuild |1 + include/uapi/linux/bpf.h | 303 + 3 files changed, 305 insertions(+), 293 deletions(-) create mode 100644 include/uapi/linux/bpf.h diff --git a/include/linux/filter.h b/include/linux/filter.h index a3287d1c9a56..b43ad6a2b3cf 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -9,303 +9,11 @@ #include #include #include - -/* Internally used and optimized filter representation with extended - * instruction set based on top of classic BPF. - */ - -/* instruction classes */ -#define BPF_ALU64 0x07/* alu mode in double word width */ - -/* ld/ldx fields */ -#define BPF_DW 0x18/* double word */ -#define BPF_XADD 0xc0/* exclusive add */ - -/* alu/jmp fields */ -#define BPF_MOV0xb0/* mov reg to reg */ -#define BPF_ARSH 0xc0/* sign extending arithmetic shift right */ - -/* change endianness of a register */ -#define BPF_END0xd0/* flags for endianness conversion: */ -#define BPF_TO_LE 0x00/* convert to little-endian */ -#define BPF_TO_BE 0x08/* convert to big-endian */ -#define BPF_FROM_LEBPF_TO_LE -#define BPF_FROM_BEBPF_TO_BE - -#define BPF_JNE0x50/* jump != */ -#define BPF_JSGT 0x60/* SGT is signed '>', GT in x86 */ -#define BPF_JSGE 0x70/* SGE is signed '>=', GE in x86 */ -#define BPF_CALL 0x80/* function call */ -#define BPF_EXIT 0x90/* function return */ - -/* Register numbers */ -enum { - BPF_REG_0 = 0, - BPF_REG_1, - BPF_REG_2, - BPF_REG_3, - BPF_REG_4, - BPF_REG_5, - BPF_REG_6, - BPF_REG_7, - BPF_REG_8, - BPF_REG_9, - BPF_REG_10, - __MAX_BPF_REG, -}; - -/* BPF has 10 general purpose 64-bit registers and stack frame. */ -#define MAX_BPF_REG__MAX_BPF_REG - -/* ArgX, context and stack frame pointer register positions. Note, - * Arg1, Arg2, Arg3, etc are used as argument mappings of function - * calls in BPF_CALL instruction. - */ -#define BPF_REG_ARG1 BPF_REG_1 -#define BPF_REG_ARG2 BPF_REG_2 -#define BPF_REG_ARG3 BPF_REG_3 -#define BPF_REG_ARG4 BPF_REG_4 -#define BPF_REG_ARG5 BPF_REG_5 -#define BPF_REG_CTXBPF_REG_6 -#define BPF_REG_FP BPF_REG_10 - -/* Additional register mappings for converted user programs. */ -#define BPF_REG_A BPF_REG_0 -#define BPF_REG_X BPF_REG_7 -#define BPF_REG_TMPBPF_REG_8 - -/* BPF program can access up to 512 bytes of stack space. */ -#define MAX_BPF_STACK 512 - -/* Helper macros for filter block array initializers. */ - -/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ - -#define BPF_ALU64_REG(OP, DST, SRC)\ - ((struct bpf_insn) {\ - .code = BPF_ALU64 | BPF_OP(OP) | BPF_X,\ - .dst_reg = DST, \ - .src_reg = SRC, \ - .off = 0, \ - .imm = 0 }) - -#define BPF_ALU32_REG(OP, DST, SRC)\ - ((struct bpf_insn) {\ - .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ - .dst_reg = DST, \ - .src_reg = SRC, \ - .off = 0, \ - .imm = 0 }) - -/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ - -#define BPF_ALU64_IMM(OP, DST, IMM)\ - ((struct bpf_insn) {\ - .code = BPF_ALU64 | BPF_OP(OP) | BPF_K,\ - .dst_reg = DST, \ - .src_reg = 0, \ - .off = 0, \ - .imm = IMM }) - -#define BPF_ALU32_IMM(OP, DST, IMM)\ - ((struct bpf_insn) {\ - .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ - .dst_reg = DST, \ - .src_reg = 0, \ - .off = 0, \ - .imm = IMM }) - -/*
Re: linux-next: build failure after merge of the net-next tree
This is totally my bad. Already posted the fix some time ago. N�r��yb�X��ǧv�^�){.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a��� 0��h���i
[PATCH RFC v2 net-next 06/16] bpf: enable bpf syscall on x64
done as separate commit to ease conflict resolution Signed-off-by: Alexei Starovoitov --- arch/x86/syscalls/syscall_64.tbl |1 + include/linux/syscalls.h |2 ++ include/uapi/asm-generic/unistd.h |4 +++- kernel/sys_ni.c |3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl index ec255a1646d2..edbb8460e1b5 100644 --- a/arch/x86/syscalls/syscall_64.tbl +++ b/arch/x86/syscalls/syscall_64.tbl @@ -323,6 +323,7 @@ 314common sched_setattr sys_sched_setattr 315common sched_getattr sys_sched_getattr 316common renameat2 sys_renameat2 +317common bpf sys_bpf # # x32-specific system call numbers start at 512 to avoid cache impact diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b0881a0ed322..2b524aeba262 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -866,4 +866,6 @@ asmlinkage long sys_process_vm_writev(pid_t pid, asmlinkage long sys_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2); asmlinkage long sys_finit_module(int fd, const char __user *uargs, int flags); +asmlinkage long sys_bpf(int cmd, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5); #endif diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 333640608087..41e20f8fb87e 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -699,9 +699,11 @@ __SYSCALL(__NR_sched_setattr, sys_sched_setattr) __SYSCALL(__NR_sched_getattr, sys_sched_getattr) #define __NR_renameat2 276 __SYSCALL(__NR_renameat2, sys_renameat2) +#define __NR_bpf 277 +__SYSCALL(__NR_bpf, sys_bpf) #undef __NR_syscalls -#define __NR_syscalls 277 +#define __NR_syscalls 278 /* * All syscalls below here should go away really, diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 36441b51b5df..877c9aafbfb4 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -213,3 +213,6 @@ cond_syscall(compat_sys_open_by_handle_at); /* compare kernel pointers */ cond_syscall(sys_kcmp); + +/* access BPF programs and maps */ +cond_syscall(sys_bpf); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 08/16] bpf: add hashtable type of BPF maps
add new map type: BPF_MAP_TYPE_HASH and its simple (not auto resizeable) hash table implementation Signed-off-by: Alexei Starovoitov --- include/uapi/linux/bpf.h |1 + kernel/bpf/Makefile |2 +- kernel/bpf/hashtab.c | 371 ++ 3 files changed, 373 insertions(+), 1 deletion(-) create mode 100644 kernel/bpf/hashtab.c diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 5e1bfbc9cdc7..3ea11ba053a8 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -347,6 +347,7 @@ enum bpf_map_attributes { enum bpf_map_type { BPF_MAP_TYPE_UNSPEC, + BPF_MAP_TYPE_HASH, }; #endif /* _UAPI__LINUX_BPF_H__ */ diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile index e9f7334ed07a..558e12712ebc 100644 --- a/kernel/bpf/Makefile +++ b/kernel/bpf/Makefile @@ -1 +1 @@ -obj-y := core.o syscall.o +obj-y := core.o syscall.o hashtab.o diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c new file mode 100644 index ..6e481cacbba3 --- /dev/null +++ b/kernel/bpf/hashtab.c @@ -0,0 +1,371 @@ +/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +#include +#include +#include + +struct bpf_htab { + struct bpf_map map; + struct hlist_head *buckets; + struct kmem_cache *elem_cache; + char *slab_name; + spinlock_t lock; + u32 count; /* number of elements in this hashtable */ + u32 n_buckets; /* number of hash buckets */ + u32 elem_size; /* size of each element in bytes */ +}; + +/* each htab element is struct htab_elem + key + value */ +struct htab_elem { + struct hlist_node hash_node; + struct rcu_head rcu; + struct bpf_htab *htab; + u32 hash; + u32 pad; + char key[0]; +}; + +#define HASH_MAX_BUCKETS 1024 +#define BPF_MAP_MAX_KEY_SIZE 256 +static struct bpf_map *htab_map_alloc(struct nlattr *attr[BPF_MAP_ATTR_MAX + 1]) +{ + struct bpf_htab *htab; + int err, i; + + htab = kmalloc(sizeof(*htab), GFP_USER); + if (!htab) + return ERR_PTR(-ENOMEM); + + /* look for mandatory map attributes */ + err = -EINVAL; + if (!attr[BPF_MAP_KEY_SIZE]) + goto free_htab; + htab->map.key_size = nla_get_u32(attr[BPF_MAP_KEY_SIZE]); + + if (!attr[BPF_MAP_VALUE_SIZE]) + goto free_htab; + htab->map.value_size = nla_get_u32(attr[BPF_MAP_VALUE_SIZE]); + + if (!attr[BPF_MAP_MAX_ENTRIES]) + goto free_htab; + htab->map.max_entries = nla_get_u32(attr[BPF_MAP_MAX_ENTRIES]); + + htab->n_buckets = (htab->map.max_entries <= HASH_MAX_BUCKETS) ? + htab->map.max_entries : HASH_MAX_BUCKETS; + + /* hash table size must be power of 2 */ + if ((htab->n_buckets & (htab->n_buckets - 1)) != 0) + goto free_htab; + + err = -E2BIG; + if (htab->map.key_size > BPF_MAP_MAX_KEY_SIZE) + goto free_htab; + + err = -ENOMEM; + htab->buckets = kmalloc(htab->n_buckets * sizeof(struct hlist_head), + GFP_USER); + + if (!htab->buckets) + goto free_htab; + + for (i = 0; i < htab->n_buckets; i++) + INIT_HLIST_HEAD(>buckets[i]); + + spin_lock_init(>lock); + htab->count = 0; + + htab->elem_size = sizeof(struct htab_elem) + + round_up(htab->map.key_size, 8) + + htab->map.value_size; + + htab->slab_name = kasprintf(GFP_USER, "bpf_htab_%p", htab); + if (!htab->slab_name) + goto free_buckets; + + htab->elem_cache = kmem_cache_create(htab->slab_name, +htab->elem_size, 0, 0, NULL); + if (!htab->elem_cache) + goto free_slab_name; + + return >map; + +free_slab_name: + kfree(htab->slab_name); +free_buckets: + kfree(htab->buckets); +free_htab: + kfree(htab); + return ERR_PTR(err); +} + +static inline u32 htab_map_hash(const void *key, u32 key_len) +{ + return jhash(key, key_len, 0); +} + +static inline struct hlist_head *select_bucket(struct bpf_htab *htab, u32 hash) +{ + return >buckets[hash & (htab->n_buckets - 1)]; +} + +static struct htab_elem *lookup_elem_raw(struct hlist_head *head, u32 hash, +void *key, u32 key_size) +{ + struct htab_elem *l; + + hlist_for_each_entry_rcu(l, head, hash_node) { +
[PATCH RFC v2 net-next 09/16] bpf: expand BPF syscall with program load/unload
eBPF programs are safe run-to-completion functions with load/unload methods from userspace similar to kernel modules. User space API: - load eBPF program fd = bpf_prog_load(bpf_prog_type, struct nlattr *prog, int len) where 'prog' is a sequence of sections (TEXT, LICENSE, MAP_ASSOC) TEXT - array of eBPF instructions LICENSE - must be GPL compatible to call helper functions marked gpl_only MAP_FIXUP - array of {insn idx, map fd} used by kernel to adjust imm constants in 'mov' instructions used to access maps - unload eBPF program close(fd) User space example of syscall(__NR_bpf, BPF_PROG_LOAD, prog_type, ...) follows in later patches Signed-off-by: Alexei Starovoitov --- include/linux/bpf.h | 33 + include/linux/filter.h |9 +- include/uapi/linux/bpf.h | 29 + kernel/bpf/core.c|5 +- kernel/bpf/syscall.c | 309 ++ net/core/filter.c|9 +- 6 files changed, 388 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 91e2caf8edf9..4967619595cc 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -46,4 +46,37 @@ struct bpf_map_type_list { void bpf_register_map_type(struct bpf_map_type_list *tl); struct bpf_map *bpf_map_get(u32 map_id); +/* eBPF function prototype used by verifier to allow BPF_CALLs from eBPF programs + * to in-kernel helper functions and for adjusting imm32 field in BPF_CALL + * instructions after verifying + */ +struct bpf_func_proto { + u64 (*func)(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); + bool gpl_only; +}; + +struct bpf_verifier_ops { + /* return eBPF function prototype for verification */ + const struct bpf_func_proto *(*get_func_proto)(enum bpf_func_id func_id); +}; + +struct bpf_prog_type_list { + struct list_head list_node; + struct bpf_verifier_ops *ops; + enum bpf_prog_type type; +}; + +void bpf_register_prog_type(struct bpf_prog_type_list *tl); + +struct bpf_prog_info { + bool is_gpl_compatible; + enum bpf_prog_type prog_type; + struct bpf_verifier_ops *ops; + u32 *used_maps; + u32 used_map_cnt; +}; + +void free_bpf_prog_info(struct bpf_prog_info *info); +struct sk_filter *bpf_prog_get(u32 ufd); + #endif /* _LINUX_BPF_H */ diff --git a/include/linux/filter.h b/include/linux/filter.h index b43ad6a2b3cf..822b310e75e1 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -30,12 +30,17 @@ struct sock_fprog_kern { struct sk_buff; struct sock; struct seccomp_data; +struct bpf_prog_info; struct sk_filter { atomic_trefcnt; u32 jited:1,/* Is our filter JIT'ed? */ - len:31; /* Number of filter blocks */ - struct sock_fprog_kern *orig_prog; /* Original BPF program */ + ebpf:1, /* Is it eBPF program ? */ + len:30; /* Number of filter blocks */ + union { + struct sock_fprog_kern *orig_prog; /* Original BPF program */ + struct bpf_prog_info*info; + }; struct rcu_head rcu; unsigned int(*bpf_func)(const struct sk_buff *skb, const struct bpf_insn *filter); diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 3ea11ba053a8..06ba71b49f64 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -333,6 +333,13 @@ enum bpf_cmd { * returns zero and stores next key or negative error */ BPF_MAP_GET_NEXT_KEY, + + /* verify and load eBPF program +* prog_id = bpf_prog_load(bpf_prog_type, struct nlattr *prog, int len) +* prog is a sequence of sections +* returns fd or negative error +*/ + BPF_PROG_LOAD, }; enum bpf_map_attributes { @@ -350,4 +357,26 @@ enum bpf_map_type { BPF_MAP_TYPE_HASH, }; +enum bpf_prog_attributes { + BPF_PROG_UNSPEC, + BPF_PROG_TEXT, /* array of eBPF instructions */ + BPF_PROG_LICENSE, /* license string */ + BPF_PROG_MAP_FIXUP, /* array of {insn idx, map fd} to fixup insns */ + __BPF_PROG_ATTR_MAX, +}; +#define BPF_PROG_ATTR_MAX (__BPF_PROG_ATTR_MAX - 1) +#define BPF_PROG_MAX_ATTR_SIZE 65535 + +enum bpf_prog_type { + BPF_PROG_TYPE_UNSPEC, +}; + +/* integer value in 'imm' field of BPF_CALL instruction selects which helper + * function eBPF program intends to call + */ +enum bpf_func_id { + BPF_FUNC_unspec, + __BPF_FUNC_MAX_ID, +}; + #endif /* _UAPI__LINUX_BPF_H__ */ diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 265a02cc822d..e65ecdc36358 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Registers */ #define BPF_R0 regs[BPF_REG_0] @@ -528,9 +529,11 @@ void
[PATCH RFC v2 net-next 12/16] net: sock: allow eBPF programs to be attached to sockets
introduce new setsockopt() command: int fd; setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER_EBPF, , sizeof(fd)) fd is associated with eBPF program priorly loaded via: fd = syscall(__NR_bpf, BPF_PROG_LOAD, BPF_PROG_TYPE_SOCKET_FILTER, , sizeof(prog)); setsockopt() calls bpf_prog_get() which increment refcnt of the program, so it doesn't get unloaded while socket is using the program. The same eBPF program can be attached to different sockets. Program exit automatically closes socket which calls sk_filter_uncharge() which decrements refcnt of eBPF program Signed-off-by: Alexei Starovoitov --- arch/alpha/include/uapi/asm/socket.h |2 + arch/avr32/include/uapi/asm/socket.h |2 + arch/cris/include/uapi/asm/socket.h|2 + arch/frv/include/uapi/asm/socket.h |2 + arch/ia64/include/uapi/asm/socket.h|2 + arch/m32r/include/uapi/asm/socket.h|2 + arch/mips/include/uapi/asm/socket.h|2 + arch/mn10300/include/uapi/asm/socket.h |2 + arch/parisc/include/uapi/asm/socket.h |2 + arch/powerpc/include/uapi/asm/socket.h |2 + arch/s390/include/uapi/asm/socket.h|2 + arch/sparc/include/uapi/asm/socket.h |2 + arch/xtensa/include/uapi/asm/socket.h |2 + include/linux/filter.h |1 + include/uapi/asm-generic/socket.h |2 + net/core/filter.c | 112 net/core/sock.c| 13 17 files changed, 154 insertions(+) diff --git a/arch/alpha/include/uapi/asm/socket.h b/arch/alpha/include/uapi/asm/socket.h index 3de1394bcab8..8c83c376b5ba 100644 --- a/arch/alpha/include/uapi/asm/socket.h +++ b/arch/alpha/include/uapi/asm/socket.h @@ -87,4 +87,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/avr32/include/uapi/asm/socket.h b/arch/avr32/include/uapi/asm/socket.h index 6e6cd159924b..498ef7220466 100644 --- a/arch/avr32/include/uapi/asm/socket.h +++ b/arch/avr32/include/uapi/asm/socket.h @@ -80,4 +80,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _UAPI__ASM_AVR32_SOCKET_H */ diff --git a/arch/cris/include/uapi/asm/socket.h b/arch/cris/include/uapi/asm/socket.h index ed94e5ed0a23..0d5120724780 100644 --- a/arch/cris/include/uapi/asm/socket.h +++ b/arch/cris/include/uapi/asm/socket.h @@ -82,6 +82,8 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/frv/include/uapi/asm/socket.h b/arch/frv/include/uapi/asm/socket.h index ca2c6e6f31c6..81fba267c285 100644 --- a/arch/frv/include/uapi/asm/socket.h +++ b/arch/frv/include/uapi/asm/socket.h @@ -80,5 +80,7 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/ia64/include/uapi/asm/socket.h b/arch/ia64/include/uapi/asm/socket.h index a1b49bac7951..9cbb2e82fa7c 100644 --- a/arch/ia64/include/uapi/asm/socket.h +++ b/arch/ia64/include/uapi/asm/socket.h @@ -89,4 +89,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _ASM_IA64_SOCKET_H */ diff --git a/arch/m32r/include/uapi/asm/socket.h b/arch/m32r/include/uapi/asm/socket.h index 6c9a24b3aefa..587ac2fb4106 100644 --- a/arch/m32r/include/uapi/asm/socket.h +++ b/arch/m32r/include/uapi/asm/socket.h @@ -80,4 +80,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _ASM_M32R_SOCKET_H */ diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h index a14baa218c76..ab1aed2306db 100644 --- a/arch/mips/include/uapi/asm/socket.h +++ b/arch/mips/include/uapi/asm/socket.h @@ -98,4 +98,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/mn10300/include/uapi/asm/socket.h b/arch/mn10300/include/uapi/asm/socket.h index 6aa3ce1854aa..1c4f916d0ef1 100644 --- a/arch/mn10300/include/uapi/asm/socket.h +++ b/arch/mn10300/include/uapi/asm/socket.h @@ -80,4 +80,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h index fe35ceacf0e7..d189bb79ca07 100644 --- a/arch/parisc/include/uapi/asm/socket.h +++ b/arch/parisc/include/uapi/asm/socket.h @@ -79,4 +79,6 @@ #define SO_BPF_EXTENSIONS 0x4029 +#define SO_ATTACH_FILTER_EBPF 0x402a + #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/powerpc/include/uapi/asm/socket.h b/arch/powerpc/include/uapi/asm/socket.h index a9c3e2e18c05..88488f24ae7f 100644 --- a/arch/powerpc/include/uapi/asm/socket.h +++ b/arch/powerpc/include/uapi/asm/socket.h @@ -87,4 +87,6 @@ #define SO_BPF_EXTENSIONS 48 +#define SO_ATTACH_FILTER_EBPF 49 + #endif /* _ASM_POWERPC_SOCKET_H */ diff --git
[tip:perf/core] perf script: Display PERF_RECORD_MISC_COMM_EXEC flag
Commit-ID: 022c50d09c2c2bc31506ad16c4bcba7fb418ce34 Gitweb: http://git.kernel.org/tip/022c50d09c2c2bc31506ad16c4bcba7fb418ce34 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:27 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:34 -0300 perf script: Display PERF_RECORD_MISC_COMM_EXEC flag Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-4-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 9 - tools/perf/util/evsel.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index d0281bd..198c4cc 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -603,7 +603,14 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp) { - return fprintf(fp, ": %s:%d\n", event->comm.comm, event->comm.tid); + const char *s; + + if (event->header.misc & PERF_RECORD_MISC_COMM_EXEC) + s = " exec"; + else + s = ""; + + return fprintf(fp, "%s: %s:%d\n", s, event->comm.comm, event->comm.tid); } int perf_event__process_comm(struct perf_tool *tool __maybe_unused, diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8606175..b760d32 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -960,6 +960,7 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp) ret += PRINT_ATTR2(exclude_user, exclude_kernel); ret += PRINT_ATTR2(exclude_hv, exclude_idle); ret += PRINT_ATTR2(mmap, comm); + ret += PRINT_ATTR2(mmap2, comm_exec); ret += PRINT_ATTR2(freq, inherit_stat); ret += PRINT_ATTR2(enable_on_exec, task); ret += PRINT_ATTR2(watermark, precise_ip); @@ -967,7 +968,6 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp) ret += PRINT_ATTR2(exclude_host, exclude_guest); ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel, "excl.callchain_user", exclude_callchain_user); - ret += PRINT_ATTR_U32(mmap2); ret += PRINT_ATTR_U32(wakeup_events); ret += PRINT_ATTR_U32(wakeup_watermark); @@ -1940,6 +1940,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, if_print(mmap); if_print(mmap2); if_print(comm); + if_print(comm_exec); if_print(freq); if_print(inherit_stat); if_print(enable_on_exec); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf record: Select comm_exec flag if supported
Commit-ID: 39e09d40bea440d9cfe645b55aff251294318669 Gitweb: http://git.kernel.org/tip/39e09d40bea440d9cfe645b55aff251294318669 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:28 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:34 -0300 perf record: Select comm_exec flag if supported The comm_exec flag on the attribute can later be found in the perf.data file allowing a tool to know in advance if the captured data has the flag. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-5-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/record.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 049e0a0..1657231 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -69,15 +69,26 @@ static void perf_probe_sample_identifier(struct perf_evsel *evsel) evsel->attr.sample_type |= PERF_SAMPLE_IDENTIFIER; } +static void perf_probe_comm_exec(struct perf_evsel *evsel) +{ + evsel->attr.comm_exec = 1; +} + bool perf_can_sample_identifier(void) { return perf_probe_api(perf_probe_sample_identifier); } +static bool perf_can_comm_exec(void) +{ + return perf_probe_api(perf_probe_comm_exec); +} + void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts) { struct perf_evsel *evsel; bool use_sample_identifier = false; + bool use_comm_exec; /* * Set the evsel leader links before we configure attributes, @@ -89,8 +100,13 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts) if (evlist->cpus->map[0] < 0) opts->no_inherit = true; - evlist__for_each(evlist, evsel) + use_comm_exec = perf_can_comm_exec(); + + evlist__for_each(evlist, evsel) { perf_evsel__config(evsel, opts); + if (!evsel->idx && use_comm_exec) + evsel->attr.comm_exec = 1; + } if (evlist->nr_entries > 1) { struct perf_evsel *first = perf_evlist__first(evlist); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Move pr_* debug macros into debug object
Commit-ID: 84f5d36f486609277801e827241396334185d11c Gitweb: http://git.kernel.org/tip/84f5d36f486609277801e827241396334185d11c Author: Jiri Olsa AuthorDate: Mon, 14 Jul 2014 23:46:48 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 12:58:39 -0300 perf tools: Move pr_* debug macros into debug object Moving pr_* debug macros to have it with in same object as debug variables, becase we will change them to use verbose variable in next patch. Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1405374411-29012-3-git-send-email-jo...@kernel.org [ Add missing debug.h include in python scripting glue and in the libdw unwind lib ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/tests/dwarf-unwind.c| 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 1 + tools/perf/builtin-evlist.c | 1 + tools/perf/builtin-help.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/tests/dso-data.c | 1 + tools/perf/tests/evsel-roundtrip-name.c | 1 + tools/perf/tests/evsel-tp-sched.c | 1 + tools/perf/tests/open-syscall-tp-fields.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/tests/parse-no-sample-id-all.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/tests/thread-mg-share.c | 1 + tools/perf/util/data.c | 1 + tools/perf/util/debug.h | 20 tools/perf/util/include/linux/kernel.h | 21 - tools/perf/util/pstack.c| 1 + .../perf/util/scripting-engines/trace-event-perl.c | 1 + .../util/scripting-engines/trace-event-python.c | 1 + tools/perf/util/trace-event-info.c | 1 + tools/perf/util/trace-event-read.c | 1 + tools/perf/util/unwind-libdw.c | 1 + tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/vdso.c | 1 + 25 files changed, 43 insertions(+), 21 deletions(-) diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c index 9f89f89..d8bbf7a 100644 --- a/tools/perf/arch/x86/tests/dwarf-unwind.c +++ b/tools/perf/arch/x86/tests/dwarf-unwind.c @@ -3,6 +3,7 @@ #include "thread.h" #include "map.h" #include "event.h" +#include "debug.h" #include "tests/tests.h" #define STACK_SIZE 8192 diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c index 3261f68..db25e93 100644 --- a/tools/perf/arch/x86/util/unwind-libunwind.c +++ b/tools/perf/arch/x86/util/unwind-libunwind.c @@ -3,6 +3,7 @@ #include #include "perf_regs.h" #include "../../util/unwind.h" +#include "../../util/debug.h" #ifdef HAVE_ARCH_X86_64_SUPPORT int libunwind__arch_reg_id(int regnum) diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index c99e0de..66e12f5 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -15,6 +15,7 @@ #include "util/parse-options.h" #include "util/session.h" #include "util/data.h" +#include "util/debug.h" static int __cmd_evlist(const char *file_name, struct perf_attr_details *details) { diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 178b88a..0384d93 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -11,6 +11,7 @@ #include "util/parse-options.h" #include "util/run-command.h" #include "util/help.h" +#include "util/debug.h" static struct man_viewer_list { struct man_viewer_list *next; diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 04c9c53..2f1a522 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -37,6 +37,7 @@ #include "util/svghelper.h" #include "util/tool.h" #include "util/data.h" +#include "util/debug.h" #define SUPPORT_OLD_POWER_EVENTS 1 #define PWR_EVENT_EXIT -1 diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 630808c..caaf37f 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -10,6 +10,7 @@ #include "machine.h" #include "symbol.h" #include "tests.h" +#include "debug.h" static char *test_file(int size) { diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c index 465cdbc..b8d8341 100644 --- a/tools/perf/tests/evsel-roundtrip-name.c +++ b/tools/perf/tests/evsel-roundtrip-name.c @@ -2,6 +2,7 @@ #include "evsel.h" #include "parse-events.h" #include "tests.h" +#include "debug.h" static
Fix mes in crash.c
Hey again Ben, I am hitting quite a few fix mes in this file. I am wondering how you would like me to fix them. Cheers Nick -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Remove verbose from functions prototypes
Commit-ID: acebd408bef17169fbf79079b96f0264b535916c Gitweb: http://git.kernel.org/tip/acebd408bef17169fbf79079b96f0264b535916c Author: Jiri Olsa AuthorDate: Mon, 14 Jul 2014 23:46:47 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 11:04:42 -0300 perf tools: Remove verbose from functions prototypes And use verbose as an global object in following functions: __map_groups__fprintf_maps __map_groups__fprintf_removed_maps map_groups__fprintf_maps map_groups__fprintf Also making map_groups__fprintf_maps static. Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1405374411-29012-2-git-send-email-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/map.c | 24 tools/perf/util/map.h | 9 - tools/perf/util/thread.c | 4 ++-- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 90122ab..40af0ac 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -479,7 +479,7 @@ print_entries: if (h->ms.map == NULL && verbose > 1) { __map_groups__fprintf_maps(h->thread->mg, - MAP__FUNCTION, verbose, fp); + MAP__FUNCTION, fp); fprintf(fp, "%.10s end\n", graph_dotted_line); } } diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 7af1480..845f627 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -12,6 +12,7 @@ #include "vdso.h" #include "build-id.h" #include "util.h" +#include "debug.h" #include const char *map_type__name[MAP__NR_TYPES] = { @@ -568,8 +569,8 @@ int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter) return ams->sym ? 0 : -1; } -size_t __map_groups__fprintf_maps(struct map_groups *mg, - enum map_type type, int verbose, FILE *fp) +size_t __map_groups__fprintf_maps(struct map_groups *mg, enum map_type type, + FILE *fp) { size_t printed = fprintf(fp, "%s:\n", map_type__name[type]); struct rb_node *nd; @@ -587,17 +588,16 @@ size_t __map_groups__fprintf_maps(struct map_groups *mg, return printed; } -size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp) +static size_t map_groups__fprintf_maps(struct map_groups *mg, FILE *fp) { size_t printed = 0, i; for (i = 0; i < MAP__NR_TYPES; ++i) - printed += __map_groups__fprintf_maps(mg, i, verbose, fp); + printed += __map_groups__fprintf_maps(mg, i, fp); return printed; } static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg, -enum map_type type, -int verbose, FILE *fp) +enum map_type type, FILE *fp) { struct map *pos; size_t printed = 0; @@ -614,23 +614,23 @@ static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg, } static size_t map_groups__fprintf_removed_maps(struct map_groups *mg, - int verbose, FILE *fp) + FILE *fp) { size_t printed = 0, i; for (i = 0; i < MAP__NR_TYPES; ++i) - printed += __map_groups__fprintf_removed_maps(mg, i, verbose, fp); + printed += __map_groups__fprintf_removed_maps(mg, i, fp); return printed; } -size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp) +size_t map_groups__fprintf(struct map_groups *mg, FILE *fp) { - size_t printed = map_groups__fprintf_maps(mg, verbose, fp); + size_t printed = map_groups__fprintf_maps(mg, fp); printed += fprintf(fp, "Removed maps:\n"); - return printed + map_groups__fprintf_removed_maps(mg, verbose, fp); + return printed + map_groups__fprintf_removed_maps(mg, fp); } int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, - int verbose, FILE *fp) + FILE *fp) { struct rb_root *root = >maps[map->type]; struct rb_node *next = rb_first(root); diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 5806a90..22d13a2 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h @@ -142,8 +142,8 @@ void map__fixup_end(struct map *map); void map__reloc_vmlinux(struct map *map); -size_t __map_groups__fprintf_maps(struct map_groups *mg, - enum map_type type, int verbose, FILE *fp);
[tip:perf/core] perf tools: Allow TSC conversion on any arch
Commit-ID: 0b437860818dc717f6a9e8a5089223a8414f5fff Gitweb: http://git.kernel.org/tip/0b437860818dc717f6a9e8a5089223a8414f5fff Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:03:03 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 12:59:00 -0300 perf tools: Allow TSC conversion on any arch It is possible to record a perf.data file on one architecture and process it on another. Consequently, TSC conversion functions need to be moved out of the arch directory. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-40-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf| 2 ++ tools/perf/arch/x86/util/tsc.c | 22 +- tools/perf/arch/x86/util/tsc.h | 3 --- tools/perf/tests/perf-time-to-tsc.c | 3 +-- tools/perf/util/tsc.c | 25 + tools/perf/util/tsc.h | 11 +++ 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 90c4983..3308b22 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -295,6 +295,7 @@ LIB_H += util/intlist.h LIB_H += util/perf_regs.h LIB_H += util/unwind.h LIB_H += util/vdso.h +LIB_H += util/tsc.h LIB_H += ui/helpline.h LIB_H += ui/progress.h LIB_H += ui/util.h @@ -374,6 +375,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o LIB_OBJS += $(OUTPUT)util/record.o LIB_OBJS += $(OUTPUT)util/srcline.o LIB_OBJS += $(OUTPUT)util/data.o +LIB_OBJS += $(OUTPUT)util/tsc.o LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/helpline.o diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c index 40021fa..3655f24 100644 --- a/tools/perf/arch/x86/util/tsc.c +++ b/tools/perf/arch/x86/util/tsc.c @@ -6,29 +6,9 @@ #include "../../perf.h" #include #include "../../util/debug.h" +#include "../../util/tsc.h" #include "tsc.h" -u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc) -{ - u64 t, quot, rem; - - t = ns - tc->time_zero; - quot = t / tc->time_mult; - rem = t % tc->time_mult; - return (quot << tc->time_shift) + - (rem << tc->time_shift) / tc->time_mult; -} - -u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) -{ - u64 quot, rem; - - quot = cyc >> tc->time_shift; - rem = cyc & ((1 << tc->time_shift) - 1); - return tc->time_zero + quot * tc->time_mult + - ((rem * tc->time_mult) >> tc->time_shift); -} - int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, struct perf_tsc_conversion *tc) { diff --git a/tools/perf/arch/x86/util/tsc.h b/tools/perf/arch/x86/util/tsc.h index 2affe03..2edc4d3 100644 --- a/tools/perf/arch/x86/util/tsc.h +++ b/tools/perf/arch/x86/util/tsc.h @@ -14,7 +14,4 @@ struct perf_event_mmap_page; int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, struct perf_tsc_conversion *tc); -u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc); -u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc); - #endif /* TOOLS_PERF_ARCH_X86_UTIL_TSC_H__ */ diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c index 3b7cd4d..0372f6e 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c @@ -8,10 +8,9 @@ #include "evsel.h" #include "thread_map.h" #include "cpumap.h" +#include "tsc.h" #include "tests.h" -#include "../arch/x86/util/tsc.h" - #define CHECK__(x) { \ while ((x) < 0) { \ pr_debug(#x " failed!\n"); \ diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c new file mode 100644 index 000..ef4749836 --- /dev/null +++ b/tools/perf/util/tsc.c @@ -0,0 +1,25 @@ +#include +#include + +#include "tsc.h" + +u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc) +{ + u64 t, quot, rem; + + t = ns - tc->time_zero; + quot = t / tc->time_mult; + rem = t % tc->time_mult; + return (quot << tc->time_shift) + + (rem << tc->time_shift) / tc->time_mult; +} + +u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) +{ + u64 quot, rem; + + quot = cyc >> tc->time_shift; + rem = cyc & ((1 << tc->time_shift) - 1); + return tc->time_zero + quot * tc->time_mult + + ((rem * tc->time_mult) >> tc->time_shift); +} diff --git a/tools/perf/util/tsc.h b/tools/perf/util/tsc.h new file mode 100644 index 000..4eca848 --- /dev/null +++ b/tools/perf/util/tsc.h @@ -0,0 +1,11 @@ +#ifndef __PERF_TSC_H +#define __PERF_TSC_H + +#include + +#include "../arch/x86/util/tsc.h" + +u64 perf_time_to_tsc(u64 ns, struct
[tip:perf/core] perf tools: Factor eprintf to allow different debug variables
Commit-ID: c95688aac7723c17b2badc23233706b2f02e58ed Gitweb: http://git.kernel.org/tip/c95688aac7723c17b2badc23233706b2f02e58ed Author: Jiri Olsa AuthorDate: Mon, 14 Jul 2014 23:46:49 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 12:58:59 -0300 perf tools: Factor eprintf to allow different debug variables This way we can easily reuse current debug functions for another debug variables other than verbose. Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1405374411-29012-4-git-send-email-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/debug.c | 12 ++-- tools/perf/util/debug.h | 12 ++-- tools/perf/util/python.c | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 299b555..c208d6f 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -16,11 +16,11 @@ int verbose; bool dump_trace = false, quiet = false; -static int _eprintf(int level, const char *fmt, va_list args) +static int _eprintf(int level, int var, const char *fmt, va_list args) { int ret = 0; - if (verbose >= level) { + if (var >= level) { if (use_browser >= 1) ui_helpline__vshow(fmt, args); else @@ -30,13 +30,13 @@ static int _eprintf(int level, const char *fmt, va_list args) return ret; } -int eprintf(int level, const char *fmt, ...) +int eprintf(int level, int var, const char *fmt, ...) { va_list args; int ret; va_start(args, fmt); - ret = _eprintf(level, fmt, args); + ret = _eprintf(level, var, fmt, args); va_end(args); return ret; @@ -51,9 +51,9 @@ void pr_stat(const char *fmt, ...) va_list args; va_start(args, fmt); - _eprintf(1, fmt, args); + _eprintf(1, verbose, fmt, args); va_end(args); - eprintf(1, "\n"); + eprintf(1, verbose, "\n"); } int dump_printf(const char *fmt, ...) diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 8a8ceb3..1cb8081 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -16,15 +16,15 @@ extern bool quiet, dump_trace; #endif #define pr_err(fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warning(fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_info(fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_debug(fmt, ...) \ - eprintf(1, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_debugN(n, fmt, ...) \ - eprintf(n, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__) #define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__) #define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__) #define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__) @@ -37,6 +37,6 @@ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); void pr_stat(const char *fmt, ...); -int eprintf(int level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int eprintf(int level, int var, const char *fmt, ...) __attribute__((format(printf, 3, 4))); #endif /* __PERF_DEBUG_H */ diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 122669c..12aa9b0 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -14,12 +14,12 @@ */ int verbose; -int eprintf(int level, const char *fmt, ...) +int eprintf(int level, int var, const char *fmt, ...) { va_list args; int ret = 0; - if (verbose >= level) { + if (var >= level) { va_start(args, fmt); ret = vfprintf(stderr, fmt, args); va_end(args); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Add --debug optionto set debug variable
Commit-ID: bbb2cea7e8dd496b41558df1a0ec9205497b7ebf Gitweb: http://git.kernel.org/tip/bbb2cea7e8dd496b41558df1a0ec9205497b7ebf Author: Jiri Olsa AuthorDate: Thu, 17 Jul 2014 12:55:00 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 12:58:59 -0300 perf tools: Add --debug optionto set debug variable Adding --debug option as a way to setup debug variables. Starting with support for verbose, more will come. It's possible to use it now with report command: $ perf --debug verbose ... $ perf --debug verbose=2 ... I'll need this support to add separated debug variable for ordered events change in order to separate debug output out of standard verbose stream. Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20140717105500.gg...@krava.redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf.txt | 10 - tools/perf/perf.c | 13 +++- tools/perf/util/debug.c | 44 +++ tools/perf/util/debug.h | 2 ++ 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt index 0eeb247..d240bb2 100644 --- a/tools/perf/Documentation/perf.txt +++ b/tools/perf/Documentation/perf.txt @@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux SYNOPSIS [verse] -'perf' [--version] [--help] COMMAND [ARGS] +'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS] + +OPTIONS +--- +--debug:: + Setup debug variable (just verbose for now) in value + range (0, 10). Use like: + --debug verbose # sets verbose = 1 + --debug verbose=2 # sets verbose = 2 DESCRIPTION --- diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 95c58fc..eed3fb2 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -13,11 +13,12 @@ #include "util/quote.h" #include "util/run-command.h" #include "util/parse-events.h" +#include "util/debug.h" #include #include const char perf_usage_string[] = - "perf [--version] [--help] COMMAND [ARGS]"; + "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]"; const char perf_more_info_string[] = "See 'perf help COMMAND' for more information on a specific command."; @@ -212,6 +213,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) printf("%s ", p->cmd); } exit(0); + } else if (!strcmp(cmd, "--debug")) { + if (*argc < 2) { + fprintf(stderr, "No variable specified for --debug.\n"); + usage(perf_usage_string); + } + if (perf_debug_option((*argv)[1])) + usage(perf_usage_string); + + (*argv)++; + (*argc)--; } else { fprintf(stderr, "Unknown option: %s\n", cmd); usage(perf_usage_string); diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index c208d6f..71d4193 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -105,3 +105,47 @@ void trace_event(union perf_event *event) } printf(".\n"); } + +static struct debug_variable { + const char *name; + int *ptr; +} debug_variables[] = { + { .name = "verbose", .ptr = }, + { .name = NULL, } +}; + +int perf_debug_option(const char *str) +{ + struct debug_variable *var = _variables[0]; + char *vstr, *s = strdup(str); + int v = 1; + + vstr = strchr(s, '='); + if (vstr) + *vstr++ = 0; + + while (var->name) { + if (!strcmp(s, var->name)) + break; + var++; + } + + if (!var->name) { + pr_err("Unknown debug variable name '%s'\n", s); + free(s); + return -1; + } + + if (vstr) { + v = atoi(vstr); + /* +* Allow only values in range (0, 10), +* otherwise set 0. +*/ + v = (v < 0) || (v > 10) ? 0 : v; + } + + *var->ptr = v; + free(s); + return 0; +} diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 1cb8081..89fb6b0 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -39,4 +39,6 @@ void pr_stat(const char *fmt, ...); int eprintf(int level, int var, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +int perf_debug_option(const char *str); + #endif /* __PERF_DEBUG_H */ -- To unsubscribe from this list: send the line
[tip:perf/core] perf machine: Fix leak of 'struct thread' on error path
Commit-ID: 418029b7324f8b90ac1dfbc8a44555d6905be761 Gitweb: http://git.kernel.org/tip/418029b7324f8b90ac1dfbc8a44555d6905be761 Author: Adrian Hunter AuthorDate: Wed, 16 Jul 2014 10:19:44 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 10:34:07 -0300 perf machine: Fix leak of 'struct thread' on error path __machine__findnew_thread() creates a 'struct thread' but does not free it on the error path. Fix it. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405495184-20441-3-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5484fa4..93c8b6f 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -370,8 +370,10 @@ static struct thread *__machine__findnew_thread(struct machine *machine, * within thread__init_map_groups to find the thread * leader and that would screwed the rb tree. */ - if (thread__init_map_groups(th, machine)) + if (thread__init_map_groups(th, machine)) { + thread__delete(th); return NULL; + } } return th; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Remove needless getopt.h includes
Commit-ID: ff527bccd469067a64f4ae9747b9045914667d34 Gitweb: http://git.kernel.org/tip/ff527bccd469067a64f4ae9747b9045914667d34 Author: Jiri Olsa AuthorDate: Mon, 14 Jul 2014 23:46:51 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 12:59:00 -0300 perf tools: Remove needless getopt.h includes We don't use getopt.h interfaces. Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1405374411-29012-6-git-send-email-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-finder.c | 1 - tools/perf/util/trace-event-read.c | 1 - 2 files changed, 2 deletions(-) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 98e3047..dca9145 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index ea3fd7f..54d9e9b 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf thread: Allow deletion of a thread with no map groups
Commit-ID: 9608b84e4dd95341b88cad646b114811f5bccbba Gitweb: http://git.kernel.org/tip/9608b84e4dd95341b88cad646b114811f5bccbba Author: Adrian Hunter AuthorDate: Wed, 16 Jul 2014 10:19:43 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 10:32:35 -0300 perf thread: Allow deletion of a thread with no map groups It needs to be possible to call thread__delete() on a thread with no map groups. This is needed for a subsequent patch which deletes a thread on the error path before map groups have been attached. Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405495184-20441-2-git-send-email-adrian.hun...@intel.com Signed-off-by: Adrian Hunter Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/thread.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 7a32f44..b9c36ef 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -60,8 +60,10 @@ void thread__delete(struct thread *thread) { struct comm *comm, *tmp; - map_groups__put(thread->mg); - thread->mg = NULL; + if (thread->mg) { + map_groups__put(thread->mg); + thread->mg = NULL; + } list_for_each_entry_safe(comm, tmp, >comm_list, list) { list_del(>list); comm__free(comm); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf symbols: Add ability to iterate over a dso' s symbols
Commit-ID: 9c00a81b6aafc4ed375a43e7a54e6cf2d720c7c6 Gitweb: http://git.kernel.org/tip/9c00a81b6aafc4ed375a43e7a54e6cf2d720c7c6 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:50 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:35 -0300 perf symbols: Add ability to iterate over a dso's symbols Expose dso__first_symbol() and dso__next_symbol() to make it possible to iterate over a dso's symbols. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-27-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 17 - tools/perf/util/symbol.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 156ae36..eb06746 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -342,6 +342,16 @@ static struct symbol *symbols__first(struct rb_root *symbols) return NULL; } +static struct symbol *symbols__next(struct symbol *sym) +{ + struct rb_node *n = rb_next(>rb_node); + + if (n) + return rb_entry(n, struct symbol, rb_node); + + return NULL; +} + struct symbol_name_rb_node { struct rb_node rb_node; struct symbol sym; @@ -412,11 +422,16 @@ struct symbol *dso__find_symbol(struct dso *dso, return symbols__find(>symbols[type], addr); } -static struct symbol *dso__first_symbol(struct dso *dso, enum map_type type) +struct symbol *dso__first_symbol(struct dso *dso, enum map_type type) { return symbols__first(>symbols[type]); } +struct symbol *dso__next_symbol(struct symbol *sym) +{ + return symbols__next(sym); +} + struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, const char *name) { diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 436169d..ee2d3cc 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -240,6 +240,9 @@ struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, const char *name); +struct symbol *dso__first_symbol(struct dso *dso, enum map_type type); +struct symbol *dso__next_symbol(struct symbol *sym); + int filename__read_build_id(const char *filename, void *bf, size_t size); int sysfs__read_build_id(const char *filename, void *bf, size_t size); int modules__parse(const char *filename, void *arg, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf symbols: Do not attempt to read data from kallsyms
Commit-ID: bdac0bcf779250e89b96d4a3f381ebaf02c2f4a9 Gitweb: http://git.kernel.org/tip/bdac0bcf779250e89b96d4a3f381ebaf02c2f4a9 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:43 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:35 -0300 perf symbols: Do not attempt to read data from kallsyms Record kallsyms binary type so that tools will not attempt to read binary data from it. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-20-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index ae2e446..156ae36 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1664,6 +1664,7 @@ do_kallsyms: free(kallsyms_allocated_filename); if (err > 0 && !dso__is_kcore(dso)) { + dso->binary_type = DSO_BINARY_TYPE__KALLSYMS; dso__set_long_name(dso, "[kernel.kallsyms]", false); map__fixup_start(map); map__fixup_end(map); @@ -1711,6 +1712,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map, if (err > 0) pr_debug("Using %s for symbols\n", kallsyms_filename); if (err > 0 && !dso__is_kcore(dso)) { + dso->binary_type = DSO_BINARY_TYPE__GUEST_KALLSYMS; machine__mmap_name(machine, path, sizeof(path)); dso__set_long_name(dso, strdup(path), true); map__fixup_start(map); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf evsel: Add 'immediate' option
Commit-ID: 2afd2bcfc3a026d6e4c2184bf41ccd74eb05758b Gitweb: http://git.kernel.org/tip/2afd2bcfc3a026d6e4c2184bf41ccd74eb05758b Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:57 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:37 -0300 perf evsel: Add 'immediate' option Add an option to cause a selected event to be enabled immediately when configured by perf_evsel__config(). This is needed when using the sched_switch tracepoint to follow object code execution. By having sched_switch enabled immediately the first sched_switch event precedes the start of other tracing. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-34-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 5 + tools/perf/util/evsel.h | 1 + 2 files changed, 6 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 40626e5..90f58cd 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -681,6 +681,11 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) if (target__none(>target) && perf_evsel__is_group_leader(evsel) && !opts->initial_delay) attr->enable_on_exec = 1; + + if (evsel->immediate) { + attr->disabled = 0; + attr->enable_on_exec = 0; + } } int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 8dfec05..d7f93ce 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -84,6 +84,7 @@ struct perf_evsel { boolsupported; boolneeds_swap; boolno_aux_samples; + boolimmediate; /* parse modifier helper */ int exclude_GH; int nr_members; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf session: Flag if the event stream is entirely in memory
Commit-ID: 919d86d3a3109d7d4f0d7347f34711ee2f8e6609 Gitweb: http://git.kernel.org/tip/919d86d3a3109d7d4f0d7347f34711ee2f8e6609 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:51 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:36 -0300 perf session: Flag if the event stream is entirely in memory Flag if the event stream is a file that has been mmapped in one go. This is useful, for example, if a tool needs to keep an event for later reference. If the new flag is set, a pointer to the event can be retained, otherwise the event must be copied. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-28-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/session.c | 9 - tools/perf/util/session.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c2f4ca9..eac14ce 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1297,8 +1297,10 @@ int __perf_session__process_events(struct perf_session *session, ui_progress__init(, file_size, "Processing events..."); mmap_size = MMAP_SIZE; - if (mmap_size > file_size) + if (mmap_size > file_size) { mmap_size = file_size; + session->one_mmap = true; + } memset(mmaps, 0, sizeof(mmaps)); @@ -1320,6 +1322,10 @@ remap: mmaps[map_idx] = buf; map_idx = (map_idx + 1) & (ARRAY_SIZE(mmaps) - 1); file_pos = file_offset + head; + if (session->one_mmap) { + session->one_mmap_addr = buf; + session->one_mmap_offset = file_offset; + } more: event = fetch_mmaped_event(session, head, mmap_size, buf); @@ -1365,6 +1371,7 @@ out_err: ui_progress__finish(); perf_session__warn_about_errors(session, tool); perf_session_free_sample_buffers(session); + session->one_mmap = false; return err; } diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 3140f8a..0321013 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -36,6 +36,9 @@ struct perf_session { struct trace_event tevent; struct events_stats stats; boolrepipe; + boolone_mmap; + void*one_mmap_addr; + u64 one_mmap_offset; struct ordered_samples ordered_samples; struct perf_data_file *file; }; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Add feature test for __sync_val_compare_and_swap
Commit-ID: f6d313699a9612a30fabe05bf2c9302c1408b5cf Gitweb: http://git.kernel.org/tip/f6d313699a9612a30fabe05bf2c9302c1408b5cf Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:53 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:36 -0300 perf tools: Add feature test for __sync_val_compare_and_swap Add a feature test for __sync_val_compare_and_swap() and __sync_bool_compare_and_swap() Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-30-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/config/Makefile | 6 ++ tools/perf/config/feature-checks/Makefile | 4 tools/perf/config/feature-checks/test-all.c| 5 + .../config/feature-checks/test-sync-compare-and-swap.c | 14 ++ 4 files changed, 29 insertions(+) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index b7f42d5..1f67aa0 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -164,6 +164,7 @@ CORE_FEATURE_TESTS =\ backtrace \ dwarf \ fortify-source \ + sync-compare-and-swap \ glibc \ gtk2\ gtk2-infobar\ @@ -199,6 +200,7 @@ LIB_FEATURE_TESTS = \ VF_FEATURE_TESTS = \ backtrace \ fortify-source \ + sync-compare-and-swap \ gtk2-infobar\ libelf-getphdrnum \ libelf-mmap \ @@ -272,6 +274,10 @@ CFLAGS += -I$(LIB_INCLUDE) CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE +ifeq ($(feature-sync-compare-and-swap), 1) + CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT +endif + ifndef NO_BIONIC $(call feature_check,bionic) ifeq ($(feature-bionic), 1) diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile index 64c84e5..6088f8d 100644 --- a/tools/perf/config/feature-checks/Makefile +++ b/tools/perf/config/feature-checks/Makefile @@ -5,6 +5,7 @@ FILES= \ test-bionic.bin \ test-dwarf.bin \ test-fortify-source.bin \ + test-sync-compare-and-swap.bin \ test-glibc.bin \ test-gtk2.bin \ test-gtk2-infobar.bin \ @@ -141,6 +142,9 @@ test-timerfd.bin: test-libdw-dwarf-unwind.bin: $(BUILD) +test-sync-compare-and-swap.bin: + $(BUILD) -Werror + -include *.d ### diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c index fe5c1e5..a7d022e 100644 --- a/tools/perf/config/feature-checks/test-all.c +++ b/tools/perf/config/feature-checks/test-all.c @@ -89,6 +89,10 @@ # include "test-libdw-dwarf-unwind.c" #undef main +#define main main_test_sync_compare_and_swap +# include "test-sync-compare-and-swap.c" +#undef main + int main(int argc, char *argv[]) { main_test_libpython(); @@ -111,6 +115,7 @@ int main(int argc, char *argv[]) main_test_timerfd(); main_test_stackprotector_all(); main_test_libdw_dwarf_unwind(); + main_test_sync_compare_and_swap(argc, argv); return 0; } diff --git a/tools/perf/config/feature-checks/test-sync-compare-and-swap.c b/tools/perf/config/feature-checks/test-sync-compare-and-swap.c new file mode 100644 index 000..c34d4ca --- /dev/null +++ b/tools/perf/config/feature-checks/test-sync-compare-and-swap.c @@ -0,0 +1,14 @@ +#include + +volatile uint64_t x; + +int main(int argc, char *argv[]) +{ + uint64_t old, new = argc; + + argv = argv; + do { + old = __sync_val_compare_and_swap(, 0, 0); + } while (!__sync_bool_compare_and_swap(, old, new)); + return old == new; +} -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf machine: Fix map groups of threads with unknown pids
Commit-ID: 29ce36121e6738012aaf00d983d25260627f2b0d Gitweb: http://git.kernel.org/tip/29ce36121e6738012aaf00d983d25260627f2b0d Author: Adrian Hunter AuthorDate: Wed, 16 Jul 2014 11:07:13 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Jul 2014 10:31:02 -0300 perf machine: Fix map groups of threads with unknown pids Events like sched_switch do not provide a pid (tgid) which can result in threads with an unknown pid. If the pid is later discovered, join the map groups. Note the thread's map groups should be empty because they are populated by MMAP events which do provide the pid and tid. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405498033-23817-1-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 57 ++- tools/perf/util/map.c | 14 tools/perf/util/map.h | 1 + 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5b80877..5484fa4 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -272,6 +272,52 @@ void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size) return; } +static void machine__update_thread_pid(struct machine *machine, + struct thread *th, pid_t pid) +{ + struct thread *leader; + + if (pid == th->pid_ || pid == -1 || th->pid_ != -1) + return; + + th->pid_ = pid; + + if (th->pid_ == th->tid) + return; + + leader = machine__findnew_thread(machine, th->pid_, th->pid_); + if (!leader) + goto out_err; + + if (!leader->mg) + leader->mg = map_groups__new(); + + if (!leader->mg) + goto out_err; + + if (th->mg == leader->mg) + return; + + if (th->mg) { + /* +* Maps are created from MMAP events which provide the pid and +* tid. Consequently there never should be any maps on a thread +* with an unknown pid. Just print an error if there are. +*/ + if (!map_groups__empty(th->mg)) + pr_err("Discarding thread maps for %d:%d\n", + th->pid_, th->tid); + map_groups__delete(th->mg); + } + + th->mg = map_groups__get(leader->mg); + + return; + +out_err: + pr_err("Failed to join map groups for %d:%d\n", th->pid_, th->tid); +} + static struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid, bool create) @@ -285,10 +331,10 @@ static struct thread *__machine__findnew_thread(struct machine *machine, * so most of the time we dont have to look up * the full rbtree: */ - if (machine->last_match && machine->last_match->tid == tid) { - if (pid != -1 && pid != machine->last_match->pid_) - machine->last_match->pid_ = pid; - return machine->last_match; + th = machine->last_match; + if (th && th->tid == tid) { + machine__update_thread_pid(machine, th, pid); + return th; } while (*p != NULL) { @@ -297,8 +343,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine, if (th->tid == tid) { machine->last_match = th; - if (pid != -1 && pid != th->pid_) - th->pid_ = pid; + machine__update_thread_pid(machine, th, pid); return th; } diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 25c571f..7af1480 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -454,6 +454,20 @@ void map_groups__exit(struct map_groups *mg) } } +bool map_groups__empty(struct map_groups *mg) +{ + int i; + + for (i = 0; i < MAP__NR_TYPES; ++i) { + if (maps__first(>maps[i])) + return false; + if (!list_empty(>removed_maps[i])) + return false; + } + + return true; +} + struct map_groups *map_groups__new(void) { struct map_groups *mg = malloc(sizeof(*mg)); diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 7758c72..5806a90 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h @@ -66,6 +66,7 @@ struct map_groups { struct map_groups *map_groups__new(void); void map_groups__delete(struct map_groups *mg); +bool map_groups__empty(struct map_groups *mg); static inline struct
[tip:perf/core] perf evsel: Add 'no_aux_samples' option
Commit-ID: 6ff1ce763921f605aaf98c7a828b7df24d6923dc Gitweb: http://git.kernel.org/tip/6ff1ce763921f605aaf98c7a828b7df24d6923dc Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:56 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:36 -0300 perf evsel: Add 'no_aux_samples' option Add an option to prevent additional samples being added to a selected event by perf_evsel__config(). This is needed when using the sched_switch tracepoint to follow object code execution. Since sched_switch will be used only for switch information, additional sampling is wasteful. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-33-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 6 +++--- tools/perf/util/evsel.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b760d32..40626e5 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -623,7 +623,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->mmap_data = track; } - if (opts->call_graph_enabled) + if (opts->call_graph_enabled && !evsel->no_aux_samples) perf_evsel__config_callgraph(evsel, opts); if (target__has_cpu(>target)) @@ -637,7 +637,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) target__has_cpu(>target) || per_cpu)) perf_evsel__set_sample_bit(evsel, TIME); - if (opts->raw_samples) { + if (opts->raw_samples && !evsel->no_aux_samples) { perf_evsel__set_sample_bit(evsel, TIME); perf_evsel__set_sample_bit(evsel, RAW); perf_evsel__set_sample_bit(evsel, CPU); @@ -650,7 +650,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->watermark = 0; attr->wakeup_events = 1; } - if (opts->branch_stack) { + if (opts->branch_stack && !evsel->no_aux_samples) { perf_evsel__set_sample_bit(evsel, BRANCH_STACK); attr->branch_sample_type = opts->branch_stack; } diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index a52e9a5..8dfec05 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -83,6 +83,7 @@ struct perf_evsel { int is_pos; boolsupported; boolneeds_swap; + boolno_aux_samples; /* parse modifier helper */ int exclude_GH; int nr_members; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Add option macro OPT_CALLBACK_OPTARG
Commit-ID: ea8e08a16a1e6566be3f775c0bd351fa52ab6b9d Gitweb: http://git.kernel.org/tip/ea8e08a16a1e6566be3f775c0bd351fa52ab6b9d Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:54 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:36 -0300 perf tools: Add option macro OPT_CALLBACK_OPTARG Add an option macro that is the same as OPT_CALLBACK except that the argument is optional and it is possible to associate additional data with it. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-31-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-options.h | 5 + 1 file changed, 5 insertions(+) diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h index d8dac8a..b59ba85 100644 --- a/tools/perf/util/parse-options.h +++ b/tools/perf/util/parse-options.h @@ -98,6 +98,7 @@ struct option { parse_opt_cb *callback; intptr_t defval; bool *set; + void *data; }; #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v ) @@ -131,6 +132,10 @@ struct option { { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\ .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\ .flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG} +#define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \ + { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), \ + .value = (v), (a), .help = (h), .callback = (f), \ + .flags = PARSE_OPT_OPTARG, .data = (d) } /* parse_options() will filter out the processed options and leave the * non-option argments in argv[]. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf evlist: Pass mmap parameters in a struct
Commit-ID: a8a8f3eb5de55aeaf007c18572668e8ec463547b Gitweb: http://git.kernel.org/tip/a8a8f3eb5de55aeaf007c18572668e8ec463547b Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:52 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:36 -0300 perf evlist: Pass mmap parameters in a struct In preparation for adding more mmap parameters, pass existing parameters in a struct. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-29-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 46 ++ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c51223a..814e954 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -606,12 +606,17 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) return evlist->mmap != NULL ? 0 : -ENOMEM; } -static int __perf_evlist__mmap(struct perf_evlist *evlist, - int idx, int prot, int mask, int fd) +struct mmap_params { + int prot; + int mask; +}; + +static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, + struct mmap_params *mp, int fd) { evlist->mmap[idx].prev = 0; - evlist->mmap[idx].mask = mask; - evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot, + evlist->mmap[idx].mask = mp->mask; + evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, mp->prot, MAP_SHARED, fd, 0); if (evlist->mmap[idx].base == MAP_FAILED) { pr_debug2("failed to mmap perf event ring buffer, error %d\n", @@ -625,8 +630,8 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, } static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, - int prot, int mask, int cpu, int thread, - int *output) + struct mmap_params *mp, int cpu, + int thread, int *output) { struct perf_evsel *evsel; @@ -635,8 +640,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, if (*output == -1) { *output = fd; - if (__perf_evlist__mmap(evlist, idx, prot, mask, - *output) < 0) + if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0) return -1; } else { if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0) @@ -651,8 +655,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, return 0; } -static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, -int mask) +static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, +struct mmap_params *mp) { int cpu, thread; int nr_cpus = cpu_map__nr(evlist->cpus); @@ -663,8 +667,8 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int output = -1; for (thread = 0; thread < nr_threads; thread++) { - if (perf_evlist__mmap_per_evsel(evlist, cpu, prot, mask, - cpu, thread, )) + if (perf_evlist__mmap_per_evsel(evlist, cpu, mp, cpu, + thread, )) goto out_unmap; } } @@ -677,8 +681,8 @@ out_unmap: return -1; } -static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, - int mask) +static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, + struct mmap_params *mp) { int thread; int nr_threads = thread_map__nr(evlist->threads); @@ -687,8 +691,8 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, for (thread = 0; thread < nr_threads; thread++) { int output = -1; - if (perf_evlist__mmap_per_evsel(evlist, thread, prot, mask, 0, - thread, )) + if (perf_evlist__mmap_per_evsel(evlist, thread, mp, 0, thread, + )) goto out_unmap; } @@ -793,7 +797,9 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, struct perf_evsel *evsel; const
[tip:perf/core] perf kvm: Move arch specific code into arch/
Commit-ID: 9daa81239e60c162153fb2a365b8492c9a9bf632 Gitweb: http://git.kernel.org/tip/9daa81239e60c162153fb2a365b8492c9a9bf632 Author: Alexander Yarygin AuthorDate: Thu, 3 Jul 2014 18:29:05 +0400 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:32 -0300 perf kvm: Move arch specific code into arch/ Parts of a 'perf kvm stat' code make sense only for x86. Let's move this code into the arch/x86/kvm-stat.c file and add util/kvm-stat.h for generic structure definitions. Add a global array 'kvm_reg_events_ops' for accessing the arch-specific 'kvm_events_ops' from generic code. Since the several global arrays (i.e. 'kvm_events_tp') have been moved to arch/*, we can not know their sizes and use them directly in builtin-kvm.c. This patch fixes that problem by adding trimming NULL element to each array and changing the behavior of their handlers in generic code. Reviewed-by: David Ahern Reviewed-by: Cornelia Huck Signed-off-by: Alexander Yarygin Acked-by: Christian Borntraeger Cc: Christian Borntraeger Cc: Cornelia Huck Cc: David Ahern Cc: Ingo Molnar Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1404397747-20939-3-git-send-email-yary...@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf| 1 + tools/perf/arch/x86/Makefile| 1 + tools/perf/arch/x86/util/kvm-stat.c | 151 ++ tools/perf/builtin-kvm.c| 297 +--- tools/perf/util/kvm-stat.h | 130 5 files changed, 317 insertions(+), 263 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 9670a16..90c4983 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -300,6 +300,7 @@ LIB_H += ui/progress.h LIB_H += ui/util.h LIB_H += ui/ui.h LIB_H += util/data.h +LIB_H += util/kvm-stat.h LIB_OBJS += $(OUTPUT)util/abspath.o LIB_OBJS += $(OUTPUT)util/alias.o diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile index d393901..9b21881 100644 --- a/tools/perf/arch/x86/Makefile +++ b/tools/perf/arch/x86/Makefile @@ -16,3 +16,4 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o LIB_H += arch/$(ARCH)/util/tsc.h HAVE_KVM_STAT_SUPPORT := 1 +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/kvm-stat.o diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c new file mode 100644 index 000..2f8d2c1 --- /dev/null +++ b/tools/perf/arch/x86/util/kvm-stat.c @@ -0,0 +1,151 @@ +#include "../../util/kvm-stat.h" +#include + +define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS); +define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS); + +static struct kvm_events_ops exit_events = { + .is_begin_event = exit_event_begin, + .is_end_event = exit_event_end, + .decode_key = exit_event_decode_key, + .name = "VM-EXIT" +}; + +/* + * For the mmio events, we treat: + * the time of MMIO write: kvm_mmio(KVM_TRACE_MMIO_WRITE...) -> kvm_entry + * the time of MMIO read: kvm_exit -> kvm_mmio(KVM_TRACE_MMIO_READ...). + */ +static void mmio_event_get_key(struct perf_evsel *evsel, struct perf_sample *sample, + struct event_key *key) +{ + key->key = perf_evsel__intval(evsel, sample, "gpa"); + key->info = perf_evsel__intval(evsel, sample, "type"); +} + +#define KVM_TRACE_MMIO_READ_UNSATISFIED 0 +#define KVM_TRACE_MMIO_READ 1 +#define KVM_TRACE_MMIO_WRITE 2 + +static bool mmio_event_begin(struct perf_evsel *evsel, +struct perf_sample *sample, struct event_key *key) +{ + /* MMIO read begin event in kernel. */ + if (kvm_exit_event(evsel)) + return true; + + /* MMIO write begin event in kernel. */ + if (!strcmp(evsel->name, "kvm:kvm_mmio") && + perf_evsel__intval(evsel, sample, "type") == KVM_TRACE_MMIO_WRITE) { + mmio_event_get_key(evsel, sample, key); + return true; + } + + return false; +} + +static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample, + struct event_key *key) +{ + /* MMIO write end event in kernel. */ + if (kvm_entry_event(evsel)) + return true; + + /* MMIO read end event in kernel.*/ + if (!strcmp(evsel->name, "kvm:kvm_mmio") && + perf_evsel__intval(evsel, sample, "type") == KVM_TRACE_MMIO_READ) { + mmio_event_get_key(evsel, sample, key); + return true; + } + + return false; +} + +static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, + struct event_key *key, + char *decode) +{ + scnprintf(decode, DECODE_STR_LEN, "%#lx:%s", + (unsigned long)key->key, + key->info ==
Re: RE: [PATCH 2/4] power_supply: Introduce generic psy charging driver
From: Tc, Jenny > > > From: Sebastian Reichel [mailto:s...@kernel.org] > > Sent: Friday, July 18, 2014 7:49 AM > > To: Tc, Jenny > > Cc: linux-kernel@vger.kernel.org; Dmitry Eremin-Solenikov; Pavel Machek; > > Anton > > Vorontsov; David Woodhouse; David Cohen; Pallala, Ramakrishna; > > myungjoo@samsung.com > > Subject: Re: [PATCH 2/4] power_supply: Introduce generic psy charging driver > > > > Hi Jenny, > > > > On Tue, Jul 08, 2014 at 11:34:19AM +0530, Jenny TC wrote: > > > The Power Supply charging driver connects multiple subsystems to do > > > charging in a generic way. The subsystems involves power_supply, > > > thermal and battery communication subsystems (1wire). With this the > > > charging is handled in a generic way. > > > > > > The driver makes use of different new features - Battery > > > Identification interfaces, pluggable charging algorithms, charger cable > > > arbitrations > > etc. > > > The patch also introduces generic interface for charger cable > > > notifications. > > > Charger cable events and capabilities can be notified using the > > > generic power_supply_notifier chain. > > > > > > Overall this driver removes the charging logic out of the charger chip > > > driver and the charger chip driver can just listen to the request from > > > the power supply charging driver to set the charger properties. This > > > can be implemented by exposing get_property and set property callbacks. > > > > this seems to be a superset of charger-manager, which is already in the > > kernel. I > > would prefer not to have two different charger mangement frameworks in the > > kernel. > > > > I suggest to add features supported by charger-manager to power supply > > charging > > driver and convert users of charger-manager to the improved driver. > > > > I CC'd MyungJoo Ham, who wrote the charger-manager, so that he can also give > > feedback. > > We are back to the initial discussions we had in the list. The initial > proposal > was for the charger manager. The charger manager is more aligned to > regulator framework, use private notification > mechanisms(cm_notify_event,fullbatt_vchk etc) and relies more on > platform data (struct charger_desc). This doesn't seems to be good to support > plug in > charger drivers, charging algorithms, battery identification drivers at > runtime. Then, the additional requirement is - Online or runtime modification or probe of the platform data (use .ko?) for "plugin chargers & battery identification) - Externally implement charging algorithms. (allow charger-manager to have an external funtion pointer?) > Power supply charger driver is introduced to meet all these requirements by > extending the existing power_supply subsystem features like > power_supply_changed event, power_supply_register, power supply thermal > throttling mechanism so that plugging new driver would be > easy. Also the user interfaces would remain the same as power_supply > subsystem. - Replace (rewrite) charger-manager's private event handlers with power supply changed work? For identifying plugin (external) chargers and feeding such information to charger-manager, extcon might be a good interconnection, which is initially designed for devices supporting differernt external chargers. (USB charger, 1.5A OEM charger, 1.0A 3rd party "popular" charger, ...) > > Able to locate link on the discussion. > http://www.gossamer-threads.com/lists/linux/kernel/1562180. Cheers, MyungJoo ps. CC'd related collegues as well. (Sangjung, Chanwoo, Jonghwa) -- MyungJoo Ham (함명주), PHD Frontier CS Lab, Software Center Samsung Electronics Cell: +82-10-6714-2858
[tip:perf/core] perf script: Add callchain to generic and tracepoint events
Commit-ID: 0f5f5bcd112292f14b75750dde7461463bb1c7bb Gitweb: http://git.kernel.org/tip/0f5f5bcd112292f14b75750dde7461463bb1c7bb Author: Joseph Schuchart AuthorDate: Thu, 10 Jul 2014 13:50:51 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:33 -0300 perf script: Add callchain to generic and tracepoint events This provides valuable information for tracing performance problems. Since this change alters the interface for the python scripts, also adjust the script generation and the provided scripts. Signed-off-by: Joseph Schuchart Acked-by: Thomas Ilsche Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Thomas Ilsche Link: http://lkml.kernel.org/r/53be7e1b.10...@tu-dresden.de Signed-off-by: Arnaldo Carvalho de Melo --- .../python/Perf-Trace-Util/lib/Perf/Trace/Core.py | 3 +- tools/perf/scripts/python/check-perf-trace.py | 4 +- .../perf/scripts/python/failed-syscalls-by-pid.py | 2 +- tools/perf/scripts/python/futex-contention.py | 4 +- tools/perf/scripts/python/net_dropmonitor.py | 2 +- tools/perf/scripts/python/netdev-times.py | 26 ++--- tools/perf/scripts/python/sched-migration.py | 41 tools/perf/scripts/python/sctop.py | 2 +- tools/perf/scripts/python/syscall-counts-by-pid.py | 2 +- tools/perf/scripts/python/syscall-counts.py| 2 +- .../util/scripting-engines/trace-event-python.c| 106 - 11 files changed, 146 insertions(+), 48 deletions(-) diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py index de7211e..38dfb72 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py +++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py @@ -107,12 +107,13 @@ def taskState(state): class EventHeaders: def __init__(self, common_cpu, common_secs, common_nsecs, -common_pid, common_comm): +common_pid, common_comm, common_callchain): self.cpu = common_cpu self.secs = common_secs self.nsecs = common_nsecs self.pid = common_pid self.comm = common_comm + self.callchain = common_callchain def ts(self): return (self.secs * (10 ** 9)) + self.nsecs diff --git a/tools/perf/scripts/python/check-perf-trace.py b/tools/perf/scripts/python/check-perf-trace.py index 4647a76..334599c 100644 --- a/tools/perf/scripts/python/check-perf-trace.py +++ b/tools/perf/scripts/python/check-perf-trace.py @@ -27,7 +27,7 @@ def trace_end(): def irq__softirq_entry(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, - vec): + common_callchain, vec): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) @@ -38,7 +38,7 @@ def irq__softirq_entry(event_name, context, common_cpu, def kmem__kmalloc(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, - call_site, ptr, bytes_req, bytes_alloc, + common_callchain, call_site, ptr, bytes_req, bytes_alloc, gfp_flags): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) diff --git a/tools/perf/scripts/python/failed-syscalls-by-pid.py b/tools/perf/scripts/python/failed-syscalls-by-pid.py index 266a836..cafeff3 100644 --- a/tools/perf/scripts/python/failed-syscalls-by-pid.py +++ b/tools/perf/scripts/python/failed-syscalls-by-pid.py @@ -39,7 +39,7 @@ def trace_end(): def raw_syscalls__sys_exit(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, - id, ret): + common_callchain, id, ret): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return diff --git a/tools/perf/scripts/python/futex-contention.py b/tools/perf/scripts/python/futex-contention.py index 11e70a3..0f5cf43 100644 --- a/tools/perf/scripts/python/futex-contention.py +++ b/tools/perf/scripts/python/futex-contention.py @@ -21,7 +21,7 @@ thread_blocktime = {} lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time process_names = {} # long-lived pid-to-execname mapping -def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, +def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, nr, uaddr, op, val, utime, uaddr2, val3): cmd = op & FUTEX_CMD_MASK if cmd != FUTEX_WAIT: @@ -31,7 +31,7 @@ def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, thread_thislock[tid] = uaddr thread_blocktime[tid] = nsecs(s, ns) -def syscalls__sys_exit_futex(event,
[tip:perf/core] perf kvm: Use defines of kvm events
Commit-ID: 44b3802122174ba499613bac3aab2e66e948ce1e Gitweb: http://git.kernel.org/tip/44b3802122174ba499613bac3aab2e66e948ce1e Author: Alexander Yarygin AuthorDate: Thu, 3 Jul 2014 18:29:04 +0400 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:32 -0300 perf kvm: Use defines of kvm events Currently perf-kvm uses string literals for kvm event names, but it works only for x86, because other architectures may have other names for those events. To reduce dependence on architecture, we add file with defines for: - kvm_entry and kvm_exit events, - exit reason field name in kvm_exit event, - length of exit reasons strings, - vcpu_id field name in kvm trace events, and replace literals in perf-kvm. Reviewed-by: Cornelia Huck Reviewed-by David Ahern Signed-off-by: Alexander Yarygin Acked-by: Christian Borntraeger Cc: Christian Borntraeger Cc: Cornelia Huck Cc: David Ahern Cc: Ingo Molnar Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1404397747-20939-2-git-send-email-yary...@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- arch/x86/include/uapi/asm/Kbuild | 1 + arch/x86/include/uapi/asm/kvm_perf.h | 16 tools/perf/MANIFEST | 1 + tools/perf/builtin-kvm.c | 34 -- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/uapi/asm/Kbuild b/arch/x86/include/uapi/asm/Kbuild index 09409c4..3dec769 100644 --- a/arch/x86/include/uapi/asm/Kbuild +++ b/arch/x86/include/uapi/asm/Kbuild @@ -22,6 +22,7 @@ header-y += ipcbuf.h header-y += ist.h header-y += kvm.h header-y += kvm_para.h +header-y += kvm_perf.h header-y += ldt.h header-y += mce.h header-y += mman.h diff --git a/arch/x86/include/uapi/asm/kvm_perf.h b/arch/x86/include/uapi/asm/kvm_perf.h new file mode 100644 index 000..3bb964f --- /dev/null +++ b/arch/x86/include/uapi/asm/kvm_perf.h @@ -0,0 +1,16 @@ +#ifndef _ASM_X86_KVM_PERF_H +#define _ASM_X86_KVM_PERF_H + +#include +#include +#include + +#define DECODE_STR_LEN 20 + +#define VCPU_ID "vcpu_id" + +#define KVM_ENTRY_TRACE "kvm:kvm_entry" +#define KVM_EXIT_TRACE "kvm:kvm_exit" +#define KVM_EXIT_REASON "exit_reason" + +#endif /* _ASM_X86_KVM_PERF_H */ diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 45da209..02b485d 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST @@ -37,3 +37,4 @@ arch/x86/include/asm/kvm_host.h arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/vmx.h arch/x86/include/uapi/asm/kvm.h +arch/x86/include/uapi/asm/kvm_perf.h diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 41dbeaf..6d73346 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -30,9 +30,7 @@ #include #ifdef HAVE_KVM_STAT_SUPPORT -#include -#include -#include +#include struct event_key { #define INVALID_KEY (~0ULL) @@ -75,7 +73,7 @@ struct kvm_events_ops { bool (*is_end_event)(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key); void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key, - char decode[20]); + char *decode); const char *name; }; @@ -126,12 +124,12 @@ static void exit_event_get_key(struct perf_evsel *evsel, struct event_key *key) { key->info = 0; - key->key = perf_evsel__intval(evsel, sample, "exit_reason"); + key->key = perf_evsel__intval(evsel, sample, KVM_EXIT_REASON); } static bool kvm_exit_event(struct perf_evsel *evsel) { - return !strcmp(evsel->name, "kvm:kvm_exit"); + return !strcmp(evsel->name, KVM_EXIT_TRACE); } static bool exit_event_begin(struct perf_evsel *evsel, @@ -147,7 +145,7 @@ static bool exit_event_begin(struct perf_evsel *evsel, static bool kvm_entry_event(struct perf_evsel *evsel) { - return !strcmp(evsel->name, "kvm:kvm_entry"); + return !strcmp(evsel->name, KVM_ENTRY_TRACE); } static bool exit_event_end(struct perf_evsel *evsel, @@ -182,12 +180,12 @@ static const char *get_exit_reason(struct perf_kvm_stat *kvm, static void exit_event_decode_key(struct perf_kvm_stat *kvm, struct event_key *key, - char decode[20]) + char *decode) { const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons, key->key); - scnprintf(decode, 20, "%s", exit_reason); + scnprintf(decode, DECODE_STR_LEN, "%s", exit_reason); } static struct kvm_events_ops exit_events = { @@ -249,9 +247,9 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample, static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, struct event_key
[tip:perf/core] perf script: Add missing calls to Py_DECREF for return values
Commit-ID: 05f832e3a267d6e45d092595bdf9339d127ea137 Gitweb: http://git.kernel.org/tip/05f832e3a267d6e45d092595bdf9339d127ea137 Author: Joseph Schuchart AuthorDate: Wed, 9 Jul 2014 16:16:31 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:33 -0300 perf script: Add missing calls to Py_DECREF for return values Signed-off-by: Joseph Schuchart Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Thomas Ilsche Link: http://lkml.kernel.org/r/53bd4ebf.5050...@tu-dresden.de Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/scripting-engines/trace-event-python.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index e55b65a..b6c1a69 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -50,10 +50,14 @@ static int zero_flag_atom; static PyObject *main_module, *main_dict; +static void handler_call_die(const char *handler_name) NORETURN; static void handler_call_die(const char *handler_name) { PyErr_Print(); Py_FatalError("problem in Python trace event handler"); + // Py_FatalError does not return + // but we have to make the compiler happy + abort(); } /* @@ -97,6 +101,7 @@ static void define_value(enum print_arg_type field_type, retval = PyObject_CallObject(handler, t); if (retval == NULL) handler_call_die(handler_name); + Py_DECREF(retval); } Py_DECREF(t); @@ -143,6 +148,7 @@ static void define_field(enum print_arg_type field_type, retval = PyObject_CallObject(handler, t); if (retval == NULL) handler_call_die(handler_name); + Py_DECREF(retval); } Py_DECREF(t); @@ -361,6 +367,7 @@ static void python_process_tracepoint(struct perf_sample *sample, retval = PyObject_CallObject(handler, t); if (retval == NULL) handler_call_die(handler_name); + Py_DECREF(retval); } else { handler = PyDict_GetItemString(main_dict, "trace_unhandled"); if (handler && PyCallable_Check(handler)) { @@ -368,6 +375,7 @@ static void python_process_tracepoint(struct perf_sample *sample, retval = PyObject_CallObject(handler, t); if (retval == NULL) handler_call_die("trace_unhandled"); + Py_DECREF(retval); } Py_DECREF(dict); } @@ -427,6 +435,7 @@ static void python_process_general_event(struct perf_sample *sample, retval = PyObject_CallObject(handler, t); if (retval == NULL) handler_call_die(handler_name); + Py_DECREF(retval); exit: Py_DECREF(dict); Py_DECREF(t); @@ -548,8 +557,7 @@ static int python_stop_script(void) retval = PyObject_CallObject(handler, NULL); if (retval == NULL) handler_call_die("trace_end"); - else - Py_DECREF(retval); + Py_DECREF(retval); out: Py_XDECREF(main_dict); Py_XDECREF(main_module); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf callchain: Fix appending a callchain from a previous sample
Commit-ID: 4d40b051b1ac41ecbc818deed27750b4c1697520 Gitweb: http://git.kernel.org/tip/4d40b051b1ac41ecbc818deed27750b4c1697520 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:35 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:35 -0300 perf callchain: Fix appending a callchain from a previous sample hist_entry__append_callchain() must check if the sample has a callcahin or it will append the callchain from a previous sample. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-12-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 48b6d3f..437ee09 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -626,7 +626,7 @@ int sample__resolve_callchain(struct perf_sample *sample, struct symbol **parent int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample) { - if (!symbol_conf.use_callchain) + if (!symbol_conf.use_callchain || sample->callchain == NULL) return 0; return callchain_append(he->callchain, _cursor, sample->period); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf machine: Fix the value used for unknown pids
Commit-ID: 1fcb8768636d38cb6fdfeef83a5ee596c4bd9c56 Gitweb: http://git.kernel.org/tip/1fcb8768636d38cb6fdfeef83a5ee596c4bd9c56 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:25 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:33 -0300 perf machine: Fix the value used for unknown pids The value used for unknown pids cannot be zero because that is used by the "idle" task. Use -1 instead. Also handle the unknown pid case when creating map groups. Note that, threads with an unknown pid should not occur because fork (or synthesized) events precede the thread's existence. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-2-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-sched.c | 12 ++-- tools/perf/util/machine.c | 6 +++--- tools/perf/util/session.c | 5 +++-- tools/perf/util/thread.c | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index c38d06c..b7f555a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -935,8 +935,8 @@ static int latency_switch_event(struct perf_sched *sched, return -1; } - sched_out = machine__findnew_thread(machine, 0, prev_pid); - sched_in = machine__findnew_thread(machine, 0, next_pid); + sched_out = machine__findnew_thread(machine, -1, prev_pid); + sched_in = machine__findnew_thread(machine, -1, next_pid); out_events = thread_atoms_search(>atom_root, sched_out, >cmp_pid); if (!out_events) { @@ -979,7 +979,7 @@ static int latency_runtime_event(struct perf_sched *sched, { const u32 pid = perf_evsel__intval(evsel, sample, "pid"); const u64 runtime = perf_evsel__intval(evsel, sample, "runtime"); - struct thread *thread = machine__findnew_thread(machine, 0, pid); + struct thread *thread = machine__findnew_thread(machine, -1, pid); struct work_atoms *atoms = thread_atoms_search(>atom_root, thread, >cmp_pid); u64 timestamp = sample->time; int cpu = sample->cpu; @@ -1012,7 +1012,7 @@ static int latency_wakeup_event(struct perf_sched *sched, struct thread *wakee; u64 timestamp = sample->time; - wakee = machine__findnew_thread(machine, 0, pid); + wakee = machine__findnew_thread(machine, -1, pid); atoms = thread_atoms_search(>atom_root, wakee, >cmp_pid); if (!atoms) { if (thread_atoms_insert(sched, wakee)) @@ -1072,7 +1072,7 @@ static int latency_migrate_task_event(struct perf_sched *sched, if (sched->profile_cpu == -1) return 0; - migrant = machine__findnew_thread(machine, 0, pid); + migrant = machine__findnew_thread(machine, -1, pid); atoms = thread_atoms_search(>atom_root, migrant, >cmp_pid); if (!atoms) { if (thread_atoms_insert(sched, migrant)) @@ -1290,7 +1290,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, return -1; } - sched_in = machine__findnew_thread(machine, 0, next_pid); + sched_in = machine__findnew_thread(machine, -1, next_pid); sched->curr_thread[this_cpu] = sched_in; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index e9b943a..5b80877 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -34,7 +34,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) return -ENOMEM; if (pid != HOST_KERNEL_ID) { - struct thread *thread = machine__findnew_thread(machine, 0, + struct thread *thread = machine__findnew_thread(machine, -1, pid); char comm[64]; @@ -286,7 +286,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine, * the full rbtree: */ if (machine->last_match && machine->last_match->tid == tid) { - if (pid && pid != machine->last_match->pid_) + if (pid != -1 && pid != machine->last_match->pid_) machine->last_match->pid_ = pid; return machine->last_match; } @@ -297,7 +297,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine, if (th->tid == tid) { machine->last_match = th; - if (pid && pid != th->pid_) + if (pid != -1 && pid != th->pid_) th->pid_ = pid; return th; } diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index
[PATCH RFC v2 net-next 14/16] samples: bpf: add mini eBPF library to manipulate maps and programs
the library includes a trivial set of BPF syscall wrappers: int bpf_create_map(int key_size, int value_size, int max_entries); int bpf_update_elem(int fd, void *key, void *value); int bpf_lookup_elem(int fd, void *key, void *value); int bpf_delete_elem(int fd, void *key); int bpf_get_next_key(int fd, void *key, void *next_key); int bpf_prog_load(enum bpf_prog_type prog_type, const struct sock_filter_int *insns, int insn_len, const char *license, const struct bpf_map_fixup *fixups, int fixup_len); Signed-off-by: Alexei Starovoitov --- samples/bpf/libbpf.c | 109 ++ samples/bpf/libbpf.h | 22 ++ 2 files changed, 131 insertions(+) create mode 100644 samples/bpf/libbpf.c create mode 100644 samples/bpf/libbpf.h diff --git a/samples/bpf/libbpf.c b/samples/bpf/libbpf.c new file mode 100644 index ..5460d1f3ad43 --- /dev/null +++ b/samples/bpf/libbpf.c @@ -0,0 +1,109 @@ +/* eBPF mini library */ +#include +#include +#include +#include +#include +#include +#include +#include "libbpf.h" + +struct nlattr_u32 { + __u16 nla_len; + __u16 nla_type; + __u32 val; +}; + +int bpf_create_map(int key_size, int value_size, int max_entries) +{ + struct nlattr_u32 attr[] = { + { + .nla_len = sizeof(struct nlattr_u32), + .nla_type = BPF_MAP_KEY_SIZE, + .val = key_size, + }, + { + .nla_len = sizeof(struct nlattr_u32), + .nla_type = BPF_MAP_VALUE_SIZE, + .val = value_size, + }, + { + .nla_len = sizeof(struct nlattr_u32), + .nla_type = BPF_MAP_MAX_ENTRIES, + .val = max_entries, + }, + }; + + return syscall(__NR_bpf, BPF_MAP_CREATE, BPF_MAP_TYPE_HASH, attr, sizeof(attr)); +} + + +int bpf_update_elem(int fd, void *key, void *value) +{ + return syscall(__NR_bpf, BPF_MAP_UPDATE_ELEM, fd, key, value); +} + +int bpf_lookup_elem(int fd, void *key, void *value) +{ + return syscall(__NR_bpf, BPF_MAP_LOOKUP_ELEM, fd, key, value); +} + +int bpf_delete_elem(int fd, void *key) +{ + return syscall(__NR_bpf, BPF_MAP_DELETE_ELEM, fd, key); +} + +int bpf_get_next_key(int fd, void *key, void *next_key) +{ + return syscall(__NR_bpf, BPF_MAP_GET_NEXT_KEY, fd, key, next_key); +} + +#define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u)) + +int bpf_prog_load(enum bpf_prog_type prog_type, + const struct bpf_insn *insns, int prog_len, + const char *license, + const struct bpf_map_fixup *fixups, int fixup_len) +{ + int nlattr_size, license_len, err; + void *nlattr, *ptr; + + license_len = strlen(license) + 1; + nlattr_size = sizeof(struct nlattr) + prog_len + sizeof(struct nlattr) + + ROUND_UP(license_len, 4) + sizeof(struct nlattr) + + fixup_len; + + ptr = nlattr = malloc(nlattr_size); + + *(struct nlattr *) ptr = (struct nlattr) { + .nla_len = prog_len + sizeof(struct nlattr), + .nla_type = BPF_PROG_TEXT, + }; + ptr += sizeof(struct nlattr); + + memcpy(ptr, insns, prog_len); + ptr += prog_len; + + *(struct nlattr *) ptr = (struct nlattr) { + .nla_len = ROUND_UP(license_len, 4) + sizeof(struct nlattr), + .nla_type = BPF_PROG_LICENSE, + }; + ptr += sizeof(struct nlattr); + + memcpy(ptr, license, license_len); + ptr += ROUND_UP(license_len, 4); + + *(struct nlattr *) ptr = (struct nlattr) { + .nla_len = fixup_len + sizeof(struct nlattr), + .nla_type = BPF_PROG_MAP_FIXUP, + }; + ptr += sizeof(struct nlattr); + + memcpy(ptr, fixups, fixup_len); + ptr += fixup_len; + + err = syscall(__NR_bpf, BPF_PROG_LOAD, prog_type, nlattr, nlattr_size); + + free(nlattr); + return err; +} diff --git a/samples/bpf/libbpf.h b/samples/bpf/libbpf.h new file mode 100644 index ..07f668e3dac0 --- /dev/null +++ b/samples/bpf/libbpf.h @@ -0,0 +1,22 @@ +/* eBPF mini library */ +#ifndef __LIBBPF_H +#define __LIBBPF_H + +struct bpf_insn; + +int bpf_create_map(int key_size, int value_size, int max_entries); +int bpf_update_elem(int fd, void *key, void *value); +int bpf_lookup_elem(int fd, void *key, void *value); +int bpf_delete_elem(int fd, void *key); +int bpf_get_next_key(int fd, void *key, void *next_key); + +struct bpf_map_fixup { + int insn_idx; + int fd; +}; +int bpf_prog_load(enum bpf_prog_type prog_type, + const struct bpf_insn *insns, int insn_len, + const char *license, + const struct bpf_map_fixup *fixups, int fixup_len); + +#endif --
[tip:perf/core] perf buildid-cache: Apply force option to copying kcore
Commit-ID: 5173fbb8a11b2857aeec9e5f4e9568d4e1b84dbd Gitweb: http://git.kernel.org/tip/5173fbb8a11b2857aeec9e5f4e9568d4e1b84dbd Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:38 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:35 -0300 perf buildid-cache: Apply force option to copying kcore Currently a copy of kcore is not made if there is one already with the same modules at the same addresses. Change this to make a copy anyway if the force (-f) option is also used. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-15-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-buildid-cache.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index b22dbb1..2a2c78f 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -125,7 +125,8 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir, return ret; } -static int build_id_cache__add_kcore(const char *filename, const char *debugdir) +static int build_id_cache__add_kcore(const char *filename, const char *debugdir, +bool force) { char dir[32], sbuildid[BUILD_ID_SIZE * 2 + 1]; char from_dir[PATH_MAX], to_dir[PATH_MAX]; @@ -144,7 +145,8 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir) scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s", debugdir, sbuildid); - if (!build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) { + if (!force && + !build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) { pr_debug("same kcore found in %s\n", to_dir); return 0; } @@ -389,7 +391,7 @@ int cmd_buildid_cache(int argc, const char **argv, } if (kcore_filename && - build_id_cache__add_kcore(kcore_filename, debugdir)) + build_id_cache__add_kcore(kcore_filename, debugdir, force)) pr_warning("Couldn't add %s\n", kcore_filename); return ret; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf script: Provide additional sample information on generic events
Commit-ID: 57608cfd8827a74237d264a197722e2c99f72da4 Gitweb: http://git.kernel.org/tip/57608cfd8827a74237d264a197722e2c99f72da4 Author: Joseph Schuchart AuthorDate: Thu, 10 Jul 2014 13:50:56 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:33 -0300 perf script: Provide additional sample information on generic events To python scripts, including pid, tid, and cpu for which the event was recorded. At the moment, the pointer to the sample struct is passed to scripts, which seems to be of little use. The patch puts this information in dictionaries for easy access by Python scripts. Signed-off-by: Joseph Schuchart Acked-by: Thomas Ilsche Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Thomas Ilsche Link: http://lkml.kernel.org/r/53be7e20.8080...@tu-dresden.de Signed-off-by: Arnaldo Carvalho de Melo --- .../util/scripting-engines/trace-event-python.c| 23 +++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index cf65404..b366b48 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -473,7 +473,7 @@ static void python_process_general_event(struct perf_sample *sample, struct thread *thread, struct addr_location *al) { - PyObject *handler, *retval, *t, *dict, *callchain; + PyObject *handler, *retval, *t, *dict, *callchain, *dict_sample; static char handler_name[64]; unsigned n = 0; @@ -489,6 +489,10 @@ static void python_process_general_event(struct perf_sample *sample, if (!dict) Py_FatalError("couldn't create Python dictionary"); + dict_sample = PyDict_New(); + if (!dict_sample) + Py_FatalError("couldn't create Python dictionary"); + snprintf(handler_name, sizeof(handler_name), "%s", "process_event"); handler = PyDict_GetItemString(main_dict, handler_name); @@ -498,8 +502,21 @@ static void python_process_general_event(struct perf_sample *sample, pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize( (const char *)>attr, sizeof(evsel->attr))); - pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize( - (const char *)sample, sizeof(*sample))); + + pydict_set_item_string_decref(dict_sample, "pid", + PyInt_FromLong(sample->pid)); + pydict_set_item_string_decref(dict_sample, "tid", + PyInt_FromLong(sample->tid)); + pydict_set_item_string_decref(dict_sample, "cpu", + PyInt_FromLong(sample->cpu)); + pydict_set_item_string_decref(dict_sample, "ip", + PyLong_FromUnsignedLongLong(sample->ip)); + pydict_set_item_string_decref(dict_sample, "time", + PyLong_FromUnsignedLongLong(sample->time)); + pydict_set_item_string_decref(dict_sample, "period", + PyLong_FromUnsignedLongLong(sample->period)); + pydict_set_item_string_decref(dict, "sample", dict_sample); + pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize( (const char *)sample->raw_data, sample->raw_size)); pydict_set_item_string_decref(dict, "comm", -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[git pull] drm fixes
Hi Linus, one nouveau deadlock fix, one qxl irq handling fix, and a set of radeon pageflipping changes that fix regressions in pageflipping since -rc1 along with a leak and backlight fix. the pageflipping fixes are a bit bigger than I'd like, but there has been a few people focused on testing them. Dave. The following changes since commit 1795cd9b3a91d4b5473c97f491d63892442212ab: Linux 3.16-rc5 (2014-07-13 14:04:33 -0700) are available in the git repository at: git://people.freedesktop.org/~airlied/linux drm-fixes for you to fetch changes up to 3c169e5629d6bce9aede3907aeb38f1c23f61952: Merge branch 'drm-fixes-3.16' of git://people.freedesktop.org/~agd5f/linux into drm-fixes (2014-07-18 09:59:21 +1000) Alex Deucher (2): drm/radeon: avoid leaking edid data drm/radeon: set default bl level to something reasonable Dave Airlie (2): Merge branch 'linux-3.16' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-fixes Merge branch 'drm-fixes-3.16' of git://people.freedesktop.org/~agd5f/linux into drm-fixes Jason Wang (1): drm/qxl: return IRQ_NONE if it was not our irq Mario Kleiner (4): drm/radeon: Prevent too early kms-pageflips triggered by vblank. drm/radeon: Remove redundant fence unref in pageflip path. drm/radeon: Add missing vblank_put in pageflip ioctl error path. drm/radeon: Make classic pageflip completion path less racy. Martin Peres (1): drm/nouveau/therm: fix a potential deadlock in the therm monitoring code Michel Dänzer (2): drm/radeon: Move pinning the BO back to radeon_crtc_page_flip() drm/radeon: Complete page flip even if waiting on the BO fence fails drivers/gpu/drm/nouveau/core/subdev/therm/temp.c | 6 +- drivers/gpu/drm/qxl/qxl_irq.c| 3 + drivers/gpu/drm/radeon/atombios_crtc.c | 8 +- drivers/gpu/drm/radeon/atombios_encoders.c | 10 +- drivers/gpu/drm/radeon/evergreen.c | 5 +- drivers/gpu/drm/radeon/evergreen_reg.h | 1 - drivers/gpu/drm/radeon/radeon.h | 3 +- drivers/gpu/drm/radeon/radeon_display.c | 198 --- drivers/gpu/drm/radeon/rv515.c | 5 +- 9 files changed, 125 insertions(+), 114 deletions(-)
[tip:perf/core] perf inject: Fix build id injection
Commit-ID: e38b43c3f3fd8ebe6f558400d1647a923bc19d44 Gitweb: http://git.kernel.org/tip/e38b43c3f3fd8ebe6f558400d1647a923bc19d44 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:34 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:34 -0300 perf inject: Fix build id injection Build Ids won't be injected unless the build id feature flag is set. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-11-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-inject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 16c7c11..cf6a605 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -389,6 +389,9 @@ static int __cmd_inject(struct perf_inject *inject) ret = perf_session__process_events(session, >tool); if (!file_out->is_pipe) { + if (inject->build_ids) + perf_header__set_feat(>header, + HEADER_BUILD_ID); session->header.data_size = inject->bytes_written; perf_session__write_header(session, session->evlist, file_out->fd, true); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf symbols: Fix missing GNU IFUNC symbols
Commit-ID: a2f3b6bf0adadcb5f9383c60aa1355e0f9cba3da Gitweb: http://git.kernel.org/tip/a2f3b6bf0adadcb5f9383c60aa1355e0f9cba3da Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:33 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:34 -0300 perf symbols: Fix missing GNU IFUNC symbols Symbols of type STT_GNU_IFUNC are functions so accept them as such. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-10-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol-elf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 6864661..dce5ccf 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -49,7 +49,8 @@ static inline uint8_t elf_sym__type(const GElf_Sym *sym) static inline int elf_sym__is_function(const GElf_Sym *sym) { - return elf_sym__type(sym) == STT_FUNC && + return (elf_sym__type(sym) == STT_FUNC || + elf_sym__type(sym) == STT_GNU_IFUNC) && sym->st_name != 0 && sym->st_shndx != SHN_UNDEF; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf tools: Fix missing kernel map load
Commit-ID: 1f2a7069b6e895487b1d9229f5f62799cc4ea0aa Gitweb: http://git.kernel.org/tip/1f2a7069b6e895487b1d9229f5f62799cc4ea0aa Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:31 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:34 -0300 perf tools: Fix missing kernel map load thread__find_addr_map() falls back to trying the kernel maps if the address is negative and is not found in userspace maps. As commented in the code, the kernel maps must be "loaded" before use. This patch ensures that happens under the fallback condition also. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-8-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 198c4cc..7e0e8ae 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -788,6 +788,7 @@ try_again: cpumode == PERF_RECORD_MISC_USER && machine && mg != >kmaps) { mg = >kmaps; + load_map = true; goto try_again; } } else { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/core] perf symbols: Record whether a dso is 64-bit
Commit-ID: c6d8f2a4a0c5e366330a6a2a94c06b652f4ca554 Gitweb: http://git.kernel.org/tip/c6d8f2a4a0c5e366330a6a2a94c06b652f4ca554 Author: Adrian Hunter AuthorDate: Mon, 14 Jul 2014 13:02:41 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:35 -0300 perf symbols: Record whether a dso is 64-bit Add a flag to 'struct dso' to record if the dso is 64-bit or not. Update the flag when reading the ELF. This is needed for instruction decoding. For example, x86 instruction decoding depends on whether or not the 64-bit instruction set is used. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405332185-4050-18-git-send-email-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c| 1 + tools/perf/util/dso.h| 1 + tools/perf/util/symbol-elf.c | 3 +++ tools/perf/util/symbol-minimal.c | 22 ++ tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 1 + 6 files changed, 29 insertions(+) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 819f104..fc006fe 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -703,6 +703,7 @@ struct dso *dso__new(const char *name) dso->data.fd = -1; dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; + dso->is_64_bit = (sizeof(void *) == 8); dso->loaded = 0; dso->rel = 0; dso->sorted_by_name = 0; diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index ad553ba..c239e86 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -90,6 +90,7 @@ struct dso { u8 annotate_warned:1; u8 short_name_allocated:1; u8 long_name_allocated:1; + u8 is_64_bit:1; u8 sorted_by_name; u8 loaded; u8 rel; diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index dce5ccf..cef8f42 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -599,6 +599,8 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, goto out_elf_end; } + ss->is_64_bit = (gelf_getclass(elf) == ELFCLASS64); + ss->symtab = elf_section_by_name(elf, , >symshdr, ".symtab", NULL); if (ss->symshdr.sh_type != SHT_SYMTAB) @@ -699,6 +701,7 @@ int dso__load_sym(struct dso *dso, struct map *map, bool remap_kernel = false, adjust_kernel_syms = false; dso->symtab_type = syms_ss->type; + dso->is_64_bit = syms_ss->is_64_bit; dso->rel = syms_ss->ehdr.e_type == ET_REL; /* diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index bd15f49..101f55d 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c @@ -288,6 +288,23 @@ int dso__synthesize_plt_symbols(struct dso *dso __maybe_unused, return 0; } +static int fd__is_64_bit(int fd) +{ + u8 e_ident[EI_NIDENT]; + + if (lseek(fd, 0, SEEK_SET)) + return -1; + + if (readn(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident)) + return -1; + + if (memcmp(e_ident, ELFMAG, SELFMAG) || + e_ident[EI_VERSION] != EV_CURRENT) + return -1; + + return e_ident[EI_CLASS] == ELFCLASS64; +} + int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, struct symsrc *ss, struct symsrc *runtime_ss __maybe_unused, @@ -295,6 +312,11 @@ int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, int kmodule __maybe_unused) { unsigned char *build_id[BUILD_ID_SIZE]; + int ret; + + ret = fd__is_64_bit(ss->fd); + if (ret >= 0) + dso->is_64_bit = ret; if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) > 0) { dso__set_build_id(dso, build_id); diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 2e6a2e2..ae2e446 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1065,6 +1065,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map, _64_bit); if (err) goto out_err; + dso->is_64_bit = is_64_bit; if (list_empty()) { err = -EINVAL; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index a81877b..436169d 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -216,6 +216,7 @@ struct symsrc { GElf_Shdr dynshdr; bool adjust_symbols; + bool is_64_bit; #endif
[tip:perf/core] perf kvm: Add stat support on s390
Commit-ID: 3be8e2a0a53c3179a44a933614f6a893da0b5c19 Gitweb: http://git.kernel.org/tip/3be8e2a0a53c3179a44a933614f6a893da0b5c19 Author: Alexander Yarygin AuthorDate: Thu, 3 Jul 2014 18:29:07 +0400 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:33 -0300 perf kvm: Add stat support on s390 On s390, the vmexit event has a tree-like structure: between exit_event_begin and exit_event_end several other events may happen and with each of them refining the previous ones. This patch adds a decoder for such events to the generic code and also the files and kvm-stat.c for s390. Commands 'perf kvm stat record', 'report' and 'live' are supported. Reviewed-by: David Ahern Signed-off-by: Alexander Yarygin Acked-by: Christian Borntraeger Cc: Christian Borntraeger Cc: Cornelia Huck Cc: David Ahern Cc: Ingo Molnar Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1404397747-20939-5-git-send-email-yary...@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- arch/s390/include/uapi/asm/Kbuild | 1 + arch/s390/include/uapi/asm/kvm_perf.h | 25 tools/perf/Documentation/perf-kvm.txt | 16 +++--- tools/perf/MANIFEST | 2 + tools/perf/arch/s390/Makefile | 2 + tools/perf/arch/s390/util/kvm-stat.c | 105 ++ tools/perf/builtin-kvm.c | 52 +++-- tools/perf/util/kvm-stat.h| 9 +++ 8 files changed, 201 insertions(+), 11 deletions(-) diff --git a/arch/s390/include/uapi/asm/Kbuild b/arch/s390/include/uapi/asm/Kbuild index 6a9a9eb..0e2b54d 100644 --- a/arch/s390/include/uapi/asm/Kbuild +++ b/arch/s390/include/uapi/asm/Kbuild @@ -16,6 +16,7 @@ header-y += ioctls.h header-y += ipcbuf.h header-y += kvm.h header-y += kvm_para.h +header-y += kvm_perf.h header-y += kvm_virtio.h header-y += mman.h header-y += monwriter.h diff --git a/arch/s390/include/uapi/asm/kvm_perf.h b/arch/s390/include/uapi/asm/kvm_perf.h new file mode 100644 index 000..3972827 --- /dev/null +++ b/arch/s390/include/uapi/asm/kvm_perf.h @@ -0,0 +1,25 @@ +/* + * Definitions for perf-kvm on s390 + * + * Copyright 2014 IBM Corp. + * Author(s): Alexander Yarygin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License (version 2 only) + * as published by the Free Software Foundation. + */ + +#ifndef __LINUX_KVM_PERF_S390_H +#define __LINUX_KVM_PERF_S390_H + +#include + +#define DECODE_STR_LEN 40 + +#define VCPU_ID "id" + +#define KVM_ENTRY_TRACE "kvm:kvm_s390_sie_enter" +#define KVM_EXIT_TRACE "kvm:kvm_s390_sie_exit" +#define KVM_EXIT_REASON "icptcode" + +#endif diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt index 52276a6..6e689dc 100644 --- a/tools/perf/Documentation/perf-kvm.txt +++ b/tools/perf/Documentation/perf-kvm.txt @@ -51,9 +51,9 @@ There are a couple of variants of perf kvm: 'perf kvm stat ' to run a command and gather performance counter statistics. Especially, perf 'kvm stat record/report' generates a statistical analysis - of KVM events. Currently, vmexit, mmio and ioport events are supported. - 'perf kvm stat record ' records kvm events and the events between - start and end . + of KVM events. Currently, vmexit, mmio (x86 only) and ioport (x86 only) + events are supported. 'perf kvm stat record ' records kvm events + and the events between start and end . And this command produces a file which contains tracing results of kvm events. @@ -103,8 +103,8 @@ STAT REPORT OPTIONS analyze events which occures on this vcpu. (default: all vcpus) --event=:: - event to be analyzed. Possible values: vmexit, mmio, ioport. - (default: vmexit) + event to be analyzed. Possible values: vmexit, mmio (x86 only), + ioport (x86 only). (default: vmexit) -k:: --key=:: Sorting key. Possible values: sample (default, sort by samples @@ -138,7 +138,8 @@ STAT LIVE OPTIONS --event=:: - event to be analyzed. Possible values: vmexit, mmio, ioport. + event to be analyzed. Possible values: vmexit, + mmio (x86 only), ioport (x86 only). (default: vmexit) -k:: @@ -147,7 +148,8 @@ STAT LIVE OPTIONS number), time (sort by average time). --duration=:: - Show events other than HLT that take longer than duration usecs. + Show events other than HLT (x86 only) or Wait state (s390 only) + that take longer than duration usecs. SEE ALSO diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 02b485d..344c4d3 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST @@ -38,3 +38,5 @@ arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/vmx.h arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm_perf.h +arch/s390/include/uapi/asm/sie.h +arch/s390/include/uapi/asm/kvm_perf.h diff --git
[PATCH RFC v2 net-next 16/16] samples: bpf: example of tracing filters with eBPF
simple packet drop monitor: - in-kernel eBPF program attaches to kfree_skb() event and records number of packet drops at given location - userspace iterates over the map every second and prints stats Signed-off-by: Alexei Starovoitov --- samples/bpf/Makefile |4 +- samples/bpf/dropmon.c | 134 + 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 samples/bpf/dropmon.c diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 95c990151644..8e3dfa0c25e4 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -2,12 +2,14 @@ obj- := dummy.o # List of programs to build -hostprogs-y := sock_example +hostprogs-y := sock_example dropmon sock_example-objs := sock_example.o libbpf.o +dropmon-objs := dropmon.o libbpf.o # Tell kbuild to always build the programs always := $(hostprogs-y) HOSTCFLAGS_libbpf.o += -I$(objtree)/usr/include HOSTCFLAGS_sock_example.o += -I$(objtree)/usr/include +HOSTCFLAGS_dropmon.o += -I$(objtree)/usr/include diff --git a/samples/bpf/dropmon.c b/samples/bpf/dropmon.c new file mode 100644 index ..d3d38832fc74 --- /dev/null +++ b/samples/bpf/dropmon.c @@ -0,0 +1,134 @@ +/* simple packet drop monitor: + * - in-kernel eBPF program attaches to kfree_skb() event and records number + * of packet drops at given location + * - userspace iterates over the map every second and prints stats + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "libbpf.h" + +#define TRACEPOINT "/sys/kernel/debug/tracing/events/skb/kfree_skb/" + +static int write_to_file(const char *file, const char *str, bool keep_open) +{ + int fd, err; + + fd = open(file, O_WRONLY); + err = write(fd, str, strlen(str)); + (void) err; + + if (keep_open) { + return fd; + } else { + close(fd); + return -1; + } +} + +static int dropmon(void) +{ + /* the following eBPF program is equivalent to C: +* void filter(struct bpf_context *ctx) +* { +* long loc = ctx->arg2; +* long init_val = 1; +* void *value; +* +* value = bpf_map_lookup_elem(MAP_ID, ); +* if (value) { +* (*(long *) value) += 1; +* } else { +* bpf_map_update_elem(MAP_ID, , _val); +* } +* } +*/ + static struct bpf_insn prog[] = { + BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_1, 8), /* r2 = *(u64 *)(r1 + 8) */ + BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_2, -8), /* *(u64 *)(fp - 8) = r2 */ + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), /* r2 = fp - 8 */ + BPF_MOV64_IMM(BPF_REG_1, 0), /* r1 = MAP_ID */ + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), + BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3), + BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */ + BPF_RAW_INSN(BPF_STX | BPF_XADD | BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0), /* xadd r0 += r1 */ + BPF_EXIT_INSN(), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, 1), /* *(u64 *)(fp - 16) = 1 */ + BPF_MOV64_REG(BPF_REG_3, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -16), /* r3 = fp - 16 */ + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), /* r2 = fp - 8 */ + BPF_MOV64_IMM(BPF_REG_1, 0), /* r1 = MAP_ID */ + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_update_elem), + BPF_EXIT_INSN(), + }; + + static struct bpf_map_fixup fixup[2]; + long long key, next_key, value = 0; + int prog_fd, map_fd, i; + char fmt[32]; + + map_fd = bpf_create_map(sizeof(key), sizeof(value), 1024); + if (map_fd < 0) { + printf("failed to create map '%s'\n", strerror(errno)); + goto cleanup; + } + + fixup[0].insn_idx = 4; + fixup[0].fd = map_fd; + fixup[1].insn_idx = 15; + fixup[1].fd = map_fd; + + prog_fd = bpf_prog_load(BPF_PROG_TYPE_TRACING_FILTER, prog, + sizeof(prog), "GPL", fixup, sizeof(fixup)); + if (prog_fd < 0) { + printf("failed to load prog '%s'\n", strerror(errno)); + return -1; + } + + sprintf(fmt, "bpf_%d", prog_fd); + + write_to_file(TRACEPOINT "filter", fmt, true); + + for (i = 0; i < 10; i++) { + key = 0; + while (bpf_get_next_key(map_fd, , _key) == 0) { + bpf_lookup_elem(map_fd, _key, ); + printf("location 0x%llx count %lld\n", next_key,
[PATCH RFC v2 net-next 11/16] bpf: allow eBPF programs to use maps
expose bpf_map_lookup_elem(), bpf_map_update_elem(), bpf_map_delete_elem() map accessors to eBPF programs Signed-off-by: Alexei Starovoitov --- include/linux/bpf.h |5 +++ include/uapi/linux/bpf.h |3 ++ kernel/bpf/syscall.c | 85 ++ 3 files changed, 93 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index b5e90efddfcf..a7566afbe23b 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -128,4 +128,9 @@ struct sk_filter *bpf_prog_get(u32 ufd); /* verify correctness of eBPF program */ int bpf_check(struct sk_filter *fp); +/* in-kernel helper functions called from eBPF programs */ +u64 bpf_map_lookup_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); +u64 bpf_map_update_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); +u64 bpf_map_delete_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); + #endif /* _LINUX_BPF_H */ diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 3f288e1d08f1..06e0f63055fb 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -377,6 +377,9 @@ enum bpf_prog_type { */ enum bpf_func_id { BPF_FUNC_unspec, + BPF_FUNC_map_lookup_elem, /* void *map_lookup_elem(map_id, void *key) */ + BPF_FUNC_map_update_elem, /* int map_update_elem(map_id, void *key, void *value) */ + BPF_FUNC_map_delete_elem, /* int map_delete_elem(map_id, void *key) */ __BPF_FUNC_MAX_ID, }; diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 9d441f17548e..2d6e6a171594 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -741,3 +741,88 @@ SYSCALL_DEFINE5(bpf, int, cmd, unsigned long, arg2, unsigned long, arg3, return -EINVAL; } } + +/* called from eBPF program under rcu lock + * + * if kernel subsystem is allowing eBPF programs to call this function, + * inside its own verifier_ops->get_func_proto() callback it should return + * (struct bpf_func_proto) { + *.ret_type = PTR_TO_MAP_CONDITIONAL, + *.arg1_type = CONST_ARG_MAP_ID, + *.arg2_type = PTR_TO_STACK_IMM_MAP_KEY, + * } + * so that eBPF verifier properly checks the arguments + */ +u64 bpf_map_lookup_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) +{ + struct bpf_map *map; + int map_id = r1; + void *key = (void *) (unsigned long) r2; + void *value; + + WARN_ON_ONCE(!rcu_read_lock_held()); + + map = idr_find(_map_id_idr, map_id); + /* eBPF verifier guarantees that map_id is valid for the life of +* the program +*/ + BUG_ON(!map); + + value = map->ops->map_lookup_elem(map, key); + + return (unsigned long) value; +} + +/* called from eBPF program under rcu lock + * + * if kernel subsystem is allowing eBPF programs to call this function, + * inside its own verifier_ops->get_func_proto() callback it should return + * (struct bpf_func_proto) { + *.ret_type = RET_INTEGER, + *.arg1_type = CONST_ARG_MAP_ID, + *.arg2_type = PTR_TO_STACK_IMM_MAP_KEY, + *.arg3_type = PTR_TO_STACK_IMM_MAP_VALUE, + * } + * so that eBPF verifier properly checks the arguments + */ +u64 bpf_map_update_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) +{ + struct bpf_map *map; + int map_id = r1; + void *key = (void *) (unsigned long) r2; + void *value = (void *) (unsigned long) r3; + + WARN_ON_ONCE(!rcu_read_lock_held()); + + map = idr_find(_map_id_idr, map_id); + /* eBPF verifier guarantees that map_id is valid */ + BUG_ON(!map); + + return map->ops->map_update_elem(map, key, value); +} + +/* called from eBPF program under rcu lock + * + * if kernel subsystem is allowing eBPF programs to call this function, + * inside its own verifier_ops->get_func_proto() callback it should return + * (struct bpf_func_proto) { + *.ret_type = RET_INTEGER, + *.arg1_type = CONST_ARG_MAP_ID, + *.arg2_type = PTR_TO_STACK_IMM_MAP_KEY, + * } + * so that eBPF verifier properly checks the arguments + */ +u64 bpf_map_delete_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) +{ + struct bpf_map *map; + int map_id = r1; + void *key = (void *) (unsigned long) r2; + + WARN_ON_ONCE(!rcu_read_lock_held()); + + map = idr_find(_map_id_idr, map_id); + /* eBPF verifier guarantees that map_id is valid */ + BUG_ON(!map); + + return map->ops->map_delete_elem(map, key); +} -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 15/16] samples: bpf: example of stateful socket filtering
this socket filter example does: - creates a hashtable in kernel with key 4 bytes and value 8 bytes - populates map[6] = 0; map[17] = 0; // 6 - tcp_proto, 17 - udp_proto - loads eBPF program: r0 = skb[14 + 9]; // load one byte of ip->proto *(u32*)(fp - 4) = r0; value = bpf_map_lookup_elem(map_id, fp - 4); if (value) (*(u64*)value) += 1; - attaches this program to eth0 raw socket - every second user space reads map[6] and map[17] to see how many TCP and UDP packets were seen on eth0 Signed-off-by: Alexei Starovoitov --- samples/bpf/.gitignore |1 + samples/bpf/Makefile | 13 samples/bpf/sock_example.c | 161 3 files changed, 175 insertions(+) create mode 100644 samples/bpf/.gitignore create mode 100644 samples/bpf/Makefile create mode 100644 samples/bpf/sock_example.c diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore new file mode 100644 index ..5465c6e92a00 --- /dev/null +++ b/samples/bpf/.gitignore @@ -0,0 +1 @@ +sock_example diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile new file mode 100644 index ..95c990151644 --- /dev/null +++ b/samples/bpf/Makefile @@ -0,0 +1,13 @@ +# kbuild trick to avoid linker error. Can be omitted if a module is built. +obj- := dummy.o + +# List of programs to build +hostprogs-y := sock_example + +sock_example-objs := sock_example.o libbpf.o + +# Tell kbuild to always build the programs +always := $(hostprogs-y) + +HOSTCFLAGS_libbpf.o += -I$(objtree)/usr/include +HOSTCFLAGS_sock_example.o += -I$(objtree)/usr/include diff --git a/samples/bpf/sock_example.c b/samples/bpf/sock_example.c new file mode 100644 index ..9b23b2b7e9d0 --- /dev/null +++ b/samples/bpf/sock_example.c @@ -0,0 +1,161 @@ +/* eBPF example program: + * - creates a hashtable in kernel with key 4 bytes and value 8 bytes + * + * - populates map[6] = 0; map[17] = 0; // 6 - tcp_proto, 17 - udp_proto + * + * - loads eBPF program: + * r0 = skb[14 + 9]; // load one byte of ip->proto + * *(u32*)(fp - 4) = r0; + * value = bpf_map_lookup_elem(map_id, fp - 4); + * if (value) + *(*(u64*)value) += 1; + * + * - attaches this program to eth0 raw socket + * + * - every second user space reads map[6] and map[17] to see how many + * TCP and UDP packets were seen on eth0 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "libbpf.h" + +static int open_raw_sock(const char *name) +{ + struct sockaddr_ll sll; + struct packet_mreq mr; + struct ifreq ifr; + int sock; + + sock = socket(PF_PACKET, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC, htons(ETH_P_ALL)); + if (sock < 0) { + printf("cannot open socket!\n"); + return -1; + } + + memset(, 0, sizeof(ifr)); + strncpy((char *)ifr.ifr_name, name, IFNAMSIZ); + if (ioctl(sock, SIOCGIFINDEX, ) < 0) { + printf("ioctl: %s\n", strerror(errno)); + close(sock); + return -1; + } + + memset(, 0, sizeof(sll)); + sll.sll_family = AF_PACKET; + sll.sll_ifindex = ifr.ifr_ifindex; + sll.sll_protocol = htons(ETH_P_ALL); + if (bind(sock, (struct sockaddr *), sizeof(sll)) < 0) { + printf("bind: %s\n", strerror(errno)); + close(sock); + return -1; + } + + memset(, 0, sizeof(mr)); + mr.mr_ifindex = ifr.ifr_ifindex; + mr.mr_type = PACKET_MR_PROMISC; + if (setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP, , sizeof(mr)) < 0) { + printf("set_promisc: %s\n", strerror(errno)); + close(sock); + return -1; + } + return sock; +} + +static int test_sock(void) +{ + static struct bpf_insn prog[] = { + BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), + BPF_LD_ABS(BPF_B, 14 + 9 /* R0 = ip->proto */), + BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4), /* *(u32 *)(fp - 4) = r0 */ + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = fp - 4 */ + BPF_MOV64_IMM(BPF_REG_1, 0), /* r1 = MAP_ID */ + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), + BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), + BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */ + BPF_RAW_INSN(BPF_STX | BPF_XADD | BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0), /* xadd r0 += r1 */ + BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */ + BPF_EXIT_INSN(), + }; + static struct bpf_map_fixup fixup[1]; + + int sock = -1, map_fd, prog_fd, i, key; + long long value = 0, tcp_cnt, udp_cnt; + + map_fd = bpf_create_map(sizeof(key), sizeof(value), 2); + if
Sparc Allmodconfig Fails
The build for sparc allmodconfig is still failing for the main branch of the linux kernel. I would recommend fixing these issues. I am attaching my build warnings and errors logs for the failing build test I did today. Cheers Nick sparc64_allmodconfig Description: Binary data
[PATCH RFC v2 net-next 05/16] bpf: introduce syscall(BPF, ...) and BPF maps
BPF syscall is a demux for different BPF releated commands. 'maps' is a generic storage of different types for sharing data between kernel and userspace. The maps can be created from user space via BPF syscall: - create a map with given type and attributes fd = bpf_map_create(map_type, struct nlattr *attr, int len) returns fd or negative error - close(fd) deletes the map Next patch allows userspace programs to populate/read maps that eBPF programs are concurrently updating. maps can have different types: hash, bloom filter, radix-tree, etc. The map is defined by: . type . max number of elements . key size in bytes . value size in bytes Next patches allow eBPF programs to access maps via API: void * bpf_map_lookup_elem(u32 fd, void *key); int bpf_map_update_elem(u32 fd, void *key, void *value); int bpf_map_delete_elem(u32 fd, void *key); This patch establishes core infrastructure for BPF maps. Next patches implement lookup/update and hashtable type. More map types can be added in the future. syscall is using type-length-value style of passing arguments to be backwards compatible with future extensions to map attributes. Different map types may use different attributes as well. The concept of type-lenght-value is borrowed from netlink, but netlink itself is not applicable here, since BPF programs and maps can be used in NET-less configurations. Signed-off-by: Alexei Starovoitov --- Documentation/networking/filter.txt | 69 +++ include/linux/bpf.h | 43 +++ include/uapi/linux/bpf.h| 24 kernel/bpf/Makefile |2 +- kernel/bpf/syscall.c| 225 +++ 5 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 include/linux/bpf.h create mode 100644 kernel/bpf/syscall.c diff --git a/Documentation/networking/filter.txt b/Documentation/networking/filter.txt index ee78eba78a9d..e14e486f69cd 100644 --- a/Documentation/networking/filter.txt +++ b/Documentation/networking/filter.txt @@ -995,6 +995,75 @@ BPF_XADD | BPF_DW | BPF_STX: lock xadd *(u64 *)(dst_reg + off16) += src_reg Where size is one of: BPF_B or BPF_H or BPF_W or BPF_DW. Note that 1 and 2 byte atomic increments are not supported. +eBPF maps +- +'maps' is a generic storage of different types for sharing data between kernel +and userspace. + +The maps are accessed from user space via BPF syscall, which has commands: +- create a map with given id, type and attributes + map_id = bpf_map_create(int map_id, map_type, struct nlattr *attr, int len) + returns positive map id or negative error + +- delete map with given map id + err = bpf_map_delete(int map_id) + returns zero or negative error + +- lookup key in a given map referenced by map_id + err = bpf_map_lookup_elem(int map_id, void *key, void *value) + returns zero and stores found elem into value or negative error + +- create or update key/value pair in a given map + err = bpf_map_update_elem(int map_id, void *key, void *value) + returns zero or negative error + +- find and delete element by key in a given map + err = bpf_map_delete_elem(int map_id, void *key) + +userspace programs uses this API to create/populate/read maps that eBPF programs +are concurrently updating. + +maps can have different types: hash, bloom filter, radix-tree, etc. + +The map is defined by: + . id + . type + . max number of elements + . key size in bytes + . value size in bytes + +The maps are accesible from eBPF program with API: + void * bpf_map_lookup_elem(u32 map_id, void *key); + int bpf_map_update_elem(u32 map_id, void *key, void *value); + int bpf_map_delete_elem(u32 map_id, void *key); + +If eBPF verifier is configured to recognize extra calls in the program +bpf_map_lookup_elem() and bpf_map_update_elem() then access to maps looks like: + ... + ptr_to_value = map_lookup_elem(const_int_map_id, key) + access memory [ptr_to_value, ptr_to_value + value_size_in_bytes] + ... + prepare key2 and value2 on stack of key_size and value_size + err = map_update_elem(const_int_map_id2, key2, value2) + ... + +eBPF program cannot create or delete maps +(such calls will be unknown to verifier) + +During program loading the refcnt of used maps is incremented, so they don't get +deleted while program is running + +bpf_map_update_elem() can fail if maximum number of elements reached. +if key2 already exists, bpf_map_update_elem() replaces it with value2 atomically + +bpf_map_lookup_elem() can return null or ptr_to_value +ptr_to_value is read/write from the program point of view. + +The verifier will check that the program accesses map elements within specified +size. It will not let programs pass junk values as 'key' and 'value' to +bpf_map_*_elem() functions, so these functions (implemented in C inside kernel) +can safely access the pointers in all cases. + Testing --- diff --git a/include/linux/bpf.h b/include/linux/bpf.h new file mode
[PATCH RFC v2 net-next 13/16] tracing: allow eBPF programs to be attached to events
User interface: fd = open("/sys/kernel/debug/tracing/__event__/filter") write(fd, "bpf_123") where 123 is process local FD associated with eBPF program previously loaded. __event__ is static tracepoint event. (kprobe events will be supported in the future patches) Once program is successfully attached to tracepoint event, the tracepoint will be auto-enabled close(fd) auto-disables tracepoint event and detaches eBPF program from it eBPF programs can call in-kernel helper functions to: - lookup/update/delete elements in maps - memcmp - trace_printk - load_pointer - dump_stack Signed-off-by: Alexei Starovoitov --- include/linux/ftrace_event.h |5 + include/trace/bpf_trace.h | 29 + include/trace/ftrace.h | 10 ++ include/uapi/linux/bpf.h |5 + kernel/trace/Kconfig |1 + kernel/trace/Makefile |1 + kernel/trace/bpf_trace.c | 212 kernel/trace/trace.h |3 + kernel/trace/trace_events.c| 36 +- kernel/trace/trace_events_filter.c | 72 +++- 10 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 include/trace/bpf_trace.h create mode 100644 kernel/trace/bpf_trace.c diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index cff3106ffe2c..de313bd9a434 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h @@ -237,6 +237,7 @@ enum { TRACE_EVENT_FL_WAS_ENABLED_BIT, TRACE_EVENT_FL_USE_CALL_FILTER_BIT, TRACE_EVENT_FL_TRACEPOINT_BIT, + TRACE_EVENT_FL_BPF_BIT, }; /* @@ -259,6 +260,7 @@ enum { TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT), TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT), TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT), + TRACE_EVENT_FL_BPF = (1 << TRACE_EVENT_FL_BPF_BIT), }; struct ftrace_event_call { @@ -536,6 +538,9 @@ event_trigger_unlock_commit_regs(struct ftrace_event_file *file, event_triggers_post_call(file, tt); } +struct bpf_context; +void trace_filter_call_bpf(struct event_filter *filter, struct bpf_context *ctx); + enum { FILTER_OTHER = 0, FILTER_STATIC_STRING, diff --git a/include/trace/bpf_trace.h b/include/trace/bpf_trace.h new file mode 100644 index ..2122437f1317 --- /dev/null +++ b/include/trace/bpf_trace.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + */ +#ifndef _LINUX_KERNEL_BPF_TRACE_H +#define _LINUX_KERNEL_BPF_TRACE_H + +/* For tracing filters save first six arguments of tracepoint events. + * On 64-bit architectures argN fields will match one to one to arguments passed + * to tracepoint events. + * On 32-bit architectures u64 arguments to events will be seen into two + * consecutive argN, argN+1 fields. Pointers, u32, u16, u8, bool types will + * match one to one + */ +struct bpf_context { + unsigned long arg1; + unsigned long arg2; + unsigned long arg3; + unsigned long arg4; + unsigned long arg5; + unsigned long arg6; +}; + +/* call from ftrace_raw_event_*() to copy tracepoint arguments into ctx */ +void populate_bpf_context(struct bpf_context *ctx, ...); + +#endif /* _LINUX_KERNEL_BPF_TRACE_H */ diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 26b4f2e13275..ad4987ac68bb 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -17,6 +17,7 @@ */ #include +#include /* * DECLARE_EVENT_CLASS can be used to add a generic function @@ -634,6 +635,15 @@ ftrace_raw_event_##call(void *__data, proto) \ if (ftrace_trigger_soft_disabled(ftrace_file)) \ return; \ \ + if (unlikely(ftrace_file->flags & FTRACE_EVENT_FL_FILTERED) && \ + unlikely(ftrace_file->event_call->flags & TRACE_EVENT_FL_BPF)) { \ + struct bpf_context __ctx; \ + \ + populate_bpf_context(&__ctx, args, 0, 0, 0, 0, 0); \ + trace_filter_call_bpf(ftrace_file->filter, &__ctx); \ + return; \ + } \ + \ __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
[tip:perf/core] perf kvm: Add skip_event() for --duration option
Commit-ID: 54c801ff71ba9c9ae41871e226b9d846ff9c6bab Gitweb: http://git.kernel.org/tip/54c801ff71ba9c9ae41871e226b9d846ff9c6bab Author: Alexander Yarygin AuthorDate: Thu, 3 Jul 2014 18:29:06 +0400 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 16 Jul 2014 17:57:32 -0300 perf kvm: Add skip_event() for --duration option Current code skips output of the x86 specific HLT event in order to avoid flooding the output with enabled --duration option. The events to be skipped should be architecture dependent, though. Let's add an architecture specific array of events to be skipped and introduce a skip_event() function checking against that array. Reviewed-by: Christian Borntraeger Reviewed-by: Cornelia Huck Reviewed-by: David Ahern Signed-off-by: Alexander Yarygin Cc: Christian Borntraeger Cc: Cornelia Huck Cc: David Ahern Cc: Ingo Molnar Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1404397747-20939-4-git-send-email-yary...@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/util/kvm-stat.c | 5 + tools/perf/builtin-kvm.c| 13 - tools/perf/util/kvm-stat.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c index 2f8d2c1..14e4e66 100644 --- a/tools/perf/arch/x86/util/kvm-stat.c +++ b/tools/perf/arch/x86/util/kvm-stat.c @@ -136,6 +136,11 @@ struct kvm_reg_events_ops kvm_reg_events_ops[] = { { NULL, NULL }, }; +const char * const kvm_skip_events[] = { + "HLT", + NULL, +}; + int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid) { if (strstr(cpuid, "Intel")) { diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 75ee8c1..fc2d63d 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -261,6 +261,17 @@ static bool update_kvm_event(struct kvm_event *event, int vcpu_id, return true; } +static bool skip_event(const char *event) +{ + const char * const *skip_events; + + for (skip_events = kvm_skip_events; *skip_events; skip_events++) + if (!strcmp(event, *skip_events)) + return true; + + return false; +} + static bool handle_end_event(struct perf_kvm_stat *kvm, struct vcpu_event_record *vcpu_record, struct event_key *key, @@ -312,7 +323,7 @@ static bool handle_end_event(struct perf_kvm_stat *kvm, char decode[DECODE_STR_LEN]; kvm->events_ops->decode_key(kvm, >key, decode); - if (strcmp(decode, "HLT")) { + if (!skip_event(decode)) { pr_info("%" PRIu64 " VM %d, vcpu %d: %s event took %" PRIu64 "usec\n", sample->time, sample->pid, vcpu_record->vcpu_id, decode, time_diff/1000); diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index d0d9fb1..ba937ca 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h @@ -126,5 +126,6 @@ int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid); extern const char * const kvm_events_tp[]; extern struct kvm_reg_events_ops kvm_reg_events_ops[]; +extern const char * const kvm_skip_events[]; #endif /* __PERF_KVM_STAT_H */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RFC v2 net-next 03/16] net: filter: rename struct sock_filter_int into bpf_insn
follow on patch exposes eBPF to user space and 'sock_filter_int' name no longer makes sense, so rename it to 'bpf_insn' Signed-off-by: Alexei Starovoitov --- arch/x86/net/bpf_jit_comp.c |2 +- include/linux/filter.h | 50 +-- kernel/bpf/core.c |2 +- kernel/seccomp.c|2 +- lib/test_bpf.c |4 ++-- net/core/filter.c | 18 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 99bef86ed6df..71737a83f022 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -214,7 +214,7 @@ struct jit_context { static int do_jit(struct sk_filter *bpf_prog, int *addrs, u8 *image, int oldproglen, struct jit_context *ctx) { - struct sock_filter_int *insn = bpf_prog->insnsi; + struct bpf_insn *insn = bpf_prog->insnsi; int insn_cnt = bpf_prog->len; u8 temp[64]; int i; diff --git a/include/linux/filter.h b/include/linux/filter.h index c43c8258e682..a3287d1c9a56 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -82,7 +82,7 @@ enum { /* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ #define BPF_ALU64_REG(OP, DST, SRC)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU64 | BPF_OP(OP) | BPF_X,\ .dst_reg = DST, \ .src_reg = SRC, \ @@ -90,7 +90,7 @@ enum { .imm = 0 }) #define BPF_ALU32_REG(OP, DST, SRC)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ @@ -100,7 +100,7 @@ enum { /* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ #define BPF_ALU64_IMM(OP, DST, IMM)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU64 | BPF_OP(OP) | BPF_K,\ .dst_reg = DST, \ .src_reg = 0, \ @@ -108,7 +108,7 @@ enum { .imm = IMM }) #define BPF_ALU32_IMM(OP, DST, IMM)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \ @@ -118,7 +118,7 @@ enum { /* Endianess conversion, cpu_to_{l,b}e(), {l,b}e_to_cpu() */ #define BPF_ENDIAN(TYPE, DST, LEN) \ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU | BPF_END | BPF_SRC(TYPE), \ .dst_reg = DST, \ .src_reg = 0, \ @@ -128,7 +128,7 @@ enum { /* Short form of mov, dst_reg = src_reg */ #define BPF_MOV64_REG(DST, SRC)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU64 | BPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ @@ -136,7 +136,7 @@ enum { .imm = 0 }) #define BPF_MOV32_REG(DST, SRC)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU | BPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \ @@ -146,7 +146,7 @@ enum { /* Short form of mov, dst_reg = imm32 */ #define BPF_MOV64_IMM(DST, IMM)\ - ((struct sock_filter_int) { \ + ((struct bpf_insn) {\ .code = BPF_ALU64 | BPF_MOV | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \ @@ -154,7 +154,7 @@ enum { .imm = IMM }) #define
Re: [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend
On 18 July 2014 08:55, Saravana Kannan wrote: > Not really. We much never do it during hotplug. We only do it when the > cpufreq driver unregisters. Oh yes. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Linux 3.4.95 breaks LZO tests (additional pull needed)
On Thu, Jul 17, 2014 at 08:57:56PM -0700, Derrick Pallas wrote: > An LZO update was backported in Linux 3.4.95 but fails to work if > crypto tests are enabled. It turns out that > 0ec7382036922be063b515b2a3f1d6 > f7a607392c, which updates the test vectors, did not come along for the > ride. Thanks, ~Derrick Ah, many thanks, I'll go queue that up. greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PULL 00/33] perf/core improvements and fixes
* Arnaldo Carvalho de Melo wrote: > Hi Ingo, > > Please consider pulling, > > - Arnaldo > > The following changes since commit ff2ebe46e15bd49d52b9c2f3fc77f3a9d94eac7b: > > Merge tag 'perf-core-for-mingo' of > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/core > (2014-07-16 13:48:13 +0200) > > are available in the git repository at: > > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git > tags/perf-core-for-mingo > > for you to fetch changes up to 0b437860818dc717f6a9e8a5089223a8414f5fff: > > perf tools: Allow TSC conversion on any arch (2014-07-17 12:59:00 -0300) > > > perf/core improvements and fixes: > > User visible: > > o Support S/390 in 'perf kvm stat' (Alexander Yarygin) > > Developer Stuff: > > o Various fixes and prep work related to supporting Intel PT (Adrian Hunter) > > o Introduce multiple debug variables control (Jiri Olsa) > > o Add callchain and additional sample information for python scripts (Joseph > Schuchart) > > Signed-off-by: Arnaldo Carvalho de Melo > > > Adrian Hunter (21): > perf machine: Fix the value used for unknown pids > perf script: Display PERF_RECORD_MISC_COMM_EXEC flag > perf record: Select comm_exec flag if supported > perf tools: Fix missing kernel map load > perf symbols: Fix missing GNU IFUNC symbols > perf inject: Fix build id injection > perf callchain: Fix appending a callchain from a previous sample > perf buildid-cache: Apply force option to copying kcore > perf symbols: Record whether a dso is 64-bit > perf symbols: Do not attempt to read data from kallsyms > perf symbols: Add ability to iterate over a dso's symbols > perf session: Flag if the event stream is entirely in memory > perf evlist: Pass mmap parameters in a struct > perf tools: Add feature test for __sync_val_compare_and_swap > perf tools: Add option macro OPT_CALLBACK_OPTARG > perf evsel: Add 'no_aux_samples' option > perf evsel: Add 'immediate' option > perf machine: Fix map groups of threads with unknown pids > perf thread: Allow deletion of a thread with no map groups > perf machine: Fix leak of 'struct thread' on error path > perf tools: Allow TSC conversion on any arch > > Alexander Yarygin (4): > perf kvm: Use defines of kvm events > perf kvm: Move arch specific code into arch/ > perf kvm: Add skip_event() for --duration option > perf kvm: Add stat support on s390 > > Jiri Olsa (5): > perf tools: Remove verbose from functions prototypes > perf tools: Move pr_* debug macros into debug object > perf tools: Factor eprintf to allow different debug variables > perf tools: Add --debug optionto set debug variable > perf tools: Remove needless getopt.h includes > > Joseph Schuchart (3): > perf script: Add missing calls to Py_DECREF for return values > perf script: Add callchain to generic and tracepoint events > perf script: Provide additional sample information on generic events > > arch/s390/include/uapi/asm/Kbuild | 1 + > arch/s390/include/uapi/asm/kvm_perf.h | 25 ++ > arch/x86/include/uapi/asm/Kbuild | 1 + > arch/x86/include/uapi/asm/kvm_perf.h | 16 + > tools/perf/Documentation/perf-kvm.txt | 16 +- > tools/perf/Documentation/perf.txt | 10 +- > tools/perf/MANIFEST| 3 + > tools/perf/Makefile.perf | 3 + > tools/perf/arch/s390/Makefile | 2 + > tools/perf/arch/s390/util/kvm-stat.c | 105 ++ > tools/perf/arch/x86/Makefile | 1 + > tools/perf/arch/x86/tests/dwarf-unwind.c | 1 + > tools/perf/arch/x86/util/kvm-stat.c| 156 + > tools/perf/arch/x86/util/tsc.c | 22 +- > tools/perf/arch/x86/util/tsc.h | 3 - > tools/perf/arch/x86/util/unwind-libunwind.c| 1 + > tools/perf/builtin-buildid-cache.c | 8 +- > tools/perf/builtin-evlist.c| 1 + > tools/perf/builtin-help.c | 1 + > tools/perf/builtin-inject.c| 3 + > tools/perf/builtin-kvm.c | 384 > ++--- > tools/perf/builtin-sched.c | 12 +- > tools/perf/builtin-timechart.c | 1 + > tools/perf/config/Makefile | 6 + > tools/perf/config/feature-checks/Makefile | 4 + > tools/perf/config/feature-checks/test-all.c| 5 + > .../feature-checks/test-sync-compare-and-swap.c| 14 + > tools/perf/perf.c
Re: [PATCH 00/14] cpufreq: cpu0: Extend support beyond CPU0, V2
On 18 July 2014 06:32, Rafael J. Wysocki wrote: >> > only support the following cases: >> > >> > * One clock for all CPUs >> > * One clock for each CPU >> >> Yeah, so I also proposed this yesterday that we stick to only these >> two implementations for now. And was looking at how would the >> cpufreq-generic driver come to know about this. >> >> So, one way out now is to see if "clocks" property is defined in >> multiple cpu nodes, if yes don't compare them and consider separate >> clocks for each cpu. We don't have to try matching that to any other >> node, as that's a very bad idea. Mike was already very upset with that :) >> >> @Stephen/Rafael: Does that sound any better? Ofcourse the final thing >> is to get bindings to figure out relations between CPUs.. > > Before I apply anything in this area, I need a clear statement from the ARM > people as a group on what the approach is going to be. Thanks for your response Rafael. Mike/Rob/Stephen: I believe Atleast three of you should express your views now :) So, this is what I propose: - I will start another thread with a new DT binding, something like: "clocks-ganged" = <> and then we can decide on naming/etc .. - I will drop the patch which matches clock nodes from DT and introduce another one that will just check if "clocks" is mentioned in more than one CPU. If yes, then we behave as if all CPUs have separate clock lines. That will work for Krait/mvebu and all existing users. Does that sound good? -- viresh -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Fast TSC calibration failed error
Hello, I noticed that the `arch/x86/kernel/tsc.c` has a pending patch to make this message: ``` Fast TSC calibration failed ``` into an Information Message instead of Error message. This the original post: http://lkml.iu.edu//hypermail/linux/kernel/1209.3/00224.html And here was the patch: https://lkml.org/lkml/2012/9/26/131 & https://lkml.org/lkml/2012/9/26/169 What's the status of this patch? It would be nice for this to be accepted, since the Fast TSC calibration failed message clogs up all my logs for all my Linux virtual machines. It ends up being a redundant message for centralised logging systems that always needs to be filtered out. Thanks, Roger -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] PM / OPP: cpufreq: Avoid sleeping while atomic
On 18 July 2014 04:57, Stephen Boyd wrote: > First you need to enable sleeping while atomic checking, but in reality, > I assume nobody has tried inserting a cpufreq driver as a module. The I did for sure, but long back. Over 6 months atleast :) > might_sleep() code has a check to see if the system_state is > SYSTEM_RUNNING. If it isn't running then there isn't a warning and > might_sleep() doesn't flag any problem. I wonder if that is actually the > right thing to do though? Perhaps the intention of that code is to skip > warning early on in the boot path when the scheduler isn't up and > running yet. But once the scheduler is running (which is fairly early > nowadays) I would think we want might_sleep() to trigger warnings. Maybe > that check in might_sleep() needs to be updated to check for "scheduler > running" instead of "system running"? > Right. It seems that we moved to RCU in commit > 0f5c890e9b9754d9aa5bf6ae2fc00cae65780d23 so the real Fixes line should be: > > Fixes: 0f5c890e9b97 "PM / OPP: Remove cpufreq wrapper dependency on > internal data organization" Right. > One way to avoid this problem is to put things back the way they were > before that change. Is there any real benefit to having this code live > in drivers/cpufreq/ instead of just under some config option in > drivers/base/power/opp.c? Maybe Nishanth can give more arguments than I can :), but the idea was just to keep cpufreq stuff together.. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH RT 0/4] Linux 3.2.60-rt89-rc1
16.07.2014 14:28, Rolf Peukert пишет: On 15.07.2014 01:05, Pavel Vasilyev wrote: 15.07.2014 00:06, Steven Rostedt пишет: Dear RT Folks, This is the RT stable review cycle of patch 3.2.60-rt89-rc1. Actually 3.2.61 kernel/irq/manage.c kernel/rtmutex.c This files FUZZED :( Just for the record, the (incremental) patch applies and runs without problems on an 3.2.60-rt88 (built for ARM). I'm about 3.2.61 -- Pavel. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Linux 3.4.95 breaks LZO tests (additional pull needed)
An LZO update was backported in Linux 3.4.95 but fails to work if crypto tests are enabled. It turns out that 0ec7382036922be063b515b2a3f1d6 f7a607392c, which updates the test vectors, did not come along for the ride. Thanks, ~Derrick -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Build Failures for Sh architecture
Hey Andrew and other maintainers of this architecture , I seem to be hitting a few build errors with default configurations for this architecture. I am attached my logs of these failing builds , naming each file after the build that is logged in each file. Cheers Nick allmodconfig Description: Binary data allyesconfig Description: Binary data rsk7203_defconfig Description: Binary data se7206_defconfig Description: Binary data
Re: [PATCH V3] netxen: fix ethtool rx_dropped information in ethtool get_ethtool_stats()
On 07/18/2014 09:13 AM, Ethan Zhao wrote: netxen driver has implemented netxen_nic_get_ethtool_stats() interface, but it doesn't collect stats.rxdropped in driver, so we will get different rx_dropped statistic information while using ifconfig and ethtool. this patch fills stats.rxdropped field with data from net core with dev_get_stats() just as ixgbe driver did for some of its stats. Tested with last netxen 4.0.82 Compiled with stable 3.15.6 Signed-off-by: Ethan Zhao Tested-by: Sriharsha Yadagudde --- -v2 only fix rx_dropped field, not all. -v3 workaround checkpatch.pl bug according to suggestion from Joe Perches .../ethernet/qlogic/netxen/netxen_nic_ethtool.c| 59 +++- 1 files changed, 45 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index 87e073c..2753f00 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c @@ -31,28 +31,43 @@ #include "netxen_nic.h" #include "netxen_nic_hw.h" +enum {NETDEV_STATS, NETXEN_STATS}; + struct netxen_nic_stats { char stat_string[ETH_GSTRING_LEN]; + int type; int sizeof_stat; int stat_offset; }; -#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ - offsetof(struct netxen_adapter, m) +#define NETXEN_NIC_STAT(name, m) \ +{ \ + .stat_string = name,\ + .type = NETXEN_STATS, \ + .sizeof_stat = FIELD_SIZEOF(struct netxen_adapter, m), \ + .stat_offset = offsetof(struct netxen_adapter, m) \ +} + +#define NETXEN_NETDEV_STAT(name, m)\ +{ .stat_string = name,\ + .type = NETDEV_STATS, \ + .sizeof_stat = FIELD_SIZEOF(struct rtnl_link_stats64, m), \ + .stat_offset = offsetof(struct rtnl_link_stats64, m)\ +} #define NETXEN_NIC_PORT_WINDOW 0x1 #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { - {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, - {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)}, - {"rx_dropped", NETXEN_NIC_STAT(stats.rxdropped)}, - {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)}, - {"csummed", NETXEN_NIC_STAT(stats.csummed)}, - {"rx_pkts", NETXEN_NIC_STAT(stats.rx_pkts)}, - {"lro_pkts", NETXEN_NIC_STAT(stats.lro_pkts)}, - {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)}, - {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, + NETXEN_NIC_STAT("xmit_called", stats.xmitcalled), + NETXEN_NIC_STAT("xmit_finished", stats.xmitfinished), + NETXEN_NETDEV_STAT("rx_dropped", rx_dropped), + NETXEN_NIC_STAT("tx_dropped", stats.txdropped), + NETXEN_NIC_STAT("csummed", stats.csummed), + NETXEN_NIC_STAT("rx_pkts", stats.rx_pkts), + NETXEN_NIC_STAT("lro_pkts", stats.lro_pkts), + NETXEN_NIC_STAT("rx_bytes", stats.rxbytes), + NETXEN_NIC_STAT("tx_bytes", stats.txbytes), }; #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats) @@ -677,11 +692,27 @@ netxen_nic_get_ethtool_stats(struct net_device *dev, { struct netxen_adapter *adapter = netdev_priv(dev); int index; + struct rtnl_link_stats64 temp; + const struct rtnl_link_stats64 *net_stats; + char *p = NULL; + net_stats = dev_get_stats(dev, ); for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { - char *p = - (char *)adapter + - netxen_nic_gstrings_stats[index].stat_offset; + + switch (netxen_nic_gstrings_stats[index].type) { + case NETDEV_STATS: + p = (char *)net_stats + + netxen_nic_gstrings_stats[index].stat_offset; + break; + case NETXEN_STATS: + p = (char *)adapter + + netxen_nic_gstrings_stats[index].stat_offset; + break; + default: + data[index] = 0; + continue; If there is a chance of default case, then it will be always in switch case ...? + } + data[index] = (netxen_nic_gstrings_stats[index].sizeof_stat == sizeof(u64)) ? *(u64 *) p : *(u32 *) p; -- Regards, Varka Bhadram. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More
[PATCH/linux-next] Documentation:DocBook: Fix file paths in gadget.tmpl
Started on linux-next 2014-07-17, commit 5ed4ac73e5975b was added. This patch moves file location from driver/usb/gadget to driver/usb/gadget/function. Because of this change, make xmldocs started to fail, because the gadget.tmpl file still have an old paths. Masanari Iida (1): Documentation:Docbook: Fix file locations in gadget.tmpl Documentation/DocBook/gadget.tmpl | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.0.1.537.g81e776d -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH/linux-next] Documentation:Docbook: Fix file locations in gadget.tmpl
Because of file location changes by commit 5ed4ac73e5975, make xmldocs failed because of missing files. Fix file paths in gadget.tmpl file. Signed-off-by: Masanari Iida --- Documentation/DocBook/gadget.tmpl | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/DocBook/gadget.tmpl b/Documentation/DocBook/gadget.tmpl index 2c425d7..6416292 100644 --- a/Documentation/DocBook/gadget.tmpl +++ b/Documentation/DocBook/gadget.tmpl @@ -556,11 +556,11 @@ been converted to this framework. Near-term plans include converting all of them, except for "gadgetfs". -!Edrivers/usb/gadget/f_acm.c -!Edrivers/usb/gadget/f_ecm.c -!Edrivers/usb/gadget/f_subset.c -!Edrivers/usb/gadget/f_obex.c -!Edrivers/usb/gadget/f_serial.c +!Edrivers/usb/gadget/function/f_acm.c +!Edrivers/usb/gadget/function/f_ecm.c +!Edrivers/usb/gadget/function/f_subset.c +!Edrivers/usb/gadget/function/f_obex.c +!Edrivers/usb/gadget/function/f_serial.c -- 2.0.1.537.g81e776d -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH V3] netxen: fix ethtool rx_dropped information in ethtool get_ethtool_stats()
netxen driver has implemented netxen_nic_get_ethtool_stats() interface, but it doesn't collect stats.rxdropped in driver, so we will get different rx_dropped statistic information while using ifconfig and ethtool. this patch fills stats.rxdropped field with data from net core with dev_get_stats() just as ixgbe driver did for some of its stats. Tested with last netxen 4.0.82 Compiled with stable 3.15.6 Signed-off-by: Ethan Zhao Tested-by: Sriharsha Yadagudde --- -v2 only fix rx_dropped field, not all. -v3 workaround checkpatch.pl bug according to suggestion from Joe Perches .../ethernet/qlogic/netxen/netxen_nic_ethtool.c| 59 +++- 1 files changed, 45 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index 87e073c..2753f00 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c @@ -31,28 +31,43 @@ #include "netxen_nic.h" #include "netxen_nic_hw.h" +enum {NETDEV_STATS, NETXEN_STATS}; + struct netxen_nic_stats { char stat_string[ETH_GSTRING_LEN]; + int type; int sizeof_stat; int stat_offset; }; -#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ - offsetof(struct netxen_adapter, m) +#define NETXEN_NIC_STAT(name, m) \ +{ \ + .stat_string = name,\ + .type = NETXEN_STATS, \ + .sizeof_stat = FIELD_SIZEOF(struct netxen_adapter, m), \ + .stat_offset = offsetof(struct netxen_adapter, m) \ +} + +#define NETXEN_NETDEV_STAT(name, m)\ +{ .stat_string = name,\ + .type = NETDEV_STATS, \ + .sizeof_stat = FIELD_SIZEOF(struct rtnl_link_stats64, m), \ + .stat_offset = offsetof(struct rtnl_link_stats64, m)\ +} #define NETXEN_NIC_PORT_WINDOW 0x1 #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { - {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, - {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)}, - {"rx_dropped", NETXEN_NIC_STAT(stats.rxdropped)}, - {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)}, - {"csummed", NETXEN_NIC_STAT(stats.csummed)}, - {"rx_pkts", NETXEN_NIC_STAT(stats.rx_pkts)}, - {"lro_pkts", NETXEN_NIC_STAT(stats.lro_pkts)}, - {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)}, - {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, + NETXEN_NIC_STAT("xmit_called", stats.xmitcalled), + NETXEN_NIC_STAT("xmit_finished", stats.xmitfinished), + NETXEN_NETDEV_STAT("rx_dropped", rx_dropped), + NETXEN_NIC_STAT("tx_dropped", stats.txdropped), + NETXEN_NIC_STAT("csummed", stats.csummed), + NETXEN_NIC_STAT("rx_pkts", stats.rx_pkts), + NETXEN_NIC_STAT("lro_pkts", stats.lro_pkts), + NETXEN_NIC_STAT("rx_bytes", stats.rxbytes), + NETXEN_NIC_STAT("tx_bytes", stats.txbytes), }; #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats) @@ -677,11 +692,27 @@ netxen_nic_get_ethtool_stats(struct net_device *dev, { struct netxen_adapter *adapter = netdev_priv(dev); int index; + struct rtnl_link_stats64 temp; + const struct rtnl_link_stats64 *net_stats; + char *p = NULL; + net_stats = dev_get_stats(dev, ); for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { - char *p = - (char *)adapter + - netxen_nic_gstrings_stats[index].stat_offset; + + switch (netxen_nic_gstrings_stats[index].type) { + case NETDEV_STATS: + p = (char *)net_stats + + netxen_nic_gstrings_stats[index].stat_offset; + break; + case NETXEN_STATS: + p = (char *)adapter + + netxen_nic_gstrings_stats[index].stat_offset; + break; + default: + data[index] = 0; + continue; + } + data[index] = (netxen_nic_gstrings_stats[index].sizeof_stat == sizeof(u64)) ? *(u64 *) p : *(u32 *) p; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 2/4] power_supply: Introduce generic psy charging driver
> From: Sebastian Reichel [mailto:s...@kernel.org] > Sent: Friday, July 18, 2014 7:49 AM > To: Tc, Jenny > Cc: linux-kernel@vger.kernel.org; Dmitry Eremin-Solenikov; Pavel Machek; Anton > Vorontsov; David Woodhouse; David Cohen; Pallala, Ramakrishna; > myungjoo@samsung.com > Subject: Re: [PATCH 2/4] power_supply: Introduce generic psy charging driver > > Hi Jenny, > > On Tue, Jul 08, 2014 at 11:34:19AM +0530, Jenny TC wrote: > > The Power Supply charging driver connects multiple subsystems to do > > charging in a generic way. The subsystems involves power_supply, > > thermal and battery communication subsystems (1wire). With this the > > charging is handled in a generic way. > > > > The driver makes use of different new features - Battery > > Identification interfaces, pluggable charging algorithms, charger cable > > arbitrations > etc. > > The patch also introduces generic interface for charger cable notifications. > > Charger cable events and capabilities can be notified using the > > generic power_supply_notifier chain. > > > > Overall this driver removes the charging logic out of the charger chip > > driver and the charger chip driver can just listen to the request from > > the power supply charging driver to set the charger properties. This > > can be implemented by exposing get_property and set property callbacks. > > this seems to be a superset of charger-manager, which is already in the > kernel. I > would prefer not to have two different charger mangement frameworks in the > kernel. > > I suggest to add features supported by charger-manager to power supply > charging > driver and convert users of charger-manager to the improved driver. > > I CC'd MyungJoo Ham, who wrote the charger-manager, so that he can also give > feedback. We are back to the initial discussions we had in the list. The initial proposal was for the charger manager. The charger manager is more aligned to regulator framework, use private notification mechanisms(cm_notify_event,fullbatt_vchk etc) and relies more on platform data (struct charger_desc). This doesn't seems to be good to support plug in charger drivers, charging algorithms, battery identification drivers at runtime. Power supply charger driver is introduced to meet all these requirements by extending the existing power_supply subsystem features like power_supply_changed event, power_supply_register, power supply thermal throttling mechanism so that plugging new driver would be easy. Also the user interfaces would remain the same as power_supply subsystem. Able to locate link on the discussion. http://www.gossamer-threads.com/lists/linux/kernel/1562180. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/7] firmware_class: perform new LSM checks
On Mon, 14 Jul 2014, Kees Cook wrote: > This attaches LSM hooks to the existing firmware loading interfaces: > filesystem-found firmware and demand-loaded blobs. > static int fw_get_filesystem_firmware(struct device *device, > @@ -640,6 +646,12 @@ static ssize_t firmware_loading_store(struct device *dev, > break; > case 0: > if (test_bit(FW_STATUS_LOADING, _buf->status)) { > + if (security_kernel_fw_from_file(NULL, fw_buf->data, > + fw_buf->size)) { > + fw_load_abort(fw_priv); > + break; > + } > + > set_bit(FW_STATUS_DONE, _buf->status); > clear_bit(FW_STATUS_LOADING, _buf->status); > > Can you explain the loading store, and what the semantics are for an LSM when a NULL is passed as the file? -- James Morris -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3] PM / devfreq: Add possible_frequencies device attribute
On 07/16/2014 05:50 PM, MyungJoo Ham wrote: > On Wed, Jul 16, 2014 at 12:01 PM, Saravana Kannan > wrote: >> Some devices use freq_table instead of OPP. For those devices, the >> available_frequencies sysfs file shows up empty. So, add a >> possible_frequencies attribute/syfs file that list all the possible >> frequencies. >> >> For devices that use OPP, the output of this file will match >> available_frequencies. It may change in the future to show all OPP >> frequencies -- even the disabled ones. >> >> Signed-off-by: Saravana Kannan > > Hi, > > > Please add a documentation entry for this new ABI having a little > justification and usage included. Will do. > > Plus, I am considering to move trans_stat along with this entry to somewhere > such as .../stat/* > (you don't need to take care of this.) Ok. > > Besides, as OPP seems becoming the standard as imagined when devfreq > development started, > soon, devfreq may require OPP unless the devfreq device has continuous > frequencies. I agree. Only one caveat with OPP is that if a device isn't using OPP to do any voltage scaling, then it forces a voltage column with 0s. Also, even if we make OPP mandatory, we'll still want trans_stats that currently seem to depend on freq_table being populated. I was actually planning on sending out more patches later that'll do a lot of stuff automatically for devices with OPP. Like creating freq_table, etc. -Saravana -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v12 11/11] seccomp: add thread sync ability
On Thu, 17 Jul 2014, Kees Cook wrote: > Twelfth time's the charm! :) Btw, there doesn't seem to be an official seccomp maintainer. Kees, would you like to volunteer for this? If so, send in a patch for MAINTAINERS, and set up a git tree for me to pull from. -- James Morris -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend
On 07/16/2014 10:35 PM, Viresh Kumar wrote: On 17 July 2014 01:26, Saravana Kannan wrote: On 07/16/2014 04:16 AM, Srivatsa S. Bhat wrote: That is, we wanted to do the kobject cleanup after releasing the hotplug lock, and POST_DEAD stage was well-suited for that. I think, this has changed in Saravana's patch, we do it in the PREPARE stage now. Not really. We much never do it during hotplug. We only do it when the cpufreq driver unregisters. This should be easier to see in v4, where I'm breaking up the patches into easier diffs. Commit 1aee40ac9c8 (cpufreq: Invoke __cpufreq_remove_dev_finish() after releasing cpu_hotplug.lock) explains this in detail. Saravana, please take a look at that reasoning and ensure that your patch doesn't re-introduce those deadlock possibilities! But all of that was needed _because_ we were creating and destroying policies and kobjs all the time. We don't do that anymore. So, I don't think any of that applies. We only destroy when the cpufreq driver is unregistered. That's kinda of the point of this patchset. Thoughts? See above. -Saravana -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/