Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp635898lfv; Tue, 12 Apr 2022 00:34:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk4FiuU1zEwfFj1qh+POEHRQSCnOhFZWULvbxBnadAroRoREi50gzzPwPNqBuGV+05VK3g X-Received: by 2002:a05:6402:2056:b0:41d:70c3:2904 with SMTP id bc22-20020a056402205600b0041d70c32904mr14368760edb.397.1649748853977; Tue, 12 Apr 2022 00:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649748853; cv=none; d=google.com; s=arc-20160816; b=FcNIJ2XfkHBha2OR+m1Uovqy3Ot/M0V5nrl2J4T4+CTqigGjNPAvLBsqdaL5evAlfy e1Rf186JjblbcFtTYHS+geZjLpDdcr/qtYlBCQoKJpJ0cSpRqWQATI0R8cGp7vyC46X9 nI020TITFqk4FSd9tfG/vULovfkDKzU+3hNYo7/g5tyZ20r3xWpk3xQrugvKcMwJVgpW riNaofn+JVLnsOhZdfN99fA/N6/JPJHyvScgksZEKEYSAyDJd+jUWUwwSEb7LeSIOJSy nTxLkw5v+VV//8/DlobumwG06uwIQh1BpF1Wl1fiHrT4uXK1oLdDzPl78Pkk2rjceuRj lKSw== 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=2BJwi+4MUHVrKX308NfOg46ABCdrEGwFNuCfJTM4PEA=; b=hRss9WG4q+if4pLcdpqYk260ssRLZaboaMyrxPYVp1pAPCq61Th0PxlFQsQQu82cvE Lk8npzOQAlhnt+xJSiY9QVE9WukzO3TUbyaQHYrgJXpGvjCrODZmXj55/hHWQsGjGzyi lYOU9UX4TNqy+NAn4OK4ZDwNWMarDAnjGDWBHo0jnC0UWpmS6ZMIkTqY6AyEH+H+cFpG dT4WX7zYaPw76K8aZ1iwjXUVBGQqyZp72m7SwuR4iPc9d0QGXkrrWdbrHl84yxsImRRX UVfntlYs8ZzsfA5BW7k8Wkzx7rp/1e5lFdAx4cX6Oie3Ctj0zygYVOu1IJquSOXVX1K3 j3gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=MN50Hswb; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a056402269100b0041cc318987fsi9939949edd.550.2022.04.12.00.33.49; Tue, 12 Apr 2022 00:34:13 -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=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=MN50Hswb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242946AbiDIRww (ORCPT + 99 others); Sat, 9 Apr 2022 13:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234519AbiDIRwt (ORCPT ); Sat, 9 Apr 2022 13:52:49 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 180A21CFFB5 for ; Sat, 9 Apr 2022 10:50:41 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id b21so20019866lfb.5 for ; Sat, 09 Apr 2022 10:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2BJwi+4MUHVrKX308NfOg46ABCdrEGwFNuCfJTM4PEA=; b=MN50HswbicjFFL7K5mQ5CImChULXEkQz0FzkiaI3+yYKdPBrcrNzQMylJQdy8TjEQf 5wcmnqtlY6cIWr4Xwwhf9qfp8YDXgnNp89sliELF/wPXIOODX3w4yMpkdZo4HBh1nycu HS84zY9faBsIE5HwW8AqridmwGGbjA8ZCFMdSkmf8q+yET0bkKRsutZOyVTnJxI0XK0X zT8+sXdketeYf0lWkZ/JTEURmbHJhouPvYqBYKM/lXukoPLyzU99u0RB86e6XN0moGGi Y5ih3+OSgtBEuDPI8SUkl+4qC2exssdnliXZ71YfnkSnuCm5gudeyMUsppD01fj1gAeH 0xFg== 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=2BJwi+4MUHVrKX308NfOg46ABCdrEGwFNuCfJTM4PEA=; b=d0/q9ZgsLrPyMR6vRDyrUzIbID4JzvSxQjGu2CbQuNIlH2TOAc1S/FAA9kvRPEiXt7 28/G4HezwoAsixHwQhAlECrleDrAUA22Zwy+qgA4AJBtlTv8+T2+HCg2yjS38xhECbF4 EtJ/mZqB66ZvdWdiFsPTsqtrkTr/PUazSJEjHgwMEagRLwE1zc9piI/ZZqLnpM5uwN2A 14p8PqGUBXE+fzmW4i6SgVwea79PvxANqBJbeMSSD7bUkQaJF69epWtHVf0++BKG74gQ Z18allygGGFQMiYkrU18xba2Ckrn4fWpa6pzXIkCcnnEgi49v5XDzfVTuTmxf2sQudJk Yscg== X-Gm-Message-State: AOAM5309uZUbGA77YRgUThC/DmLEp5x+AbQadYx2u9Yfv7eq81J7nl/e kBv/EDpaBxiakNIBdbBYSdpW4Q== X-Received: by 2002:a05:6512:ac1:b0:46b:8fd0:b030 with SMTP id n1-20020a0565120ac100b0046b8fd0b030mr2977704lfu.372.1649526639318; Sat, 09 Apr 2022 10:50:39 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id h24-20020a19ca58000000b0046b9dbfc809sm65098lfj.56.2022.04.09.10.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Apr 2022 10:50:38 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 1747B1039DB; Sat, 9 Apr 2022 20:52:10 +0300 (+03) Date: Sat, 9 Apr 2022 20:52:10 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: "Kirill A. Shutemov" , Borislav Petkov , 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 , Brijesh Singh , Mike Rapoport , David Hildenbrand , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: Re: [PATCHv4 1/8] mm: Add support for unaccepted memory Message-ID: <20220409175210.xik3ue3shpagskvi@box.shutemov.name> References: <20220405234343.74045-1-kirill.shutemov@linux.intel.com> <20220405234343.74045-2-kirill.shutemov@linux.intel.com> <93a7cfdf-02e6-6880-c563-76b01c9f41f5@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <93a7cfdf-02e6-6880-c563-76b01c9f41f5@intel.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 08, 2022 at 12:11:58PM -0700, Dave Hansen wrote: > On 4/5/22 16:43, Kirill A. Shutemov wrote: > > Kernel only needs to accept memory once after boot, so during the boot > > and warm up phase there will be a lot of memory acceptance. After things > > are settled down the only price of the feature if couple of checks for > > PageUnaccepted() in allocate and free paths. The check refers a hot > > variable (that also encodes PageBuddy()), so it is cheap and not visible > > on profiles. > > Let's also not sugar-coat this. Page acceptance is hideously slow. > It's agonizingly slow. To boot, it's done holding a global spinlock > with interrupts disabled (see patch 6/8). At the very, very least, each > acceptance operation involves a couple of what are effectively ring > transitions, a 2MB memset(), and a bunch of cache flushing. > > The system is going to be downright unusable during this time, right? Well, yes. The CPU that doing accepting is completely blocked by it. But other CPUs may proceed until in in its turn steps onto memory accepting. > Sure, it's *temporary* and only happens once at boot. But, it's going > to suck. > > Am I over-stating this in any way? > > The ACCEPT_MEMORY vmstat is good to have around. Thanks for adding it. > But, I think we should also write down some guidance like: > > If your TDX system seems as slow as snail after boot, look at > the "accept_memory" counter in /proc/vmstat. If it is > incrementing, then TDX memory acceptance is likely to blame. Sure. Will add to commit message. > Do we need anything more discrete to tell users when acceptance is over? I can imagine setups that where acceptance is never over. A VM running a workload with fixed dataset can have planty of memory unaccepted. I don't think "make it over" should be the goal. > For instance, maybe they run something and it goes really slow, they > watch "accept_memory" until it stops. They rejoice at their good > fortune! Then, memory allocation starts falling over to a new node and > the agony beings anew. > > I can think of dealing with this in two ways: > > cat /sys/.../unaccepted_pages_left > > which just walks the bitmap and counts the amount of pages remaining. or > something like: > > echo 1 > /sys/devices/system/node/node0/make_the_pain_stop > > Which will, well, make the pain stop on node0. Sure we can add handles. But API is hard. Maybe we should wait and see what is actually needed. (Yes, I'm lazy.:) -- Kirill A. Shutemov