Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1073820ybl; Wed, 14 Aug 2019 10:16:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyT0GRGdP4CGgUGopsbV6bYO7umuUb2MPZfBTvQn8UNGEL7QdeoULeVf4a3sekW2TM3eK9U X-Received: by 2002:a65:500a:: with SMTP id f10mr203369pgo.105.1565802970127; Wed, 14 Aug 2019 10:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802970; cv=none; d=google.com; s=arc-20160816; b=x2p7UJRpBJi6KFZITAMEsMAIu1BzzbDI1msN619phy2jjZTTy+xURZWDN/+Kb/gv3W cR4B7mQmJ+Wh7urQwv/eHCKpyZI8ZRrNc1+/BwLa7EcUSunfp5050kMc2aziIcZA1vGf hBdztF9RgTKge4ajJlGArgYGtkIzn4pZS5vOwSsINdN1g/bOnpionvXJubHVDzolPHSa h1/3HKN6tlCRE8OSnA10SznYXXQxRU5lzMwPSkOjTcH+JPtU4++At5MKL75rtdajh4Ki L5hMiymFUvMKYee//yiFiPCq5RddZ2UAlyrXo4zzOnzAY9VBrhT3a74lWb/eF7CDZoMi LUXA== 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=Au1tle03Ac3zoYYcLURornlnntt5D1Iy3T+12yTz7jY=; b=mBDKGIHpyYsgl3XvQjn2HFe3lnAdvbrgJbQx5/fh+0BNkN3SgUwAtkIqu24daCOy7Y 6KNtKq3iaykfGn3nv/7agqdp1IbaQPOiwfax5XcGJAD0V5fmEf1dGN1DURj0uI8EltKJ hxw+G1ngOEQGyHJy03Wydb5+gAb++SAsb4PPtTGa2uw4VN3KnBFBvJYgngXBl7c5YPg9 b5uOqVTCiVrKx/z0YiqFwVTeBY8d4+EVX/DmX/HChdNnJ3bQHKClj+Dp+zC4zTwFMKX6 aPFqXSQqmQZBOf3JEYh9BZeg4To2X91A6CR+diSF+SEBTxCfC8npFLoyNAlT9pJxrVj9 /+UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fbv1XCZN; 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 a14si175259pjo.102.2019.08.14.10.15.53; Wed, 14 Aug 2019 10:16:10 -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=fbv1XCZN; 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 S1730985AbfHNRPU (ORCPT + 99 others); Wed, 14 Aug 2019 13:15:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:39904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731213AbfHNRPS (ORCPT ); Wed, 14 Aug 2019 13:15:18 -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 B4D922173B; Wed, 14 Aug 2019 17:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802918; bh=fGHYA2jkSjAb5qy2817gBuqAcPDx6rCnCyhCJyo463A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fbv1XCZNXlQ0PNNjb1yVvqjOiN7Zv+9OJ2OOx8tZdKCmEkOLQwKBAr94S0YM/lS2/ /BLLvBoXnIRm8JpNtyCphO0OH73gOUkG8DAXFxwXowx1Q9oSmUQ3Dvf9UgQRg3z/xU epMeEsW+eOeafNW9yjhpGoB5bqQpMLOq3vVk2BPM= 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.14 50/69] perf/core: Fix creating kernel counters for PMUs that override event->cpu Date: Wed, 14 Aug 2019 19:01:48 +0200 Message-Id: <20190814165748.941530786@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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 3d4eb6f840eba..ea4f3f7a0c6f3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10474,7 +10474,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