Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2015108lqo; Mon, 13 May 2024 05:44:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOGt4UMnek0/QJdCelz8NYIMpvN6zHDckF1roPY4N5cPPYrRUamnEDfkbitQsPO8cXsnSnEr39ioShaklHeLRbx1vUtvX87x211YHrRQ== X-Google-Smtp-Source: AGHT+IGiL2ltza3OtGzc5X8bQsYZzrJl5v83fh0AMHA0fg4dnp+86pTn6tIUSn4DkeNzLbaERuGw X-Received: by 2002:a17:90a:5901:b0:2b3:28be:dd6e with SMTP id 98e67ed59e1d1-2b6ccd6baedmr7588054a91.33.1715604273746; Mon, 13 May 2024 05:44:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715604273; cv=pass; d=google.com; s=arc-20160816; b=jRoZMi1qI6+suVNrHsGT++k+6OxZbh5eYmbXPCYfbtmOiLOg8tp7RN5VFqF/Z6ArHS 58p5cfHVISeSCYREzTsJqdSrlTxEFtT3moq6nLcn/TtGG9AcYB5ho+1Q2TxGGmzPDkPd brbCEG8THC2gfddh0fEyrwhYA8Ubcy1VNb3Ir5mYTovmQ4i/JWcZM1lOy2pOTzJwyBUs CdFI6BKJlDV0+s0JeqmENcceHFb6fPDpayD/6rBVDp9Ohe7BGYjgaN+H0aEBKJ/kCVo3 chFL69bgpeY6i0qOppaB3IqpTNL0djegt3LWPAegvuPAv9Ykfp7Sv1KgfZHqhzqr/52E HhJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=oAB6AC0uf4kU0wwIw6N445hCMYVKJ7r1lOXf9S9Bb5c=; fh=lQXfVfYvOXLboqfgKUXsrdqy2N5gVh9JZrXiTR7Ojkw=; b=Af3FvTGNfwT9yhDvz3l6SiRqnwvOoQUn6AoPWI0F86psV6ZzvsQXqh8Vgx9NZfzbrh B6LsGNVy6L6J+oIOXmxTsdu2f00d5JYtUSV1izKc7KnhI2NNk6mZKN6NxJsQHf0i3KKA 4iFJ2HnnI7kkzTQEz5chdVEXcAi+Do8UHuju+xKomXzr+XoJjdGF4/gkqs5QbAJR6EgJ 87EvI8vWwdR5rHn6y+cBo7CCOfVRa2s4aZxagpWWs4GANFfJM9bOlQhsn91nTNUEuAlA Oic7KLDZwravzsXizTGqRnQULtOBPCL9FKzWKDZZgWNcChR/t0Px3sgA4yFJvwoyQGX4 RPVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kL6heHlS; 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-177573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628fc6287si11827987a91.146.2024.05.13.05.44.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 05:44:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kL6heHlS; 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-177573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177573-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6498C2824DE for ; Mon, 13 May 2024 12:44:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BF2114F9C9; Mon, 13 May 2024 12:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kL6heHlS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8PQOmpRe" 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 CFDB115099B for ; Mon, 13 May 2024 12:44:17 +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=1715604259; cv=none; b=dHHggqGRGta6aZ9CdywdtlsGOcCOfBofGtMD3jT9uWIKw+AjnBEJiFuPFKwUwnDazzJS3q0onr7iapivLghxycoks7vFSIBKMxz7+IgM77duu/6U8eLc3YfH4/MDRgDyXj8fmqsN05EfpmD0LHKYpwQ7iqKm0wiVvL0GFy7Q5Uk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715604259; c=relaxed/simple; bh=8KSUVzTvqxp7OIdS+GOnbv91geAiKRiZv1Q7eZCzMQc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=IBrB4nW1bDM+P3an98D+dytbsuHODCHG8mDagCjj9WNeobMarA6X9+g9WfxEH45nEewGARy+fhZkxa5NwatGjr55At2YxE4CYRVdiVywRFAhVriBDn5oGbrHKtFwzMFFCkdOT6BZuArgZnwtt2qIwmQHPCUCw2Vs8me/x/tvLQU= 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=kL6heHlS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8PQOmpRe; 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 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715604255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oAB6AC0uf4kU0wwIw6N445hCMYVKJ7r1lOXf9S9Bb5c=; b=kL6heHlSPMN/pHLoNZnqKMl30/S5c6EGVaohafb3ZLJrndk7gd3/VWYn5uZ8OL45HoZiMP YTPtp8yQG9+LQCEa8uFjPBXUZMKGKpHAqB07i3LanfCAtgLtIh9NaIPyM7PnAEUVSmIlNt oExT8knvUv0siYIwnr1SAMd3RUqGdF95IVYFRstmi3VJVbS4O0RlixfaJYX7CJrdA+3s7V 9UiGJczxrBP7Ojxm0XvQ/75cbhTzK923acjp83pMIpH+UXjqLkAWg4VtdehvDcbbH618ak 4il4PoaqgI5nr0Ei8SZ7g2EWNaWbaQUbyxNnqsinpo/jWMNxMqaI+3mqZLUBmg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715604255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oAB6AC0uf4kU0wwIw6N445hCMYVKJ7r1lOXf9S9Bb5c=; b=8PQOmpReg3DfXxCsRL+7m3s8iwztutKUd+RWc0d4ypaxfy6pMG9iUjllvTSzqaQCTGBu1X ESvttDPH+iekbdDw== To: Dongli Zhang , x86@kernel.org Cc: mingo@redhat.com, Borislavbp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, joe.jin@oracle.com, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev Subject: Re: [PATCH 1/1] x86/vector: Fix vector leak during CPU offline In-Reply-To: <20240510190623.117031-1-dongli.zhang@oracle.com> References: <20240510190623.117031-1-dongli.zhang@oracle.com> Date: Mon, 13 May 2024 14:44:15 +0200 Message-ID: <87msotnaow.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, May 10 2024 at 12:06, Dongli Zhang wrote: > The absence of IRQD_MOVE_PCNTXT prevents immediate effectiveness of > interrupt affinity reconfiguration via procfs. Instead, the change is > deferred until the next instance of the interrupt being triggered on the > original CPU. > > When the interrupt next triggers on the original CPU, the new affinity is > enforced within __irq_move_irq(). A vector is allocated from the new CPU, > but if the old vector on the original CPU remains online, it is not > immediately reclaimed. Instead, apicd->move_in_progress is flagged, and the > reclaiming process is delayed until the next trigger of the interrupt on > the new CPU. > > Upon the subsequent triggering of the interrupt on the new CPU, > irq_complete_move() adds a task to the old CPU's vector_cleanup list if it > remains online. Subsequently, the timer on the old CPU iterates over its > vector_cleanup list, reclaiming vectors. > > However, if the old CPU is offline before the interrupt triggers again on > the new CPU, irq_complete_move() simply resets both apicd->move_in_progress > and apicd->prev_vector to 0. Consequently, the vector remains unreclaimed > in vector_matrix, resulting in a CPU vector leak. I doubt that. Any interrupt which is affine to an outgoing CPU is migrated and eventually pending moves are enforced: cpu_down() ... cpu_disable_common() fixup_irqs() irq_migrate_all_off_this_cpu() migrate_one_irq() irq_force_complete_move() free_moved_vector(); No? In fact irq_complete_move() should never see apicd->move_in_progress with apicd->prev_cpu pointing to an offline CPU. The CPU offline case in __vector_schedule_cleanup() should not even exist or at least just emit a warning. If you can trigger that case, then there is something fundamentally wrong with the CPU hotplug interrupt migration code and that needs to be investigated and fixed. Thanks, tglx