Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp440915pxu; Fri, 11 Dec 2020 06:08:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoZbuWY55po7K4abr5YWWRlZUppidH3qbHjAffDiw3hJnOQAKZ4ffQT3kpA8hmXddreNGH X-Received: by 2002:a17:906:ce21:: with SMTP id sd1mr10817417ejb.396.1607695699793; Fri, 11 Dec 2020 06:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607695699; cv=none; d=google.com; s=arc-20160816; b=pgt9hM7q138gw3G1LMIXM/zHd+UNyv06X8CXPHNRB6aB2Xfd9T6A3WJTzkn7o/R27B f+5lIxPiwMGpPYCDB/1qwURYeTm3bQQbr2g8+OqNu4pqckWCdF2TnUDl9Yy248tXLMQR utZ2nn1SCcUegO3Cd0hYXfH2kHQHoSExqy7esqi4usYHheGTZ6HOjt4Hjen53AFZ11cP gnh+qKIgpZGupLgJ+o+ebHNgbiaO+PCDFaNfEQOI4+XgidMKYNglhBVCJgKJU5cFY4hk Dhv/xZsZmmq1Z6TJTHA0XM2YpBAyCy/vw281afJZTXdl9EhPPHPe5SbkrNTVdFy0Xj5x tH7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=dJl5hEzN0y59Vtw87cxNPpF86WC4d2s1wMxA3PvngTY=; b=d1SRnw1x1M9HfG1CqAGoZDc8Wv1NhYWNTggwrrg7ZvBPUHjk3479v3A0GFsWdeltk+ NKkZlZ4jqsiNLaCqqgc9sK2SgYo2OF+YZyQjg1bB6WiyNuqjAwbytku21/HLj1A2q1Os tDyySPFoo73iBtiIrf5BaMg0iOy3akoFkoeJZ7iAhWl2aI3k/PkzrKhSFbAfGuLFA6rf KCBY4Ix+6QDGwYCBGwyHloT4XqD7nh6ubxJKnm4hxRMMebXo822q2cgB6M3jTXq4N+vm 1/Drsgc7ZeeRX+ANb5gAD2yydkQhY8MZN1ABckvzCpy0p1MbzuBX2ddydFxC4Fyhc/4R r7Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="QkF7/TAu"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si4367836ejo.343.2020.12.11.06.07.56; Fri, 11 Dec 2020 06:08: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=@redhat.com header.s=mimecast20190719 header.b="QkF7/TAu"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404393AbgLKM05 (ORCPT + 99 others); Fri, 11 Dec 2020 07:26:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39574 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390375AbgLKM0V (ORCPT ); Fri, 11 Dec 2020 07:26:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607689494; 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=dJl5hEzN0y59Vtw87cxNPpF86WC4d2s1wMxA3PvngTY=; b=QkF7/TAu+9MaJ57Au/MC5dEtDIBw42E1JkMSJiNI4vLDIwlZ3CMYngEE0E8TN9d8E41v48 M6xwVzaPA9WVYU0gbhfUMu/5m7ELiqt6oQzgGYmwOOKbspAJCgFzTIdmaGy4cCjsJGUpbf WACDgdz+r0aiqL0cQlhPKKjb13UnApU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-N81QwZVPP1C0LtTBqbC3nw-1; Fri, 11 Dec 2020 07:24:52 -0500 X-MC-Unique: N81QwZVPP1C0LtTBqbC3nw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4683E10082EE; Fri, 11 Dec 2020 12:24:51 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.7a2m.lab.eng.bos.redhat.com [10.16.222.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9A1C5F9A6; Fri, 11 Dec 2020 12:24:50 +0000 (UTC) Subject: Re: [PATCH] x86/apic/vector: Fix ordering in vector assignment To: Thomas Gleixner , LKML Cc: x86@kernel.org, Shung-Hsi Yu , Ming Lei , Peter Xu References: <87ft4djtyp.fsf@nanos.tec.linutronix.de> From: Prarit Bhargava Message-ID: Date: Fri, 11 Dec 2020 07:24:50 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <87ft4djtyp.fsf@nanos.tec.linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/10/20 3:18 PM, Thomas Gleixner wrote: > Prarit reported that depending on the affinity setting the > > ' irq $N: Affinity broken due to vector space exhaustion.' > > message is showing up in dmesg, but the vector space on the CPUs in the > affinity mask is definitely not exhausted. > > Shung-Hsi provided traces and analysis which pinpoints the problem: > > The ordering of trying to assign an interrupt vector in > assign_irq_vector_any_locked() is simply wrong if the interrupt data has a > valid node assigned. It does: > > 1) Try the intersection of affinity mask and node mask > 2) Try the node mask > 3) Try the full affinity mask > 4) Try the full online mask > > Obviously #2 and #3 are in the wrong order as the requested affinity > mask has to take precedence. > > In the observed cases #1 failed because the affinity mask did not contain > CPUs from node 0. That made it allocate a vector from node 0, thereby > breaking affinity and emitting the misleading message. > > Revert the order of #2 and #3 so the full affinity mask without the node > intersection is tried before actually affinity is broken. > > If no node is assigned then only the full affinity mask and if that fails > the full online mask is tried. > > Fixes: d6ffc6ac83b1 ("x86/vector: Respect affinity mask in irq descriptor") > Reported-by: Shung-Hsi Yu > Reported-by: Prarit Bhargava > Signed-off-by: Thomas Gleixner > Tested-by: Shung-Hsi Yu > Cc: stable@vger.kernel.org > --- > arch/x86/kernel/apic/vector.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) > > --- a/arch/x86/kernel/apic/vector.c > +++ b/arch/x86/kernel/apic/vector.c > @@ -273,20 +273,24 @@ static int assign_irq_vector_any_locked( > const struct cpumask *affmsk = irq_data_get_affinity_mask(irqd); > int node = irq_data_get_node(irqd); > > - if (node == NUMA_NO_NODE) > - goto all; > - /* Try the intersection of @affmsk and node mask */ > - cpumask_and(vector_searchmask, cpumask_of_node(node), affmsk); > - if (!assign_vector_locked(irqd, vector_searchmask)) > - return 0; > - /* Try the node mask */ > - if (!assign_vector_locked(irqd, cpumask_of_node(node))) > - return 0; > -all: > + if (node != NUMA_NO_NODE) { > + /* Try the intersection of @affmsk and node mask */ > + cpumask_and(vector_searchmask, cpumask_of_node(node), affmsk); > + if (!assign_vector_locked(irqd, vector_searchmask)) > + return 0; > + } > + > /* Try the full affinity mask */ > cpumask_and(vector_searchmask, affmsk, cpu_online_mask); > if (!assign_vector_locked(irqd, vector_searchmask)) > return 0; > + > + if (node != NUMA_NO_NODE) { > + /* Try the node mask */ > + if (!assign_vector_locked(irqd, cpumask_of_node(node))) > + return 0; > + } > + > /* Try the full online mask */ > return assign_vector_locked(irqd, cpu_online_mask); > } > Tested-and-Reviewed-by: Prarit Bhargava P.