From patchwork Tue Jul 16 07:44:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11045421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74073112C for ; Tue, 16 Jul 2019 07:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6596D285A8 for ; Tue, 16 Jul 2019 07:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59F95285AA; Tue, 16 Jul 2019 07:49:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0006285A8 for ; Tue, 16 Jul 2019 07:49:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hnIBx-0002uQ-Nw; Tue, 16 Jul 2019 07:48:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hnIBw-0002u6-O6 for xen-devel@lists.xenproject.org; Tue, 16 Jul 2019 07:48:04 +0000 X-Inumbo-ID: 096525e0-a79e-11e9-a140-27e16e1e6b08 Received: from m9a0001g.houston.softwaregrp.com (unknown [15.124.64.66]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 096525e0-a79e-11e9-a140-27e16e1e6b08; Tue, 16 Jul 2019 07:48:02 +0000 (UTC) Received: FROM m9a0001g.houston.softwaregrp.com (15.121.0.191) BY m9a0001g.houston.softwaregrp.com WITH ESMTP; Tue, 16 Jul 2019 07:48:01 +0000 Received: from M9W0067.microfocus.com (2002:f79:be::f79:be) by M9W0068.microfocus.com (2002:f79:bf::f79:bf) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 16 Jul 2019 07:44:27 +0000 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (15.124.72.11) by M9W0067.microfocus.com (15.121.0.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Tue, 16 Jul 2019 07:44:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gAKmWnXA7QBhsNKIFAdKuOap1DX2B5njWcW5nES9jS2QL2R9MPQOjZAC9gtG35vkuOfa7OgRyym/LKcyTDGwgplw8GsC+aKae848l6WP2HrmJx+8d6dYxzeVtnskaSMoTs8564olKsZm0p6Z6wTbn3vRKEY1dFhkOGJxkkzNTrgIDWMBkuKSQ+v9poLhMAfkHs7mOT6vUlD3H9ZqQVAR3AHE6J0/eyedD1Do+uilaqfsd6oCGTyYh3f4IOAjhKtXBcqd/REUNu2ypd8rGJ9VfmsPK5hujxNbTv6ipabEdaJjyOekxv0yWZ6+IUlCAMyYyLLfkZOE0WHCGhB7L+7CQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UcP8GYNOpduM3r6dwUuYkp76fE5Zx9qWnYDzPW/DR1k=; b=A5WI7/K67PY9YNiaJFHLERPcz4thJuTsy+BhGIzEfopo97Wnfm5I1lcWYpzxbZuxFjshtnbKlrXO723ow1WWAA4guVfaWYiaBybHdFQPZBaacfEjYdRb3wdPe1cvVUeHth1ANmxna1ZKBweKqYQQUAZCdgOau7VxSoS+wzX8l3IopZDGw3ylBLuIwwSfh/Njl8Ublul2mu7uSNBXxwplYYsIHVIH1zCVRY0NPuWBEyjV77gUQj53/5HPIaph8mRD+5r9YXqkVU+sc4FCCLon58rqVP3hrMdYjFuCvluUWcVejNUzom9P6fr0/Z4zYxcV/0QJUfpSgSbTNprooe2gAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none Received: from DM6PR18MB3401.namprd18.prod.outlook.com (10.255.174.218) by DM6PR18MB2667.namprd18.prod.outlook.com (20.179.107.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Tue, 16 Jul 2019 07:44:26 +0000 Received: from DM6PR18MB3401.namprd18.prod.outlook.com ([fe80::1fe:35f6:faf3:78c7]) by DM6PR18MB3401.namprd18.prod.outlook.com ([fe80::1fe:35f6:faf3:78c7%7]) with mapi id 15.20.2073.012; Tue, 16 Jul 2019 07:44:26 +0000 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v4 12/13] x86/IRQ: eliminate some on-stack cpumask_t instances Thread-Index: AQHVO6pKDn1083D/KkaQ2jj4uqEkWw== Date: Tue, 16 Jul 2019 07:44:26 +0000 Message-ID: <37f03698-7664-1c3d-0d2d-3ac8d1636fc1@suse.com> References: <5cda711a-b417-76e9-d113-ea838463f225@suse.com> In-Reply-To: <5cda711a-b417-76e9-d113-ea838463f225@suse.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: DB7PR05CA0035.eurprd05.prod.outlook.com (2603:10a6:10:36::48) To DM6PR18MB3401.namprd18.prod.outlook.com (2603:10b6:5:1cc::26) authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@suse.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [87.234.252.170] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 20f6830b-a294-45c0-c3ea-08d709c16d57 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:DM6PR18MB2667; x-ms-traffictypediagnostic: DM6PR18MB2667: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-forefront-prvs: 0100732B76 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(346002)(366004)(376002)(396003)(136003)(189003)(199004)(6436002)(102836004)(5640700003)(8676002)(53936002)(6506007)(4326008)(386003)(6512007)(7736002)(186003)(6116002)(6486002)(305945005)(52116002)(2906002)(66066001)(11346002)(81166006)(2616005)(8936002)(316002)(476003)(3846002)(66476007)(446003)(76176011)(2351001)(99286004)(26005)(81156014)(31686004)(68736007)(6916009)(256004)(14444005)(14454004)(486006)(71190400001)(478600001)(71200400001)(31696002)(5660300002)(86362001)(80792005)(2501003)(54906003)(36756003)(25786009)(64756008)(66556008)(66946007)(66446008); DIR:OUT; SFP:1102; SCL:1; SRVR:DM6PR18MB2667; H:DM6PR18MB3401.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: wpKpMaS6zdx64J1grMh7ELt58X3uBo3rUzan+IbnjC6jl8p/w7uLkz11kN8ExdlGg0LY6FM5GST2rQYOk0074snWAagSN1xhbyumqsAm/uqf2XWa89EQWILMHlqTT0CDGSLMY9kqoOUq6L5z6dW/rhfiFVmBqJRRoEQHJVVO9BfUm34izIb/x0umoCH296oAX///TvFaw9qUY5OVK5A5+ki7va30ViF09DMKH7JAs281I4+RqeCyv0IaUkuzfhthmK5F0BQYtviZFlCur+l6lYOnerTTWFwnaqTyjeOqLJso4Y0FWLWOri6TQnsjs3YuiDHxnGthbrw4dkHk3KSi4GFTaTv03GTwQZDK9dQFdgLiVq17BEaGU1tZnrSNdRSY27QQm+tfgEkaJFTL47R4+4YVrNS9UCaK5df/Lo8AplY= Content-ID: <0F5E1125388404499713AD39BF6D88FE@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 20f6830b-a294-45c0-c3ea-08d709c16d57 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jul 2019 07:44:26.5240 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JBeulich@suse.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR18MB2667 X-OriginatorOrg: suse.com Subject: [Xen-devel] [PATCH v4 12/13] x86/IRQ: eliminate some on-stack cpumask_t instances X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use scratch_cpumask where possible, to avoid creating these possibly large stack objects. We can't use it in _assign_irq_vector() and set_desc_affinity(), as these get called in IRQ context. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Acked-by: Andrew Cooper --- v4: Re-base over changes earlier in the series. v3: New. --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -285,14 +285,15 @@ static void _clear_irq_vector(struct irq { unsigned int cpu, old_vector, irq = desc->irq; unsigned int vector = desc->arch.vector; - cpumask_t tmp_mask; + cpumask_t *tmp_mask = this_cpu(scratch_cpumask); BUG_ON(!valid_irq_vector(vector)); /* Always clear desc->arch.vector */ - cpumask_and(&tmp_mask, desc->arch.cpu_mask, &cpu_online_map); + cpumask_and(tmp_mask, desc->arch.cpu_mask, &cpu_online_map); - for_each_cpu(cpu, &tmp_mask) { + for_each_cpu(cpu, tmp_mask) + { ASSERT( per_cpu(vector_irq, cpu)[vector] == irq ); per_cpu(vector_irq, cpu)[vector] = ~irq; } @@ -308,16 +309,17 @@ static void _clear_irq_vector(struct irq desc->arch.used = IRQ_UNUSED; - trace_irq_mask(TRC_HW_IRQ_CLEAR_VECTOR, irq, vector, &tmp_mask); + trace_irq_mask(TRC_HW_IRQ_CLEAR_VECTOR, irq, vector, tmp_mask); if ( likely(!desc->arch.move_in_progress) ) return; /* If we were in motion, also clear desc->arch.old_vector */ old_vector = desc->arch.old_vector; - cpumask_and(&tmp_mask, desc->arch.old_cpu_mask, &cpu_online_map); + cpumask_and(tmp_mask, desc->arch.old_cpu_mask, &cpu_online_map); - for_each_cpu(cpu, &tmp_mask) { + for_each_cpu(cpu, tmp_mask) + { ASSERT( per_cpu(vector_irq, cpu)[old_vector] == irq ); TRACE_3D(TRC_HW_IRQ_MOVE_FINISH, irq, old_vector, cpu); per_cpu(vector_irq, cpu)[old_vector] = ~irq; @@ -1169,7 +1171,6 @@ static void irq_guest_eoi_timer_fn(void struct irq_desc *desc = data; unsigned int i, irq = desc - irq_desc; irq_guest_action_t *action; - cpumask_t cpu_eoi_map; spin_lock_irq(&desc->lock); @@ -1206,14 +1207,18 @@ static void irq_guest_eoi_timer_fn(void switch ( action->ack_type ) { + cpumask_t *cpu_eoi_map; + case ACKTYPE_UNMASK: if ( desc->handler->end ) desc->handler->end(desc, 0); break; + case ACKTYPE_EOI: - cpumask_copy(&cpu_eoi_map, action->cpu_eoi_map); + cpu_eoi_map = this_cpu(scratch_cpumask); + cpumask_copy(cpu_eoi_map, action->cpu_eoi_map); spin_unlock_irq(&desc->lock); - on_selected_cpus(&cpu_eoi_map, set_eoi_ready, desc, 0); + on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 0); return; } @@ -2458,7 +2463,7 @@ void fixup_irqs(const cpumask_t *mask, b { bool break_affinity = false, set_affinity = true; unsigned int vector; - cpumask_t affinity; + cpumask_t *affinity = this_cpu(scratch_cpumask); if ( irq == 2 ) continue; @@ -2489,9 +2494,9 @@ void fixup_irqs(const cpumask_t *mask, b if ( desc->arch.move_cleanup_count ) { /* The cleanup IPI may have got sent while we were still online. */ - cpumask_andnot(&affinity, desc->arch.old_cpu_mask, + cpumask_andnot(affinity, desc->arch.old_cpu_mask, &cpu_online_map); - desc->arch.move_cleanup_count -= cpumask_weight(&affinity); + desc->arch.move_cleanup_count -= cpumask_weight(affinity); if ( !desc->arch.move_cleanup_count ) release_old_vec(desc); } @@ -2518,10 +2523,10 @@ void fixup_irqs(const cpumask_t *mask, b { unsigned int cpu; - cpumask_and(&affinity, desc->arch.old_cpu_mask, &cpu_online_map); + cpumask_and(affinity, desc->arch.old_cpu_mask, &cpu_online_map); spin_lock(&vector_lock); - for_each_cpu(cpu, &affinity) + for_each_cpu(cpu, affinity) per_cpu(vector_irq, cpu)[desc->arch.old_vector] = ~irq; spin_unlock(&vector_lock); @@ -2532,23 +2537,23 @@ void fixup_irqs(const cpumask_t *mask, b if ( !cpumask_intersects(mask, desc->affinity) ) { break_affinity = true; - cpumask_setall(&affinity); + cpumask_setall(affinity); } else - cpumask_copy(&affinity, desc->affinity); + cpumask_copy(affinity, desc->affinity); if ( desc->handler->disable ) desc->handler->disable(desc); if ( desc->handler->set_affinity ) - desc->handler->set_affinity(desc, &affinity); + desc->handler->set_affinity(desc, affinity); else if ( !(warned++) ) set_affinity = false; if ( desc->handler->enable ) desc->handler->enable(desc); - cpumask_copy(&affinity, desc->affinity); + cpumask_copy(affinity, desc->affinity); spin_unlock(&desc->lock); @@ -2559,7 +2564,7 @@ void fixup_irqs(const cpumask_t *mask, b printk("Cannot set affinity for IRQ%u\n", irq); else if ( break_affinity ) printk("Broke affinity for IRQ%u, new: %*pb\n", - irq, nr_cpu_ids, cpumask_bits(&affinity)); + irq, nr_cpu_ids, cpumask_bits(affinity)); } /* That doesn't seem sufficient. Give it 1ms. */