From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933592AbbLHQoN (ORCPT ); Tue, 8 Dec 2015 11:44:13 -0500 Received: from mga14.intel.com ([192.55.52.115]:51793 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932402AbbLHQoL (ORCPT ); Tue, 8 Dec 2015 11:44:11 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,400,1444719600"; d="scan'208";a="856540160" From: Alexander Shishkin To: Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org, vince@deater.net, eranian@google.com, johannes@sipsolutions.net, Arnaldo Carvalho de Melo Subject: Re: [PATCH 2/7] perf: Generalize task_function_call()ers In-Reply-To: <20151203173431.GC3816@twins.programming.kicks-ass.net> References: <1449138762-15194-1-git-send-email-alexander.shishkin@linux.intel.com> <1449138762-15194-3-git-send-email-alexander.shishkin@linux.intel.com> <20151203173431.GC3816@twins.programming.kicks-ass.net> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Tue, 08 Dec 2015 18:42:01 +0200 Message-ID: <87vb88yjs6.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > OK, so the retry_state thing is clever, but either I'm too tired or its > not quite right. Nor do I think its actually required. > > /me frobs... > > Hmm, I cannot seem to convince myself the current code is correct to > begin with. > > In any case, consider the below (on top of my previous collapse patch). > The two 'hard' cases are perf_event_{dis,en}able(), those appear to play > silly games with event->state. > > So starting with perf_event_disable(); we don't strictly need to test > for event->state == ACTIVE, ctx->is_active is enough. If the event is > not scheduled while the ctx is, __perf_event_disable() still does the > right thing. Its a little less efficient to IPI in that case, over-all > simpler. > > For perf_event_enable(); the same goes, but I think that's actually > broken in its current form. The current condition is: ctx->is_active && > event->state == OFF, that means it doesn't do anything when !ctx->active > && event->state == OFF. This is wrong, it should still mark the event > INACTIVE in that case, otherwise we'll still not try and schedule the > event once the context becomes active again. Yes, this does look more logically correct. > > > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -1766,6 +1766,20 @@ int __perf_event_disable(void *info) > return 0; > } > > +void ___perf_event_disable(void *info) Only maybe change these to __perf_event_disable_locked() or something visually distinctive from the 'active' callback? FWIW, Reviewed-by: Alexander Shishkin Thanks, -- Alex