Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753144Ab2FKJ0e (ORCPT ); Mon, 11 Jun 2012 05:26:34 -0400 Received: from www.linutronix.de ([62.245.132.108]:37433 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011Ab2FKJ0d (ORCPT ); Mon, 11 Jun 2012 05:26:33 -0400 Date: Mon, 11 Jun 2012 11:26:12 +0200 (CEST) From: Thomas Gleixner To: Rusty Russell cc: Peter Zijlstra , Fenghua Yu , Ingo Molnar , H Peter Anvin , Suresh B Siddha , Tony Luck , Asit K Mallick , Arjan Dan De Ven , linux-kernel , x86 , linux-pm , "Srivatsa S. Bhat" Subject: Re: [PATCH] kthread: Implement park/unpark facility In-Reply-To: <878vfviv1h.fsf@rustcorp.com.au> Message-ID: References: <1338833876-29721-1-git-send-email-fenghua.yu@intel.com> <1338842001.28282.135.camel@twins> <87zk8iioam.fsf@rustcorp.com.au> <878vfviv1h.fsf@rustcorp.com.au> User-Agent: Alpine 2.02 (LFD 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1636 Lines: 45 On Sun, 10 Jun 2012, Rusty Russell wrote: > On Tue, 5 Jun 2012 15:41:48 +0200 (CEST), Thomas Gleixner wrote: > > Subject: kthread: Implement park/unpark facility > > From: Thomas Gleixner > > Date: Wed, 18 Apr 2012 16:37:40 +0200 > > > > To avoid the full teardown/setup of per cpu kthreads in the case of > > cpu hot(un)plug, provide a facility which allows to put the kthread > > into a park position and unpark it when the cpu comes online again. > > Like the idea, but the API is awkward. Now you've made returning from a > thread do different things depending on whether it was parked or not. > > How about just have the thread call "kthread_parkme()" which only > returns if/when the thread is unparked? > > So the thread does: > > while (!kthread_should_stop()) { > if (kthread_should_park()) { > ... cleanup ... > kthread_parkme(); > ... restore ... > } > ... work ... > } > > Threads which never exit have "for (;;)" instead of while > (!kthread_should_stop()). Makes sense. Will have a go on that. One other thing what I'm thinking about is to avoid the synchronous parking mechanism, i.e. just tell the thread to park and check the park state later before going further down. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/