Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1316977
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v4 22/22] thermal/intel_powerclamp: Convert the kthread to kthread worker API |
| Date | 2016-01-25 17:40 +0100 |
| Message-ID | <qUSll-6Ia-41@gated-at.bofh.it> (permalink) |
| References | <qURyW-64A-19@gated-at.bofh.it> <qURyZ-64A-87@gated-at.bofh.it> |
| Organization | OTC |
On Mon, 25 Jan 2016 16:45:11 +0100 Petr Mladek <pmladek@suse.com> wrote: > 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 intel powerclamp kthreads into the kthread > worker because they need to have a good control over the assigned > CPUs. > > IMHO, the most natural way is to split one cycle into two works. > First one does some balancing and let the CPU work normal > way for some time. The second work checks what the CPU has done > in the meantime and put it into C-state to reach the required > idle time ratio. The delay between the two works is achieved > by the delayed kthread work. > > The two works have to share some data that used to be local > variables of the single kthread function. This is achieved > by the new per-CPU struct kthread_worker_data. It might look > as a complication. On the other hand, the long original kthread > function was not nice either. > > The patch tries to avoid extra init and cleanup works. All the > actions might be done outside the thread. They are moved > to the functions that create or destroy the worker. Especially, > I checked that the timers are assigned to the right CPU. > > The two works are queuing each other. It makes it a bit tricky to > break it when we want to stop the worker. We use the global and > per-worker "clamping" variables to make sure that the re-queuing > eventually stops. We also cancel the works to make it faster. > Note that the canceling is not reliable because the handling > of the two variables and queuing is not synchronized via a lock. > But it is not a big deal because it is just an optimization. > The job is stopped faster than before in most cases. > > Signed-off-by: Petr Mladek <pmladek@suse.com> > CC: Zhang Rui <rui.zhang@intel.com> > CC: Eduardo Valentin <edubezval@gmail.com> > CC: Jacob Pan <jacob.jun.pan@linux.intel.com> > CC: linux-pm@vger.kernel.org Tested v3 for functionality and performance, v4 seems unchanged for this patch according to changelog. Acked-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v4 00/22] kthread: Use kthread worker API more widely Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 21/22] thermal/intel_powerclamp: Remove duplicated code that starts the kthread Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
Re: [PATCH v4 21/22] thermal/intel_powerclamp: Remove duplicated code that starts the kthread Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-25 17:30 +0100
[PATCH v4 18/22] IB/fmr_pool: Convert the cleanup thread into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 03/22] kthread: Allow to call __kthread_create_on_node() with va_list args Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 19/22] memstick/r592: Better synchronize debug messages in r592_io kthread Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 12/22] kthread: Use try_lock_kthread_work() in flush_kthread_work() Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 17/22] ipmi: Convert kipmi kthread into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 08/22] kthread: Initial support for delayed kthread work Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
Re: [PATCH v4 08/22] kthread: Initial support for delayed kthread work Tejun Heo <tj@kernel.org> - 2016-01-25 20:10 +0100
[PATCH v4 01/22] timer: Allow to check when the timer callback has not finished yet Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
Re: [PATCH v4 01/22] timer: Allow to check when the timer callback has not finished yet Tejun Heo <tj@kernel.org> - 2016-01-25 19:50 +0100
[PATCH v4 06/22] kthread: Add destroy_kthread_worker() Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
[PATCH v4 22/22] thermal/intel_powerclamp: Convert the kthread to kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 16:50 +0100
Re: [PATCH v4 22/22] thermal/intel_powerclamp: Convert the kthread to kthread worker API Jacob Pan <jacob.jun.pan@linux.intel.com> - 2016-01-25 17:40 +0100
[PATCH v4 20/22] memstick/r592: convert r592_io kthread into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 17:00 +0100
[PATCH v4 15/22] hung_task: Convert hungtaskd into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 17:00 +0100
[PATCH v4 16/22] kmemleak: Convert kmemleak kthread into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 17:00 +0100
[PATCH v4 13/22] mm/huge_page: Convert khugepaged() into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 17:00 +0100
[PATCH v4 14/22] ring_buffer: Convert benchmark kthreads into kthread worker API Petr Mladek <pmladek@suse.com> - 2016-01-25 17:00 +0100
[PATCH v4 11/22] kthread: Better support freezable kthread workers Petr Mladek <pmladek@suse.com> - 2016-01-25 17:10 +0100
Re: [PATCH v4 11/22] kthread: Better support freezable kthread workers Tejun Heo <tj@kernel.org> - 2016-01-25 20:30 +0100
[PATCH v4 09/22] kthread: Allow to cancel kthread work Petr Mladek <pmladek@suse.com> - 2016-01-25 17:20 +0100
Re: [PATCH v4 09/22] kthread: Allow to cancel kthread work Tejun Heo <tj@kernel.org> - 2016-01-25 20:20 +0100
[PATCH v4 02/22] kthread/smpboot: Do not park in kthread_create_on_cpu() Petr Mladek <pmladek@suse.com> - 2016-01-25 17:20 +0100
[PATCH v4 07/22] kthread: Detect when a kthread work is used by more workers Petr Mladek <pmladek@suse.com> - 2016-01-25 17:20 +0100
Re: [PATCH v4 07/22] kthread: Detect when a kthread work is used by more workers Tejun Heo <tj@kernel.org> - 2016-01-25 20:00 +0100
[PATCH v4 04/22] kthread: Add create_kthread_worker*() Petr Mladek <pmladek@suse.com> - 2016-01-25 17:20 +0100
Re: [PATCH v4 04/22] kthread: Add create_kthread_worker*() Tejun Heo <tj@kernel.org> - 2016-01-25 20:00 +0100
csiph-web