Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752835AbbEZKRM (ORCPT ); Tue, 26 May 2015 06:17:12 -0400 Received: from [198.137.202.9] ([198.137.202.9]:50677 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752603AbbEZKRL (ORCPT ); Tue, 26 May 2015 06:17:11 -0400 Date: Tue, 26 May 2015 12:15:48 +0200 From: Peter Zijlstra To: Stephane Eranian Cc: Ingo Molnar , Vince Weaver , Jiri Olsa , "Liang, Kan" , LKML Subject: Re: [PATCH v2 02/11] perf/x86: Improve HT workaround GP counter constraint Message-ID: <20150526101548.GL3644@twins.programming.kicks-ass.net> References: <20150522132905.416122812@infradead.org> <20150522133135.447912500@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: 1878 Lines: 40 Please trim your email. On Tue, May 26, 2015 at 02:37:52AM -0700, Stephane Eranian wrote: > > @@ -822,8 +830,24 @@ int x86_schedule_events(struct cpu_hw_ev > > > > /* slow path */ > > if (i != n) { > > + int gpmax = x86_pmu.num_counters; > > + > > + /* > > + * Do not allow scheduling of more than half the available > > + * generic counters. > > + * > > + * This helps avoid counter starvation of sibling thread by > > + * ensuring at most half the counters cannot be in exclusive > > + * mode. There is no designated counters for the limits. Any > > + * N/2 counters can be used. This helps with events with > > + * specific counter constraints. > > + */ > > + if (is_ht_workaround_enabled() && !cpuc->is_fake && > > + READ_ONCE(cpuc->excl_cntrs->exclusive_present)) > > + gpmax /= 2; > > + > What I don't like about this part is that this is a hack to work around a bug > on some limited Intel CPUs and yet it is in the middle of generic x86 code. > I understand it will be inoperative on AMD PMU and is not used by Intel > uncore. On KNC or P6, you will not have is_ht_workaround_enabled(). > Could this be made a x86_pmu callback? x86_pmu.counter_limit()? It'll be slower though. You get an indirect function call in there. But sure we can clean that up later if you like; there's other things needing to be fixed here first. I'm going to overhaul the whole get/put constraints stuff first. -- 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/