Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1194630imm; Fri, 28 Sep 2018 13:49:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV62n7lNcWa3W3R0F+N8kudaRgJk2vxx4dpVOgemMOb6AyOAi+o1bMgCuP5KE/Bl2H6UKYsB4 X-Received: by 2002:a17:902:e088:: with SMTP id cb8-v6mr270707plb.189.1538167791395; Fri, 28 Sep 2018 13:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538167791; cv=none; d=google.com; s=arc-20160816; b=QLt4xY+LqgYAGII474dhJNp0ncWQMvF3q0TBUw+MAWom+onFxZpuQuuDR2Orck3ElG +HEK8QUtussWkENVXijSe03xsBM0097vtPvVVhy5nBS2rNZE2NE7ltMrHA+TSEGgnJWl 5agFD7y6GLweIGecEvGTGWaJPvnN9wIljeeHBE1SV95pifVFnsuyzOvA0tgTpsmAq/DX 95vvHZkh2W3nudIwH0TRWsvmc3oWhRtueccYoAMiIe1YvutDI47X0Noa6sMKb3ufJRQh fgq/AOro4lP8bAKBA/cDX1m0uN4khAt8JQnKAv2dfwlvxeJK0CNpnPiV4ugA1XvErPk2 vykA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=XL6CVgl3zRvqTSvYZYGQV9QQw8BlGwHs7FFoaWb6zpI=; b=SN/x4kbo1wfY/Y3K6m78bHTr89UQaTi49zTCE/wEI4MnvzXJA/9ayM/K/lPNBXUgr+ GbESks44sprB1VlqazrM1lu9zcddJh/ZnslH73jTMwAcXiasT1BKWclPqoXc1vCvInaf FAFwso2BUWb7adWohAk/oy7GJYQLm/sw70+UIWBwYc5RFmTCM9FPtxyYffA48wmUdtRZ Rm6B+9zBBfYY1xnfXiHmFc+f6GQTDT/VJGUdSCW9w1pGcLluhICC8EkxiBv2FRuA6cm8 Fkwi2XBJm/fsEiDPyVAJcJrlSH6UHmZ4fqZXRaypRy+B6lN/MyrM23oEEsQEZSeygSP+ tVDw== ARC-Authentication-Results: i=1; mx.google.com; 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 f62-v6si5721728pfg.35.2018.09.28.13.49.36; Fri, 28 Sep 2018 13:49:51 -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; 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 S1727206AbeI2DO5 (ORCPT + 99 others); Fri, 28 Sep 2018 23:14:57 -0400 Received: from terminus.zytor.com ([198.137.202.136]:50539 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbeI2DO5 (ORCPT ); Fri, 28 Sep 2018 23:14:57 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8SKmrlp558133 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Sep 2018 13:48:53 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8SKmqFm558130; Fri, 28 Sep 2018 13:48:52 -0700 Date: Fri, 28 Sep 2018 13:48:52 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Reinette Chatre Message-ID: Cc: mingo@kernel.org, peterz@infradead.org, reinette.chatre@intel.com, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, reinette.chatre@intel.com, peterz@infradead.org, mingo@kernel.org In-Reply-To: <6486385d1f30336e9973b24c8c65f5079543d3d3.1537377064.git.reinette.chatre@intel.com> References: <6486385d1f30336e9973b24c8c65f5079543d3d3.1537377064.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/core: Add sanity check to deal with pinned event failure Git-Commit-ID: befb1b3c2703897c5b8ffb0044dc5d0e5f27c5d7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: befb1b3c2703897c5b8ffb0044dc5d0e5f27c5d7 Gitweb: https://git.kernel.org/tip/befb1b3c2703897c5b8ffb0044dc5d0e5f27c5d7 Author: Reinette Chatre AuthorDate: Wed, 19 Sep 2018 10:29:06 -0700 Committer: Thomas Gleixner CommitDate: Fri, 28 Sep 2018 22:44:53 +0200 perf/core: Add sanity check to deal with pinned event failure It is possible that a failure can occur during the scheduling of a pinned event. The initial portion of perf_event_read_local() contains the various error checks an event should pass before it can be considered valid. Ensure that the potential scheduling failure of a pinned event is checked for and have a credible error. Suggested-by: Peter Zijlstra Signed-off-by: Reinette Chatre Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: acme@kernel.org Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/6486385d1f30336e9973b24c8c65f5079543d3d3.1537377064.git.reinette.chatre@intel.com --- kernel/events/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index c80549bf82c6..dcb093e7b377 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3935,6 +3935,12 @@ int perf_event_read_local(struct perf_event *event, u64 *value, goto out; } + /* If this is a pinned event it must be running on this CPU */ + if (event->attr.pinned && event->oncpu != smp_processor_id()) { + ret = -EBUSY; + goto out; + } + /* * If the event is currently on this CPU, its either a per-task event, * or local to this CPU. Furthermore it means its ACTIVE (otherwise