Re: [PATCH v3 5/7] pmem: add copy_from_iter_pmem() and clear_pmem()

From: Christoph Hellwig
Date: Mon Aug 17 2015 - 15:10:22 EST


> #include <linux/uaccess.h>
> +#include <linux/uio.h>
> +

Can we keep this in linux/pmem.h? I'm pretty sure the stubs would need
it as well, and even if they don't it'll keep the includes consistent.

> +{
> + size_t len;
> +
> + len = copy_from_iter_nocache((void __force *)addr, bytes, i);
> +
> + /*
> + * copy_from_iter_nocache() on x86 only uses non-temporal stores for
> + * iovec iterators, so for other types (bvec & kvec) we must do a
> + * cache write-back.

Shouldn't we fi that?

> + */
> + if (iter_is_iovec(i) == false)
> + __arch_wb_cache_pmem(addr, bytes);

And if not and iter_needs_pmem_wb helper to encode this knowledge would
be useful.

> +static inline void arch_clear_pmem(void __pmem *addr, size_t size)
> +{
> + /* TODO: implement the zeroing via non-temporal writes */
> + if (size == PAGE_SIZE && ((unsigned long)addr & ~PAGE_MASK) == 0)
> + clear_page((void __force *)addr);
> + else
> + memset((void __force *)addr, 0, size);
> +
> + __arch_wb_cache_pmem(addr, size);

Please add a local vaiable so that the __force casting is only needed
once. Same for other functions with this pattern.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/