Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752798Ab2FJGiu (ORCPT ); Sun, 10 Jun 2012 02:38:50 -0400 Received: from ozlabs.org ([203.10.76.45]:40921 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082Ab2FJGie (ORCPT ); Sun, 10 Jun 2012 02:38:34 -0400 From: Rusty Russell To: Thomas Gleixner 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: References: <1338833876-29721-1-git-send-email-fenghua.yu@intel.com> <1338842001.28282.135.camel@twins> <87zk8iioam.fsf@rustcorp.com.au> User-Agent: Notmuch/0.12 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Sun, 10 Jun 2012 15:10:42 +0930 Message-ID: <878vfviv1h.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1319 Lines: 36 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()). Cheers, Rusty. -- 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/