Re: [PATCH RFC 01/14] x86/asm: add iosubmit_cmds512() based on movdir64b CPU instruction

From: Dan Williams
Date: Fri Nov 22 2019 - 12:20:53 EST


On Fri, Nov 22, 2019 at 1:00 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Thu, Nov 21, 2019 at 09:52:19AM -0700, Dave Jiang wrote:
> > No what I mean was those primitives are missing the checks and we should
> > probably address that at some point.
>
> Oh, patches are always welcome! :)
>
> > How would I detect that? Add a size (in bytes) parameter for the total
> > source data?
>
> Sure.
>
> So, here's the deal: the more I look at this thing, the more I think
> this iosubmit_cmds512() function should not be in a generic header but
> in an intel-/driver-specific one. Why?
>
> Well, movdir64b is Intel-only for now, you don't have a fallback
> option for the platforms which do not support that insn and it is more
> preferential for you to do the feature check once at driver init and
> then call the function because you *know* you have movdir64b support
> and not have any feature check in the function itself, not even a fast
> static_cpu_has() one.
>
> And this way you can do away with alignment and size checks because you
> control what your driver does.
>
> If it turns out that this function needs to be shared with other
> platforms, then we can consider lifting it into a generic header and
> making it more generic.
>
> Ok?

I do agree that iosubmit_cmds512() can live in a driver specific
header, and it was my fault for advising Dave to make it generic. The
long story of how that came to pass below, but the short story is yes,
lets just make this one driver specific.

The long story is that there is already line of sight for a need for
other generic movdir64b() helpers as mentioned in the changelog, and
iosubmit_cmds512() got wrapped up in that momentum.

For those cases the thought would be to have memset512() for case1 and
__iowrite512_copy() for case3. Where memset512() writes a
non-incrementing source to an incrementing destination, and
__iowrite512_copy() copies an incrementing source to an incrementing
destination. Those 2 helpers *would* have fallbacks, but with the
option to use something like cpu_has_write512() to check in advance
whether those routines will fallback, or not.

That can be a discussion for a future patchset when those users arrive.