From nobody Thu Oct 30 22:42:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1760599905; cv=none; d=zohomail.com; s=zohoarc; b=aQQkd3EW1ibHp0XwOjVejB8+0Rbk8XFkMeMrP4bA8+lgYEdJfUHBkUVe2oxcH5zICM7wcn7zUea1m2fD2vLIOTGnxCVXWy6jF3Rwqla6ef8k6DemX3+TITiYjUEkQoDQVBstVH3QPew2AZwXItkYROGglQ6LXky4S013Fvh5rOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760599905; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dY/Gq5Ca3KZa4aryi+C7Ydf3Q3EvvsHfYx82DOTDz1w=; b=ZBdAS4t6yJ9CwFQpC4pSOsT+ZjlI4mcZKcbArQjbsIOMgkKw+svklKpcE2bnY4lWgg6/6LlpnIesOi1K+y1BRr2/7xLvxpVfvd6Zk26++Ahap0KG0gnRHnreoDPDqL5u1VGlZwhZXsUQ2n5jfgQM54MstslXpmRusbwoj0tOcE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1760599905390981.1320050603604; Thu, 16 Oct 2025 00:31:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1144162.1477613 (Exim 4.92) (envelope-from ) id 1v9ISL-00070W-W4; Thu, 16 Oct 2025 07:31:25 +0000 Received: by outflank-mailman (output) from mailman id 1144162.1477613; Thu, 16 Oct 2025 07:31:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v9ISL-00070P-TJ; Thu, 16 Oct 2025 07:31:25 +0000 Received: by outflank-mailman (input) for mailman id 1144162; Thu, 16 Oct 2025 07:31:24 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v9ISK-0006tj-Jb for xen-devel@lists.xenproject.org; Thu, 16 Oct 2025 07:31:24 +0000 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [2a00:1450:4864:20::42e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1dd27ae8-aa62-11f0-9d15-b5c5bf9af7f9; Thu, 16 Oct 2025 09:31:23 +0200 (CEST) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-426fd62bfeaso144221f8f.2 for ; Thu, 16 Oct 2025 00:31:23 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426f2f72e18sm11779917f8f.0.2025.10.16.00.31.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Oct 2025 00:31:22 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1dd27ae8-aa62-11f0-9d15-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1760599883; x=1761204683; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=dY/Gq5Ca3KZa4aryi+C7Ydf3Q3EvvsHfYx82DOTDz1w=; b=IMRw0g97ZdxLoVXJthlygda/RGvgHGuSGCN33c6A7LzmmeNG+hpGqiY/LMANv+kz6X J7/DU2pZuk6kg/n8c+HfY5HvHRtAieGCKbTCz2MvQDhKO1406y20vPy+/FQD7C5oNxM5 j50coT2bMhdZrVrI6qtjEwqcD9756Sik53Lf3GZPhHeBiUVVllMhpe75FT0/I3xowXe+ lznlBkMy+LWukn+XLEYVujchKtv8iUf2pZHQRI095iZA1rFkBq7+JKhtPzc2dEM/d535 +QrLxV5cr7tzOdbjuoyjosClVTlZXvmuuSWzaJj0IEPqzMrmOU7UH06adXnlfc6cr6b0 L9UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760599883; x=1761204683; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dY/Gq5Ca3KZa4aryi+C7Ydf3Q3EvvsHfYx82DOTDz1w=; b=tXk45a3MxMeYTDinMf6EUgRhl3x20j+iHr9XVlqzC9vbsb36s/7lvMk81YQS5OFIbj 6ZYaEkr/uWqLVpQ9vzDTmngpD9Wf+EJDGtIY0c7BEqZdCPZfW5+o1BUQNo1D2TPaHxLZ qvdzk52jhqhGKYJGbpRu79ZveGEog0bxsZTL49H/kKDY9aBTnYo9F7Wi17bhxFuauoKJ 0nHQyL04a12KRTjLfW/4GBWFAoUrBCz9/1/M5dJZJvT7r3jXGhi+MvR2DyneEDCjYPS5 /iH5Sq9sWZPwf/pbIaYypSJOQRLumKUjj9DT0Mx5w4LjWZ8uQACc5CLoGXnLVz65zJe0 YsAA== X-Gm-Message-State: AOJu0YzdVmLbblgWedhl4hcsUTqMPbVddw5jcGPouG6KaPw2v83WyUey RF0nfFI0FpW/TPdYiLWtqJ+qCzmGlAZKfNvtQmAlhzivRZSgfQ7+FvWLTxGQUqaPzKEjrjG0l3N o4Ys= X-Gm-Gg: ASbGncu/g8ANVJe/KPT9nfZ0wZ5BxXNii10E8wL1x6vDr6fkIRc7FMGSJSSJEmokCDV gUcQdeBerWtVTqSrDY7WWUWfbsKHYiOZsw3RoWGFymfp+rNp0XaLnPezVsVB/d+MeFm2TwZSXVv FIlDRTKYhrycId/9YJcXPZkm0HznPBdaUG0uhMjRBUSrBt52vQy5Cfb6BSUSd2ir5A+B4mTVXEV 9WpEwEsvs3lqe+ModxaWFGce6zsKC5rMCmfCs1YUlWKblZJXEtHNRrCesRi0H17ExBl/r6mDUZm CuhKFXRhjhI6myRnw8xNcbWN540zECEk1j/KvkldmakKR1sfTYSusbJMESR4GxHAovCa80+UzZa 75yX7AYrmdCeczcwbUJeGpPvKefyUi+hyd/tOADKDNHetDSmJgAtS1Y+1acWwN5esbdH/2RI+Li udnwpxvkUssk4x4CHiiJZRjM4qcbuJ2zvQAM7o/Q35+31b9WQmo8hgMctDQf4n X-Google-Smtp-Source: AGHT+IHusol4E14t4qvwqiu7du/3b194OHhB5uz8RBbu13+RjRqjAV2KzamIIX4rbL8gRfSxkQqZig== X-Received: by 2002:a5d:5f93:0:b0:3ec:2ef7:2134 with SMTP id ffacd0b85a97d-42667177df1mr17192465f8f.18.1760599882842; Thu, 16 Oct 2025 00:31:22 -0700 (PDT) Message-ID: <494c897c-a138-4d16-93b2-67e3aa8d41e7@suse.com> Date: Thu, 16 Oct 2025 09:31:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.21 01/10] x86/HPET: limit channel changes From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Oleksii Kurochko References: <8d94abf8-70d1-478c-885e-ff9a960ac72d@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <8d94abf8-70d1-478c-885e-ff9a960ac72d@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1760599906736158500 Content-Type: text/plain; charset="utf-8" Despite 1db7829e5657 ("x86/hpet: do local APIC EOI after interrupt processing") we can still observe nested invocations of hpet_interrupt_handler(). This is, afaict, a result of previously used channels retaining their IRQ affinity until some other CPU re-uses them. Such nesting is increasingly problematic with higher CPU counts, as both handle_hpet_broadcast() and cpumask_raise_softirq() have a cpumask_t local variable. IOW already a single level of nesting may require more stack space (2 times above 4k) than we have available (8k), when NR_CPUS=3D16383 (the maximum value presently possible). Signed-off-by: Jan Beulich --- Whether this is still worthwhile with "x86/HPET: use single, global, low- priority vector for broadcast IRQ" isn't quite clear to me. --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -442,6 +442,8 @@ static void __init hpet_fsb_cap_lookup(v num_hpets_used, num_chs); } =20 +static DEFINE_PER_CPU(struct hpet_event_channel *, lru_channel); + static struct hpet_event_channel *hpet_get_channel(unsigned int cpu) { static unsigned int next_channel; @@ -454,9 +456,21 @@ static struct hpet_event_channel *hpet_g if ( num_hpets_used >=3D nr_cpu_ids ) return &hpet_events[cpu]; =20 + /* + * Try the least recently used channel first. It may still have its I= RQ's + * affinity set to the desired CPU. This way we also limit having mul= tiple + * of our IRQs raised on the same CPU, in possibly a nested manner. + */ + ch =3D per_cpu(lru_channel, cpu); + if ( ch && !test_and_set_bit(HPET_EVT_USED_BIT, &ch->flags) ) + { + ch->cpu =3D cpu; + return ch; + } + + /* Then look for an unused channel. */ next =3D arch_fetch_and_add(&next_channel, 1) % num_hpets_used; =20 - /* try unused channel first */ for ( i =3D next; i < next + num_hpets_used; i++ ) { ch =3D &hpet_events[i % num_hpets_used]; @@ -479,6 +493,8 @@ static void set_channel_irq_affinity(str { struct irq_desc *desc =3D irq_to_desc(ch->msi.irq); =20 + per_cpu(lru_channel, ch->cpu) =3D ch; + ASSERT(!local_irq_is_enabled()); spin_lock(&desc->lock); hpet_msi_mask(desc);