Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1453497iob; Fri, 29 Apr 2022 05:47:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym5fCDobR5RYjmFhdffOjOe1sxs5LJadyKRv4FJNkzkyfCwdEvNpmomXFiE7CmV4jF6J7q X-Received: by 2002:a17:90a:d083:b0:1c9:94bb:732d with SMTP id k3-20020a17090ad08300b001c994bb732dmr3796116pju.106.1651236455069; Fri, 29 Apr 2022 05:47:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1651236455; cv=pass; d=google.com; s=arc-20160816; b=wwjO7SMAPhi2CZ40qiUJLSuN92YAJOw3D6vKLPO82hhXwZ9d50lYjp5Za3c+S1/F98 9nRSjJHqxPUKWeRgPzbQeg0STKgIBh9lPw+oKBrwZ5vqC+RILPnIQVaSU1BkLLYid8Ia fogz5jsMf2OGnlRScQyIXngE042E4ifDUC9PI8uUYPZMdqelbxXSVsdIStj+RRWB2oLh GXS5j0A/9nc4SrG69BWwct5Y8S8e7m9JjrfwWf3NWwC6kcXyB73JjRXKINZz8GxqbpPn 47JshtQBtsVOqeK5SgoXUzE6ewptws0jGKOWmqFiMx+VsXbMrzQ5rFRCrYAwypTVtwTR BuoA== 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=MHyjmv6EmE/QTAvmeEyXrOh4NqTSariZbbI0t5FQLx8=; b=kK8coAeButFk3e0HshAbxG9nofXLTwqMaxtA3LrfT9mVN4Cw0yfu9H1saw6oOkCioO zXnMEF0ZszYq+wQIzL2a5PD7hyadhcSWYPyb9ElZkiemye9pa2F1lIZKXJprNFtqloHV xnTDJSsR3IeKDQTxzko5nTH9fa1y2E8RJ3vnZOR/uqvlNbdL2X4NB1QKq4NjPxy4cbTC QRn6RkkBhLULF99noNGU4YUBtU6bshxRBJqNQpvGwfK0XUXXmP4BjaZ739oUTMwF8Q7p aJr/FkzXYPb9InMNoeMTYB6ENEmZmTlUdZvW1JhzLVd/knTIE+EfmAK0nEhyvo1idjIr p2rw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="AS0fZD/h"; 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 h191-20020a6383c8000000b003ab187113c3si7089578pge.115.2022.04.29.05.47.16; Fri, 29 Apr 2022 05:47:35 -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="AS0fZD/h"; 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 S238190AbiD2FOU (ORCPT + 99 others); Fri, 29 Apr 2022 01:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237670AbiD2FOO (ORCPT ); Fri, 29 Apr 2022 01:14:14 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2077.outbound.protection.outlook.com [40.107.212.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4156714006; Thu, 28 Apr 2022 22:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MJXGe9MDJijwnX7yML7UWoAbCUVtLbBmspJUZBev3LtOrgKReSMpPVR/yQ16Tnrb4zeauUDen6RabatGXbFKvjaV1az4c5ueJ+Qh07mAqUQpy2vISaPIBOqw+yLOaQ4Zj6gFa7HL3wIavPaXfOiZCjTZFFjLWhkH36YW5Y++pmXioSn1/9v4xZDoTjEw/uy3vhaUc34KxvSStB321KFCRb6Htkz+p964wFeQAghwYqwsbqeq3zG9X25Yx7TLC5WcWcFjszJMwZdSw3+lvaWDvaEl8aCpKdyni2PbJFkTNsMp5UY8x0adrxnYSudl/OPv5WYpqV7oj37SGmuHglh0cg== 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=MHyjmv6EmE/QTAvmeEyXrOh4NqTSariZbbI0t5FQLx8=; b=MMsvYlctWgO+Z9HxcfVQ5n1QDYZSezfd6acWD8PyIhVtjBsWQ8PD/WWcqvgb1a+49LeHKNRMk/wPD0RyjzDzkJFfWwReeypRdN01pmyoz43Ug/jYmaL+Ova/bp9rJuOxaVN6GbC7r798Hk3ecKRrI7yP2VM92bi2Nwl5aHgTJqIOIxnZS+hRXZcxhFjKBGSR3XYzqiTV63Cy6n5GGkmn9NnAMh9ovaWO3QVVOPTvGaxil3XByqnK/lifs0fbF6JT9AeGE1ySaQtpU2DvFX2C3L5tr41zo+6Tjr6/mL3LQPM4ec4E+qzXPKq0N1c+RBTlUOQFsj62nCAAnb66/uEdTA== 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=MHyjmv6EmE/QTAvmeEyXrOh4NqTSariZbbI0t5FQLx8=; b=AS0fZD/hlW4qz2aWtVLAO+S8VwOZWVAC7YxktfeisAOaxoU35omx7RwdRvgBWXguXgK/CyhPz2qobuKqKs5NWRjnEEkqf7pvXr6VTi3L99KpxQ34E9mvR67vUkEqu1PaE/1Tdse7jbmPz4o2MSFZclGAmaHIrEIYtu4NZj1gGSk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN6PR1201MB0178.namprd12.prod.outlook.com (2603:10b6:405:55::20) by SN1PR12MB2527.namprd12.prod.outlook.com (2603:10b6:802:23::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Fri, 29 Apr 2022 05:10:54 +0000 Received: from BN6PR1201MB0178.namprd12.prod.outlook.com ([fe80::ed22:dd57:358b:9fb0]) by BN6PR1201MB0178.namprd12.prod.outlook.com ([fe80::ed22:dd57:358b:9fb0%10]) with mapi id 15.20.5206.013; Fri, 29 Apr 2022 05:10:54 +0000 Message-ID: <3f799406-25f0-3105-250b-dfc68cac263f@amd.com> Date: Fri, 29 Apr 2022 10:40:39 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v4 6/7] perf/x86/amd/core: Add PerfMonV2 overflow handling Content-Language: en-US To: Like Xu Cc: peterz@infradead.org, 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: <6bb3a6de79afbdb1ebc1b804fb8c2002c00cbaee.1651058600.git.sandipan.das@amd.com> <5c227ef8-72d2-9254-f061-128974a6dc7d@gmail.com> From: Sandipan Das In-Reply-To: <5c227ef8-72d2-9254-f061-128974a6dc7d@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN3PR01CA0022.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:97::23) To BN6PR1201MB0178.namprd12.prod.outlook.com (2603:10b6:405:55::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25dc7eea-d5f7-45e6-44a6-08da299ea2ae X-MS-TrafficTypeDiagnostic: SN1PR12MB2527: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: BkrG1JL9dCkVISmdtZw+1tUvl0Nn39ySPJazt8TVVNPAZYY9W0dVDYFs5aIe6TI1KZ6WWvR3mlPei+GwcjebOsfjUO/U+GdjP9vnaUl3ETUOhgKNJmG+WsvBKKX3e1BOGudxjF2qwYcCnAR2AiT6zmeNxceJI4bEkX4idrbetIQQCioxWfPeIj6tuifLLLchJfeuvZw1tGRr07aCZMGjGuzH+TTdBUEuZYsEZJnT9/WEHIwC6Z06gQrN74AoZY15f5BrS4szDbzP9wqQaCpCtKGV26KkB+9Lu5tyeHfdAPdrOw/wrCSkvXDiSEawQEFOkQCLCuHVkdY4dSrlOFRT/48fBrwLUd1sqIxhkNUKw3M7TXvufq8A8a6ckDZqsecEoO4JZmCuzmMI93SGcYCarK/ITP4/jICYxgom2t+yfINKdEdciaack3sKEQnkEAES3Vg0v6EpNPSMTOpei7HU4o17y6ygTL/HTFP9p98feuBIE+LD2vUTdBmZbOy2l1nrbL8RagI1DCtSpqoTs3ViE9/W/TW5S3webm/rk4ftq9eCZxQGPLB7FJP4jJ6lsvBeSU4KksGLph5Sf46ehy48hgcfElQyoTO42NpoQZ+nG9P/nEJHGi23MWbm4mbZTfbfsIyNNCA/BPkv4MGTAnco6DgfM/WxbrgNWTfwef2v1Sgn49BFBl1Nm4r8GiFgFbARldl+79vWp7G0NK1tuk5Mo6tBqzvA9HcyOmJJ/2jsb2Y= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR1201MB0178.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(2906002)(83380400001)(316002)(31686004)(31696002)(86362001)(6506007)(26005)(6512007)(4326008)(38100700002)(6666004)(53546011)(66476007)(66556008)(6916009)(8676002)(66946007)(36756003)(5660300002)(6486002)(2616005)(186003)(44832011)(4744005)(7416002)(8936002)(508600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?STh2S0VObTNwdTYxU1VnQ2VCRFd0QWZCWU9nYXY2WEhFU3VkTnpaelUwcHJ3?= =?utf-8?B?SHZRdERqdVFhMmc3NFRQc1dTUjRHYVhSZld6YjhaYnRyZ1EyU1pKMlBCcm53?= =?utf-8?B?bDJXUWJDUXdsK0pEc2FQOTZtOS8wajU1bUlHMWVsdE91dHZPRmRCWG90bWxT?= =?utf-8?B?TWNzOW9mT1BtNXFRZ3dTRVJxLzNKaWp4dzFYODlDZTVSWHJIT3g4S3N1N3lE?= =?utf-8?B?Qk85cWRWZ01TeGhuSVVJRWlvYm5VMnhzVUo1KysvRVJDQkpwNEVjTzJLVFpv?= =?utf-8?B?dmJqYVJX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Uk9FVWRV?= =?utf-8?B?NFUzaWhqcDFoSXVFMWN6TUxwbjZlOEJ0QUFmTUtCZS9seUFXM0p2T05Ia2JN?= =?utf-8?B?S01iOGF3MFNSQ3V4U1kyYUVvS1ZlZC9ZZlJPWDBwVTFxOUU3UzNFeGpkcHE0?= =?utf-8?B?OXl5d2hqOXRmbWg1cjREZTR1UkJER2Nmd3I0S29JelBKd3RJV1FzdkswRTl6?= =?utf-8?B?NFBEa3JDVHh5VXRMNzZSdThUTHlKOHh4THdtZ0NPdUFJbERnc1M2QT09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25dc7eea-d5f7-45e6-44a6-08da299ea2ae X-MS-Exchange-CrossTenant-AuthSource: BN6PR1201MB0178.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2022 05:10:54.1310 (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: 69PVVXFUI3q5MWJdd/mpkp5uk+zG/m37ohKgeGUdgTdaq5p+iZ29nO540QhFtI9zSpVJEY0YZRMOTnhQMUV/PQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2527 X-Spam-Status: No, score=-2.1 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 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 On 4/28/2022 7:10 PM, Like Xu wrote: > On 27/4/2022 7:31 pm, Sandipan Das wrote: >> +static inline void amd_pmu_ack_global_status(u64 status) >> +{ >> +    /* >> +     * PerfCntrGlobalStatus is read-only but an overflow acknowledgment > > If wrmsrl PerfCntrGlobalStatus, remain silent or report #GP ? > This is a read-only MSR and writes are silently ignored. >> +     * mechanism exists; writing 1 to a bit in PerfCntrGlobalStatusClr >> +     * clears the same bit in PerfCntrGlobalStatus >> +     */ >> + >> +    /* Only allow modifications to PerfCntrGlobalStatus.PerfCntrOvfl */ >> +    status &= amd_pmu_global_cntr_mask; >> +    wrmsrl(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR, status); > > If rdmsrl PerfCntrGlobalStatusClr, does it return 0 or the value of PerfCntrGlobalStatus ? > This is a write-only MSR and reads are undefined. The "Field Access Type" section from the AMD Processor Programming Reference (PPR) has these details. - Sandipan