Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp133862imm; Wed, 5 Sep 2018 16:29:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYiH/0/WQWJ2+r/rFbj+5EKgAyQ88UKjDoNRutQfDBk967sLH4EEMKD0Xfjqs7npoU/5pQt X-Received: by 2002:a62:2459:: with SMTP id r86-v6mr49285pfj.31.1536190141621; Wed, 05 Sep 2018 16:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536190141; cv=none; d=google.com; s=arc-20160816; b=LIDfccQTuxLvJv+GHpi9uNcuE1wXqyDlDqeNmE7pOy4o+PaBNi13SYsk6CPZUI4JdA DAZekB2K+pU2AHBiPgZFoQOvbU426iMXcZA0XcwGUboRADFetwi8/F9MVV13kXcEAlzd ctPR1gAN6KhtA5qX0FmNkkiZpXpo0ILkO/RBdILmDAYQUyOtm9m2PS9h3qFiW4jJdjsf C7U098visw/DATK9aOS9cujAjBLG2p0YhgkFG3wAQT32T8+u4xxpvRCpJVmgXnI3ptHi BBiE+C6/Z8v1BOyl8bkwQ0xpc2buujNbPfy/aTyfTCtSeA7ShtGJewI0CrLwbWf/qgOv ygCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=D0NehT10WGLfn0JfwjvflrvuQD+fllyIT5nmoVHf6xU=; b=bhPkrPy5y+NeGWDh8BNLp5W/ZlB0DbRSVzZw6UYfL+FqfJo45zoIzJn4gpmV/BC1t2 aeSjT1yoo+F00HCl71lMAXpvBWNSeIKIMp0O+EFffA2e+fkUgIMEFfA/bAok2ygPjPy7 yTCTHIKxI9JO8efhE5k40/rtcQEN2B4nU4Q1LjZssTZYXcL4GRkVkbR35K5alUiYJTTl gVxcFyaLd6fMheOKl6v3ycIu34Tb/OC7GnbrSWKjQy5jyUQ6XC3Lj8dyhWSvOtmchYK9 vRja77RYDZKCmairvofjshvjeCo/YIZDDoSpl+Qh6PX9r8A0A3sCYcWiiekxlMApupNF bxNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JTGeafCP; dkim=pass header.i=@codeaurora.org header.s=default header.b=JTGeafCP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j124-v6si3783786pfb.191.2018.09.05.16.28.46; Wed, 05 Sep 2018 16:29:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JTGeafCP; dkim=pass header.i=@codeaurora.org header.s=default header.b=JTGeafCP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727681AbeIFD7h (ORCPT + 99 others); Wed, 5 Sep 2018 23:59:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52306 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727501AbeIFD7h (ORCPT ); Wed, 5 Sep 2018 23:59:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 95DAF605BD; Wed, 5 Sep 2018 23:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536190029; bh=179maZzWo08TIaue7WJHIp59MvWk5ZoZ1JhweW4496w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JTGeafCPThj7vScbD6eVRi9xzhQrshUPKBDyYfhmZAF/x+149xNONn1RMU/ZWTLEd nomIwGN3SK+66r6JpPkVM/wdKwJULuMowGFjhp6bRf/0TDx6k1/gZpfh+ESLBD4Hhn buWVaD8bFhuyVUD4bCFAQdHNMKIH31YMVI1JJnTY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 4DBE5601D9; Wed, 5 Sep 2018 23:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536190029; bh=179maZzWo08TIaue7WJHIp59MvWk5ZoZ1JhweW4496w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JTGeafCPThj7vScbD6eVRi9xzhQrshUPKBDyYfhmZAF/x+149xNONn1RMU/ZWTLEd nomIwGN3SK+66r6JpPkVM/wdKwJULuMowGFjhp6bRf/0TDx6k1/gZpfh+ESLBD4Hhn buWVaD8bFhuyVUD4bCFAQdHNMKIH31YMVI1JJnTY= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 05 Sep 2018 16:27:09 -0700 From: pheragu@codeaurora.org To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, ckadabi@codeaurora.org, tsoni@codeaurora.org, bryanh@codeaurora.org, Prasad Sodagudi Subject: Re: [PATCH] genirq: Avoid race between cpu hot plug and irq_desc() allocation paths In-Reply-To: References: <1536167131-20585-1-git-send-email-pheragu@codeaurora.org> Message-ID: <819e8a811ebf49366d75676922903368@codeaurora.org> X-Sender: pheragu@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-09-05 11:23, Thomas Gleixner wrote: > On Wed, 5 Sep 2018, Prakruthi Deepak Heragu wrote: > >> One of the cores might have just allocated irq_desc() and other core >> might be doing irq migration in the hot plug path. In the hot plug >> path >> during the IRQ migration, for_each_active_irq macro is trying to get >> irqs whose bits are set in allocated_irqs bit map but there is no >> return >> value check after irq_to_desc for desc validity. > > Confused. All parts involved, irq allocation/deallocation and the CPU > hotplug code take sparse_irq_lock to prevent exavtly that. > Removing the NULL pointer check and adding this sparse_irq_lock that you suggested will solve this issue. The code looks like this now. Is this okay? diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c index 9409b55..f2ef76e 100644 --- a/kernel/irq/cpuhotplug.c +++ b/kernel/irq/cpuhotplug.c @@ -185,14 +185,10 @@ void irq_migrate_all_off_this_cpu(void) { struct irq_desc *desc; unsigned int irq; - + irq_lock_sparse(); for_each_active_irq(irq) { bool affinity_broken; - desc = irq_to_desc(irq); - if (!desc) - continue; - raw_spin_lock(&desc->lock); affinity_broken = migrate_one_irq(desc); raw_spin_unlock(&desc->lock); @@ -202,6 +198,7 @@ void irq_migrate_all_off_this_cpu(void) irq, smp_processor_id()); } } + irq_unlock_sparse(); } static void irq_restore_affinity_of_irq(struct irq_desc *desc, unsigned int cpu) > Thanks, > > tglx Thanks, Prakruthi Deepak Heragu