Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2909575iog; Mon, 27 Jun 2022 05:34:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZ9732LeGMKQtxjBhXynGN6EOW4Z5m1l0g5w0npGcZcaipDKAo9wG09XB9FO7aV6KZPJVQ X-Received: by 2002:a17:907:3f9d:b0:726:31d9:c872 with SMTP id hr29-20020a1709073f9d00b0072631d9c872mr12418909ejc.524.1656333255848; Mon, 27 Jun 2022 05:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333255; cv=none; d=google.com; s=arc-20160816; b=VCXSnH0M6FfDnmQF9Gw3TsK6KUX0deUDlsSugl7/4rgtE45JivvCUMPp9vEDie7kxL lxdQroXkvsgPtXbdVBTF/+hknxi7ps96uoVTCFnjfwzLagD0IgNFvISC8Z6a25TlNAFA wpr09mh/en+mknthhHirmqNq0+9QmBufKqcNgNr73McVMueDbhSYea9aMSNSfmxjBM5x AZHBGMd36LO59/zjxPo0RH8V9KhlS1eUkGvHPSGo/hKIRxJiEoLRZVSt3Yc7XbKh0TRR KxwGXF4MiTEsAVOX7eKYf7n6bOVwviv9ORPmbMJrF6DFRc6Y4BE5QN8j/8M5ve5hsxBA 9Xiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=09jNkOMQrfOHnQJtKpMVz0Baa1CGSowDEdDgD+fiaLU=; b=qKvDFHYbqZx3bigsM39eDF7/5AsXAY/K5wrxXnvTyTvLqeoeYkZXNRgYdc6W/tr1MH ivnakhK6p61vr2mMTWCDpYM5yUqyAeWZjGZGerot1Na0LXJfXwDQk36cfa7eu66OILOS YyZkF8S9NxDkUbsCgseWMDD6sKLJG7safzqwbr9lYEo+CY4cqsQXCrz7LXPer2RyqPRS K18OxHB+60wn24FW5ZJlqLsdMoBxkstrLQmo9q4FnfzIBW7PS6cGCirZflFcuvz/qftf AlopVfndqcwaer3++ExD7OvtuoWvrbB/qHp3qRuTVvdZ6jFtNu8UhWoxhLsUzanH0F5B 01kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lYEsFFs2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a17090655d600b00710939b43a6si11532813ejp.69.2022.06.27.05.33.50; Mon, 27 Jun 2022 05:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lYEsFFs2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbiF0L0n (ORCPT + 99 others); Mon, 27 Jun 2022 07:26:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234825AbiF0LZu (ORCPT ); Mon, 27 Jun 2022 07:25:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C2765A8; Mon, 27 Jun 2022 04:25:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D47D261366; Mon, 27 Jun 2022 11:25:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC98EC3411D; Mon, 27 Jun 2022 11:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329136; bh=Dr1tPwRBXZXzKH51dcRtoXnJy+WZCNIc6xKbvhjml14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lYEsFFs2zVn54Z7j0IzRtu8Cl0reglfnE/9w9s7gHJDdbzzlOdY3jExmoQIiozx1v iQL4PGa+ebnLlP4fAc3I4cmAlL5PZhuZ6N8x+V1R7N/n1+CQ1L1PpbpIX2FkLHwFrJ SiwKQ1ftSpcBWtMnE/1r47O7N5/AYUMGEzKM5LGI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Sumanth Korikkar , Alexander Gordeev , Sasha Levin Subject: [PATCH 5.10 062/102] s390/cpumf: Handle events cycles and instructions identical Date: Mon, 27 Jun 2022 13:21:13 +0200 Message-Id: <20220627111935.311225486@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Richter [ Upstream commit be857b7f77d130dbbd47c91fc35198b040f35865 ] Events CPU_CYCLES and INSTRUCTIONS can be submitted with two different perf_event attribute::type values: - PERF_TYPE_HARDWARE: when invoked via perf tool predefined events name cycles or cpu-cycles or instructions. - pmu->type: when invoked via perf tool event name cpu_cf/CPU_CYLCES/ or cpu_cf/INSTRUCTIONS/. This invocation also selects the PMU to which the event belongs. Handle both type of invocations identical for events CPU_CYLCES and INSTRUCTIONS. They address the same hardware. The result is different when event modifier exclude_kernel is also set. Invocation with event modifier for user space event counting fails. Output before: # perf stat -e cpum_cf/cpu_cycles/u -- true Performance counter stats for 'true': cpum_cf/cpu_cycles/u 0.000761033 seconds time elapsed 0.000076000 seconds user 0.000725000 seconds sys # Output after: # perf stat -e cpum_cf/cpu_cycles/u -- true Performance counter stats for 'true': 349,613 cpum_cf/cpu_cycles/u 0.000844143 seconds time elapsed 0.000079000 seconds user 0.000800000 seconds sys # Fixes: 6a82e23f45fe ("s390/cpumf: Adjust registration of s390 PMU device drivers") Signed-off-by: Thomas Richter Acked-by: Sumanth Korikkar [agordeev@linux.ibm.com corrected commit ID of Fixes commit] Signed-off-by: Alexander Gordeev Signed-off-by: Sasha Levin --- arch/s390/kernel/perf_cpum_cf.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c index 0eb1d1cc53a8..dddb32e53db8 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -292,6 +292,26 @@ static int __hw_perf_event_init(struct perf_event *event, unsigned int type) return err; } +/* Events CPU_CYLCES and INSTRUCTIONS can be submitted with two different + * attribute::type values: + * - PERF_TYPE_HARDWARE: + * - pmu->type: + * Handle both type of invocations identical. They address the same hardware. + * The result is different when event modifiers exclude_kernel and/or + * exclude_user are also set. + */ +static int cpumf_pmu_event_type(struct perf_event *event) +{ + u64 ev = event->attr.config; + + if (cpumf_generic_events_basic[PERF_COUNT_HW_CPU_CYCLES] == ev || + cpumf_generic_events_basic[PERF_COUNT_HW_INSTRUCTIONS] == ev || + cpumf_generic_events_user[PERF_COUNT_HW_CPU_CYCLES] == ev || + cpumf_generic_events_user[PERF_COUNT_HW_INSTRUCTIONS] == ev) + return PERF_TYPE_HARDWARE; + return PERF_TYPE_RAW; +} + static int cpumf_pmu_event_init(struct perf_event *event) { unsigned int type = event->attr.type; @@ -301,7 +321,7 @@ static int cpumf_pmu_event_init(struct perf_event *event) err = __hw_perf_event_init(event, type); else if (event->pmu->type == type) /* Registered as unknown PMU */ - err = __hw_perf_event_init(event, PERF_TYPE_RAW); + err = __hw_perf_event_init(event, cpumf_pmu_event_type(event)); else return -ENOENT; -- 2.35.1