From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755721Ab0DEREm (ORCPT ); Mon, 5 Apr 2010 13:04:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46852 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755653Ab0DEREf (ORCPT ); Mon, 5 Apr 2010 13:04:35 -0400 Date: Mon, 5 Apr 2010 18:29:01 +0200 From: Oleg Nesterov To: Lai Jiangshan 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, Gautham R Shenoy Subject: Re: [PATCH 2/2] cpuhotplug: make get_online_cpus() scalability by using percpu counter Message-ID: <20100405162901.GA3567@redhat.com> References: <4BB9BD8A.9040209@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BB9BD8A.9040209@cn.fujitsu.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 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. Lai, I didn't read this patch carefully yet (and I can't apply it to Linus's tree). But at first glance, > 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. OTOH, I do not understand why the result of __get_cpu_var(refcount) must be visible to refcount_sum() if we race with cpu_hotplug_begin(), so it seems to me cpu_hotplug_begin() also needs synchronize_sched() before refcount_sum(). Oleg.