Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp277086ybv; Wed, 5 Feb 2020 05:28:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyITm5WaM9MoXdzmvNMRsvxdeZIVk23K86IYWa4S8W/RksxNzrgSsvVCOLfiwgRFVzZHOhA X-Received: by 2002:aca:4994:: with SMTP id w142mr2689862oia.178.1580909302644; Wed, 05 Feb 2020 05:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580909302; cv=none; d=google.com; s=arc-20160816; b=d0JfFqGeacFFwc7aY0JUoyydXKOxwUSVmvvXXxUk2d9DxQ9JTumRyGrHo+vo7Cl6c9 SGKlX4SH3ocCOLq7ykmkKCYS4alxebp2woIkrmsmIC88K/73UNFDNX0YBceWnQVvGnEB UeToQiPZ1B/pOyWHxXpY3JrQyQ3yHrJNtEk3MnMmL+piaBHvKXNjh1QKuG46JLr8+mqK ALxIfRXmqmiwaUJ7wJMnK1kq9Wl2BsJ+mCmdfaIr3ZWdkPAFb4ntg89PixJiJ97UU+0G 1LVGBzVB9+vz/0cyLUBQ1tQLsaAE5VPgqVjrWpp2ulgg7SQuEShoWzh9NNIbWS+sdJTQ gWdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2iTmjWroM0axQMfNXSTY4B+Vwm8DbZJfE7GwGUvjpyQ=; b=P9CWM6gOMP0Ni3E/8uYfdr7Awrc9wyewde1Q+V1pZUkWVkm7mLAcNI3hjUIdBMJke9 pkSFJfWbtuZrrGiVTpRu4mpCXYcfpgJkMZIeUeT9e/jXH6KqEJ0wNfZFwGkirgakOa5G IDLkafi6MiNd+fHpwxkZjVWm2LVo7J+PGhKiYGb/xuLFO6Hx5TyGgeS1J5j3LzGX5Uwo epEwteZNLDiKm6eKfzg+odRh4m5wl/1anW+FKmKFFhRMR0df8fTGdxEBHuYYd2Cqb+bx vuwh9Ispks2bNeTtgbHoCjLf+jtzE41gRCjRJY5v3YDSHka/q/QdcvDpflCG25D5fvfw y9cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NwK7gQWq; 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 a12si11459719oie.87.2020.02.05.05.28.10; Wed, 05 Feb 2020 05:28: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=NwK7gQWq; 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 S1728273AbgBEN1B (ORCPT + 99 others); Wed, 5 Feb 2020 08:27:01 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:36225 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726822AbgBEN1A (ORCPT ); Wed, 5 Feb 2020 08:27:00 -0500 Received: by mail-ot1-f68.google.com with SMTP id j20so1902087otq.3; Wed, 05 Feb 2020 05:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2iTmjWroM0axQMfNXSTY4B+Vwm8DbZJfE7GwGUvjpyQ=; b=NwK7gQWqLfS/JUcGRZD+ikHP6oDzawbpGi52vOScViy7NpUb95lXZ/qUrSo13MJZuk 5/yZgqQKnkk0cMi5K7k1nZ3Jkn32nXwG8KZDA4HzCX1QzJqELzGfLhg1RjDGNfa9+j16 2WgZ5TU6eDlgZr1yrAB0vtYMLNBqb/QSpHhDJA1FB9nSMkk+3OGgHseBOnZn6Ydg8Lvg vJrmPR0nsLR7TIHrGo1+7I32n8wSUO3gmaXbvmBTsVMwTUQjtr/3fgwqRRomCz40+hgs alg9cOYWy3/bXhMOq/p+kABPeatiwUrS7yeF9cVyPolffFTFyh/K1iyMZI+aP89YauAq +bTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2iTmjWroM0axQMfNXSTY4B+Vwm8DbZJfE7GwGUvjpyQ=; b=WzjJo3ZViRdjrUhgzA7oeCBf1SGXCNRCCJ9KureROJrZQPPHo18zB3pA77vKxRCZwT z+A8Kg9eqGYSsv/2rSUIL3X4EzQGtdmNIj+EyyPJExj0q9rcKIRv3unG4BZE28Hd1wLd GYDAlY786hvEl8b6q/HyOUzeKAOMVRzLN9RuYt/54OXpHDTCxAHCy+Dztc/8G3KeqxKG g2ZpktZeNZbw+LkIWJMoztrUJ00bLX+5hCgaK+KHhTKpoUPdvZzWikzSNZZALEuBuZ4P eyPlj6Zf3laI8MRkD5ux9fImxkfUZWPRq6qfL7HslJSDSkxDMJ1+WqwEFat7ihUO3mM+ 0AKg== X-Gm-Message-State: APjAAAWHS8fTBYZ6AoMYZ7dW4PAac1C4nVqxgojfVWRas28V8tTn8eFz gHd7VcvG+QmzCP5OBPNQRT7VHNOGuiBi7mZIToU= X-Received: by 2002:a05:6830:231d:: with SMTP id u29mr26656265ote.185.1580909219503; Wed, 05 Feb 2020 05:26:59 -0800 (PST) MIME-Version: 1.0 References: <878slio6hp.fsf@vitty.brq.redhat.com> <874kw6o1ve.fsf@vitty.brq.redhat.com> In-Reply-To: <874kw6o1ve.fsf@vitty.brq.redhat.com> From: Wanpeng Li Date: Wed, 5 Feb 2020 21:26:48 +0800 Message-ID: Subject: Re: [PATCH] KVM: Pre-allocate 1 cpumask variable per cpu for both pv tlb and pv ipis To: Vitaly Kuznetsov Cc: LKML , kvm , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel , Thadeu Lima de Souza Cascardo 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 On Tue, 4 Feb 2020 at 22:36, Vitaly Kuznetsov wrote: > > 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. Will do. Wanpeng