Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp683570imi; Thu, 21 Jul 2022 08:58:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vKPjb+IUXCr9wX7umg1FruwxyNzSDs9oeYvEQ0QWihgMXlbZZ/M3lct7dLBR0CftSRDJsT X-Received: by 2002:a17:907:868e:b0:72e:fac8:ce51 with SMTP id qa14-20020a170907868e00b0072efac8ce51mr31253027ejc.549.1658419101661; Thu, 21 Jul 2022 08:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658419101; cv=none; d=google.com; s=arc-20160816; b=Q84sJGWIZfvC9//0WXY0W+5CqOl4ZSbnkaTO1Pi5GuyWwjblSQFR9qG6b6B4owIajc vYLybkcRVnO88odqAwtGTnOtU7Ni6Wbew0gsf0rK8r5xsz/jSr6iS5AcnejPHgoVpOAK +QvRBRq449gjKhlMn+zv7YkChPAlhhDprwbuKiP2eH1B6UJ8AzF03nBcJLcW1MBqEs6y oH3SzyjqmzTl7FSpWQRrABCJ2x0Vev5Qau7K56isFD0KVFgnk84+b0DNXqBKQb/btahn /+S+LnymvgSIuS2kuaHnVPbl26g8TBx85xZAeKySM3wEFA9iDzUhj0WEY3cMmTIiSevU 5kiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=BHNqUikkfi6+yEZRvozlYvEZM0bWammPSemIVVZ9s9Y=; b=JAw4u9/wZNOg2+oCfcC8mv3W5YFgPuz+p1uox4SU5AVykzx4DONtOIHAf4D32MBf1o gCdlEcDgLRtDrSwBTZIpWTwhk14Mify1d1zYqmzV/uZZh6qvdvkSp/h/Ct9cpkjXMkGB E/qC4l/ed8JUfur9KKC8mfxeKteARMbtwFztV0cSSwHvSa+I6VrdCej9qnavqd1bgfsB DR00p/ABKhqYOoybxoXWnUh/qbsyo/1poDVcsfggxZRyMnCqLnXKPTNKY2GprfiFfFNv LIAwL0UIOiDugmQRcf1d7US0CDe9buJTyfxfDmb5zIlvCmzfryDDl8OKX3QRbQs9Ur1O qmAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XXKtHJ0+; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc20-20020a170907169400b0072b6ea73316si3357794ejc.664.2022.07.21.08.57.32; Thu, 21 Jul 2022 08:58:21 -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=@intel.com header.s=Intel header.b=XXKtHJ0+; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232847AbiGUPtr (ORCPT + 99 others); Thu, 21 Jul 2022 11:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbiGUPtk (ORCPT ); Thu, 21 Jul 2022 11:49:40 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 497E7CE24; Thu, 21 Jul 2022 08:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658418575; x=1689954575; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=cxrvSMixUSva/vWiltebPsIj2OtNtkjOCGTWpSyZWFU=; b=XXKtHJ0+GpkHO3LhMloMZuf/tQ8zaUPP53SsmrhAm/hgXro6IqN8BR9K rPKekpLEjD9LG5NKtOzzJyoLFqJLkQClRZsB5tgy+JfG5Pszmet29YzHX I6AtidlnO0YeNYRCg9Lf8jN/xPXGfPn3OySHVkrtmdVEyLVJhp8VfNSu7 /I9WMGEXLTXC8cUmtGgRK81jvtQ2pJnS1Qn9NeHyqAQKb4ys81G2BUGff P1xdoAH1T61E/MqDhh8KGlVBUGLsg6MxFoXOrgfpOO73P08fzEE1n1s3B TGbs9txnEHOVpfUip+vOlxq3rvVp04sS2KUa6fbxZvmABT1JFW1mewwkP w==; X-IronPort-AV: E=McAfee;i="6400,9594,10415"; a="267481965" X-IronPort-AV: E=Sophos;i="5.93,183,1654585200"; d="scan'208";a="267481965" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 08:49:34 -0700 X-IronPort-AV: E=Sophos;i="5.93,183,1654585200"; d="scan'208";a="573792891" Received: from vasantgx-mobl.amr.corp.intel.com (HELO [10.212.244.191]) ([10.212.244.191]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 08:49:32 -0700 Message-ID: Date: Thu, 21 Jul 2022 08:49:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCHv7 02/14] mm: Add support for unaccepted memory Content-Language: en-US To: Borislav Petkov , "Kirill A. Shutemov" Cc: Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-3-kirill.shutemov@linux.intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 7/21/22 08:14, Borislav Petkov wrote: > On Tue, Jun 14, 2022 at 03:02:19PM +0300, Kirill A. Shutemov wrote: >> On-demand memory accept means latency spikes every time kernel steps >> onto a new memory block. The spikes will go away once workload data >> set size gets stabilized or all memory gets accepted. > What does that mean? > > If we're accepting 2M pages and considering referential locality, how > are those "spikes" even noticeable? Acceptance is slow and the heavy lifting is done inside the TDX module. It involves flushing old aliases out of the caches and initializing the memory integrity metadata for every cacheline. This implementation does acceptance in 2MB chunks while holding a global lock. So, those (effective) 2MB clflush+memset's (plus a few thousand cycles for the hypercall/tdcall transitions) can't happen in parallel. They are serialized and must wait on each other. If you have a few hundred CPUs all trying to allocate memory (say, doing the first kernel compile after a reboot), this is going to be very, very painful for a while. That said, I think this is the right place to _start_. There is going to need to be some kind of follow-on solution (likely background acceptance of some kind). But, even with that solution, *this* code is still needed to handle the degenerate case where the background accepter can't keep up with foreground memory needs.