Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4500497pxb; Tue, 25 Jan 2022 11:43:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIgfU2iRT0ExZXmg3XMhhQId7/hN/cIiEWl3F+YrY7J4cI8h1ly7nIheCUUeD5VR7zY+Gh X-Received: by 2002:a17:902:e804:b0:14b:4ae9:1b4f with SMTP id u4-20020a170902e80400b0014b4ae91b4fmr11325018plg.20.1643139799885; Tue, 25 Jan 2022 11:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643139799; cv=none; d=google.com; s=arc-20160816; b=ZvMV/UW2AQf3fl4HwVobjFO6DWAQVTovkCU03febTIxpr4DVfGOd3JmeBrdECXDY77 +WsOkawai9u/AfxR+iSs9S79Jc3DHJmm4ufCypkUkU7RwLmJoZ/xeNfnNf7JKy2yMbUg 0axEmymcUa5yVNu9+LTRC1CJly4s7fAlW80Lxc/+sohrgruM5A0/vfM0lJvFqBMoYpgf vAPsAv6MH2nbgZUgdujoH6atOvR5UPMbx8QM7PyfX+v09BYzvT12HIQQL9RdSf3HyqgI rga0S3rcp538MNdeUZpN908Y5EfAZ8n4IpH7AiPv9TImB56kTgbzeh5EW/JIHaXevC4A pp3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=dOS25TKw6n71gIGPSITHggzZTZ40qS4KyoJADB/fI5M=; b=h3at+ailbQu/+W8/I3tO+f1Tf8o9WgiDxkTM5KCJ1fUpGYIVoly9zGMErhRf7N6z9u cJJKe7DzQs65lNpQdMYRUCVvz0J93eEXj1cwFeFKeVReMb1BZQ8lQByN1WKTUzmSvDRA swjhgogif5w7v0uxfy7kpFoEEgICMl1XjiG9qjoaz6sBVjOx+CNSPKIAQn8Agasrjdi8 y/50cyeRV3HWPb/KT5/Loqn6kG349h61MxG/RafClieZy9NMHZGfmr2SWC4S8bXui7WN c5xjeS1xIq5TfQLoc7WK0cAt2xb4ml23yzRmJ7YH0Z8gbWsR4ooRUezbD/LXBdhBqlqD EP8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kC2Xu95k; 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 c23si10439964pgl.253.2022.01.25.11.42.59; Tue, 25 Jan 2022 11:43:19 -0800 (PST) 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=k20201202 header.b=kC2Xu95k; 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 S245635AbiAYNe3 (ORCPT + 99 others); Tue, 25 Jan 2022 08:34:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381875AbiAYNbq (ORCPT ); Tue, 25 Jan 2022 08:31:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA780C061401 for ; Tue, 25 Jan 2022 05:31:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A2A73B81808 for ; Tue, 25 Jan 2022 13:31:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57BFFC340E0; Tue, 25 Jan 2022 13:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643117500; bh=VFFdhBpsOtOA9gLsN7npiOLz+ztAhun2ZxBpU+Q5C64=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kC2Xu95kvANS/QX2cmpTb2ymReoAJy0TIn8BhL+cSLQmbNUu7Ug5q9QvMNLV/ttix Gg3LEhnG9TraPICGKuAQUMDeXVsFgQGpq/0v9UfGvFjn3zvF27JPAGxf3/fvPisbWK 5KPywb2bwEXeWcYd4welhKPUfFpP8ridVFWk9PM+Hk+/0CYLQLmqmTO/gj887LI45D nT4E5Qg/656ewOFWjfXjzO7El5UxbJlrnphj6Zrcezre3zmtlIixFOfjd3WgJMvTCI x8G+Okb7nq5Gba33paDMkYJzs2c65ZXh8rRk+0QALBhStNNAq7skPsxJ7iV7YjbPlp a3PDNNbLv/bmw== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nCLv8-002uqs-C5; Tue, 25 Jan 2022 13:31:38 +0000 Date: Tue, 25 Jan 2022 13:31:38 +0000 Message-ID: <87sftc6ix1.wl-maz@kernel.org> From: Marc Zyngier To: Xiongfeng Wang Cc: , , , John Garry Subject: Re: [PATCH] irqchip/gic-v3-its: Select housekeeping CPUs preferentially for managed IRQs In-Reply-To: <12ac7447-34dc-8497-b608-ada5a2ba17c4@huawei.com> References: <20220124073440.88598-1-wangxiongfeng2@huawei.com> <87a6fl8jgb.wl-maz@kernel.org> <12ac7447-34dc-8497-b608-ada5a2ba17c4@huawei.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/27.1 (x86_64-pc-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: wangxiongfeng2@huawei.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, guohanjun@huawei.com, john.garry@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Jan 2022 12:49:20 +0000, Xiongfeng Wang wrote: > > Hi Marc, > > On 2022/1/24 19:24, Marc Zyngier wrote: > > + John Garry, as he was reporting issues around the same piece of code[1] > > > > On Mon, 24 Jan 2022 07:34:40 +0000, > > Xiongfeng Wang wrote: > >> > >> When using kernel parameter 'isolcpus=managed_irq,xxxx' to bind the > >> managed IRQs to housekeeping CPUs, the effective_affinity sometimes > >> still contains the non-housekeeping CPUs. > >> > >> irq_do_set_affinity() passes the housekeeping cpumask to > >> chip->irq_set_affinity(), but ITS driver select CPU according to > >> irq_common_data->affinity. While 'irq_common_data->affinity' is updated > >> after chip->irq_set_affinity() is called in irq_do_set_affinity(). Also > >> 'irq_common_data->affinity' may contains non-housekeeping CPUs. I found > >> the below link explaining the reason. > >> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2267032.html > >> > >> To modify CPU selecting logic to prefer housekeeping CPUs, select CPU > >> from the input cpumask parameter first. If none of it is online, then > >> select CPU from 'irq_common_data->affinity'. > >> > >> Signed-off-by: Xiongfeng Wang > >> --- > >> drivers/irqchip/irq-gic-v3-its.c | 5 ++++- > >> 1 file changed, 4 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > >> index d25b7a864bbb..17c15d3b2784 100644 > >> --- a/drivers/irqchip/irq-gic-v3-its.c > >> +++ b/drivers/irqchip/irq-gic-v3-its.c > >> @@ -1624,7 +1624,10 @@ static int its_select_cpu(struct irq_data *d, > >> > >> cpu = cpumask_pick_least_loaded(d, tmpmask); > >> } else { > >> - cpumask_and(tmpmask, irq_data_get_affinity_mask(d), cpu_online_mask); > >> + cpumask_and(tmpmask, aff_mask, cpu_online_mask); > >> + if (cpumask_empty(tmpmask)) > >> + cpumask_and(tmpmask, irq_data_get_affinity_mask(d), > >> + cpu_online_mask); > > > > I think that the online_cpu_mask logical and is a bit wrong. A managed > > interrupt should be able to target an offline CPU: > > > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > > index eb0882d15366..0cea46bdaf99 100644 > > --- a/drivers/irqchip/irq-gic-v3-its.c > > +++ b/drivers/irqchip/irq-gic-v3-its.c > > @@ -1620,7 +1620,7 @@ static int its_select_cpu(struct irq_data *d, > > > > cpu = cpumask_pick_least_loaded(d, tmpmask); > > } else { > > - cpumask_and(tmpmask, irq_data_get_affinity_mask(d), cpu_online_mask); > > + cpumask_copy(tmpmask, aff_mask); > > > > /* If we cannot cross sockets, limit the search to that node */ > > if ((its_dev->its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) && > > I have tested the above modification with 'maxcpus=1' kernel parameter and got > the following CallTrace. > > [ 14.679493][ T5] pstate: 204000c9 (nzCv daIF +PAN -UAO -TCO -DIT -SSBS > BTYPE=--) > [ 14.687114][ T5] pc : lpi_update_config+0xe0/0x300 > [ 14.692146][ T5] lr : lpi_update_config+0x3c/0x300 That's a problem similar to what John was seeing: the CPU isn't there, and a lot of stuff goes very wrong in the absence of a CPU targeted by a managed interrupt. > > We still have an issue when the system hasn't booted with all its > > CPUs, as the corresponding collections aren't initialised and we > > end-up in a rather bad place. > > Shall we fix this 'effective CPU of managed IRQs is not housekeeping > CPU' issue first, or we will wait until the 'maxcpus=1' issue is > fixed. I this we need to address this first. There is no point in only half fixing it. Thanks, M. -- Without deviation from the norm, progress is not possible.