Completion callbacks
Folks,
Quoted 11 lines
Liang Zhen ??:
Quoted 8 lines
Quoted 7 lines
2. we change
ptlrpc_master_callbackso that: it makes a copy of EV and queue it in a
FIFO and return, another thread process ev's in this FIFO and callback one by one and
we can guarantee events order and call real callbacks withoutlnet_lock
Quoted 4 lines
We can even have an
eq_callback_thread(or threads pool) in LNet,lnet_enq_event_locked()enqueue event and wakeup thecallback_thread, so we don't need change ptlrpc at all.
I dislike the idea of introducing any additional callback-devoted threads because 1) it would spoil the original design of callbacks as light-weight notifications and 2) introduce additional latency. I'd prefer to see per-MD locks (or per-EQ array of locks, that's quite equivalent) to serialize calling callbacks associated with any particular MD. This approach looks more natural and "right" than inventing callback-threads.
Sincerely,
Maxim
I think it's a requirement that software using the API's is not aware of this (ie no significant changes in ptlrpc). As long as the solution is compatible with that, this looks fine.
Peter
Quoted 33 lines · Maxim V. Patlasov
Folks,
Quoted 11 lines
Liang Zhen ??:
Quoted 8 lines
Quoted 7 lines
2. we change
ptlrpc_master_callbackso that: it makes a copy of EV and queue it in a
FIFO and return, another thread process ev's in this FIFO and callback one by one and
we can guarantee events order and call real callbacks withoutlnet_lockQuoted 4 lines
We can even have an
eq_callback_thread(or threads pool) in LNet,lnet_enq_event_locked()enqueue event and wakeup thecallback_thread, so we don't need change ptlrpc at all.I dislike the idea of introducing any additional callback-devoted threads because 1) it would spoil the original design of callbacks as light-weight notifications and 2) introduce additional latency. I'd prefer to see per-MD locks (or per-EQ array of locks, that's quite equivalent) to serialize calling callbacks associated with any particular MD. This approach looks more natural and "right" than inventing callback-threads.
Sincerely,
Maxim_______________________________________________
Lustre-devel mailing list
Lustre-devel at lists.lustre.org
http://lists.lustre.org/mailman/listinfo/lustre-devel
Thank you for all your feedback.
-- Braam wrote...
Quoted 8 lines
Quoted 5 lines
The change we're considering is to use one lock per EQ so that we get better concurrency by using many EQs. This avoids complicating the existing EQ locking code, but it does require Lustre changes. However making Lustre use a pool of EQs (say 1 per CPU) should be a very simple and self-contained change.
This doesn't sound so attractive. Isn't it possible to hide this under the LNET API?
Indeed, but it's not so simple - see Liang/Isaac's suggestion and my comment below.
-- Nikita wrote...
Quoted 3 lines
What about starting with a single lock for callbacks, _different_ from the lock protecting ME matching? Also, what callbacks lock protects exactly? Maybe it can be replaced with a read-write lock?
Indeed - that would allow us to determine whether we really need to work further of EQ callback concurrency.
-- Liang Zhan wrote...
Quoted 8 lines
Quoted 5 lines
The change we're considering is to detect when a portal is used exclusively for match-unique MEs (situation (b) - we already use different portals for (a) and (b)) and match using a hash table rather than a list search.
if we can always ignore "
ignore_bits" of ME (never used by Lustre), we can hash MEs bymatch_bits, otherwise we can only hash NID of peer which is less reasonable to me.
The "ignore_bits" parameter _is_ used by lustre. The 2 usages I mentioned were "match any", where peer ID is don't care and ignore_bits is -1, and "match unique", where peer ID is fully specified and ignore_bits is 0.
Quoted 5 lines
Isaac and I discussed about this and we think:
1. We can create an array of locks for each EQ (for example NCPUs locks for each EQ), and hash MD (i.e, by handle cookie) to these locks to get cocurrent ofeq_callbackwithout losing order of events for each MD, also, upper layers wouldn't see any change.
Yes, this ensures callbacks on each MD remain ordered - however the current code also guarantees that the callback and any MD auto-unlinking completes before LNetEQPoll() can return. We have to verify that relaxing ordering here is OK or else do some similar lock-hashing, say on the EQ slot.
Quoted 3 lines
We can even have an
eq_callback_thread(or threads pool) in LNet,lnet_enq_event_locked()enqueue event and wakeup thecallback_thread, so we don't need change ptlrpc at all.
That adds unnecessary context switching. EQ callbacks may happen in the context either of the thread doing a PUT or GET (PUT buffered immediately or you're using the lolnd), or more normally, of an LND worker thread. That's plenty of potential concurrency we can exploit.
Cheers,
Eric
Eric Barton ??:
Quoted 7 lines
Quoted 6 lines
Isaac and I discussed about this and we think:
1. We can create an array of locks for each EQ (for example NCPUs locks for each EQ), and hash MD (i.e, by handle cookie) to these locks to get cocurrent ofeq_callbackwithout losing order of events for each MD, also, upper layers wouldn't see any change.
Quoted 6 lines
Yes, this ensures callbacks on each MD remain ordered - however the current code also guarantees that the callback and any MD auto-unlinking completes before
LNetEQPoll()can return. We have to verify that relaxing ordering here is OK or else do some similar lock-hashing, say on the EQ slot.
Yes, then we will need two lock-tables just for serializing eq_callback and LNetEQPoll, and I think this part of code will be complex but the only benefit is concurrency of eq_callback. After think over it again, I perfer to
design like this:
1. Have different hash table for different LNet descriptor handles.
2. lnet_eq_lock
protects EQ-handle table, and all EQ related operations
3. lnet_portal_lock
protects ME-handle table, and all ME related operations, also, attach/detach/match MD will need this lock too.
4. lnet_md_lock (lock-table)
each slot of the lock-table protects a MD-handle table (MDs are hashed into different MD-tables by handle-cookie), it also protects all MD operations in the MD-table, eq_callbacks are serialized by it as well.
5. it's legal to have lnet_md_lock then race lnet_eq_lock or lnet_portal_lock
6. lnet_lock
it protects rest part of LNet (peer table, router-buffer, credits...)
Now let's see some examples:
1. LNetMDBind: only needs lnet_md_lock(i) to insert to MD-table
2. LNetMDAttach: needs lnet_md_lock(i) to insert to MD-table, then lnet_portal_lock() to attach with ME
3. LNetPut: needs lnet_md_lock(i) to find MD, then lnet_lock() for rest ops
4. lnet_parse_put: needs lnet_portal_lock() for matching
5. lnet_finalize: needs lnet_md_lock(i) (may need lnet_portal_lock for a short while if MD is on portal) to check status of MD, serialze callback and md_unlink, lnet_eq_lock to enqueue event, then lnet_lock to return credits etc.
6. LNetEQPoll: needs lnet_eq_lock
Although add more new locks here, but it's natural to have different locks for
different objects, also, everything still follow original logic of LNet, implementation is very straightforward, most time we just need to replace LNET_LOCK with new lock name.
All LNet interfaces can benefity from change like this: We will not only have
better concurrency of eq_callback, we also have concurrency of all APIs.
(If we want, we can even have individual lock for each portal based on this design(save portal index in ME handle), although I think it's no really necessary...)
Quoted 7 lines
_______________________________________________
Lustre-devel mailing list
Lustre-devel at lists.lustre.org
http://lists.lustre.org/mailman/listinfo/lustre-devel