Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp675815lqd; Wed, 24 Apr 2024 13:27:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCwQfrhdm5frQZs7L8Z4rwPiKMoBZ8M/+rb5/IMkA8ZqjR24XfVlSsQHKXO2d+gptX0hVm1fI0vjGmf3NqJcuqlmVW57Y2Wo/GPvxAyQ== X-Google-Smtp-Source: AGHT+IH2egJ9eFhFw01WpM3Z8zdLc5g/xoA4F9BSnf5LPcLZdZ9JMKhll2IPhRptniYEBO470RQA X-Received: by 2002:a05:6a21:150a:b0:1a5:bc5d:3c0a with SMTP id nq10-20020a056a21150a00b001a5bc5d3c0amr4734898pzb.61.1713990442359; Wed, 24 Apr 2024 13:27:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713990442; cv=pass; d=google.com; s=arc-20160816; b=odjbfFa1tSsmAAQy7co8KXl+8zRooGpiWiXnP6BF9EMWcZlC7bqMzrWNmTSpGSRyW5 kdpXI0xUOEtw75CgOY5gIn7SAnhI4nf5R2a7nomCVReMzmSfnMN8ql+Z41yDoh1XxwS/ i0k1pNRWDfAKMxeQq/7YaTZR4v1fHxIMGPlNUWbwZFldkxJxgBIgRFAPdEqZsutjLywF yQlqC1gnXm0IX8UyUQwVQ1YgluAAlcY8azGqzcqlX9C4wRoKVGzl0jokVHN3A4whUiKz Olu4inI1jPFU0IZJ1xyVMiFm1m4TiL7IdhNTqONpbHnRoU+tDuVTDpRfmF8ELG09nIlf XaJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=7n5OD7GVj5CfbcvRy5NQoNf4Xal09VkHc+GcS0pq+Qs=; fh=oXUpI9KreLRQb0ZkA0MGVrOEzJh23CiAdTNctIZPNzM=; b=bp+fockhd4DWiy+DAc3xepMEjRIAJygW2zBbCXPzqRHzOy3TLThLZjchrL6jVghfC8 X2yl6AWPhGQOSYokfrHpwmMRcvrFHbhF2syzA3CiiSTBwO3hDRu+xQYf52owB00kz9bd GVDTsEHlTcNnFS5MIpf2K7U3mwlg55eutcCZVXEddkoRnMkjTOIr56PWsSwn2SZmAVJE iyxKGbk2al38DK4/tq2w1zoC0Q+XWJ+43UoXIk5onQ1JMq3kNAcnD1WKw7chyWQuMGVr btheZHhLMZBF2uYaiJaZpu6Q2J7zkn6fGp2cWOZ99PYKTIp8vKuyapsF1gOny+d0jcv4 ucag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XzOnwIwW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-157647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f5-20020a056a00238500b006ed0b798f56si12007492pfc.48.2024.04.24.13.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 13:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XzOnwIwW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-157647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 72907B28057 for ; Wed, 24 Apr 2024 20:04:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25294143860; Wed, 24 Apr 2024 20:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XzOnwIwW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="08HiiVdH" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4779F1BF37; Wed, 24 Apr 2024 20:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713989053; cv=none; b=cMhQjNBJ1/UTiTR6ELsKC7hPWyJR7pI3WgrVspVSPLDJtkY0gjVjSgRZJEHUriZ+mhblF/qgUQ9TJ9LybucBI0v8N9wb+zUb2NqxTNqn4kk0YDDYB6BdVU32P/u3wT+BHHbgSkmZWKEVYrtqtiCHJRNuE0p/jUxtrhLqU4VlM5Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713989053; c=relaxed/simple; bh=w94XIBk0DaKqMjDZ0Eyy69eu2Ki6DxY5h6cahh+IEZw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=pU+M8jtMSfY/jHEqqOq1tfmbSOaifSKu7iASJHrX8bxCWSU7MVGRLcye8VkQjSnNa74ut/PuKW3YzGPf35kmUSzzsWklQgTc6v/HvrbqE8Gp5jej3t2fUQPJlXzvPXnA1EtmPlcYKirfojBYRqeMsvkEYOCTK9gLova06wiN5zE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XzOnwIwW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=08HiiVdH; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Wed, 24 Apr 2024 20:04:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713989047; h=from:from:sender:sender:reply-to: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; bh=7n5OD7GVj5CfbcvRy5NQoNf4Xal09VkHc+GcS0pq+Qs=; b=XzOnwIwWzHZuEIqsxB6HBLWiHiSOWmnVd0D/JPOh2X+z6rMMXeBg1eFn/1iZnqk56ap1L/ /HaY5FDD1mvMRtiyDVg2qrov3ZrHcZF/FuBmA8NBtKYWEgcr9V70wJiOO3vZ07KYltQSSx 3E1NyU3jf/PNf62ZdM5c5HuaWoK+OI77jqTZf9tQdbrnfceuTS5RwoiezXHZazFAfh6vFu +DyXSc4/gkTyo0TD0VWTys7ZrJ7AMWW1+Wqt7HFb9ziut+3XgNt3oDJr8pMCwSBMUiDSdN 42rA/fDLCYsOOKr9geRSI3SDKfXxCQAQ24FQX+blJSpJ6FLE+v8QShXGO7hX9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713989047; h=from:from:sender:sender:reply-to: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; bh=7n5OD7GVj5CfbcvRy5NQoNf4Xal09VkHc+GcS0pq+Qs=; b=08HiiVdH2lW4xB8spzUuN8zqhXaLwrYJZRYR/3W2w5KBoxxSTTO2wuNcJS0JUB7xgilBjg JEnjeq6Ez5aDMoCw== From: "tip-bot2 for Dawei Li" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/gic-v3-its: Avoid explicit cpumask allocation on stack Cc: Dawei Li , Thomas Gleixner , Marc Zyngier , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240416085454.3547175-4-dawei.li@shingroup.cn> References: <20240416085454.3547175-4-dawei.li@shingroup.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171398904698.10875.9923984308673388567.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the irq/core branch of tip: Commit-ID: fcb8af4cbcd122e33ceeadd347b8866d32035af7 Gitweb: https://git.kernel.org/tip/fcb8af4cbcd122e33ceeadd347b8866d32035af7 Author: Dawei Li AuthorDate: Tue, 16 Apr 2024 16:54:50 +08:00 Committer: Thomas Gleixner CommitterDate: Wed, 24 Apr 2024 21:23:49 +02:00 irqchip/gic-v3-its: Avoid explicit cpumask allocation on stack In general it's preferable to avoid placing cpumasks on the stack, as for large values of NR_CPUS these can consume significant amounts of stack space and make stack overflows more likely. Remove cpumask var on stack and use cpumask_any_and() to address it. Signed-off-by: Dawei Li Signed-off-by: Thomas Gleixner Reviewed-by: Marc Zyngier Link: https://lore.kernel.org/r/20240416085454.3547175-4-dawei.li@shingroup.cn --- drivers/irqchip/irq-gic-v3-its.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fca888b..20f9542 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3826,9 +3826,9 @@ static int its_vpe_set_affinity(struct irq_data *d, bool force) { struct its_vpe *vpe = irq_data_get_irq_chip_data(d); - struct cpumask common, *table_mask; + unsigned int from, cpu = nr_cpu_ids; + struct cpumask *table_mask; unsigned long flags; - int from, cpu; /* * Changing affinity is mega expensive, so let's be as lazy as @@ -3850,10 +3850,15 @@ static int its_vpe_set_affinity(struct irq_data *d, * If we are offered another CPU in the same GICv4.1 ITS * affinity, pick this one. Otherwise, any CPU will do. */ - if (table_mask && cpumask_and(&common, mask_val, table_mask)) - cpu = cpumask_test_cpu(from, &common) ? from : cpumask_first(&common); - else + if (table_mask) + cpu = cpumask_any_and(mask_val, table_mask); + if (cpu < nr_cpu_ids) { + if (cpumask_test_cpu(from, mask_val) && + cpumask_test_cpu(from, table_mask)) + cpu = from; + } else { cpu = cpumask_first(mask_val); + } if (from == cpu) goto out;