Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1857821iob; Fri, 29 Apr 2022 14:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0d5xkK0jlgXVHPsYAN/MEdcQtRvofjzpOOqCl03ZwSpRoHzfOduZF31ufMFBxbWVkZPSL X-Received: by 2002:a05:6512:3185:b0:472:10b4:34e3 with SMTP id i5-20020a056512318500b0047210b434e3mr883092lfe.217.1651268610391; Fri, 29 Apr 2022 14:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651268610; cv=none; d=google.com; s=arc-20160816; b=OINge18yl4fHHvsWD4qsJW+FwB0UtYNkpRTxU66p6qVymwL+v/TQ/oiWcKOCqsp9h5 dAHXwsq/p68spoY7U4wCkWIDdjSNa3u03dDLMWGaoXK7AC/ug41XTLVOnaW2Ei6WTqDh ELQJCdVbxzZlHGuT+8U3iYP41858wXA0zF1CWVglPgScZ2TqKNhuJCo09EgJ3S3xI29N 7JldWTtfEbrq7slIIvPQ+vnkriIqOOT9xJdAQnXyK/bvzbcR/H1CWfuuQK6PYdxMXarB BdlJzEhlEGbkgcRMQ8X+mhlcJExYpbZDFWDHaZxRgGvBWucWWMF5IkDYPPVMl3ucq002 I5Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OnYazrMvgjAnK39Hwy/HWHAyF1qxYkIiwXZn1EY9XSk=; b=GMqyXwFjC8Vbi27eVkEEj035errazimnyGeDqvHVt/bCwhvYaOgfwns3uTQF/fAApK 5w76rZL0q+L8SZR4+8sQzg/Y5081ceKToXJxE7hVjhwKnj0k1IQoOXfasr6vDpjizUG9 mg01XCcjbqn00KNETO5j5ukYOktAM0ZHrA/Y7ExFGndFR/6dj4+gG0L5mcEKSP1YeZBU GxXBoedqQtEr3rGD6knEOWJ1wcU3MS5xMqOnkigVL/yH/dISUUTKSO2YPC0prUGke98I aTO4FuVvhVl8tx65J9aJxJFs150doYxJz2ecCgC9fKHaRw3flqh3frreM70MA25n+3R+ jYQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UMUIQSPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a0565123f0f00b0047236fea14fsi6995548lfa.381.2022.04.29.14.43.01; Fri, 29 Apr 2022 14:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UMUIQSPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377367AbiD2OeH (ORCPT + 99 others); Fri, 29 Apr 2022 10:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377389AbiD2Odz (ORCPT ); Fri, 29 Apr 2022 10:33:55 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DD3F7A for ; Fri, 29 Apr 2022 07:30:36 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id j8so7278560pll.11 for ; Fri, 29 Apr 2022 07:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OnYazrMvgjAnK39Hwy/HWHAyF1qxYkIiwXZn1EY9XSk=; b=UMUIQSPWcLSx8MA2om6Gv5iUt7MrgelgAhKlFugl76vVYAQGPwqRKwwHcfQ+b5VK73 HiN0r1ku46T2ATBuu0T8FBelYeZbpLetOcbZl/WeU2tOeEgbHe45Y0Zs/Lhgni8cqSzY iHhY4v8CMUD9lTZ+zxhMlBDZowBCbw+6kbimf1H98jOyhE8jmBz/3SC0UQONAnjZqkWZ IrRjBjnktRSJO2hc3rcC159T7nLvNfTmz8JWq4t79pvRFFlf9DQtYW0TsFu5LKYScifI 05fGmZYs3Y+i2TS1skz/WaOR6iLZOgUVzWkvm9XN/YZ8SP2m2ZLltJu8oJyIu+bGkxyx TrKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OnYazrMvgjAnK39Hwy/HWHAyF1qxYkIiwXZn1EY9XSk=; b=3JQgdyeQpiWU5kZzN1ebTbqdce1tNpIwUCuc+FYTxE+VeMP4zXyo6qt/Q1J4Wr8S28 Qfpt5fYteQx0U5Ry2bBq1ZDr2qxSI0EOFHGKd5Cj8qxifnPl9U9uNEV9fvNJHsHdpdAi tH6LoqicZ8r38kHjAtVsn3CE0LNf+2tmO7fbZl1I69Cw/uRZMX3iMkG73MQyrqccGJKu oY7UwFj+8LUJ2mTvhoNU6KvcwywbaPVwayXFN1SzwZVuCJBtdYILN4UM4MDvW4gvPpdT FN+qy6E9OFW7t0ePv74jnlXk3jRNkTYZWbM48Zwb+PKroL7ZPnzMHOJEKiOKA4LTIfv4 Cqqw== X-Gm-Message-State: AOAM532+dMRgS8vgksKI6mbkGfVcTGs2o0EJ6oVrUAd70MQRbRJ5h6Tk B5S880qSVb4NiCq6AAsFn+L3qg== X-Received: by 2002:a17:90a:d082:b0:1ca:be58:c692 with SMTP id k2-20020a17090ad08200b001cabe58c692mr4274403pju.238.1651242635899; Fri, 29 Apr 2022 07:30:35 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id z21-20020a631915000000b003c14af5062dsm5628933pgl.69.2022.04.29.07.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 07:30:35 -0700 (PDT) Date: Fri, 29 Apr 2022 14:30:31 +0000 From: Sean Christopherson To: Dave Hansen Cc: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, isaku.yamahata@intel.com Subject: Re: [PATCH v3 13/21] x86/virt/tdx: Allocate and set up PAMTs for TDMRs Message-ID: References: <3664ab2a8e0b0fcbb4b048b5c3aa5a6e85f9618a.camel@intel.com> <5984b61f-6a4a-c12a-944d-f4a78bdefc3d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5984b61f-6a4a-c12a-944d-f4a78bdefc3d@intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 29, 2022, Dave Hansen wrote: > On 4/29/22 00:46, Kai Huang wrote: > > On Thu, 2022-04-28 at 10:12 -0700, Dave Hansen wrote: > >> This is also a good place to note the downsides of using > >> alloc_contig_pages(). > > > > For instance: > > > > The allocation may fail when memory usage is under pressure. > > It's not really memory pressure, though. The larger the allocation, the > more likely it is to fail. The more likely it is that the kernel can't > free the memory or that if you need 1GB of contiguous memory that > 999.996MB gets freed, but there is one stubborn page left. > > alloc_contig_pages() can and will fail. The only mitigation which is > guaranteed to avoid this is doing the allocation at boot. But, you're > not doing that to avoid wasting memory on every TDX system that doesn't > use TDX. > > A *good* way (although not foolproof) is to launch a TDX VM early in > boot before memory gets fragmented or consumed. You might even want to > recommend this in the documentation. What about providing a kernel param to tell the kernel to do the allocation during boot? Or maybe a sysfs knob to reserve/free the memory, a la nr_overcommit_hugepages? I suspect that most/all deployments that actually want to use TDX would much prefer to eat the overhead if TDX VMs are never scheduled on the host, as opposed to having to deal with a host in a TDX pool not actually being able to run TDX VMs.