Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1015895imm; Wed, 19 Sep 2018 10:32:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaM1yfBEEZZuDs6G3QmWpUmAOUYF1o38p/U/SgUAnLvn2Y6ZuuOcbSp3FgobygU2YHuiJeV X-Received: by 2002:a17:902:24d:: with SMTP id 71-v6mr35112354plc.91.1537378327568; Wed, 19 Sep 2018 10:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537378327; cv=none; d=google.com; s=arc-20160816; b=R15bMy0Ia0WaBxJ3TkAe+kv41jMbcCUoePgSUQWnp1e16LcwGsWFCFQh4FFjRlWuRS F4IVcEbEvHi/HaRXOm/9D0PUZquV5pu6zXYp0kqv5Tlidk7SNhbs0jeJ6r8emo4fqydC Upxm8JVlXT5HQZyqSHatWCsCJe8jk/K/XiZL4MvkbtNh3FiC1YW4ZobwfyKn2EihOfzw L2FIO90xDoyjpXzk1zhyZrS2oHGBu2CYZgPTYifUUFoSLMOfr2le9jMLywRgDE2yF/FD LgusIinHUoK10ytGbBbGT4BbHSYr1ZZp7+puTXU/aMUKL1BlPZx4N80zsaf6CTZUBtpc gH/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=Bp5WFqrdKxoYMrT8ya7yXPuL/cGxX15SDh3/D01rLY0=; b=vmgj5wfLWIPWzCoayAphpaZZka+pkZ2s+b39aJF8pCb1DIeTHEMwu+1lPl1aaYfyfM RnQdMJdoXdqUGKTGBN/3fAMOB3rA/qcinAdsAaSDHwiX2BQ8Sy9fYiC+fnJtKnpD1il4 9BfNPIISm0kI+GQqZqNFMTtId9WZMHlaMBAFSejLlZlds3pYDgL1gzpaNNNSctXZHwhy eA+XM7Op3HLivSQxE/PtM7DL44qHAg/uIRZC19W+2RsNG359CVE6CwVEygJG5IlK54KO x1BmJwG9/Sii4rSQ4CzeBj1ENylkopE0L7Mwan8qT2c4a1wgNHcv9Yu5/M3ykrZgX8Yj DLVA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18-v6si19628837pll.344.2018.09.19.10.31.52; Wed, 19 Sep 2018 10:32:07 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733084AbeISXJb (ORCPT + 99 others); Wed, 19 Sep 2018 19:09:31 -0400 Received: from mga05.intel.com ([192.55.52.43]:33317 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732520AbeISXI7 (ORCPT ); Wed, 19 Sep 2018 19:08:59 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2018 10:30:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,394,1531810800"; d="scan'208";a="87551379" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga002.fm.intel.com with ESMTP; 19 Sep 2018 10:30:01 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org Cc: gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH V5 1/6] perf/core: Add sanity check to deal with pinned event failure Date: Wed, 19 Sep 2018 10:29:06 -0700 Message-Id: <6486385d1f30336e9973b24c8c65f5079543d3d3.1537377064.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Link: http://lkml.kernel.org/r/20180807093615.GY2494@hirez.programming.kicks-ass.net Suggested-by: Peter Zijlstra Signed-off-by: Reinette Chatre --- kernel/events/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 2a62b96600ad..191c0c2e10de 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3940,6 +3940,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 -- 2.17.0