Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7845575rwp; Wed, 19 Jul 2023 00:50:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFuSSbIBxYjSVtfEI4Lp5044JJ5wf1JqZXlO+2hvHdglHw1HSltpoxCzt3SvGbevstSU6ry X-Received: by 2002:a05:6402:3596:b0:521:ae30:787d with SMTP id y22-20020a056402359600b00521ae30787dmr1412727edc.21.1689753003400; Wed, 19 Jul 2023 00:50:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689753003; cv=pass; d=google.com; s=arc-20160816; b=ay59koJDgINiLGS+b285ktgYCOkm1OSvrnH7/dkyPHIccYYCHLE3B7bGdiFdENfVzB 6xtVRTiZt2hizBdbZO/awsoLlp999aSai+5kR8orWVDmK2Yc1rNjXwftWe8JdFGIC0i1 7+GdG5rE0pT03qtjZgzyjrng9X8lSPMWW5q87wcOM0UjgAxdOOfSplwsNYYoVtl64TOI p+g726QSzlsacSCr7oca7aiTvss6t9C4Eu6lSgqyx/USEBA7GFd1Nz65oZ+5WjhTz9F6 vBwPkUx6NUdopW3tj4Cc52lBkLaJmkSkOpW2Xv3P2rTlpjvkAvj/HU5m8DTsS/w4XJNt wY+w== 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=rHllduRS8RM2SMjQ7dYTR0VtJnjzjQjAXWlYgoyvR4s=; fh=WCp9vy/Wy93dRpM94C0sfZ1CqkhlXLYzsJU+TbDGxm0=; b=C2p76thruUlPPefoLpHxPck7/sLfEYZW6CiShrck26U7l4hdhg1HKTLZRrIt6OE6/c A0RP8RIh7bqufosQyWs3kuDIFimMlHOs6/YfkNacMamUDxDPxxSb5Uv04ct7TYg4PSys RoBlrKMotCuYgKIlI5RyqI8ScucHYU99uHvPXjsFfzvdK9i3ZomNaA0t56c481jTn4+r 17dEQkwckZD6fnoz6ivp3m0jHURJ+M67lYH1Xtb5NNL172URTNrZRsIqsErDDyrOQSG7 ajoS72TnxGF78LbH4V3ez+kd/bE2PedVdvjQwl+N08Q8WxRVwHP5AkGb7EwoCCQT6Zb0 4TjQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=05VGt52n; 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 x12-20020aa7cd8c000000b0051e3cb37258si2553891edv.178.2023.07.19.00.49.38; Wed, 19 Jul 2023 00:50:03 -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=05VGt52n; 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 S229517AbjGSHic (ORCPT + 99 others); Wed, 19 Jul 2023 03:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjGSHia (ORCPT ); Wed, 19 Jul 2023 03:38:30 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2089.outbound.protection.outlook.com [40.107.100.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B555AE47; Wed, 19 Jul 2023 00:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ATr6MPU/6cU9P2Il045Lp3uB+JgEXkmcHEXyeHZaXDDLrKJxOp3trUYGpmrukWsnA3hmhcRn8wNgvTRxrXX9nuPIfn6R9xY4jkausGrom4ECJd9RwiMZkksyYQOjsXXZicZET6EzyOKfrc565uipKKO7h6b0hkrHCxeu3eq7ckOM5qYNkaf16T9zBE8OTuEtm8WN5m2kHQzhdI3F4Mv9qIUgITKo9p0C6IfnRstDEv0+ouu+k2OT+xHXTKCAW2mTUHFUjy9ZOcuNVZXxqbD37GqFWS7bzMFF3pFU+3CzLhiZ5T7c9xBREJFSMGR+HBx/Jz/mXotYPkwW1B+FyV8A+A== 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=rHllduRS8RM2SMjQ7dYTR0VtJnjzjQjAXWlYgoyvR4s=; b=ZscU3xp5vmt7hn+GPiYCZYOkzit+jImPMJN0IvIejgx8PAYvpz1XKtCCYNmL+3ydmDeG+iIatT4dxDH6QrdxvWhZsIJeqoljkgV8zqkWCDo8f3hafKTVn6nUcGLz4kM2604iH2bdKHRjF6fCPfuRoLisOXoxL5/ESyqAyHhs4pjUXGPtZXLgsGANpODY9InGZgcROFVWazrg/w+n93Id7JZKjzLqk6kp7sG33LFi5ac1tfn8iDsogKeK+2EwiPpkonP7UizyyANNQExkbDz6whLfvzcAuff+03AFX9lEnSQSLecwFb/fTK2WFjuuFFjzbdhlNjZaYKwmGWHGJyKoyA== 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=rHllduRS8RM2SMjQ7dYTR0VtJnjzjQjAXWlYgoyvR4s=; b=05VGt52nvRdJHus0iCHS/FUl9RMfNyum+VkS7ZmWabVoe7EwYqW2rdL9ClaClo4qumHROxFxOxkD00zOdivBKfOtBjE/Ukx75NxcRc2RAhgPONUyzVAwsmKU7r0u4CDmDJ60b+v5+cUDPH4xIsglAxByZUARmGHCJBxjs/RmDFA= 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 PH7PR12MB7018.namprd12.prod.outlook.com (2603:10b6:510:1b8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 07:38:26 +0000 Received: from PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::f535:4eb5:f7a0:ebac]) by PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::f535:4eb5:f7a0:ebac%5]) with mapi id 15.20.6588.031; Wed, 19 Jul 2023 07:38:26 +0000 Message-ID: <0ec93276-e97a-0a66-fe86-4f355cf1d411@amd.com> Date: Wed, 19 Jul 2023 13:07:59 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/6] x86/cpuid: Add smp helper Content-Language: en-US To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, x86@kernel.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, eranian@google.com, ananth.narayan@amd.com, ravi.bangoria@amd.com, santosh.shukla@amd.com References: <827723d8f506411700c68bccc5072ec8d918d2de.1689748843.git.sandipan.das@amd.com> <20230719072850.GA3529734@hirez.programming.kicks-ass.net> From: Sandipan Das In-Reply-To: <20230719072850.GA3529734@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN2PR01CA0206.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:e9::17) To PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5712:EE_|PH7PR12MB7018:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e719ed0-c505-4498-d054-08db882b17a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nq91q77yBs0XmZABGSf4gtpy9VKr9dcF7CcOtohqegx9FMOHXC/6FJQ94h1sZtIVMBFfh1kdKAJj1JcSvxkxV6c26CO7uQTuYAtW4Cth9YRMuxC1JAaHNkmVdiiXce4fFhTQbWXIofDyo2b5SzoAa7/ETJAJfDJOV3B1NAioyeXosKc4b9+hkZ6GfO8qL1rvGqd+9RKaEOWE/u5gYMxxw53q3GzhO9VQrtIVidD1TgyWQpKGvnTCaVrVo9JlvGyGye2XU54fuLkTipTe6H8dfILnViX09c+PssBLS51OOqX/vTwZLWw0uvVRWqAn5LMeh5GVJcmk5YtHYpTcRc1LTN6j+YbwsUbiCZg3Z89lHFYZTz/r8kztOMJPS3J7cHaxpUjQWSUpbSgWJ3ghep7X6ChWPWY8lC5bISxjMVCbumfciMVVt04Env9QzvjFvNz3oaoP2NBLtTQAXHioaaVUHQvf7lZcTabhVEdW30BRBRM4S5q2QwkwZtpKx2p+G679AzmE/1xOIRCPYJljpR2ur9wVvof9rzYq9udeTmCuEG4ei1WANNhgwaoaprE85evzyeDRrbVhzZ78qWzKRZno1b+SLLxC93GUIVG3+HWbeCHed4KKYdNS8cfw32k/eqWBFkcYSSbP5Jz5j5TFynUEyQ== 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:(13230028)(4636009)(136003)(376002)(346002)(366004)(39860400002)(396003)(451199021)(86362001)(2616005)(31686004)(36756003)(316002)(6916009)(4326008)(31696002)(6486002)(6512007)(6666004)(38100700002)(6506007)(53546011)(186003)(26005)(478600001)(2906002)(66476007)(5660300002)(66556008)(66946007)(8936002)(7416002)(8676002)(44832011)(41300700001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bXpDYWNORXZBK2pxWG4ycGw0K2xWQk50RENBS1RtcnZNSEtEKzdTbk1CenZC?= =?utf-8?B?QUgxQUh2ZGNyQm13YlpWWTN3a2FQS21LTkpoblRRTGhJOUFkWVJoVHZOckla?= =?utf-8?B?WDJYRDdPaFc5V3RtV3ZYUllneXlnVDYwaU5jM0o1L0RDYjNiMkZaLzZQQjFs?= =?utf-8?B?ZnkzNk1Wc3pKYUNjRzZrZ0xhZElucjBjWVIzb21RcDRxenJsaTNFcHJHbmx4?= =?utf-8?B?SVdrOEJSWm9tNkpZYlNFTFJETzdKbDlYK2NtR3d5WG5XbDJlVlFQbnpTakVv?= =?utf-8?B?NCtzbDNzL1VtTDBKNDlqYjhJMXlTRG5tdDR4UU56V2luenFQZmZ0UU5XRGtM?= =?utf-8?B?eGdiZlkvelMyTTlidy9KbmRWYll1Zm1kYUNTMGZaMVJoYXFkTFhQSGZLd0s0?= =?utf-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17a8 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5712.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 07:38:26.0459 (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: IQK11iDOL+MFDXLhRfdsP+FaQzOpSTSgfgUepvbl7Ah2dMSArbBM9NQdRItcigb/x9Ncyh5SXAw1z7753KhVCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7018 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 7/19/2023 12:58 PM, Peter Zijlstra wrote: > On Wed, Jul 19, 2023 at 12:25:38PM +0530, Sandipan Das wrote: >> Depending on which CPU the CPUID instruction is executed, some leaves >> can report different values. There are cases where it may be required >> to know all possible values. >> >> E.g. for AMD Zen 4 processors, the ActiveUmcMask field from leaf >> 0x80000022 ECX, which provides a way to determine the active memory >> controllers, can have different masks on CPUs belonging to different >> sockets as each socket can follow a different DIMM population scheme. >> Each memory channel is assigned a memory controller (UMC) and if no >> DIMMs are attached to a channel, the corresponding memory controller >> is inactive. There are performance monitoring counters exclusive to >> each memory controller which need to be represented under separate >> PMUs. So, it will be necessary to know the active memory controllers >> on each socket during the initialization of the UMC PMUs irrespective >> of where the uncore driver's module init runs. >> >> Add a new helper that executes CPUID on a particular CPU and returns >> the EAX, EBX, ECX and EDX values. >> > > So I hate all this for multiple reasons: > > - the wohle foo_on_cpu() model generally leads to atrocious code that > does multiple IPIs, I've seen rdmsr_on_cpu() followed by > wrmsr_on_cpu() and worse things, just don't do this. > > - The whole CPUID thing is insane; we should read CPUID -- all of it -- > *ONCE* at bringup and thereafter never touch the instruction ever > again. It could be people are already working on patches to this > effect. > > - Different CPUID values for different CPUs is a pain :/ Thanks for the clarification. Will remove this. - Sandipan