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

From: Dave Hansen
Date: Wed Nov 20 2019 - 16:50:33 EST


On 11/20/19 1:23 PM, Dave Jiang wrote:
> +static inline void __iowrite512(void __iomem *__dst, const void *src)
> +{
> + volatile struct { char _[64]; } *dst = __dst;

This _looks_ like gibberish. I know it's not, but it is subtle enough
that it really needs specific comments.

> +static inline void iosubmit_cmds512(void __iomem *dst, const void *src,
> + size_t count)
> +{
> + const u8 *from = src;
> + const u8 *end = from + count * 64;
> +
> + if (!cpu_has_write512())
> + return;
> +
> + while (from < end) {
> + __iowrite512(dst, from);
> + from += 64;
> + }
> +}

Won't this silently just drop things if the CPU doesn't have movdir64b
support?

It seems like this shouldn't be called at all if
!cpu_has_write512(), but wouldn't something like this be mroe appropriate?

if (!cpu_has_write512()) {
WARN_ON_ONCE(1);
return;
}

Is the caller just supposed to infer that "dst" was never overwritten?