Re: [PATCH] kernfs: use stack-buf for small writes.
From: Al Viro
Date: Wed Sep 24 2014 - 15:17:35 EST
On Tue, Sep 23, 2014 at 02:06:33PM +1000, NeilBrown wrote:
>
> For a write <= 128 characters, don't use kmalloc.
>
> mdmon, part of mdadm, will sometimes need to write
> to a sysfs file in order to allow writes to the array
> to continue. This is important to support RAID metadata
> types that the kernel doesn't know about.
>
> It is important that this write doesn't block on
> memory allocation. The safest way to ensure that is to
> use an on-stack buffer.
Is it, now? What happens if caller of write(2) loses CPU and gets
the page it's writing from swapped out, just as it's getting to
issuing the actual syscall? copy_from_user() will fault and cause
memory allocation for you...
> Writes are always small, typically less than 10 characters.
Translation: "but my userland code uses it _that_ way; surely, nobody
would do anything else..."
--
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/