Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757474AbbEVNmt (ORCPT ); Fri, 22 May 2015 09:42:49 -0400 Received: from casper.infradead.org ([85.118.1.10]:49431 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757211AbbEVNmp (ORCPT ); Fri, 22 May 2015 09:42:45 -0400 Date: Fri, 22 May 2015 15:42:42 +0200 From: Peter Zijlstra To: mingo@kernel.org Cc: vincent.weaver@maine.edu, eranian@google.com, jolsa@redhat.com, kan.liang@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 02/11] perf/x86: Improve HT workaround GP counter constraint Message-ID: <20150522134242.GH3644@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: <20150522133135.447912500@infradead.org> 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: 1359 Lines: 46 On Fri, May 22, 2015 at 03:29:07PM +0200, Peter Zijlstra wrote: > @@ -696,11 +699,16 @@ static bool __perf_sched_find_counter(st > goto done; > } > } > + > /* Grab the first unused counter starting with idx */ > idx = sched->state.counter; > for_each_set_bit_from(idx, c->idxmsk, INTEL_PMC_IDX_FIXED) { > + if (!__test_and_set_bit(idx, sched->state.used)) { > + if (sched->state.nr_gp++ >= sched->max_gp) > + return false; Note the placement inside the success path of the GP allocation, instead of the attempt a GP place we had before. > + > goto done; > + } > } > > return false; > @@ -2000,6 +1999,11 @@ intel_get_excl_constraints(struct cpu_hw > * across HT threads > */ > is_excl = c->flags & PERF_X86_EVENT_EXCL; > + if (is_excl && !(event->hw.flags & PERF_X86_EVENT_EXCL_ACCT)) { > + event->hw.flags |= PERF_X86_EVENT_EXCL_ACCT; > + if (!cpuc->n_excl++) > + WRITE_ONCE(excl_cntrs->has_exclusive[tid], 1); > + } > > /* > * xl = state of current HT And that is what keeps repeated get_event_constraints() calls from ever increasing our n_excl count. -- 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/