From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161627Ab3DKSH6 (ORCPT ); Thu, 11 Apr 2013 14:07:58 -0400 Received: from www.sr71.net ([198.145.64.142]:48940 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161570Ab3DKSH4 (ORCPT ); Thu, 11 Apr 2013 14:07:56 -0400 Message-ID: <5166FBFB.2030703@sr71.net> Date: Thu, 11 Apr 2013 11:07:55 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Thomas Gleixner CC: Borislav Petkov , "Srivatsa S. Bhat" , LKML , Dave Jones , dhillf@gmail.com, Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH] kthread: Prevent unpark race which puts threads on the wrong cpu References: <515F457E.5050505@sr71.net> <515FCAC6.8090806@linux.vnet.ibm.com> <20130407095025.GA31307@pd.tnic> <20130408115553.GA4395@pd.tnic> <516439DF.3050901@sr71.net> <51647C30.3050109@sr71.net> <5165C087.4060404@sr71.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/11/2013 03:19 AM, Thomas Gleixner wrote: > --- linux-2.6.orig/kernel/smpboot.c > +++ linux-2.6/kernel/smpboot.c > @@ -185,8 +185,18 @@ __smpboot_create_thread(struct smp_hotpl > } > get_task_struct(tsk); > *per_cpu_ptr(ht->store, cpu) = tsk; > - if (ht->create) > - ht->create(cpu); > + if (ht->create) { > + /* > + * Make sure that the task has actually scheduled out > + * into park position, before calling the create > + * callback. At least the migration thread callback > + * requires that the task is off the runqueue. > + */ > + if (!wait_task_inactive(tsk, TASK_PARKED)) > + WARN_ON(1); > + else > + ht->create(cpu); > + } > return 0; > } This one appears to be doing the trick. I'll run the cpus in an online/offline loop for a bit and make sure it's stable. It's passed several round so far, which is way more than it's done up to this point, though.