On 10/04/2018 07:05 AM, Sebastian Andrzej Siewior wrote: > Most users of __raw_xsave_addr() use a feature number, shift it to a > mask and then __raw_xsave_addr() shifts it back to the feature number. > > Make __raw_xsave_addr() use the feature number as argument. This generally looks like a nice cleanup. Thanks for taking a look at it! > diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c > index 87a57b7642d36..38d0b5ea40425 100644 > --- a/arch/x86/kernel/fpu/xstate.c > +++ b/arch/x86/kernel/fpu/xstate.c > @@ -811,10 +811,8 @@ void fpu__resume_cpu(void) > * > * Note: does not work for compacted buffers. > */ > -void *__raw_xsave_addr(struct xregs_state *xsave, int xstate_feature_mask) > +void *__raw_xsave_addr(struct xregs_state *xsave, int feature_nr) > { Could we call this 'xfeature_nr' consistently? > - int feature_nr = fls64(xstate_feature_mask) - 1; > - > if (!xfeature_enabled(feature_nr)) { > WARN_ON_FPU(1); > return NULL; > @@ -842,6 +840,7 @@ void *__raw_xsave_addr(struct xregs_state *xsave, int xstate_feature_mask) > */ > void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature) > { > + int feature_nr; > /* > * Do we even *have* xsave state? > */ > @@ -869,7 +868,8 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature) > if (!(xsave->header.xfeatures & xstate_feature)) > return NULL; > > - return __raw_xsave_addr(xsave, xstate_feature); > + feature_nr = fls64(xstate_feature) - 1; > + return __raw_xsave_addr(xsave, feature_nr); > } Should we also be using a feature number for get_xsave_addr()? In other words, could you take a look and see how widely we should be doing this kind of conversion and not just limit it to __raw_xsave_addr()?