From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757975Ab0DGNfm (ORCPT ); Wed, 7 Apr 2010 09:35:42 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:54179 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1757926Ab0DGNfl (ORCPT ); Wed, 7 Apr 2010 09:35:41 -0400 Message-ID: <4BBC8A11.3040501@cn.fujitsu.com> Date: Wed, 07 Apr 2010 21:35:13 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Oleg Nesterov , Gautham R Shenoy CC: Rusty Russell , Benjamin Herrenschmidt , Hugh Dickins , Ingo Molnar , "Paul E. McKenney" , Nathan Fontenot , Peter Zijlstra , Andrew Morton , Thomas Gleixner , Sachin Sant , "H. Peter Anvin" , Shane Wang , Roland McGrath , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] cpuhotplug: make get_online_cpus() scalability by using percpu counter References: <4BB9BD8A.9040209@cn.fujitsu.com> <20100405162901.GA3567@redhat.com> <20100406120039.GC5680@redhat.com> In-Reply-To: <20100406120039.GC5680@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov wrote: > On 04/05, Oleg Nesterov wrote: >> On 04/05, Lai Jiangshan wrote: >>> 1) get_online_cpus() must be allowed to be called recursively, so I added >>> get_online_cpus_nest for every task for new code. >> Well, iirc one of the goals of >> >> cpu-hotplug: replace lock_cpu_hotplug() with get_online_cpus() >> 86ef5c9a8edd78e6bf92879f32329d89b2d55b5a >> >> was avoiding the new members in task_struct. I leave this up to you >> and Gautham. Old get_online_cpus() is read-preference, I think the goal of this ability is allow get_online_cpus()/put_online_cpus() to be called nested. But read-preference RWL may cause write side starvation, so I abandon this ability, and use per-task counter for allowing get_online_cpus()/put_online_cpus() to be called nested, I think this deal is absolutely worth. >> >> >> Lai, I didn't read this patch carefully yet (and I can't apply it to >> Linus's tree). But at first glance, > > because I tried to apply it without 1/2 ;) > >>> void put_online_cpus(void) >>> { >>> ... >>> + if (!--current->get_online_cpus_nest) { >>> + preempt_disable(); >>> + __get_cpu_var(refcount)--; >>> + if (cpu_hotplug_task) >>> + wake_up_process(cpu_hotplug_task); >> This looks unsafe. In theory nothing protects cpu_hotplug_task from >> exiting if refcount_sum() becomes zero, this means wake_up_process() >> can hit the freed/reused/unmapped task_struct. Probably cpu_hotplug_done() >> needs another synhronize_sched() before return. > > Yes, I think this is true, at least in theory. preempt_disable() prevent cpu_hotplug_task from exiting. Thanks, Lai