migration/multifd: Simplify locking in sender thread
authorPeter Xu <peterx@redhat.com>
Fri, 2 Feb 2024 10:28:41 +0000 (18:28 +0800)
committerPeter Xu <peterx@redhat.com>
Mon, 5 Feb 2024 06:42:10 +0000 (14:42 +0800)
commite3cce9af10b06c51434ced4e1a6686f1ce43e124
treeeabbd21ad2f4bde133c1b5fc26a58ee9cf0f3fe4
parentf5f48a7891cf6664a920ba52f6f4dea1646049a4
migration/multifd: Simplify locking in sender thread

The sender thread will yield the p->mutex before IO starts, trying to not
block the requester thread.  This may be unnecessary lock optimizations,
because the requester can already read pending_job safely even without the
lock, because the requester is currently the only one who can assign a
task.

Drop that lock complication on both sides:

  (1) in the sender thread, always take the mutex until job done
  (2) in the requester thread, check pending_job clear lockless

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240202102857.110210-8-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
migration/multifd.c