Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755149Ab3DOQMi (ORCPT ); Mon, 15 Apr 2013 12:12:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47142 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752548Ab3DOQMh (ORCPT ); Mon, 15 Apr 2013 12:12:37 -0400 Date: Mon, 15 Apr 2013 18:09:08 +0200 From: Oleg Nesterov To: Robin Holt Cc: "Srivatsa S. Bhat" , Ingo Molnar , Paul Mackerras , Linus Torvalds , "H. Peter Anvin" , Andrew Morton , Linux Kernel Mailing List , Russ Anderson , Shawn Guo , Thomas Gleixner , Ingo Molnar , the arch/x86 maintainers , "Paul E. McKenney" , Tejun Heo , Lai Jiangshan , Michel Lespinasse , "rusty@rustcorp.com.au" , Peter Zijlstra Subject: Re: Bulk CPU Hotplug (Was Re: [PATCH] Do not force shutdown/reboot to boot cpu.) Message-ID: <20130415160908.GA17950@redhat.com> References: <20130410111620.GB29752@gmail.com> <20130411053106.GA9042@drongo> <5166B05E.8010904@linux.vnet.ibm.com> <20130411134837.GE3672@sgi.com> <20130412053718.GC3887@gmail.com> <5167A52F.6020503@linux.vnet.ibm.com> <20130412093149.GT3658@sgi.com> <20130413163022.GA7500@redhat.com> <20130415160408.GA3658@sgi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130415160408.GA3658@sgi.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1309 Lines: 35 On 04/15, Robin Holt wrote: > > On Sat, Apr 13, 2013 at 06:30:22PM +0200, Oleg Nesterov wrote: > > On 04/12, Robin Holt wrote: > > > > > > +void migrate_to_boot_cpu(void) > > > +{ > > > + /* The boot cpu is always logical cpu 0 */ > > > + int reboot_cpu_id = 0; > > > + > > > + /* Make certain the cpu I'm about to reboot on is online */ > > > + if (!cpu_online(reboot_cpu_id)) > > > + reboot_cpu_id = smp_processor_id(); > > > + > > > + /* Make certain I only run on the appropriate processor */ > > > + set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id)); > > > > This is only theoretical, but perhaps it makes sense to set > > PF_THREAD_BOUND before set_cpus_allowed_ptr() ? To prevent the > > race with another thread doing sched_setaffinity(). > > I don't quite understand this comment. We are migrating our own thread. > How does setting PF_THREAD_BOUND have any effect? Suppose that another thread does, say, sys_sched_setaffinity(our_pid) right after set_cpus_allowed_ptr(). If we set PF_THREAD_BOUND the next set_cpus_allowed() will fail. Oleg. -- 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/