From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AFE4C2BD09 for ; Tue, 9 Jul 2024 17:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=txWFpwGnvOu9QFzJiCC8zu5uRGQCIBjC/kvWz1kKaQA=; b=JivMDgGbBrhM3L GFgLHOPPGCndAdviN3bxS73/8/2nWR7Ol1rKJMByjkStLOLqrEJLgIeN1ahniL3jarhFlAn5f3DpZ b/6FcxDsyABhpIUbkTlJjuMvmdw59So+6G3HPVVmZTlqLZH/KgPthTuKQhc6LWA1tDRraDtfoVEKr wYQReSyqQg+fylpBL8/Fnt8qUtSMGNufvEI4C4NI3U7e6fQi1N8SimPa8pTXXFbBhyoH+7SsyW2W7 w+Ihp1aEhn1hor3tjOdjRVXEeGlV6xXxB0k7Q/MmRbQCFEIPJJ223mIsu9C51psVXV5+sfXoTqa2F /DSpgZ8cEaYhaetXCIWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sREUL-000000089R8-2Uf5; Tue, 09 Jul 2024 17:18:49 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sREU5-000000089Mx-1yN3 for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 17:18:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720545509; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=txWFpwGnvOu9QFzJiCC8zu5uRGQCIBjC/kvWz1kKaQA=; b=IlpkS9TZZjWcG3les+6YJvHZUyrgtqm7Y7+OYSybuM2gyaFN3Co6DAt9J7Iab62wlfPQou hyuYTCjRv6A0l7Mug4ffHJ1rDYQgNIoojoro0UrcJha8PVX7quw88gMfI84eBTIn0ehX8O ib7R0L534E1jbeoghClJn509Wi0SqjA= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-80w1nRLQNTetYEKoYj4Q7A-1; Tue, 09 Jul 2024 13:18:25 -0400 X-MC-Unique: 80w1nRLQNTetYEKoYj4Q7A-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3d62d0a3808so5602485b6e.0 for ; Tue, 09 Jul 2024 10:18:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720545505; x=1721150305; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=txWFpwGnvOu9QFzJiCC8zu5uRGQCIBjC/kvWz1kKaQA=; b=SgVASzuWVNeID97N8U1Dl5y2HGmQ0ZPV2jQE2mqZhWrSlE9agpd/o7JZANFIPc45hE dzFm3kM9gOl7SK/ti4TqWtNRTZM2KLZvqScMOuTWaw9d1cHI4SHr6KQB3cLXDqixs1i8 vzkclpJA0yvMFQnKMg84yQGZlbcttQyGYTfSODe0pX5B0KzOCh3g+7JI1lkGtcf11Jr/ WG82oz5NF9uI1fit/BfnT+j995pAIqY7Nx++DGKAjzydoKLsKtHuz0LO86ocw2FlXipt G1UzG7ABgevX53AnB9aZLBiPTZfX1jVB2wsc2axAjHk4cPMD7QJoRrfpbp8iC3yR7x9t IVog== X-Forwarded-Encrypted: i=1; AJvYcCWBvJjjagqdahOe0bPmfWbQFV+FGxi6UY0xfCOB+fAMvRy0NdqHLprIVDaCF0+XOxpXpArLSONC/texuww7iWxfAq9FQcIUD9ad4zft7YePNkwmHn8= X-Gm-Message-State: AOJu0YzSNJSLnEnz1yDyOG8v254MR2M2DAA9Dr4lvV0kYoYMG+0mXaPg zJtpcj7WlNNNKPxYd9DIYO8rpWNCD/ZhinPC1JnSTMJD1NN9AD+GLxkuENsbvORlcdgtGqa5QKg st2eNM2xbmLusdqrKc0LJSJwJIGa7yhMvhHcrRGJeyhsQ1hDrysKdKV1HIxlEpRNOkPLWyVVA X-Received: by 2002:a05:6808:140c:b0:3d9:2d9c:8aff with SMTP id 5614622812f47-3d93c085d8cmr3345138b6e.45.1720545504678; Tue, 09 Jul 2024 10:18:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCg8hXYGmEjThxs8qicr/EaSUtmrtO5gek2UVhqCZuwkZ1767RBJduAkyXwsp1LLvcYZ+Ylg== X-Received: by 2002:a05:6808:140c:b0:3d9:2d9c:8aff with SMTP id 5614622812f47-3d93c085d8cmr3345103b6e.45.1720545504247; Tue, 09 Jul 2024 10:18:24 -0700 (PDT) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79f1902909asm114532285a.58.2024.07.09.10.18.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jul 2024 10:18:23 -0700 (PDT) Message-ID: Date: Tue, 9 Jul 2024 19:18:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [kvm-unit-tests PATCH v1 1/2] arm/pmu: skip the PMU introspection test if missing To: Alexandru Elisei , =?UTF-8?Q?Alex_Benn=C3=A9e?= Cc: Peter Maydell , pbonzini@redhat.com, drjones@redhat.com, thuth@redhat.com, kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@arm.com, maz@kernel.org, Anders Roxell , Andrew Jones , "open list:ARM" References: <20240702163515.1964784-1-alex.bennee@linaro.org> <20240702163515.1964784-2-alex.bennee@linaro.org> <87ed82slt8.fsf@draig.linaro.org> From: Eric Auger In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_101833_605456_47333BCA X-CRM114-Status: GOOD ( 34.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: eric.auger@redhat.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On 7/9/24 17:05, Alexandru Elisei wrote: > Hi, > > On Tue, Jul 09, 2024 at 03:05:07PM +0100, Alex Bennée wrote: >> Peter Maydell writes: >> >>> On Tue, 9 Jul 2024 at 09:58, Alexandru Elisei wrote: >>>> Hi, >>>> >>>> On Tue, Jul 02, 2024 at 05:35:14PM +0100, Alex Bennée wrote: >>>>> The test for number of events is not a substitute for properly >>>>> checking the feature register. Fix the define and skip if PMUv3 is not >>>>> available on the system. This includes emulator such as QEMU which >>>>> don't implement PMU counters as a matter of policy. >>>>> >>>>> Signed-off-by: Alex Bennée >>>>> Cc: Anders Roxell >>>>> --- >>>>> arm/pmu.c | 7 ++++++- >>>>> 1 file changed, 6 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/arm/pmu.c b/arm/pmu.c >>>>> index 9ff7a301..66163a40 100644 >>>>> --- a/arm/pmu.c >>>>> +++ b/arm/pmu.c >>>>> @@ -200,7 +200,7 @@ static void test_overflow_interrupt(bool overflow_at_64bits) {} >>>>> #define ID_AA64DFR0_PERFMON_MASK 0xf >>>>> >>>>> #define ID_DFR0_PMU_NOTIMPL 0b0000 >>>>> -#define ID_DFR0_PMU_V3 0b0001 >>>>> +#define ID_DFR0_PMU_V3 0b0011 >>>>> #define ID_DFR0_PMU_V3_8_1 0b0100 >>>>> #define ID_DFR0_PMU_V3_8_4 0b0101 >>>>> #define ID_DFR0_PMU_V3_8_5 0b0110 >>>>> @@ -286,6 +286,11 @@ static void test_event_introspection(void) >>>>> return; >>>>> } >>>>> >>>>> + if (pmu.version < ID_DFR0_PMU_V3) { >>>>> + report_skip("PMUv3 extensions not supported, skip ..."); >>>>> + return; >>>>> + } >>>>> + >>>> I don't get this patch - test_event_introspection() is only run on 64bit. On >>>> arm64, if there is a PMU present, that PMU is a PMUv3. A prerequisite to >>>> running any PMU tests is for pmu_probe() to succeed, and pmu_probe() fails if >>>> there is no PMU implemented (PMUVer is either 0, or 0b1111). As a result, if >>>> test_event_introspection() is executed, then a PMUv3 is present. >>>> >>>> When does QEMU advertise FEAT_PMUv3*, but no event counters (other than the cycle >>>> counter)? >> The other option I have is this: >> >> --8<---------------cut here---------------start------------->8--- >> arm/pmu: event-introspection needs icount for TCG >> >> The TCG accelerator will report a PMU (unless explicitly disabled with >> -cpu foo,pmu=off) however not all events are available unless you run >> under icount. Fix this by splitting the test into a kvm and tcg >> version. > As far as I can tell, if test_event_introspection() fails under TCG without > icount then there are two possible explanations for that: > > 1. Not all the events whose presence is checked by test_event_introspection() > are actually required by the architecture. > > 2. TCG without icount is not implementing all the events required by the > architecture. > > If 1, then test_event_introspection() should be fixed. I had a look and the > function looked correct to me (except that the event name is not INST_PREC, > it's INST_SPEC in the Arm DDI0487J.A and K.a, but that's not relevant for > correctness). > > From what I can tell from what Peter and you have said, explanation 2 is the > correct one, because TCG cannot implement all the required events when icount is > not specified. As far as test_event_introspection() is concerned, I consider > this to be the expected behaviour: it fails because the required events are not > implemented. I don't think the function should be changed to work around how > QEMU was invoked. Do you agree? > > If you know that the test will fail without special command line parameters when > accel is TCG, then I think what you are suggesting looks correct to me: the > original test is skipped if KVM is not present, and when run under TCG, the > correct parameters are passed to QEMU. This looks sensible to me too Eric > > Thanks, > Alex > >> Signed-off-by: Alex Bennée >> >> 1 file changed, 8 insertions(+) >> arm/unittests.cfg | 8 ++++++++ >> >> modified arm/unittests.cfg >> @@ -52,8 +52,16 @@ extra_params = -append 'cycle-counter 0' >> file = pmu.flat >> groups = pmu >> arch = arm64 >> +accel = kvm >> extra_params = -append 'pmu-event-introspection' >> >> +[pmu-event-introspection-icount] >> +file = pmu.flat >> +groups = pmu >> +arch = arm64 >> +accel = tcg >> +extra_params = -icount shift=1 -append 'pmu-event-introspection' >> + >> [pmu-event-counter-config] >> file = pmu.flat >> groups = pmu >> --8<---------------cut here---------------end--------------->8--- >> >> which just punts icount on TCG to its own test (note there are commented >> out versions further down the unitests.cfg file) >> >> -- >> Alex Bennée >> Virtualisation Tech Lead @ Linaro