Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5757765iob; Tue, 10 May 2022 03:02:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztMIt6uY7nedTu1N+mZP3y9QabMGQ0RO1jRlBs5x0gNTgIdak3WU0MTJCOjc5JS1BgVesw X-Received: by 2002:a05:6638:1207:b0:32b:7c4e:4088 with SMTP id n7-20020a056638120700b0032b7c4e4088mr9170954jas.122.1652176941701; Tue, 10 May 2022 03:02:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652176941; cv=pass; d=google.com; s=arc-20160816; b=umbfi+OeRDQNHcuJAalmjHoibXAcUVkwRZ4HBKtDh0QKYjvz+ilT6rN4uWhjsCG86H OcpXMsUk6q9E/1WrNTJMoq/wPAiBASBIduUtZwzvpbwn715LU2PGFIera5sPu1r0wcIA oCJ4LWbASuHDjycKkE93sU4KVB3gCg+YU+ZUiaMF8G4yMMeYxPy+3VOAMiJWTnX6tyUH 7c+MD1Y48zLpSmhl7j82N4WrvVGWW25K2FKRT5lBpPNKlKXMix5ffxvtYtuq06pHPAqe EM3R6+ta50aY1ji6CNB+uVUPYqYD0EsfOAIYs0LS9c96svMk09+1Y/WEYDKqtgBNxEgZ Ri5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=lmxUCVVBFAlPe2H3bATYdkx73UKJsZ08UyNfqHTfBMI=; b=eiu8waJPW+t3ZFEulcRd1YFkmGEeP7qBTHCLv6j04z26ilBHBvTu8B+iWdjri2Y2LU ek3LwF1kIZLlDys6p9r86KOAkitmEnM33YK+9aPT6g1SZpW6xv/fBw+qpfE5uwSQjYr7 5F6E2U7yReWTPpWMDaYvS2etSrlbvUv0eawPMyLyoKyyj00f18tXtoL4QIzQObVJPtVs CtxRyCOMOD2IoPUFAUHbf8YLSRJk5OyS6jm1FYWRZJ5PDpW1RP3okaJocIVqTwJLifq5 VyLU9+7BvaBoPXgt8aLzl9pcwMm0gYUXs7njyjoWUF2qXF1WdVyZPea0b476yM4orrED uYrA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=flRuDicy; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a056e021a4b00b002cbcb15fb98si12003164ilv.127.2022.05.10.03.02.06; Tue, 10 May 2022 03:02:21 -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=@amd.com header.s=selector1 header.b=flRuDicy; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238057AbiEJIk4 (ORCPT + 99 others); Tue, 10 May 2022 04:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbiEJIkx (ORCPT ); Tue, 10 May 2022 04:40:53 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2076.outbound.protection.outlook.com [40.107.212.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E45B22DA32; Tue, 10 May 2022 01:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tou4MJ34YX+DNHOBOsGVTXpDmk4PFIdQGoqdDMSnGpwpQA2BL4Ng5Lrhm+6ByOW9+hhkDhSXvzIhJgHphEpvR90foUxbTjdICPeBh4e65P9M5Ww8c/CXMj/N49Rzm3bmlMLSWxm1Tb5V9OzVepCw/l2zctd9fTCq8a96AnPktxhr0b+edlvyQjc2yBIpVFh7zwhwzGEZeCmAT8OM7CNyqf/2yc5Gw4lvuGsDiXIneXtg3ET8KDuzRZ+544XEAvU/JOYHqjKT/RrfqIAKPvFQOq2gQ0fwWoWcZwf+6DCINtJUrSHKx1+yxO5aBW/xeHpqlMR/+zn1r1XjiRp/St5VlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lmxUCVVBFAlPe2H3bATYdkx73UKJsZ08UyNfqHTfBMI=; b=TrPirl8PqROC0NL2TC0xPU1ZJCabCnlkT1TQUAlF4coWW9T/5K2+ozrGclUTB5Nmm/zLLCEioHNCdoT++fiBTn/g4rjijwV6nwd0gUgXkOY0b/iJms2PfTEap7oG2paKprTa//vJfYUQjEhs7Op+FEUz2NU9aLvWbJoworSRLoTHSOz1pTLLSLAMAiOWwMsyqDQUiW51RtHpENRED2oJ/CgOjIEHOl100o4Hb6HXGGwK9SgeYhma5HKJ3+SuGSomnj59zQBZ9Cjljfq/8DYC+mixX1ACMw3comMWNxQO82uufMVpEKwhBmcpOAspOI5535+yCvjEtZldmy2fVdG9lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lmxUCVVBFAlPe2H3bATYdkx73UKJsZ08UyNfqHTfBMI=; b=flRuDicy3oRHKyzLugRtj4MqmKjlWr6slfyBMfJfW7rcPV7190BbMCgrg6I3yCqzGUaxv94u8m8eG20NwOV/pTyJ8oe4jEOGoSYuKy5Qouax6J3Xa3PVgJKC1Z9fkK5vmULy1unp2HFEX5UKe3dkIRMeLKB917eJdoOFGVUDTPQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) by DM6PR12MB4140.namprd12.prod.outlook.com (2603:10b6:5:221::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Tue, 10 May 2022 08:36:50 +0000 Received: from PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::8d3b:6561:8563:4f1b]) by PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::8d3b:6561:8563:4f1b%9]) with mapi id 15.20.5227.023; Tue, 10 May 2022 08:36:50 +0000 Message-ID: <29103c7d-8108-cce8-8369-496a08c5c6d8@amd.com> Date: Tue, 10 May 2022 14:06:35 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 3/7] perf/x86/amd/core: Detect PerfMonV2 support Content-Language: en-US To: Peter Zijlstra Cc: Like Xu , bp@alien8.de, dave.hansen@linux.intel.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, jolsa@kernel.org, tglx@linutronix.de, mingo@redhat.com, pbonzini@redhat.com, jmattson@google.com, eranian@google.com, puwen@hygon.cn, ananth.narayan@amd.com, ravi.bangoria@amd.com, santosh.shukla@amd.com, "linux-kernel@vger.kernel.org" , linux-perf-users@vger.kernel.org, x86@kernel.org References: <8d3e23760726cf6647a98999e1fcd12a37f36a42.1651058600.git.sandipan.das@amd.com> <78e001bd-42bd-5481-5a19-1a0bcca9a63c@gmail.com> <96e41431-eb80-f61d-9ab9-c76cd9b6086a@amd.com> From: Sandipan Das In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN3PR01CA0103.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:9b::15) To PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb839330-c71a-43d3-ed4b-08da32603a1a X-MS-TrafficTypeDiagnostic: DM6PR12MB4140:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7FfK6SJXIvZOJZhklWgiNtmAg+31etvASHUDOdjMi+wg0mJNbSmwkgXdkovjIO7iv0GaQvxfomXPU+r9qMH/2eE9hu1QqcPWwEAcJKK0L//KCOvycHVI6fbLoE1exsYbz7xwSTeqm3Js9CzRa22ZNR6rV3QR1oDsrjFUc5yTRfh1o/XGu3gChDpTQpAtejeyhHep1RexQIFhzqHuE1idnCirqN6/F9RaqBcqdbug7IpKs952XKTJ6nrpixyG/8q1xDjCX+jZVj8jn6m9hBG7+qjrZLHXJhmgl6Av3pcDTGDbrucTDsFSTf1PJJ3ALcaydZ2UtFMolHp9vxr4Yjgqtr796pVq4oLJ1Sf1iKROcdaGB4ypUhbyqFY5dmlLrve8ORAQi3bBro5I/VhcpkXNYsX5fuRD/zpwbodn0vmxjbwVl3wFEtCel5NbTbmz0tZXn2zqA2yb8yywakwyGOzG7lZhbku51BZkGnsMleK78AdjWhX2z6RYjUeFORQRyK1A/Shv26d3s+Y40XFADKcwZsFSOcwBqBEF+ocyJw+JZ/LloAO2rU3v9fuD/npopEZNKnT+11a/5UiAd5+nGNctx+Q7OTzihqAPC8gKn+wlunGAULFHDYIxGCNO/u73B97yiSCvUFkZzbmhVyKRu/391Rw1ycStx87iGokLHCgsQrFpcOoL5r2QLYabXBt67Fb/zxAwKXcHuOsiVJSyNWkRkDY+ND9oymoi+z226qM+Bws= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB5712.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6666004)(36756003)(316002)(54906003)(6916009)(2616005)(31686004)(186003)(83380400001)(4326008)(8676002)(6506007)(66946007)(8936002)(31696002)(26005)(66556008)(6512007)(66476007)(38100700002)(53546011)(508600001)(2906002)(7416002)(44832011)(6486002)(5660300002)(86362001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z2x5VEwvQmVRQzNUckNmU3crZDRnSnpadUd1QkY1a09XVXg2Q3pzVWlwNlkv?= =?utf-8?B?ZHN6NWRXRTQ1dDB0WXBMMVFETHE2eURPRHIzd1Z5SzN6N2xVaHVaRUpIZGRi?= =?utf-8?B?OTRmanpsd3dUaHBQRGJPK0VSKzFIY25pMm5sZENuNEJOSjRxMDd5K0wwMmVY?= =?utf-8?B?RHVSRlZzVjFRWnFjT0FLTkhkbnhVaFBBb3ZHYzdlWFljWjg4WUtKN2RKQTZn?= =?utf-8?B?ZkxrS3NjTUEvMlJjR1ZxMHc5RzVhYWpFN2VrT3hDb09tTjVPWTVISkZiSTgr?= =?utf-8?B?WHU1RVZrSWtaelYzWUN3T0hITE84alJWc21NN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?= =?utf-8?B?WVdUOHB6MTUzY3kvRzliMUFmVHlVSXFGRzJzVjVBOGNWUkNVWUV0ZmpyVm5o?= =?utf-8?B?dnFXc0hjWGRwN0gzV044cCs2VTc4aHVvOWJBVWhEVE4yZkk1Wnl0TUQzNVd2?= =?utf-8?B?SVpud3haMEQ0WitDS0NOZm5hcHZsMGs2TUxZVVdyUndsY1M3a2xlNmdGdFpk?= =?utf-8?B?OTl3Ym5tQ3pYcEVWNHpXZ2ltazFNVWFBekJhT1I1SUQvOFRrWkdvdz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb839330-c71a-43d3-ed4b-08da32603a1a X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5712.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2022 08:36:50.3188 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SEDNk/mpwTP1gcyumDq7kEmuYWuhR+z+CI1ASEPNDECfnxnsOQ+oKfj0o4Ae186np9RhrkTQqPI1yvHWM3JiRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4140 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Hi Peter, On 5/9/2022 6:41 PM, Peter Zijlstra wrote: > On Mon, May 09, 2022 at 06:38:19PM +0530, Sandipan Das wrote: >> >> On 5/9/2022 6:31 PM, Like Xu wrote: >>> On 27/4/2022 7:31 pm, Sandipan Das wrote: >>> >>>>       x86_pmu.num_counters    = AMD64_NUM_COUNTERS_CORE; >>> >>> Thus boot_cpu_has(X86_FEATURE_PERFCTR_CORE) is true. >>> >>>> + >>>> +    /* Check for Performance Monitoring v2 support */ >>>> +    if (boot_cpu_has(X86_FEATURE_PERFMON_V2)) { >>>> +        /* Update PMU version for later usage */ >>>> +        x86_pmu.version = 2; >>> >>> Is it safe to assume that once AMD CPU has the PERFMON_V2 (or further) bit, >>> >>> it must also have the PERFCTR_CORE bit set ? >>> >> >> Yes, always. There won't be a case where PERFCTR_CORE is absent >> but PERFMON_V2 is present. > > Let me introduce you to this dodgy virt stuff :-) Best put a sanity > check on it. I see that amd_core_pmu_init() returns if X86_FEATURE_PERFCTR_CORE is not found right after entry. Is there anywhere else that you feel should have an additional sanity check? I also noticed a bug in the X86_FEATURE_PERFCTR_CORE feature check where it should have returned something like -ENODEV instead of 0. Will send out a fix for it. - Sandipan