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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29319D149C1 for ; Fri, 25 Oct 2024 16:15:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B6326B0082; Fri, 25 Oct 2024 12:15:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9660B6B0083; Fri, 25 Oct 2024 12:15:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 805DA6B0085; Fri, 25 Oct 2024 12:15:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 631E66B0082 for ; Fri, 25 Oct 2024 12:15:05 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 59039120D37 for ; Fri, 25 Oct 2024 16:14:47 +0000 (UTC) X-FDA: 82712622426.20.225A337 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf25.hostedemail.com (Postfix) with ESMTP id 1A67AA000A for ; Fri, 25 Oct 2024 16:14:48 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ere1JOuJ; spf=pass (imf25.hostedemail.com: domain of maz@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=maz@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729872850; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZPD02BSGkv8ElGifQ8Bj9gaTeEhmbG3yYd68KWp/xDo=; b=YQzJB4vCKd1Dp2auYAJnq5mYyUzTOM63C74MdLSIhA3HQbPEaM0rPomeBM+TWKTPCe0qLR e2hTulia0Nj4/VOV34+GGPjur6aAN/QwR9CSlGSO2xkKj6enusfIBP419eff+J6zRkHcBb k82Z9Kzd8nawCteg+sICTX0vlMGkyF8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ere1JOuJ; spf=pass (imf25.hostedemail.com: domain of maz@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=maz@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729872850; a=rsa-sha256; cv=none; b=SOAAqZ8pnTyfFI2Jx1MvDaFTfvVT3X8bMX7/7/GuFmX44Cm1OBHxu4guLVjvYnxrVUMBza f3BKf3Z50LPKKqjmox4EcxAh0UWF7ml+G+RyRqeQ+8s+8L+W5SlXMCL2Xr3q3YuoqmAN+2 D77IMH38fY38C7SYAmCmUVmNavWcgZg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 54BC7A42F99; Fri, 25 Oct 2024 16:13:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E1C5C4CEC3; Fri, 25 Oct 2024 16:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729872901; bh=xauMgPi9VccclOak+q41k9wam+BeYz0R/HH/+WYNJ20=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ere1JOuJ0Cp0k43C9N+4F8AYElMcYXchbYav/fwlMx9L7Y+J1U0x7ypS3IRS9iOhw /B5XgAhfBHrbG+JY5zrrgWasaga0EU+isSHt0Lk0cPbGeN/bnGGmEDbTPNdB4SFfXw e05ZLxWX2I5HTH9yBLkF94dnnuOaHAlJdqrTt/hlR60AgxwGID6/1AWm1amwT0ubT/ 4x70261adP4tZntRLMYiGe6qScpk+qUl2+M+RUgFzxbw9jI/7zaStmTu+Qx3WfqCvg sq9FwIXdsksXZpQ0dgvSNlcHUtkMzWiR9ICqP687M1/VwwTMPAecqFVyDMTP7aDk8p vbpAPCxkOvF4w== 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 1t4Mxm-006qyI-Uv; Fri, 25 Oct 2024 17:14:59 +0100 Date: Fri, 25 Oct 2024 17:14:57 +0100 Message-ID: <86h6902m7y.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: References: <20241021042218.746659-1-yuzhao@google.com> <20241021042218.746659-4-yuzhao@google.com> <86a5ew41tp.wl-maz@kernel.org> 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=UTF-8 Content-Transfer-Encoding: quoted-printable 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-Rspam-User: X-Stat-Signature: wpad1hhjye91qdig1fogett9h1typ3kt X-Rspamd-Queue-Id: 1A67AA000A X-Rspamd-Server: rspam11 X-HE-Tag: 1729872888-460501 X-HE-Meta: U2FsdGVkX18exFdRh730++yOeCgx8gbVM90Y8aiNpZeWZJsPHekdZud4gXO0UfCOUOvf1MuuBXVUw8eT9swgCfPZOoLPp86POuJdgXvOJYr3PRY9wILLyfaHNRDOv530LvBReRUwIUelzusqf78KKe6TS7rp73tx7MvUnaGn1mGOPuwBRbnkSw0c+1m6Xg9AKSiHtL1q+7r132fPye3Eaj7MgEQyQxPo1et4bcoKErLiHyUMHOBu37zXzjlwYjl29SeE+SNJ+D2IgpjkwDhViVeaOS7tz/aNmU9aPFKbHypVCInjWmdIZh/FJaNcwivqyOZ/NnAznr9jvwDgGsSlU8GLUCTmScnt7RJHo2BJI/ewpAWUy88inkrFsNNM53MBIC2RqCq91PKc1YYB7zAJMnMmgi0iPXi5SogUttlKDfWNjFbfDtAKfOnGfPWF36SCIqgRmagYvmXY1nWfpGuwtyBisha977wq6RIpFQnDOoqFcbjT2cSAuDf8+nAJMbBa88LpgYhieUyk5KbthSwt/PSjZ97OnSkT4iG5kh1wCFpFh3v8d6RTI/JhEvuCzwPCWSR5X5EIWqqM/hp9g3i1arLJYZrANU9aq4YbB+MimInSRSij3M3+qiVbLrBP8f0u4ou98NEbOMqs9+PUTQeNgDTZmOWcq499Ay2XppE/92prEk06IO97VzwE75kMwdE176ge/M6iPonF5GTpeIIzgEuhLv64GmS/pJUMlEzUC9PNdH+GIcD8P95k09yDAgHD4zqlnq68Kq2tB6zWW9y7F+s4qfWRwu6aXYjVmu+zGYMB1e7hj92Tk+GLjMu7vXNdABcYMsVL7p+eWRXgdi1JqNQpL5NWOJoAJAdQaa1eJqShW8Ee4V19ar3EQYr1aDRgYYdEKsz/g4pj8gr0p7B3zlYCkIzVonZPRAAyRkDWEALi9geJOlekjABCq5gaSb9tZJA0RhXAokMXgq1+E1n BlL/+uVD I3MEpeLsoetag/3z5ou365XEz413rLf1YV791/P9EwkyO38T8/YQ21Iyr0Xksxcsn6URncVvzHnigWMxv9A+DrHKvMzjpYSPyrR8tSqOKApCAeE+X2+HYYTomDobD3i9V/VgTR5Jjiyg0+bkJH0LSfv2vDlHRHoZix2RV3cgHUBu97WoV63Ym0YUfqMD+R+YCDDq6PYxmT0OJnPl6CiY8kcR5PDwyV9oRskDXDYh72nHgpVS33KAqNiLNyi4FhbWQWUAXIMh1V62bo0g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, 25 Oct 2024 06:07:45 +0100, Yu Zhao wrote: >=20 > Hi Marc, >=20 > On Tue, Oct 22, 2024 at 9:03=E2=80=AFAM Marc Zyngier wro= te: > > > > On Mon, 21 Oct 2024 05:22:15 +0100, > > Yu Zhao wrote: > > > > > > @@ -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. >=20 > This is exactly because "we don't IPI offline CPUs, in general", > assuming "we" means the kernel, not GIC. >=20 > My interpretation of what the GIC spec says ("0b1: Interrupts routed > to all PEs in the system, excluding self") is that it broadcasts IPIs to > "cpu_present_mask" (minus the local one). So if the kernel uses > "cpu_online_mask" here, GIC would send IPIs to offline CPUs > (cpu_present_mask ^ cpu_online_mask), which I don't know whether it's > a defined behavior. Offline CPUs are not known to the kernel. Most likely, they are either powered off, or spending quality time in Secure or Realm mode. Either way, this is none of our business. Your approach would make also the kernel perform pretty inconsistently depending on whether CPUs are offline and not. >=20 > But if you actually meant GIC doesn't IPI offline CPUs, then yes, here > the kernel should use "cpu_online_mask". >=20 > > > + 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. >=20 > You are right: it should handle that case. >=20 > > This also seem an like expensive way to do it. How about something > > like: > > > > int mcnt =3D cpumask_weight(mask); > > int ocnt =3D cpumask_weight(cpu_online_mask); > > if (mcnt =3D=3D ocnt) { > > /* Broadcast to all CPUs including self */ >=20 > Does the comment mean the following two steps? > 1. Broadcasting to everyone else. > 2. Sending to self. Correct. > My understanding of the "Interrupt Routing Mode" is that it can't > broadcast to all CPUs including self, and therefore we need the above > two steps, which still can be a lot faster. Is my understanding > correct? Yes. Thanks, M. --=20 Without deviation from the norm, progress is not possible.