Re: tcp_sendpage and page allocation lifetime vs. iscsi

From: Avi Kivity
Date: Mon Apr 25 2005 - 14:45:13 EST

David S. Miller wrote:

On Mon, 25 Apr 2005 22:11:16 +0300
Avi Kivity <avi@xxxxxxxxxx> wrote:

you need a completion to tell you when your buffer has been sent. you can use the kiocb parameter to tcp_sendmsg, as it has a completion. however, tcp_sendmsg does not appear to use it.

in effect, you need tcp aio, but the mainline kernel does not support it yet.

Or, he could simply not try to reuse the private buffer he is
giving to TCP.

you are describing a memory leak. at some point he must free (or otherwise reuse) these pages.

theoretically he could peek at the tcp sequence number, but an event-driven, protocol-agnostic completion seems better to me.

* light goes on *

yes, if he frees the pages immediately after tcp_sendpage, then the reference count would remain elevated until tcp completes sending these pages. so the sequence

allocate pages
fill with data
free pages

should be safe?

(I am still wishing for tcp aio, though)

Do not meddle in the internals of kernels, for they are subtle and quick to panic.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at