From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754055AbdIDXlF (ORCPT ); Mon, 4 Sep 2017 19:41:05 -0400 Received: from mga06.intel.com ([134.134.136.31]:18405 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754027AbdIDXlE (ORCPT ); Mon, 4 Sep 2017 19:41:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,476,1498546800"; d="scan'208";a="148068938" From: "Huang\, Ying" To: Thomas Gleixner Cc: "Huang\, Ying" , Subject: Re: [PATCH] IRQ, cpu-hotplug: Fix a race between CPU hotplug and IRQ desc alloc/free References: <20170904085308.17637-1-ying.huang@intel.com> Date: Tue, 05 Sep 2017 07:41:01 +0800 In-Reply-To: (Thomas Gleixner's message of "Mon, 4 Sep 2017 11:23:01 +0200") Message-ID: <87fuc2yquq.fsf@yhuang-mobile.sh.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thomas Gleixner writes: > On Mon, 4 Sep 2017, Huang, Ying wrote: >> diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c >> index 638eb9c83d9f..af9029625271 100644 >> --- a/kernel/irq/cpuhotplug.c > ry> +++ b/kernel/irq/cpuhotplug.c >> @@ -129,10 +129,13 @@ void irq_migrate_all_off_this_cpu(void) >> struct irq_desc *desc; >> unsigned int irq; >> >> + irq_lock_sparse(); > > You cannot take that lock here as irq_migrate_all_off_this_cpu() is called > with interrupts disabled. Oh, sorry, I misunderstand the code. I will only keep the !desc check in the patch. > The protection in takedown_cpus() is wrong. Patch below. > > Thanks, > > tglx > ---- > > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -642,13 +642,13 @@ static int takedown_cpu(unsigned int cpu > wait_for_completion(&st->done); > BUG_ON(st->state != CPUHP_AP_IDLE_DEAD); > > - /* Interrupts are moved away from the dying cpu, reenable alloc/free */ > - irq_unlock_sparse(); > - > hotplug_cpu__broadcast_tick_pull(cpu); > /* This actually kills the CPU. */ > __cpu_die(cpu); > > + /* Interrupts are moved away from the dying cpu, reenable alloc/free */ > + irq_unlock_sparse(); > + I don't understand this. It appears that irq_migrate_all_off_this_cpu() is called in take_cpu_down() which has sparse_irq_lock held already. Best Regards, Huang, Ying > tick_cleanup_dead_cpu(cpu); > return 0; > }