Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5040008ybl; Tue, 4 Feb 2020 06:39:08 -0800 (PST) X-Google-Smtp-Source: APXvYqywhf/fOe6JFMwsswnftcqOcHAfKodJcx7D08Za7w6pN2A7u2W0bTDcKeofAfyivMvrjrnV X-Received: by 2002:a9d:6184:: with SMTP id g4mr21188877otk.223.1580827148655; Tue, 04 Feb 2020 06:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580827148; cv=none; d=google.com; s=arc-20160816; b=M50M/bECfx6nspKAeaDhigIiOp3oBqx7B21awm4ugLiVvsOk93Q+SVUpieTirstePd 0s1hv56I/Ht8TtnvXf9MC1TnWC+mIwlRfTRZzoTEdTzcm4bBfWfFefMz/3Y3ph3/wfcn rg7DZp3fYykg+IzodO8nLCnA07LlM1pLbsODhAZZomC1+igD4Vx5LOsNXcvjEvE1gYpt W16+i49DX5xXWJwpPTNKb6+gF9cLDcMJ7pHXvCRLnRr7n3wITEJnjwE1gq3tC8xnHcVr Cf/ZD0IQBxpYbSw5x/Po/vkDW87HClCZ0vdpF3e8A2iZCa55/Qv6CnwGt7gZDG3jJBvN fWUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=d4oID/MjfqTQ+n08/EIWcONdJe6Z2nq4WI7xtUbHDEI=; b=AwWmN6GkaTdFJ0WW00Y+AvHiqMh1OoaBUDun/P/zGWqSzmGsZQA1KXU2o+R/m77a9Y UlY5izH/1yPKfAypT8v4CuyHQ1s05UHIcB/62mSecBj9cq58ADl77ELb8rzRuI0wi5iR iKbHd3UsQJkD85t+P37JIP+dgKcPZ+IYP5KmekgNFl1uzzAsec8QIWkA81dxjPBkxQJR R4RQbkm1hCcfi7QC8VAKhWanrnOOD5YGSeLJ+AWbPHN0m/VrTP7RJ8FPH4gcBnCXHDn7 +0+3ety54zfZM992xlVkPVVpLrX9vri9DHI5z63eT7E7za/hLpWSlFHewZVbTDz1T7M4 QCNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b2jpMKPN; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si9500230oib.164.2020.02.04.06.38.56; Tue, 04 Feb 2020 06:39:08 -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=@redhat.com header.s=mimecast20190719 header.b=b2jpMKPN; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727290AbgBDOhA (ORCPT + 99 others); Tue, 4 Feb 2020 09:37:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:57210 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727250AbgBDOhA (ORCPT ); Tue, 4 Feb 2020 09:37:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580827018; 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: in-reply-to:in-reply-to:references:references; bh=d4oID/MjfqTQ+n08/EIWcONdJe6Z2nq4WI7xtUbHDEI=; b=b2jpMKPN4ZkcVTOIyiCIiBnZCxncdCbEEVLFwP+IZj9MZ45OiNI/zqm+BH38hyE8R5I9Ut zN8UMVnTRswXbC+UFZQg3khWasyH1wpJ57UHmS4OIev5HU3JBjPUN0CIG8JBeoZLKD4qHv PWE75WRwn+rLZXY/wT8CUtPithAiTMM= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-D0XqkzqUPe6e6N2DKR8IVA-1; Tue, 04 Feb 2020 09:36:56 -0500 X-MC-Unique: D0XqkzqUPe6e6N2DKR8IVA-1 Received: by mail-wr1-f72.google.com with SMTP id s13so10210421wru.7 for ; Tue, 04 Feb 2020 06:36:56 -0800 (PST) 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:in-reply-to:references:date :message-id:mime-version; bh=d4oID/MjfqTQ+n08/EIWcONdJe6Z2nq4WI7xtUbHDEI=; b=MfOTtqt7yWkiNF7NNffH5Z1gxn2yqVGbL+UGnfWlFDl+9E3njqcdX/f5S4pYqVcmZ2 o899yz93LHfXjwsPnSSxORYtoosiffHwJGoi5qpEJ72FnA4L76vxalZyLnGxGV/NxBVF 96a4hkseoJ9d7fdG3Hkqnk3Wq9c2jJ0MMZ8aMJ7+WAiQOi+mnFSQEbQd9v+azhp4MwYm +nHVryDhMF3NsqEcu/NpLZMgBbX9UkOAPFu2oIiLq2SrgK3TqvYZbkKyKJyz/v3u4AVs 3Yj2NiTCoV131nVzF06FrAJmkXJC3UXJUA9oCUB68NoUq0nBX/YOEVgo6XcnoivnmZ/L dA/Q== X-Gm-Message-State: APjAAAXN3iGRPUcCySZyTKtCsH9w7rQPbey0LmdtbCCB8RiJa/Hy1Hyr nBRoPqXij+nfpOkVkzgq2KpvMp/srypRYeWoVtmPLrMY2lhk85XhUxWpsRs2OyAmp8JXg0HZFTU Xf6Thv8vm5NV/3dk2LXyKJnWz X-Received: by 2002:a1c:9dce:: with SMTP id g197mr5906151wme.23.1580827015035; Tue, 04 Feb 2020 06:36:55 -0800 (PST) X-Received: by 2002:a1c:9dce:: with SMTP id g197mr5906138wme.23.1580827014828; Tue, 04 Feb 2020 06:36:54 -0800 (PST) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id e18sm29407471wrw.70.2020.02.04.06.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 06:36:54 -0800 (PST) From: Vitaly Kuznetsov To: Wanpeng Li Cc: LKML , kvm , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel , Thadeu Lima de Souza Cascardo Subject: Re: [PATCH] KVM: Pre-allocate 1 cpumask variable per cpu for both pv tlb and pv ipis In-Reply-To: References: <878slio6hp.fsf@vitty.brq.redhat.com> Date: Tue, 04 Feb 2020 15:36:53 +0100 Message-ID: <874kw6o1ve.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wanpeng Li writes: >> >> Honestly, I'd simplify the check in kvm_alloc_cpumask() as >> >> if (!kvm_para_available()) >> return; >> >> and allocated masks for all other cases. > > This will waste the memory if pv tlb and pv ipis are not exposed which > are the only users currently. > My assumption is that the number of cases where we a) expose KVM b) don't expose IPIs and PV-TLB and c) care about 1 cpumask per cpu is relatively low. Ok, let's at least have a function for if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && !kvm_para_has_hint(KVM_HINTS_REALTIME) && kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) as we now check it twice: in kvm_alloc_cpumask() and kvm_guest_init(), something like pv_tlb_flush_supported(). We can also do pv_ipi_supported() and probably others for consistency. Also, probably not for this patch but it all makes me wonder why there's no per-cpu 'scratch' cpumask for the whole kernel to use. We definitely need it for hypervisor support but I also see arch/x86/kernel/apic/x2apic_cluster.c has similar needs. -- Vitaly