Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1207252pxu; Sat, 24 Oct 2020 04:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhiJFrncYXBNuVYcwj0W23trG2xSGTHziT7BTMvCnTSyztNZm4amV5U0lJEl7QQVmx7aEO X-Received: by 2002:a50:eb45:: with SMTP id z5mr6449177edp.144.1603537267023; Sat, 24 Oct 2020 04:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603537267; cv=none; d=google.com; s=arc-20160816; b=D6A5WMZAn5/HD+wV+zkaRRp+JYJgGMmw95QqbCbw5hvQqu1J6aJRHYq9eMOrcgvawH bsvsDaEqkN9HjW6S6cm3AuelZ0wmjMCPYH9JnmBQetxV/Rg6vAqVh/uPEaBMhmT3E0wF tGryF2qQmZw5Dhwrvw9/FPHOR+UJ8Lljj0uIr1gLrnOwxgUl0jaA+xFQrJv+wL4O//JM SIgHQOMRha4sIutT2Un10HXDIWSHY6RlyhbTjGrQJOl03nuwqFSvPXHPwJm25wYrrEmr hdh6odiPsOxE+B+Q2n9j/eSL8KffgeukKPN1KZBTd68QpkHZEyQFCBGJ0qdcjTNBEGMX 8DLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=G6Z6+HIqSbWO5fJ4UZRSY+czR0y86ALg6HnhXtZO/4w=; b=DnPDUUzCg6M4AEgM0YP3ExmB2e+qwIyGf9ihzEUyxf4ee1tOh7EltJV6M/k6HCzFA0 yqorScnQpiM67RLxe6kA0K8tPXEkgnWVfxllAP4bVTsXZcB1qYF1vaGihVODcaMisJHs f+45XsgX86PAPBiTzRk5tgwJ6GYN/pYsTXaeZiLAtUQd+vgI3P7J0o/fB7Eqh3DWoK1Q j4GeCqrtVIA01FU0s7s8EV+FwGRVN1i+GC6fvXkOOXtQyVuIu9XMQ0LRVyyBWX2LA9V6 K9qcVypoIUnqvM2qvJRu4nQGEB3vZPLWVrVoh43ExqppswCmcZ0v2+cdwvzGxxkiD+87 Bexw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HnHE3LKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si2726090edq.317.2020.10.24.04.00.44; Sat, 24 Oct 2020 04:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HnHE3LKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759395AbgJXDiy (ORCPT + 99 others); Fri, 23 Oct 2020 23:38:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:46604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759389AbgJXDiy (ORCPT ); Fri, 23 Oct 2020 23:38:54 -0400 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08096223EA for ; Sat, 24 Oct 2020 03:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603510733; bh=YMEvV6dcm7AXyyY8ChedIM35amwdXFyfa+CzZQS9MyQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HnHE3LKNsDzMMu0iWImTJUna+X9HmmVJG1IjwvSTCLQj3XaPgwExLsX+glRnjcLQ9 bV4YUPoQXKICOdHSjxa/TSx1Yp1c+gNz1+p4ZN1D4c/Aa8yyshyZFKC2cxqyfttWSX kKnXCTsYHRn7zUj27u0yw48XhIcC6bQfYGGCxSj4= Received: by mail-lj1-f179.google.com with SMTP id d24so3651288ljg.10 for ; Fri, 23 Oct 2020 20:38:52 -0700 (PDT) X-Gm-Message-State: AOAM533o9/VEaDdG6rnj+8M8WA2tIDqITjXJ3+wxn6+Et5iGxXvVDLa5 6y6GlUvzW3SlRCyE/Ya85TO39LYTsUfot9fl8MU= X-Received: by 2002:a2e:85c4:: with SMTP id h4mr1842690ljj.250.1603510731255; Fri, 23 Oct 2020 20:38:51 -0700 (PDT) MIME-Version: 1.0 References: <1603448245-79429-1-git-send-email-guoren@kernel.org> <1603448245-79429-2-git-send-email-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Sat, 24 Oct 2020 11:38:40 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] irqchip/irq-sifive-plic: Fixup couldn't broadcast to multi CPUs To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Greentime Hu , Zong Li , Atish Patra , Thomas Gleixner , Jason Cooper , Marc Zyngier , wesley@sifive.com, Yash Shah , Christoph Hellwig , linux-riscv , "linux-kernel@vger.kernel.org List" , Guo Ren Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 23, 2020 at 8:17 PM Anup Patel wrote: > > On Fri, Oct 23, 2020 at 3:48 PM wrote: > > > > From: Guo Ren > > > > If "echo 3 > /proc/irq/1/smp_affinity", we want irq 1 could be > > broadcast to CPU0 & CPU1 and one of them would pick up the irq > > handler. > > > > But current implementation couldn't let multi CPUs process the > > same IRQ concurrent. > > > > Signed-off-by: Guo Ren > > --- > > drivers/irqchip/irq-sifive-plic.c | 23 ++++++----------------- > > 1 file changed, 6 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c > > index 2e56576..0003322 100644 > > --- a/drivers/irqchip/irq-sifive-plic.c > > +++ b/drivers/irqchip/irq-sifive-plic.c > > @@ -114,15 +114,12 @@ static inline void plic_irq_toggle(const struct cpumask *mask, > > static void plic_irq_unmask(struct irq_data *d) > > { > > struct cpumask amask; > > - unsigned int cpu; > > struct plic_priv *priv = irq_get_chip_data(d->irq); > > > > cpumask_and(&amask, &priv->lmask, cpu_online_mask); > > - cpu = cpumask_any_and(irq_data_get_affinity_mask(d), > > - &amask); > > - if (WARN_ON_ONCE(cpu >= nr_cpu_ids)) > > - return; > > - plic_irq_toggle(cpumask_of(cpu), d, 1); > > + cpumask_and(&amask, &amask, irq_data_get_affinity_mask(d)); > > + > > + plic_irq_toggle(&amask, d, 1); > > } > > > > static void plic_irq_mask(struct irq_data *d) > > @@ -136,24 +133,16 @@ static void plic_irq_mask(struct irq_data *d) > > static int plic_set_affinity(struct irq_data *d, > > const struct cpumask *mask_val, bool force) > > { > > - unsigned int cpu; > > struct cpumask amask; > > struct plic_priv *priv = irq_get_chip_data(d->irq); > > > > cpumask_and(&amask, &priv->lmask, mask_val); > > + cpumask_and(&amask, &amask, cpu_online_mask); > > > > - if (force) > > - cpu = cpumask_first(&amask); > > - else > > - cpu = cpumask_any_and(&amask, cpu_online_mask); > > - > > - if (cpu >= nr_cpu_ids) > > - return -EINVAL; > > + irq_data_update_effective_affinity(d, &amask); > > > > plic_irq_toggle(&priv->lmask, d, 0); > > - plic_irq_toggle(cpumask_of(cpu), d, 1); > > - > > - irq_data_update_effective_affinity(d, cpumask_of(cpu)); > > + plic_irq_toggle(&amask, d, 1); > > > > return IRQ_SET_MASK_OK_DONE; > > } > > -- > > 2.7.4 > > > > In the past, a similar patch was proposed by Zong Li (SiFive). We > have good reasons to not allow multiple CPUs handle the same IRQ. > > Refer, https://lkml.org/lkml/2020/4/26/201 > > NACK from my side. Thx for sharing the information, I agree with Zong Li & Greentime's aspect: Don't limit the usage of PLIC! We could let (one hart -> one irq) as default. I also agree that using irq broadcast indiscriminately can cause performance problems. (Anup and Mark Z's view) I think you've discussed enough at that time and l won't persist the patch. -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/