[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <449bd407-0f54-47dc-bb3c-034e92a5145b@zytor.com>
Date: Wed, 12 Feb 2025 00:33:06 -0800
From: Xin Li <xin@...or.com>
To: babu.moger@....com, Reinette Chatre <reinette.chatre@...el.com>,
corbet@....net, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, tony.luck@...el.com,
peternewman@...gle.com
Cc: x86@...nel.org, hpa@...or.com, paulmck@...nel.org,
akpm@...ux-foundation.org, thuth@...hat.com, rostedt@...dmis.org,
xiongwei.song@...driver.com, pawan.kumar.gupta@...ux.intel.com,
daniel.sneddon@...ux.intel.com, jpoimboe@...nel.org,
perry.yuan@....com, sandipan.das@....com, kai.huang@...el.com,
xiaoyao.li@...el.com, seanjc@...gle.com, xin3.li@...el.com,
andrew.cooper3@...rix.com, ebiggers@...gle.com,
mario.limonciello@....com, james.morse@....com,
tan.shaopeng@...itsu.com, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, maciej.wieczor-retman@...el.com,
eranian@...gle.com
Subject: Re: [PATCH v11 10/23] x86/resctrl: Remove MSR reading of event
configuration value
On 2/11/2025 11:44 AM, Moger, Babu wrote:
> Hi Xin,
>
> On 2/7/25 04:07, Xin Li wrote:
>> On 2/6/2025 8:17 AM, Reinette Chatre wrote:
>>>>> + wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0);
>>>> This is the existing code, however it would be better to use wrmsrl()
>>>> when the higher 32-bit are all 0s:
>>>>
>>>> wrmsrl(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config);
>>>>
>>> Could you please elaborate what makes this change better?
>>
>> In short, it takes one less argument, and doesn't pass an argument of 0.
>>
>> The longer story is that hpa and I are refactoring the MSR access APIs
>> to accommodate the immediate form of MSR access instructions. And we
>> are not happy about that there are too many MSR access APIs and their
>> uses are *random*. The native wrmsr() and wrmsrl() are essentially the
>> same and the only difference is that wrmsr() passes a 64-bit value to be
>> written into a MSR in *2* u32 arguments. But we already have struct msr
>> defined in asm/shared/msr.h as:
>> struct msr {
>> union {
>> struct {
>> u32 l;
>> u32 h;
>> };
>> u64 q;
>> };
>> };
>>
>> it's more natural to do the same job with this data structure in most
>> cases. And we want to remove wrmsr() and only keep wrmsrl(), thus a
>> developer won't have to figure out which one is better to use :-P.
>>
>> For that to happen, one cleanup is to replace wrmsr(msr, low, 0) with
>> wrmsrl(msr, low) (low is automatically converted to u64 from u32).
>>
>> However, I'm fine if Babu wants to keep it as-is.
>
> Thanks for the explanation. Changed it to use wrmsrl().
>
You're welcome. And thanks for making the change.
Powered by blists - more mailing lists