Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3822890imc; Thu, 14 Mar 2019 06:12:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHvwbxujvoOleHR0BBQiBF2xd+esB5sBPCPinIUi8QPajBaWY6MyTv+xiKWgREcxSobpjI X-Received: by 2002:a63:d542:: with SMTP id v2mr45351473pgi.52.1552569150226; Thu, 14 Mar 2019 06:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552569150; cv=none; d=google.com; s=arc-20160816; b=riWGLGJl0fAYtqMRNMWf4X0tx9MX6uZpLYaGP8BriO6d0BqZkq4GQWHaKTlZjbZEh4 MOhrVXTTOx06/On41k0LAFxqJ9StNekhYV1J5ep3O2vaAk0zCX+CBnbghGJ6c9fndXsR 1jn2Nybn7mHRSljpGWqUED0Z0al+cEyNg5q2ovpCTjFHda0eS227dD8tu2XlA0bndO+d EmeMViZ4YGVo8v2mUEb/+s0loCtIb04ODJoNh61Vz8ZP7UbbX7VwrtffJ8NFsqRYs/wa hA6KYRlGBartPpQ0u6JPUqA0psZUfmojE5i+Lh4CllbetxdpGZ7E7sv7f0qsjBNU+PLM 32/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=51LsL6zBq2dD+dHWWzXV54l4My7JvojSdAsyn2uDHBY=; b=OuUmd+w7L527xGbbyo2bX+amxKaVeh/FIUYHob/bNA/LImw0r9O1+jjaEtIIhFfaEL wwl+YFUA3fnPKXg+NR0sivLqZtHYVGld5raIdCzVrZ4+tPxZ6kXqYPmMtgsZ6GK11K5p MRfRiNKGrKsL4/0r8MDUwgK5OIBVCdd0DdzgmUlZicwz3gjrovDkz1pNCSCpPTc7KeQB GL/6ZwLaim9xOI2DY9Uaq3kBohp6JyJPNZxWe446CTpQ7Ka0EFcSL27Rlr7zqGWOA6p2 1RysT+Ol7LykP1LUcxh26qstlk2gc8ZegjUreGQTq3aiQM/l0R4OyFTB/K9KSDvktKT3 o5gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="DxLw/J2P"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a143si13453804pfd.24.2019.03.14.06.12.14; Thu, 14 Mar 2019 06:12:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="DxLw/J2P"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbfCNNLi (ORCPT + 99 others); Thu, 14 Mar 2019 09:11:38 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44342 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726752AbfCNNLh (ORCPT ); Thu, 14 Mar 2019 09:11:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=51LsL6zBq2dD+dHWWzXV54l4My7JvojSdAsyn2uDHBY=; b=DxLw/J2P8MHZtRpLOvK7nkA/LZ +m2AkfnSEvxpkrAnVVI1fV0C6srxJbXMR6W7CNTu0Dn2FGI71P8rRMd/bbiravCpYyvevSDC6KMDO Ka51gquEjpLp9pdYFWtUezGFVJbV1dx+MphcPrdF/2JEWI7fhR5/gMkW307xAHDpEImCoWPhDrkzj Ip90U4eyYiHaW0aJZSPxcB1k1VLy8i6gZh3T3a25NAVLzbHmj0ZAKo7KbVPXLG44w4chl3BD0An/t L9c+1HMUPRPpUnt2zROwzSm75tnyxkZ+iY3puzkaSv18CZIjDj+QToHs00LTNizjzgT+FPCb9kY4l oiKwSmJw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4Q8u-0006XO-UT; Thu, 14 Mar 2019 13:11:29 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 4E634203C07C0; Thu, 14 Mar 2019 14:11:27 +0100 (CET) Message-Id: <20190314130705.651247561@infradead.org> User-Agent: quilt/0.65 Date: Thu, 14 Mar 2019 14:01:16 +0100 From: Peter Zijlstra To: mingo@kernel.org, eranian@google.com, jolsa@redhat.com Cc: linux-kernel@vger.kernel.org, tonyj@suse.com, nelson.dsouza@intel.com, peterz@infradead.org Subject: [RFC][PATCH 3/8] perf/x86: Simplify x86_pmu.get_constraints() interface References: <20190314130113.919278615@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a special case for validate_events() where we'll call x86_pmu.get_constraints(.idx=-1). It's purpose, up until recent, seems to be to avoid taking a previous constraint from cpuc->event_constraint[] in intel_get_event_constraints(). (I could not find any other get_event_constraints() implementation using @idx) However, since that cpuc is freshly allocated, that array will in fact be initialized with NULL pointers, achieving the very same effect. Therefore remove this exception. Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/events/core.c | 2 +- arch/x86/events/intel/core.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2031,7 +2031,7 @@ static int validate_event(struct perf_ev if (IS_ERR(fake_cpuc)) return PTR_ERR(fake_cpuc); - c = x86_pmu.get_event_constraints(fake_cpuc, -1, event); + c = x86_pmu.get_event_constraints(fake_cpuc, 0, event); if (!c || !c->weight) ret = -EINVAL; --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2931,11 +2931,9 @@ static struct event_constraint * intel_get_event_constraints(struct cpu_hw_events *cpuc, int idx, struct perf_event *event) { - struct event_constraint *c1 = NULL; - struct event_constraint *c2; + struct event_constraint *c1, *c2; - if (idx >= 0) /* fake does < 0 */ - c1 = cpuc->event_constraint[idx]; + c1 = cpuc->event_constraint[idx]; /* * first time only @@ -3410,7 +3408,7 @@ tfa_get_event_constraints(struct cpu_hw_ /* * Without TFA we must not use PMC3. */ - if (!allow_tsx_force_abort && test_bit(3, c->idxmsk) && idx >= 0) { + if (!allow_tsx_force_abort && test_bit(3, c->idxmsk)) { c = dyn_constraint(cpuc, c, idx); c->idxmsk64 &= ~(1ULL << 3); c->weight--;