From: Kyle Moffett <mrlinuxman@mac.com>
To: david@lang.hm
Cc: Satyam Sharma <satyam.sharma@gmail.com>,
Lars Ellenberg <lars.ellenberg@linbit.com>,
Jens Axboe <axboe@kernel.dk>, Andrew Morton <akpm@osdl.org>,
LKML Kernel <linux-kernel@vger.kernel.org>,
netdev@vger.kernel.org
Subject: Re: [DRIVER SUBMISSION] DRBD wants to go mainline
Date: Wed, 25 Jul 2007 23:43:38 -0400 [thread overview]
Message-ID: <B3CFC70C-ADBC-406A-A2C8-908530FED007@mac.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707251900410.21378@asgard.lang.hm>
On Jul 25, 2007, at 22:03:37, david@lang.hm wrote:
> On Wed, 25 Jul 2007, Satyam Sharma wrote:
>> On 7/25/07, Lars Ellenberg <lars.ellenberg@linbit.com> wrote:
>>> On Wed, Jul 25, 2007 at 04:41:53AM +0530, Satyam Sharma wrote:
>>>> [...]
>>>> But where does the "send" come into the picture over here -- a
>>>> send won't block forever, so I don't foresee any issues
>>>> whatsoever w.r.t. kthreads conversion for that. [ BTW I hope
>>>> you're *not* using any signals-based interface for your kernel
>>>> thread _at all_. Kthreads disallow (ignore) all signals by
>>>> default, as they should, and you really shouldn't need to write
>>>> any logic to handle or > do-certain-things-on-seeing a signal
>>>> in a well designed kernel thread. ] and the sending latency is
>>>> crucial to performance, while the recv will not timeout for the
>>>> next few seconds. Again, I don't see what sending latency has
>>>> to do with a kernel_thread to kthread conversion. Or with
>>>> signals, for that matter. Anyway, as Kyle Moffett mentioned
>>>> elsewhere, you could probably look at other examples (say
>>>> cifs_demultiplexer_thread() in fs/cifs/connect.c).
>>>
>>> the basic problem, and what we use signals for, is: it is
>>> waiting in recv, waiting for the peer to say something. but I
>>> want it to stop recv, and go send something "right now".
>>
>> That's ... weird. Most (all?) communication between any two
>> parties would follow a protocol where someone recv's stuff, does
>> something with it, and sends it back ... what would you send
>> "right now" if you didn't receive anything?
>
> becouse even though you didn't receive anything you now have
> something important to send.
>
> remember that both sides can be sitting in receive mode. this puts
> them both in a position to respond to the other if the other has
> something to say.
Why not just have 2 threads, one for "sending" and one for
"receiving". When your receiving thread gets data it takes
appropriate locks and processes it, then releases the locks and goes
back to waiting for packets. Your sending thread would take
appropriate locks, generate data to send, release locks, and transmit
packets. You don't have to interrupt the receive thread to send
packets, so where's the latency problem, exactly?
If I were writing that in userspace I would have:
(A) The pool of IO-generating threads (IE: What would ordinarily be
userspace)
(B) One or a small number of data-reception threads.
(C) One or a small number of data-transmission threads.
When you get packets to process in your network-reception thread(s),
you queue appropriate disk IOs and any appropriate responses with
your transmission thread(s). You can basically just sit in a loop on
tcp_recvmsg=>demultiplex=>do-stuff. When your IO-generators actually
make stuff to send you queue such data for disk IO, then packetize it
and hand it off to your data-transmission threads.
If you made all your sockets and inter-thread pipes nonblocking then
in userspace you would just epoll_wait() on the sockets and pipes and
be easily able to react to any IO from anywhere.
In kernel space there are similar nonblocking interfaces, although it
would probably be easier just to use a couple threads.
Cheers,
Kyle Moffett
next prev parent reply other threads:[~2007-07-26 3:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070721203819.GA10706@mail.linbit.com>
[not found] ` <20070722213202.1f5d1cab.mrlinuxman@mac.com>
[not found] ` <20070723133202.GB23495@mail.linbit.com>
2007-07-24 0:48 ` [DRIVER SUBMISSION] DRBD wants to go mainline Kyle Moffett
[not found] ` <a781481a0707230640h17e6d83l5c2359e41f3ec7b7@mail.gmail.com>
[not found] ` <20070723211947.GD6477@mail.linbit.com>
[not found] ` <a781481a0707241611v3c35f6bdsb7af97d382b9298f@mail.gmail.com>
[not found] ` <20070725094638.GA2444@mail.linbit.com>
[not found] ` <a781481a0707250512v29d41b1bh25bcd358e7381d38@mail.gmail.com>
[not found] ` <Pine.LNX.4.64.0707251900410.21378@asgard.lang.hm>
2007-07-26 3:43 ` Kyle Moffett [this message]
2007-07-26 9:17 ` Evgeniy Polyakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B3CFC70C-ADBC-406A-A2C8-908530FED007@mac.com \
--to=mrlinuxman@mac.com \
--cc=akpm@osdl.org \
--cc=axboe@kernel.dk \
--cc=david@lang.hm \
--cc=lars.ellenberg@linbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=satyam.sharma@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox