Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2284366imc; Tue, 12 Mar 2019 10:34:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUtyEiKE199v4XpyCkyOYdOWEjAxec8W0AN0hymel5FDZbw5+kjATpAR4qq8/o2LRmSDJM X-Received: by 2002:a63:ee55:: with SMTP id n21mr6658988pgk.211.1552412041509; Tue, 12 Mar 2019 10:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552412041; cv=none; d=google.com; s=arc-20160816; b=XXFhFAbvil9d7wEhII/RNUGUpqlsVvICH9lvGp/Z621QEU+1ZwSC8an0pH6WzVWARs LzpHHwyrUhUT4dcD0yF59vXL7jD8fj05fZHnzNcwdFEWaA7eTbOCtverKy2f4Ufb2PRS LpRyLd2zRR7HYG0BaZIBTgCZaY+Wu1QpjvjJJJR6eR4FwIwH0LxLwq3ZTl4hQO4wl4ra V5G123BPoC317A2iwVMeP2RFNLruXrrGqfybpIEXbWDnh9vUFDnglb0RRvyC7WR8G0Oc Jj9WsOV9ft19Si1uMv6LF0Iu80rhzaY/HQovFsmEgPo93LFA6Vk5itWrNGssDEpLIj6z wQug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=duuYt5E4XdS6CV1F3D2RPrNMMW8Vot3dabTMh9h3tb0=; b=TbHNUwTk6ttmedlfxxeiiFTv4LK2HtR77KxJ+ngp9p3BdpMReFQpmrphVXYIRRcr5e fAE4Ckf68Jnwl0mqeBJ1nAtf42eTRBaSwZt6i5HqpanzEd9sOmkGMpIg3jr4rJAEVpIr r8FQseIfwlB+WKngnJG4gIjG2Jv1U9eX8uGxXAZVOS01KWh5LEGdhl6Ef1YPRf98zUPR MFl/JrU6LwohJmNT/zjlEQoOCt56M8xO5GiStJgsMtdLpq8gmjABCrwVfaE0I2SCsEhl EZ2Z85wgXG4JIEpqKOMpyOBBpLmrS+khRNAjgLsvW04cNF5TI5hhIkO7qUMMmHGFv253 dH4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CpqdtZdt; 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 32si8803438pls.415.2019.03.12.10.33.45; Tue, 12 Mar 2019 10:34:01 -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=pass header.i=@kernel.org header.s=default header.b=CpqdtZdt; 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 S1729273AbfCLRbc (ORCPT + 99 others); Tue, 12 Mar 2019 13:31:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729464AbfCLRRK (ORCPT ); Tue, 12 Mar 2019 13:17:10 -0400 Received: from localhost (unknown [104.133.8.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFA6E217D8; Tue, 12 Mar 2019 17:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552411029; bh=1tdeYFIXL7uYmksV6OONGB8Q/eBH0Ifxu3NGtf7CBZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CpqdtZdtF4ZtXe790sWUQOWAS6V2hT06dD5nClB/DLQiYlpSbZFRPvrhAHg4/2pM0 /igobZIwICbX9FQH91c5/uEgF45yrPYayTHY0pZluAodtiIr5C6S3cvlb/30B0yLqT 0yrAHJr9AAUEzapVr42tamKIh9VWBs/0U4tGsL28= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Thomas Gleixner Subject: [PATCH 4.14 133/135] perf/x86/intel: Generalize dynamic constraint creation Date: Tue, 12 Mar 2019 10:09:40 -0700 Message-Id: <20190312170353.414674067@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170341.127810985@linuxfoundation.org> References: <20190312170341.127810985@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Peter Zijlstra (Intel)" commit 11f8b2d65ca9029591c8df26bb6bd063c312b7fe upstream Such that we can re-use it. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/intel/core.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2640,6 +2640,35 @@ intel_stop_scheduling(struct cpu_hw_even } static struct event_constraint * +dyn_constraint(struct cpu_hw_events *cpuc, struct event_constraint *c, int idx) +{ + WARN_ON_ONCE(!cpuc->constraint_list); + + if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) { + struct event_constraint *cx; + + /* + * grab pre-allocated constraint entry + */ + cx = &cpuc->constraint_list[idx]; + + /* + * initialize dynamic constraint + * with static constraint + */ + *cx = *c; + + /* + * mark constraint as dynamic + */ + cx->flags |= PERF_X86_EVENT_DYNAMIC; + c = cx; + } + + return c; +} + +static struct event_constraint * intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event, int idx, struct event_constraint *c) { @@ -2669,27 +2698,7 @@ intel_get_excl_constraints(struct cpu_hw * only needed when constraint has not yet * been cloned (marked dynamic) */ - if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) { - struct event_constraint *cx; - - /* - * grab pre-allocated constraint entry - */ - cx = &cpuc->constraint_list[idx]; - - /* - * initialize dynamic constraint - * with static constraint - */ - *cx = *c; - - /* - * mark constraint as dynamic, so we - * can free it later on - */ - cx->flags |= PERF_X86_EVENT_DYNAMIC; - c = cx; - } + c = dyn_constraint(cpuc, c, idx); /* * From here on, the constraint is dynamic.