]> asedeno.scripts.mit.edu Git - linux.git/commit
IB/fmr_pool: Convert the cleanup thread into kthread worker API
authorPetr Mladek <pmladek@suse.com>
Mon, 17 Oct 2016 15:39:32 +0000 (17:39 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 25 Apr 2017 18:24:17 +0000 (14:24 -0400)
commit50b6778c44e426d7ef7ae30e06314f511faf383a
tree68a36f7a3d57ee9e11eb5b9e7546e6b06f2a0e1b
parent4d6f28591fe415fc5233e9148c66a1b81ad17425
IB/fmr_pool: Convert the cleanup thread into kthread worker API

Kthreads are currently implemented as an infinite loop. Each
has its own variant of checks for terminating, freezing,
awakening. In many cases it is unclear to say in which state
it is and sometimes it is done a wrong way.

The plan is to convert kthreads into kthread_worker or workqueues
API. It allows to split the functionality into separate operations.
It helps to make a better structure. Also it defines a clean state
where no locks are taken, IRQs blocked, the kthread might sleep
or even be safely migrated.

The kthread worker API is useful when we want to have a dedicated
single thread for the work. It helps to make sure that it is
available when needed. Also it allows a better control, e.g.
define a scheduling priority.

This patch converts the frm_pool kthread into the kthread worker
API because I am not sure how busy the thread is. It is well
possible that it does not need a dedicated kthread and workqueues
would be perfectly fine. Well, the conversion between kthread
worker API and workqueues is pretty trivial.

The patch moves one iteration from the kthread into the work function.
It is queued only when there is a pending work. Therefore we do not
need to compare flush_ser and req_ser at the beginning. On the contrary,
the same work could be queued only once at a time. Therefore it has to
re-queue itself if some requests are pending.

Otherwise, wake_up_process() is replaced by queuing the work.

Important: The change is only compile tested. I did not find an easy
way how to check it in a real life.

Signed-off-by: Petr Mladek <pmladek@suse.com>
TO: Doug Ledford <dledford@redhat.com>
CC: Sean Hefty <sean.hefty@intel.com>
CC: Hal Rosenstock <hal.rosenstock@gmail.com>
CC: linux-rdma@vger.kernel.org
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/fmr_pool.c