Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754143AbbGFKz1 (ORCPT ); Mon, 6 Jul 2015 06:55:27 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:42175 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753828AbbGFKz0 (ORCPT ); Mon, 6 Jul 2015 06:55:26 -0400 Date: Mon, 6 Jul 2015 12:55:17 +0200 From: Peter Zijlstra To: "Liang, Kan" Cc: Vince Weaver , "linux-kernel@vger.kernel.org" , Ingo Molnar , Arnaldo Carvalho de Melo , Stephane Eranian Subject: Re: perf: fuzzer triggered warning in intel_pmu_drain_pebs_nhm() Message-ID: <20150706105517.GZ3644@twins.programming.kicks-ass.net> References: <20150703131336.GI19282@twins.programming.kicks-ass.net> <37D7C6CF3E00A74B8858931C1DB2F07701885A65@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F07701885A65@SHSMSX103.ccr.corp.intel.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2087 Lines: 54 On Fri, Jul 03, 2015 at 08:08:27PM +0000, Liang, Kan wrote: > If we cleared the last bit, we not only drain the buffer but also decrease > the event->ctx->pmu, which is used to flush the PEBS buffer during > context switches. > We need to disable cpuc->pebs_enabled before changing > event->ctx->pmu as below. > Indeed, mind sending a proper patch so I can press 'A' on it? > diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c > b/arch/x86/kernel/cpu/perf_event_intel_ds.c > index 71fc402..76285c1 100644 > --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c > +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c > @@ -754,6 +754,11 @@ void intel_pmu_pebs_disable(struct > perf_event *event) > struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); > struct hw_perf_event *hwc = &event->hw; > struct debug_store *ds = cpuc->ds; > + bool large_pebs = ds->pebs_interrupt_threshold > > + ds->pebs_buffer_base + x86_pmu.pebs_record_size; > + > + if (large_pebs) > + intel_pmu_drain_pebs_buffer(); > > cpuc->pebs_enabled &= ~(1ULL << hwc->idx); > > @@ -762,12 +767,8 @@ void intel_pmu_pebs_disable(struct > perf_event *event) > else if (event->hw.flags & PERF_X86_EVENT_PEBS_ST) > cpuc->pebs_enabled &= ~(1ULL << 63); > > - if (ds->pebs_interrupt_threshold > > - ds->pebs_buffer_base + x86_pmu.pebs_record_size) { > - intel_pmu_drain_pebs_buffer(); > - if (!pebs_is_enabled(cpuc)) > - perf_sched_cb_dec(event->ctx->pmu); > - } > + if (large_pebs && !pebs_is_enabled(cpuc)) > + perf_sched_cb_dec(event->ctx->pmu); > > if (cpuc->enabled) > wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled); > > > > Thanks, > Kan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/