Received: by 10.223.185.116 with SMTP id b49csp4184855wrg; Mon, 26 Feb 2018 12:46:16 -0800 (PST) X-Google-Smtp-Source: AH8x225WU6unW/X6WXyUPNu37/YpcPXRDk1sjabHEPPJ4pASA7pT5ywV93lwQjL6c3SfmuJhRs1t X-Received: by 2002:a17:902:b109:: with SMTP id q9-v6mr12020690plr.340.1519677976395; Mon, 26 Feb 2018 12:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519677976; cv=none; d=google.com; s=arc-20160816; b=GLgRPYtkjK/PW6bMjkm2UirLtxJTE/ug22FosdRdQxxX0XZMwd46MYKitr4f1gnlPo ftwduz+hJC5kpNOOdFukmOvrnde4zwcCdRmx2Ld7cB3rUAoUiMOI2xS89HXFZatl1S3k QmQJzFsYQ+lvUW4Lq5UmWqDZWw3tweUQ4XS60+gEZ4ZtoLFuS4F3wLr68Jf7KBrCpqI6 It74JrhhY3rWAesyet0iysaK0yBCH4UTikXC1+ESY2zod68e3/DJhfaBgcGqSSyvsAGv f+XWYlQLVcn3pqC1nebUViMM6repxe7NIP+2UStkGkMCIBQeGhOkAfYhmp+7tiDgtqNe KTpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5HTJbw1GXF9zWZNfbQ8FzRB327TVgK0HY+ZcwzVIFy0=; b=RcMB7U32pkmv8LgTLYxCYVR5gz1MMxeesBttyQR2dBfWjwusmk/qjM/V2oODtSRrrH FDEgiUfoSv4GZohLrF9pzSi1Mc5jWSGmaQPWa8D3qYM8bSZwEGIO6lWNV48/Y4l/p4KH KrzQhQX2PzBuSJfq+/H0wVz+OTRdhYFZ1o2k8STCcLUpEpiIb7mOfLNw6cmP+EKUD2QW zHftY+lC+d8aLr8btcnJHK9L3SLH/+ADlhBez+/MatTqPIIeBFxhIY1zSDU4Au4WgY0l xGpzb0uqv0aCgVdXNPeeAGZ49aqR5fqIVYD4BKPgUSPwWJ1xxKQwQxtYji/0hGzHlZcO jzkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si7212048pli.696.2018.02.26.12.46.00; Mon, 26 Feb 2018 12:46:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753417AbeBZU02 (ORCPT + 99 others); Mon, 26 Feb 2018 15:26:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35722 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753389AbeBZU01 (ORCPT ); Mon, 26 Feb 2018 15:26:27 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 847B31009; Mon, 26 Feb 2018 20:26:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuriy Vostrikov , Thomas Gleixner , Peter Zijlstra , Randy Dunlap Subject: [PATCH 4.15 16/64] genirq/matrix: Handle CPU offlining proper Date: Mon, 26 Feb 2018 21:21:53 +0100 Message-Id: <20180226202154.136078662@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202153.453363333@linuxfoundation.org> References: <20180226202153.453363333@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 651ca2c00405a2ae3870cc0b4f15a182eb6fbe26 upstream. At CPU hotunplug the corresponding per cpu matrix allocator is shut down and the allocated interrupt bits are discarded under the assumption that all allocated bits have been either migrated away or shut down through the managed interrupts mechanism. This is not true because interrupts which are not started up might have a vector allocated on the outgoing CPU. When the interrupt is started up later or completely shutdown and freed then the allocated vector is handed back, triggering warnings or causing accounting issues which result in suspend failures and other issues. Change the CPU hotplug mechanism of the matrix allocator so that the remaining allocations at unplug time are preserved and global accounting at hotplug is correctly readjusted to take the dormant vectors into account. Fixes: 2f75d9e1c905 ("genirq: Implement bitmap matrix allocator") Reported-by: Yuriy Vostrikov Signed-off-by: Thomas Gleixner Tested-by: Yuriy Vostrikov Cc: Peter Zijlstra Cc: Randy Dunlap Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20180222112316.849980972@linutronix.de Signed-off-by: Greg Kroah-Hartman --- kernel/irq/matrix.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/kernel/irq/matrix.c +++ b/kernel/irq/matrix.c @@ -16,6 +16,7 @@ struct cpumap { unsigned int available; unsigned int allocated; unsigned int managed; + bool initialized; bool online; unsigned long alloc_map[IRQ_MATRIX_SIZE]; unsigned long managed_map[IRQ_MATRIX_SIZE]; @@ -81,9 +82,11 @@ void irq_matrix_online(struct irq_matrix BUG_ON(cm->online); - bitmap_zero(cm->alloc_map, m->matrix_bits); - cm->available = m->alloc_size - (cm->managed + m->systembits_inalloc); - cm->allocated = 0; + if (!cm->initialized) { + cm->available = m->alloc_size; + cm->available -= cm->managed + m->systembits_inalloc; + cm->initialized = true; + } m->global_available += cm->available; cm->online = true; m->online_maps++; @@ -370,14 +373,16 @@ void irq_matrix_free(struct irq_matrix * if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end)) return; - if (cm->online) { - clear_bit(bit, cm->alloc_map); - cm->allocated--; + clear_bit(bit, cm->alloc_map); + cm->allocated--; + + if (cm->online) m->total_allocated--; - if (!managed) { - cm->available++; + + if (!managed) { + cm->available++; + if (cm->online) m->global_available++; - } } trace_irq_matrix_free(bit, cpu, m, cm); }