netdev
[Top] [All Lists]

Re: kiocb->private is too large for kiocb's on-stack

To: William Lee Irwin III <wli@xxxxxxxxxxxxxx>
Subject: Re: kiocb->private is too large for kiocb's on-stack
From: Andrew Morton <akpm@xxxxxxxx>
Date: Mon, 28 Jun 2004 01:12:32 -0700
Cc: linux-kernel@xxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx, davem@xxxxxxxxxx
In-reply-to: <20040628080801.GO21066@xxxxxxxxxxxxxx>
References: <20040628080801.GO21066@xxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
William Lee Irwin III <wli@xxxxxxxxxxxxxx> wrote:
>
> sizeof(struct kiocb) is dangerously large for a structure commonly
> allocated on-stack. This patch converts the 24*sizeof(long) field,
> ->private, to a void pointer for use by file_operations entrypoints.
> A ->dtor() method is added to the kiocb in order to support the release
> of dynamically allocated structures referred to by ->private.
> 
> The sole in-tree users of ->private are async network read/write,
> which are not, in fact, async, and so need not handle preallocated
> ->private as they would need to if ->ki_retry were ever used. The sole
> truly async operations are direct IO pread()/pwrite() which do not
> now use ->ki_retry(). All they would need to do in that case is to
> check for ->private already being allocated for async kiocbs.
> 
> This rips 88B off the stack on 32-bit in the common case.
> 

>  int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
>  {
>       struct kiocb iocb;
> +     struct sock_iocb siocb;
>       int ret;
>  
>       init_sync_kiocb(&iocb, NULL);
> +     iocb.private = &siocb;
>       ret = __sock_sendmsg(&iocb, sock, msg, size);
>       if (-EIOCBQUEUED == ret)
>               ret = wait_on_sync_kiocb(&iocb);

That's so much better than what we had before it ain't funny.

Was this runtime tested?

<Prev in Thread] Current Thread [Next in Thread>