From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759130AbdACNqf (ORCPT ); Tue, 3 Jan 2017 08:46:35 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:43190 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757973AbdACNp0 (ORCPT ); Tue, 3 Jan 2017 08:45:26 -0500 Date: Tue, 3 Jan 2017 14:45:25 +0100 From: Peter Zijlstra To: Jiri Olsa Cc: lkml , Ingo Molnar , Andi Kleen , Alexander Shishkin , Arnaldo Carvalho de Melo , Vince Weaver Subject: Re: [PATCH 4/4] perf/x86/intel: Throttle PEBS events only from pmi Message-ID: <20170103134525.GW3107@twins.programming.kicks-ass.net> References: <1482931866-6018-1-git-send-email-jolsa@kernel.org> <1482931866-6018-5-git-send-email-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1482931866-6018-5-git-send-email-jolsa@kernel.org> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 28, 2016 at 02:31:06PM +0100, Jiri Olsa wrote: > This patch fixes following WARNING: > > WARNING: CPU: 15 PID: 15768 at arch/x86/events/core.c:1256 x86_pmu_start+0x1b3/0x1c0 > ... > Call Trace: > > dump_stack+0x86/0xc3 > __warn+0xcb/0xf0 > warn_slowpath_null+0x1d/0x20 > x86_pmu_start+0x1b3/0x1c0 > perf_event_task_tick+0x342/0x3f0 > scheduler_tick+0x75/0xd0 > update_process_times+0x47/0x60 > tick_sched_handle.isra.19+0x25/0x60 > tick_sched_timer+0x3d/0x70 > __hrtimer_run_queues+0xfb/0x510 > hrtimer_interrupt+0x9d/0x1a0 > local_apic_timer_interrupt+0x38/0x60 > smp_trace_apic_timer_interrupt+0x56/0x25a > trace_apic_timer_interrupt+0x9d/0xb0 > ... > > which happens AFAICS under following conditions: > (we have PEBS events configured) > > - x86_pmu_enable reconfigures counters and calls: > - x86_pmu_stop on PEBS event > - x86_pmu_stop drains the PEBS buffer, crosses > the throttle limit and sets: > event->hw.interrupts = MAX_INTERRUPTS > - following x86_pmu_start call starts the event > - perf_event_task_tick is triggered > - perf_adjust_freq_unthr_context sees event with > MAX_INTERRUPTS set and calls x86_pmu_start on already > started event, which triggers the warning > > My first attempt to fix this was to unthrottle the event > before starting it in x86_pmu_enable. But I think that > omitting the throttling completely when we are not in the > PMI is better. Hurm,.. good catch that. Makes a bit of a mess of things though. Then again, I cannot quickly think of something better either :/