lkml.org 
[lkml]   [2022]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v3 4/6] x86/gsseg: move local_irq_save/restore() into asm_load_gs_index()
Date
> On October 18, 2022 10:25:31 AM PDT, "Li, Xin3" <xin3.li@intel.com> wrote:
> >> > static inline void native_load_gs_index(unsigned int selector) {
> >> > - unsigned long flags;
> >> > -
> >> > - local_irq_save(flags);
> >> > asm_load_gs_index(selector);
> >> > - local_irq_restore(flags);
> >> > }
> >>
> >> static inline void native_load_gs_index(unsigned int selector) {
> >> unsigned long flags;
> >>
> >> if (cpu_feature_enabled(LKGS)) {
> >> native_lkgs(selector);
> >> } else {
> >> local_irq_save(flags);
> >> asm_load_gs_index(selector);
> >> local_irq_restore(flags);
> >> }
> >> }
> >>
> >> For paravirt enabled kernels we want during feature detection:
> >>
> >> if (cpu_feature_enabled(LKGS)))
> >> pv_ops.cpu.load_gs_index = native_lkgs;
> >
> >If we use static_cpu_has in native_load_gs_index
> > if (static_cpu_has(X86_FEATURE_LKGS)) {
> > native_lkgs(selector);
> > }
> >
> >We don't have to change pv_ops.cpu.load_gs_index, right?
> >
> >Thanks!
> >Xin
> >
> >>
> >> No?
> >>
> >> Thanks,
> >>
> >> tglx
> >
>
> You don't *have* to, but it would mean a branch to a branch, so it would be
> more efficient. It would strictly be an optimization.

Right, the generated object file shows that static_cpu_has is less efficient than ALTERNATIVE.
\
 
 \ /
  Last update: 2022-10-18 23:30    [W:0.118 / U:0.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site