[systemd-devel] [RFC 5/8] HACK1: optimize copy operations in kdbus_conn_queue_alloc()

Kay Sievers kay at vrfy.org
Wed Jun 25 03:20:49 PDT 2014


On Wed, Jun 25, 2014 at 11:13 AM, AKASHI Takahiro
<takahiro.akashi at linaro.org> wrote:
> This function copies the reply message directly into receiver's buffer
> (pool slice). Looking into the implementation closely, however, there are
> multiple occurrences of copy operations, kdbus_pool_slice_copy(), which
> then executes costly prolog/epilog functions, say set_fs() and
> write_begin/write_end(), on each entry/exit.
>
> This patch uses a temporary buffer on the stack to compose a message and
> replace a costly function, kdbus_pool_slice_copy(), to memcpy() wherever
> possible, although I have to further confirm that this change is actually
> safe.

> +#if KDBUS_HACK1
> +       tmp = kmalloc(vec_data, GFP_KERNEL);

You meant a malloced temporary buffer, not one allocated on the stack, right?

We need to handle larger vectors than kmalloc can handle, that's why
we copy directly to the receiver, and to avoid 2 copies.

Did you find out what exactly in the call chain of our "open-coded
write" shows up as expensive here?

Kay


More information about the systemd-devel mailing list