From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A701D2C56B for ; Tue, 22 Oct 2024 15:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8jH1VGIEiF8MkQeq8fWyVOk3Ng5z7UQqjPzeTHAhPvw=; b=Z02kstaJdsym13ICn+J0wkEGXM Qfjcsja4T6K4eTeJs6l9zpAuWyOTVml3gWjN1bEit7ErAvZ5/Tswvn51V95xN+IiAy6x3Phqqob0M Hf7Fs9RaF+WiMMJE4Z9FmpyTCMhboh1kLrLnojoaCCwwoIWSfhajNFdWav8xJ9PYIOordO7M2Tqn7 nrzYznumDiv80FwdL1IjKkb95McQ9byCVPOfKFiJfeD6uky6lfv9EKmSZugoXdEMsLLn/2xe6Dh4c qgs2Z0Bhjk+SITSKJuztJnTZCGu6UutbAlzcm2LmA/GKFCMVXgRb2mROTDkp/8l2ETqg2pAwrHSsW UhxJn/rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3GXq-0000000BDKy-3Zxd; Tue, 22 Oct 2024 15:11:38 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t3GQ2-0000000BC3x-421n for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 15:03:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E65E85C5D7C; Tue, 22 Oct 2024 15:03:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 155D9C4CEC3; Tue, 22 Oct 2024 15:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729609414; bh=EXIbBWpPxQgw5OS+2NNlvlI+XZ4mQxYPcta2uTuFDik=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jr+fK39jEPMv8GhnVtleuXBvliCGw2V3l9S84b9y2yRSr35+23AgavMlOle1NFKYz xfEYB5EaMmz5x5nQoQf7aAZ/rteed4MiNfuG0ZHcukw36mL+m8Y3qyPwoWxU4FbIn2 kIwzROGLUkrVqEk7G7b6CiREo8J8MxcHnlM9F+0q/fWrFIwEcy67LYnSMyhzqB5txm DKwtkezNDgvByrivnNRYSfjLjabFTa5PS5o802h7epDAtZXIJvG8dBmcBJuklFisGM SaS8iiEY6aOJP/w/vSuZ9x44D5NBS/wLdqhDV4dG9o+twZ8zxkHSLKYChLL9sYVVEY 6xGoU9ELfBTtQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t3GPy-005ocD-RP; Tue, 22 Oct 2024 16:03:31 +0100 Date: Tue, 22 Oct 2024 16:03:30 +0100 Message-ID: <86a5ew41tp.wl-maz@kernel.org> From: Marc Zyngier To: Yu Zhao Cc: Andrew Morton , Catalin Marinas , Muchun Song , Thomas Gleixner , Will Deacon , Douglas Anderson , Mark Rutland , Nanyong Sun , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 3/6] irqchip/gic-v3: support SGI broadcast In-Reply-To: <20241021042218.746659-4-yuzhao@google.com> References: <20241021042218.746659-1-yuzhao@google.com> <20241021042218.746659-4-yuzhao@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yuzhao@google.com, akpm@linux-foundation.org, catalin.marinas@arm.com, muchun.song@linux.dev, tglx@linutronix.de, will@kernel.org, dianders@chromium.org, mark.rutland@arm.com, sunnanyong@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241022_080335_112191_25035173 X-CRM114-Status: GOOD ( 27.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 21 Oct 2024 05:22:15 +0100, Yu Zhao wrote: > > GIC v3 and later support SGI broadcast, i.e., the mode that routes > interrupts to all PEs in the system excluding the local CPU. > > Supporting this mode can avoid looping through all the remote CPUs > when broadcasting SGIs, especially for systems with 200+ CPUs. The > performance improvement can be measured with the rest of this series > booted with "hugetlb_free_vmemmap=on irqchip.gicv3_pseudo_nmi=1": > > cd /sys/kernel/mm/hugepages/ > echo 600 >hugepages-1048576kB/nr_hugepages > echo 2048kB >hugepages-1048576kB/demote_size > perf record -g -- bash -c "echo 600 >hugepages-1048576kB/demote" > > gic_ipi_send_mask() bash sys time > Before: 38.14% 0m10.513s > After: 0.20% 0m5.132s > > Signed-off-by: Yu Zhao > --- > drivers/irqchip/irq-gic-v3.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index ce87205e3e82..42c39385e1b9 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -1394,9 +1394,20 @@ static void gic_send_sgi(u64 cluster_id, u16 tlist, unsigned int irq) > gic_write_sgi1r(val); > } > > +static void gic_broadcast_sgi(unsigned int irq) > +{ > + u64 val; > + > + val = BIT(ICC_SGI1R_IRQ_ROUTING_MODE_BIT) | (irq << ICC_SGI1R_SGI_ID_SHIFT); As picked up by the test bot, please fix the 32bit build. > + > + pr_devel("CPU %d: broadcasting SGI %u\n", smp_processor_id(), irq); > + gic_write_sgi1r(val); > +} > + > static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) > { > int cpu; > + cpumask_t broadcast; > > if (WARN_ON(d->hwirq >= 16)) > return; > @@ -1407,6 +1418,13 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) > */ > dsb(ishst); > > + cpumask_copy(&broadcast, cpu_present_mask); Why cpu_present_mask? I'd expect that cpu_online_mask should be the correct mask to use -- we don't IPI offline CPUs, in general. > + cpumask_clear_cpu(smp_processor_id(), &broadcast); > + if (cpumask_equal(&broadcast, mask)) { > + gic_broadcast_sgi(d->hwirq); > + goto done; > + } So the (valid) case where you would IPI *everyone* is not handled as a fast path? That seems a missed opportunity. This also seem an like expensive way to do it. How about something like: int mcnt = cpumask_weight(mask); int ocnt = cpumask_weight(cpu_online_mask); if (mcnt == ocnt) { /* Broadcast to all CPUs including self */ } else if (mcnt == (ocnt - 1) && !cpumask_test_cpu(smp_processor_id(), mask)) { /* Broadcast to all but self */ } which avoids the copy+update_full compare. Thanks, M. -- Without deviation from the norm, progress is not possible.