Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1066746ybl; Wed, 14 Aug 2019 10:10:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqySmmgRBvt8i4GYUwS8gcCfxV1qlR2FmB+Mo6KeYDRCxvtAajmRgvclvaxevVM4WTHafZF8 X-Received: by 2002:a65:608e:: with SMTP id t14mr158987pgu.373.1565802603061; Wed, 14 Aug 2019 10:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802603; cv=none; d=google.com; s=arc-20160816; b=gKU5QvQgQfVy6IBoWVqACBn+BNX3PyhOkFx8i/iO037Cz1Q4YIkEmr+I+AzXu39BxI LTvc4guZJVT3r/ov76TEoMQxFoQC4F8Lwv2M0rKOKjL+NlCUms6Ka38kJL4MTjqtuXaI NWrS4szie+ew5mP2rxL5KfmNnv0z+X77Cm77hejpLiGRjyqbwsHYUb/eh9lSdtkJAd36 F+QyCrFxcFXHJbFhTYTpjXMiqrXC4EF4Xhz6ZPKWwkqNLF1b0VPE63AB/U8BY+70uECp 7R/ITcwvf/A/Gsk8yTTD4blvLGXiEjVxLdF51xLi7K33SUupopZfsSKVnA1u8P7RQxYD SdNQ== 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=JdVzh+6ToKKjlK6q4Fcw/a44N4HekaUbP8cP66RpURc=; b=W4tH93Dwj0YZDzxMS20zXRbLmtKUtxruoMkonwjH994+ZFsFRODrIsXz0b0aNtGw13 VGXuXZ2fRGr1MtcWPLeCvUTFjU3+W6R7ynX5ZTgxvS6WVGmpWMvtFs71/V3bw3jI1lEL l9W4dyV4UN52xsVRqg72w38N21gph2wmOMX15L3HTy5FgtSIwsbVSsY5/EwmgcCUl4A2 h1bAaGZPRnv+LWzsRhERE5hglvoRVXNcHdEMZWQOqgTV5qhq3J4GCgQfMmxYY8qO1JJW 1cYxMb5joC1sLCSINL/R+4sDaSdsDT6SpLWlviuML0KpXESxYqufSw+FE9mJNnSTOyzd kbCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SD+dzF3S; 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 g5si233503plp.435.2019.08.14.10.09.46; Wed, 14 Aug 2019 10:10:03 -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=SD+dzF3S; 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 S1729816AbfHNRHL (ORCPT + 99 others); Wed, 14 Aug 2019 13:07:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:56556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729802AbfHNRHK (ORCPT ); Wed, 14 Aug 2019 13:07:10 -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 BD4BE2173B; Wed, 14 Aug 2019 17:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802429; bh=UGX9duJssUMBuCOetQaRW5I3+BrYmgSi/oc3xWLd2Lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SD+dzF3SPTsPpDsksPkpumPq6sD4BX4AGdR1fNULuTCN/vx4QKotiVK8uqhfQiMkS Dn88R88qIap9v+jgFwW5siVNgBo6dG3Pi9INz/m1RrrJ4ge+JaFu7pt8mm7luz4udK qZvSCZ9gtngnU1dUJvg7oVGjw9UXPoDin7V7dHDs= 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 5.2 115/144] perf/core: Fix creating kernel counters for PMUs that override event->cpu Date: Wed, 14 Aug 2019 19:01:11 +0200 Message-Id: <20190814165804.729937187@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 f851934d55d48..4bc15cff1026a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11266,7 +11266,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