Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3231070ybl; Sun, 26 Jan 2020 23:17:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyAH7xf1EBMSSNkrIV8T2kwIv42HurbvO7SCWqgzW5c+8hy1yPFa88IYoGxFFh/wE8pX9N7 X-Received: by 2002:a05:6830:1294:: with SMTP id z20mr11341834otp.60.1580109442247; Sun, 26 Jan 2020 23:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580109442; cv=none; d=google.com; s=arc-20160816; b=zKk1PN2HbS5YW++dAVXfTHXli5ZMBn8U2z2HcPSfNE8MD6r6TnuFZj/hdkN/jKSSPp D6+wYvtjVNmndesMGfaDaQG4ZguZFI6XonUAogCPd9yDXJwjV00SnF6VDT+LMBHf217u iAMEdrHTTo//sYvLkDWn+DXZWPR3jtauIe0BNxhL50gwRyPWHfGqBTieQ3MC4PGqMfck /1Z2Rt2N8H+Wlj5+U8mcTDh/K7myJTijYAM9Qd/QdTnHnxJEb5tXw0gOZnuCOLEZbbCI 7xnbId72LOF+LYJHnQN8Ec3jyMfmXjgKOMgP5306TjApUL2/y0mWKKzCkikFNpTph895 Zhog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ZTshCe94WzSsfXve6ziu+qTyps0fLQU+BDDkCbT6Bso=; b=tCMijQocO5WSDCFDXPEhdo6VKlN7+JRXj0cPZUoVafAHrSMo9swdpBW7HMQ+8/SzsG mBBdrQ6jIKLX7sKtbBWiLXS3Un75wm7HvVarATLGjPuj4FsUKfVco1OL3FApHKiAd6Qk 8ksvtDYrTRCHSSUxajhLxBfLnt+dTjl6PP6bYJPTjFLJpCGsRe8fSxRyzKyaKb+v5EmH gozqZNNLQqaAXU6rZM7Ad10CcpMAG7Zo9FK88JFeyLPgIe6HdBt24IfRHun7g/udxsSc Y004834IuckJ4QyMgE0mk9MplpLTItBJQ+/CnSnvgU2N04ZVvqgfH2TyNOfjYR5edwUN AYDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tsfuDBGT; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si6187187otl.133.2020.01.26.23.17.09; Sun, 26 Jan 2020 23:17:22 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tsfuDBGT; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbgA0HQS (ORCPT + 99 others); Mon, 27 Jan 2020 02:16:18 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:44622 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbgA0HQS (ORCPT ); Mon, 27 Jan 2020 02:16:18 -0500 Received: by mail-ot1-f66.google.com with SMTP id h9so7404093otj.11; Sun, 26 Jan 2020 23:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZTshCe94WzSsfXve6ziu+qTyps0fLQU+BDDkCbT6Bso=; b=tsfuDBGTQVhy70maJJPR3yaIKX8BjW23nAIzNWcWsDqNiB/oBXDoWDJ1whQefG8H5T qA+zgESqYPhbL05359SxdqjN7XPsc4ZCVcF60/E3vAaWD8dyjnpXX28Bw5HW44X/bShJ IspH7PC33TbNJdg9v4cXf5eQGf0WRNIbH5gI0DPlFwQAM2ZU/+tQtoN+KcJK15Uw4zgj AX5NwHYvM2nrcqgjzy2uOE8dE1NndLkC3lfJU+MUH4T9vVKIR5yoBQYrclHpQuUBjq5A MMAZ4I80FDACK65hhPDSWN3aS18HSk1chsTDXMUCsJy4Dh/Ppk5sCK+P9WP6kjloGkb6 Lu+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZTshCe94WzSsfXve6ziu+qTyps0fLQU+BDDkCbT6Bso=; b=oE35V4duXWT75m32qjpdodBvoe5fnRW5N+jSjPEmxTV8U1U2LQmzbWUMVJE1Kwb7vA Thc4hvMFWlaITAwG0KwPdEqVmXvuCcVJFOlrU+JiwAhJ6ny3KKbL1e7e4WnCIC1oBM0/ mL8L+Hyb4GNO+dMi5571Z+tOchCy+Ehv//R/cuk+rfVLpjspUWsAjxZsMmpgIhhytvsR 198qC9qmrOBhhREaCthwP2tElnn+myfv7uZQQanKdBEA+qST+l54uGSPo/SnlcO5Phfk QyHqC4UC9mDn5Hej9lsJHFZ8Z/blrzHD2VGJl/fLpGZcvzX9FtnUSzK1NSMSkREn62oi h8qA== X-Gm-Message-State: APjAAAVqM5TAOgHE3z7rJpqmHcIqs0kKlAiz0hCIEyABkolwCylB0EUN p0TO5upCK9q6IgseX5jB8UI= X-Received: by 2002:a9d:729c:: with SMTP id t28mr8584637otj.66.1580109377176; Sun, 26 Jan 2020 23:16:17 -0800 (PST) Received: from nick-Blade-Stealth.attlocal.net (23-121-157-107.lightspeed.sntcca.sbcglobal.net. [23.121.157.107]) by smtp.googlemail.com with ESMTPSA id n25sm4500248oic.6.2020.01.26.23.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 23:16:16 -0800 (PST) From: Nick Desaulniers To: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de Cc: Nick Desaulniers , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] dynamically allocate struct cpumask Date: Sun, 26 Jan 2020 23:16:02 -0800 Message-Id: <20200127071602.11460-1-nick.desaulniers@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This helps avoid avoid a potentially large stack allocation. When building with: $ make CC=clang arch/x86/ CFLAGS=-Wframe-larger-than=1000 The following warning is observed: arch/x86/kernel/kvm.c:494:13: warning: stack frame size of 1064 bytes in function 'kvm_send_ipi_mask_allbutself' [-Wframe-larger-than=] static void kvm_send_ipi_mask_allbutself(const struct cpumask *mask, int vector) ^ Debugging with: https://github.com/ClangBuiltLinux/frame-larger-than via: $ python3 frame_larger_than.py arch/x86/kernel/kvm.o \ kvm_send_ipi_mask_allbutself points to the stack allocated `struct cpumask newmask` in `kvm_send_ipi_mask_allbutself`. The size of a `struct cpumask` is potentially large, as it's CONFIG_NR_CPUS divided by BITS_PER_LONG for the target architecture. CONFIG_NR_CPUS for X86_64 can be as high as 8192, making a single instance of a `struct cpumask` 1024 B. Signed-off-by: Nick Desaulniers --- arch/x86/kernel/kvm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 32ef1ee733b7..d41c0a0d62a2 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -494,13 +494,15 @@ static void kvm_send_ipi_mask(const struct cpumask *mask, int vector) static void kvm_send_ipi_mask_allbutself(const struct cpumask *mask, int vector) { unsigned int this_cpu = smp_processor_id(); - struct cpumask new_mask; + struct cpumask *new_mask; const struct cpumask *local_mask; - cpumask_copy(&new_mask, mask); - cpumask_clear_cpu(this_cpu, &new_mask); - local_mask = &new_mask; + new_mask = kmalloc(sizeof(*new_mask), GFP_KERNEL); + cpumask_copy(new_mask, mask); + cpumask_clear_cpu(this_cpu, new_mask); + local_mask = new_mask; __send_ipi_mask(local_mask, vector); + kfree(new_mask); } /* -- 2.17.1