From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 12F2B342CB0 for ; Fri, 21 Nov 2025 16:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763742553; cv=none; b=FnZw8yJdt88rCgazE3qAMuk6UvYiXZh2T9mKs5SSjOs58Phgqxmi8AniyP+0QI2N5TUlCDBe4/0N8IURHwWfVhEP5fXIenyewC0fWuzw0xu5l7yNC0FxoHW79wd0sdBNmKTc25SJWm7vylE5Wrjd5svwDX/A/gNrMZ3hMBwS+b4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763742553; c=relaxed/simple; bh=979HLQC3lNQXGFCiSXcooaaUGR8SYmMAV/7MPWiZUSM=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=nL4DR3+qTqxzu9/Gaayj6UGkrtAPwUaG/hHGOFFrdESxZZsAHJe5cuSKlQlkut1Pf+XBgC42Nx8gjMJVyQAfKEWbEmzx+MXQS3JQHtR8UI4WO+9TNdM+hau8iRRUINI2NI22NkZe0VRNJ0fbGC0El+asxWlNGaBf5A7Pk1kmVaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WZkFKDTU; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=YYEGe/ZW; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WZkFKDTU"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="YYEGe/ZW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763742549; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/VOjYq9807PzFVxfU83VO6JTqxLAvw1GjBkW/sIQ1XY=; b=WZkFKDTU0+BMrFQpAuug/ox6RFpgZHt4N3WggtFdP3TbfOkyxXX4hutOzUAoeOuFPSmhXP tECEYeu0nPI9Wk0h6kaGjvHxnIk2GEpwBKyDCf+XRiAHROSW/0BXUdJzXAjxeQRizx5UDC SLLZqHZauPfhzBWR3Z5lmrJHxZ93ZPc= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-3Kamo_ZTMKGPgNnxaYD3ew-1; Fri, 21 Nov 2025 11:29:08 -0500 X-MC-Unique: 3Kamo_ZTMKGPgNnxaYD3ew-1 X-Mimecast-MFC-AGG-ID: 3Kamo_ZTMKGPgNnxaYD3ew_1763742548 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4ee3dfe072dso66753891cf.2 for ; Fri, 21 Nov 2025 08:29:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763742548; x=1764347348; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=/VOjYq9807PzFVxfU83VO6JTqxLAvw1GjBkW/sIQ1XY=; b=YYEGe/ZWCUyRif85/csNw0mGQp1aVXXfvUg0lNEJBag0dZqsM2VvdDxiD8QpAIswAX yYYwlL4W14ySflquf6GfmuxlZPWrW4wlU8NK4Bi3OQRhmEC5Ff5gXWHVKFTDOCeAVQpw qKlmsJVBIM+0fk3LHLDw9a0IF78WLnXAzOVvKrOYezr8DlCxRljOIv99BIUemPQZSkn5 09hVCclGM9b2lliIbG/b3fIeuBM9CMLrMaFH83tu41PhE/3neplRXCRHfrrwufWp9/MQ RxwUb64rxjAY5nYBcjrH0wXqyYAKL86exn827pTkyRxi2yFKShEiIX3nyzGCeu9C/v72 5RGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763742548; x=1764347348; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/VOjYq9807PzFVxfU83VO6JTqxLAvw1GjBkW/sIQ1XY=; b=I5x6dPzXMNbSkHQp+hKyENolRSU7RdVk2zRSKUNKYY/lv/0hlf/CU1IiRuPWFsqLKz YwegpY0JSTUPOJOamBzDqYgjWgSovU76E3US0/w8rrm8cL9rSzTbyfz2WnvjThs29An4 LnULyBrStqAn9PKoV0PLsSj9tXbcOZ15Kv3ZJzWNUiBkwx3ax3xHqABi8I/eujZj2pVz VIXVik9A9gPQe6pEoT0ubermfakZEPkJfd+p2RDR4tRo5WzPXcMbTNw0mdBYjiSl50Xz He2L0w1/VME5gmHRCftgQvF6KYGtwxpFKfh9/eycu85xbO+gM93vsyOr63bM0Zu84FzI WctQ== X-Gm-Message-State: AOJu0YwqGtoqaIDmnNfNNkfaz7OaRnq/sGbLI5c4j/vGi2kOAyA/rlfZ D8H+I4oJZDzALOcP15meqcQvzaWOnFpgkcsWkryuE6SIlE9TheA2w7JQJMOWX8d+YrXYWzzp/8H PiUE21g4OL/P+0UqwfS5Bxz/u+8gUSeXx4+/Sqt2BFRYOs/5Qh4+xd2AfD9KwQkDxTA== X-Gm-Gg: ASbGncuS5JC34Uw7hkmnEybQ4+00Eqd1eNiicK/xkDSHsiBe6zoTtSK2yPPDxXIOFoP 80ogCACjBCTtmrGnZlMAjbGp6Xu6ewm3tmlZjdINdKi+nOG7MDuQcMYdbyXpHLccy8pNkzeBsEM rQLuqLJZ5uV+3GAVXgDPYJ6+CUPXhsWhr1fFBNYL7AvJYW1dVvhwBMGpdEELEJQb8blwMh2draW P4fcrYfDhbaShJ4mM7HmA+mDyXVpRxKarXmFh/9p4qvczl3vcm8No4rWJEh4Ta+vrBKsi5v8Auy J8EEjGCKWTyDM+dBe/kmRWxF5zRgUoNgw/XMHE7HGFJuNz+pPsnM+3AAP+fxfD9rjvGN+a2IiXr UtLPGhMTdI5Ik1z82ywSu6jivWAvlvm2mJ6ex9535rMNh0cix/IsMA/ni X-Received: by 2002:a05:622a:13c6:b0:4ec:f9a1:17c5 with SMTP id d75a77b69052e-4ee58841de4mr36845221cf.10.1763742547937; Fri, 21 Nov 2025 08:29:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHplEocfCvbd0HWPMxEJVKcY+zZIueRg99xqK5/OjwLx6+Fz+GigMFjCtRmsIqmoqqlZX79PA== X-Received: by 2002:a05:622a:13c6:b0:4ec:f9a1:17c5 with SMTP id d75a77b69052e-4ee58841de4mr36844891cf.10.1763742547473; Fri, 21 Nov 2025 08:29:07 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4ee48d3a8d2sm38005971cf.3.2025.11.21.08.29.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Nov 2025 08:29:06 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Fri, 21 Nov 2025 11:29:05 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3 v3] genirq: Fix interrupt threads affinity vs. cpuset isolated partitions To: Frederic Weisbecker , Thomas Gleixner Cc: LKML , Marek Szyprowski , Marco Crivellari , Waiman Long , cgroups@vger.kernel.org References: <20251121143500.42111-1-frederic@kernel.org> <20251121143500.42111-3-frederic@kernel.org> Content-Language: en-US In-Reply-To: <20251121143500.42111-3-frederic@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/21/25 9:34 AM, Frederic Weisbecker wrote: > When a cpuset isolated partition is created / updated or destroyed, the > interrupt threads are affine blindly to all the non-isolated CPUs. And this > happens without taking into account the interrupt threads initial affinity > that becomes ignored. > > For example in a system with 8 CPUs, if an interrupt and its kthread are > initially affine to CPU 5, creating an isolated partition with only CPU 2 > inside will eventually end up affining the interrupt kthread to all CPUs > but CPU 2 (that is CPUs 0,1,3-7), losing the kthread preference for CPU 5. > > Besides the blind re-affinity, this doesn't take care of the actual low > level interrupt which isn't migrated. As of today the only way to isolate > non managed interrupts, along with their kthreads, is to overwrite their > affinity separately, for example through /proc/irq/ > > To avoid doing that manually, future development should focus on updating > the interrupt's affinity whenever cpuset isolated partitions are updated. > > In the meantime, cpuset shouldn't fiddle with interrupt threads directly. > To prevent from that, set the PF_NO_SETAFFINITY flag to them. > > Suggested-by: Thomas Gleixner > Signed-off-by: Frederic Weisbecker > Signed-off-by: Thomas Gleixner > Link: https://patch.msgid.link/20251118143052.68778-2-frederic@kernel.org > --- > kernel/irq/manage.c | 23 +++++++++++++++-------- > 1 file changed, 15 insertions(+), 8 deletions(-) > > diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c > index c1ce30c9c3ab..98b9b8b4de27 100644 > --- a/kernel/irq/manage.c > +++ b/kernel/irq/manage.c > @@ -1408,16 +1408,23 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) > * references an already freed task_struct. > */ > new->thread = get_task_struct(t); > + > /* > - * Tell the thread to set its affinity. This is > - * important for shared interrupt handlers as we do > - * not invoke setup_affinity() for the secondary > - * handlers as everything is already set up. Even for > - * interrupts marked with IRQF_NO_BALANCE this is > - * correct as we want the thread to move to the cpu(s) > - * on which the requesting code placed the interrupt. > + * The affinity may not yet be available, but it will be once > + * the IRQ will be enabled. Delay and defer the actual setting > + * to the thread itself once it is ready to run. In the meantime, > + * prevent it from ever being reaffined directly by cpuset or > + * housekeeping. The proper way to do it is to reaffine the whole > + * vector. > */ > - set_bit(IRQTF_AFFINITY, &new->thread_flags); > + kthread_bind_mask(t, cpu_possible_mask); > + > + /* > + * Ensure the thread adjusts the affinity once it reaches the > + * thread function. > + */ > + new->thread_flags = BIT(IRQTF_AFFINITY); > + > return 0; > } > LGTM Acked-by: Waiman Long