Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1077653ybl; Wed, 14 Aug 2019 10:19:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhV17Uh1DQNo9TPJo9bWTNN1nfl/9/5FhiJEWEtSEJorZ0viiKjp0ilFWVOF41WyxTM47K X-Received: by 2002:a17:902:76c7:: with SMTP id j7mr415697plt.247.1565803186010; Wed, 14 Aug 2019 10:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803186; cv=none; d=google.com; s=arc-20160816; b=XBGLKyz5NEL+OBxPO90cPOffCIkKsYD7alEdsOnyEFCK5b/7qSOxNnT9XRN0gQj2Uw NSz3YkyEm8E+oPHytX2sBnMtrWgMpdjvWSPsHaRp6V1F6W2UOILc5Qq5AEp1r0FcUPIG 1IoQy2mfYMxGpDnittdNBaJn7dHIJzn+pDck5pjIvOJZzu/CpFlvBKYclGb7QSYXHa7o Niq0KBdafPhkvYHZvD6n1au42Ifo1bJ708CRRqnKkXmykvi6FF5DMOgN9pQkgSMRxjCx XHR8rsnEf4LtHY4FZIU6iZcjzdwIWS6C3PXuFEZHt87cc/W/wy30znqjCd1HJ5595Nlg HZfA== 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=GZT0HUJ/ZX2NCG74crnH6eoNU+i1GWcrEjZDZB4NRXo=; b=Eg+cr8gIPecOumAqKYZedpe6nXAUUIq22RluCIOCZryHoSkLKEfogNuYHNedNAfwtC Ggb7wv5PAjqNAnNXV2p4ZNjfLIKxsj/wEOY9V28gLuFNjBiiJaZSiB8LVotrg82PlJXC BkkPnd0FvM5wkZz0pKzLss5sfnKWAPdx03ykuUI5wFkqNcbBKhr9LH2Pz2QhVx1pmbgp W7Z6JMvTdCgDo3nR5uEQIbNkwAgespq5wzOb86yPK6LZQUAF3sYdeyvlSRkJmBBeXQKe suMA1qQIi5+cj48DMIBGCj9RHSzSNr/tGSHTLW+E7b5xFVXcepThl5rqdn7S6/RgEcxv UFHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xd+fM4t2; 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 o37si186861pjb.94.2019.08.14.10.19.30; Wed, 14 Aug 2019 10:19:45 -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=xd+fM4t2; 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 S1730638AbfHNRS7 (ORCPT + 99 others); Wed, 14 Aug 2019 13:18:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:35820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730272AbfHNRMI (ORCPT ); Wed, 14 Aug 2019 13:12:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E2F252184B; Wed, 14 Aug 2019 17:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802728; bh=nEHSbTGvTEplwCrmU8NaBv47TnXpMbycW9HXlPkObTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xd+fM4t2GBJdq3EaCTJNFD2fwXFw171h82Eoq/9O+JjPFS1ukIqzUOIhVgjFF87Z5 1NnvLywO6tfAkrEmg+q+n5Dicx4+nIRfgGwhqVkDXruwnkjKmbT1hFJXuOrzZcs/6D mJkSgyCxWIeeYjy3PsGsjkWhp7ShR4jdQoQ1v0Ks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leonard Crestez , "Peter Zijlstra (Intel)" , Mark Rutland , Alexander Shishkin , Arnaldo Carvalho de Melo , Frank Li , Jiri Olsa , Linus Torvalds , Namhyung Kim , Thomas Gleixner , Will Deacon , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 68/91] perf/core: Fix creating kernel counters for PMUs that override event->cpu Date: Wed, 14 Aug 2019 19:01:31 +0200 Message-Id: <20190814165752.489133454@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 4ce54af8b33d3e21ca935fc1b89b58cbba956051 ] Some hardware PMU drivers will override perf_event.cpu inside their event_init callback. This causes a lockdep splat when initialized through the kernel API: WARNING: CPU: 0 PID: 250 at kernel/events/core.c:2917 ctx_sched_out+0x78/0x208 pc : ctx_sched_out+0x78/0x208 Call trace: ctx_sched_out+0x78/0x208 __perf_install_in_context+0x160/0x248 remote_function+0x58/0x68 generic_exec_single+0x100/0x180 smp_call_function_single+0x174/0x1b8 perf_install_in_context+0x178/0x188 perf_event_create_kernel_counter+0x118/0x160 Fix this by calling perf_install_in_context with event->cpu, just like perf_event_open Signed-off-by: Leonard Crestez Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Mark Rutland Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Frank Li Cc: Jiri Olsa Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Link: https://lkml.kernel.org/r/c4ebe0503623066896d7046def4d6b1e06e0eb2e.1563972056.git.leonard.crestez@nxp.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index e8979c72514be..7ca44b8523c81 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10957,7 +10957,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, goto err_unlock; } - perf_install_in_context(ctx, event, cpu); + perf_install_in_context(ctx, event, event->cpu); perf_unpin_context(ctx); mutex_unlock(&ctx->mutex); -- 2.20.1