From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BD57C4320A for ; Fri, 6 Aug 2021 07:10:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD1BF611C9 for ; Fri, 6 Aug 2021 07:10:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD1BF611C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C7ED96B006C; Fri, 6 Aug 2021 03:10:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C2F238D0002; Fri, 6 Aug 2021 03:10:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1DE18D0001; Fri, 6 Aug 2021 03:10:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 972316B006C for ; Fri, 6 Aug 2021 03:10:33 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 48024180AE7E1 for ; Fri, 6 Aug 2021 07:10:33 +0000 (UTC) X-FDA: 78443782746.32.9D231AA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id D33A0900803A for ; Fri, 6 Aug 2021 07:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628233832; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OdiX91xZyqhCMWTD+e1a7203Hh2iiQFW1H/jHSgMREc=; b=ZEJwu9F+5NmCWWBljAV343h9V/i7WvsbM1jOZG7QNw3xB4KplhPvdd6tjz/gJHmcA0ixmS Jj4Bqr7J2WmVTcYFMdiAHPoQDEZnP67eGIQgnEqSIi/Ds1m7d4ZIJ26/anyD9zbN1H+pST wHM/GI8p278Ld3bAvjzAZhlVS6XdppE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-GQjJRieeMAex657QmlmTTQ-1; Fri, 06 Aug 2021 03:10:30 -0400 X-MC-Unique: GQjJRieeMAex657QmlmTTQ-1 Received: by mail-wm1-f72.google.com with SMTP id l38-20020a05600c1d26b0290259bef426efso2139056wms.8 for ; Fri, 06 Aug 2021 00:10:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=OdiX91xZyqhCMWTD+e1a7203Hh2iiQFW1H/jHSgMREc=; b=HDOEwINaziC4csO+9KC8KlrAXa5wYRa4s7tp42GntASeb8+aroRO+RgNY0ziZi5ALl M4m8YDMgJgnOP0VbHnR2XI4ewvhvaoLdMjDbw42EjNUb+kxMKgZ0LlPNsGT0NGFHbE6P +XWXstb0BWjroOpd+oHqfnsJKBXxpCAo8k5DMXX2qxX5UzMq4s+7HrNVyo1kOQHm+LiO bXaizgCM7WIPzhvcZrClYvgncj5qQbOPnHeTxrvi1AEwOkU0PTOOybsF0acMkNQSYZwx 1smz/Lt6ikL05xZvuvPGXTTrPqPtDNXtPpZyKX8EyOXaq4aaiOkcsW5jdfin4+4sRLox dpLg== X-Gm-Message-State: AOAM532cVWjRVNROkdzwq1ZggT/wTnNFl5swwVKzhJT4KK6+AgYU7s/K 7++sM0lrAMRCpD879p0AO+ivo/7NM5745gwAsvI/SioQE1n2C0kPzf66hGHPpG4JCo8ffbiOVOh +7ZUZ+EkEYtI= X-Received: by 2002:a1c:7402:: with SMTP id p2mr18778769wmc.111.1628233829619; Fri, 06 Aug 2021 00:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3kCeiOWbbw8vg7aEBTtCpQMHk0XWodUURxQdsSZuiFQC4PLQm2T8HYcAlaq/7xcBafZ8pIw== X-Received: by 2002:a1c:7402:: with SMTP id p2mr18778739wmc.111.1628233829376; Fri, 06 Aug 2021 00:10:29 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6104.dip0.t-ipconnect.de. [91.12.97.4]) by smtp.gmail.com with ESMTPSA id a2sm8564992wrn.95.2021.08.06.00.10.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 00:10:29 -0700 (PDT) To: Claudio Imbrenda , kvm@vger.kernel.org Cc: cohuck@redhat.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Ulrich.Weigand@de.ibm.com, "linux-mm@kvack.org" , Michal Hocko References: <20210804154046.88552-1-imbrenda@linux.ibm.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v3 00/14] KVM: s390: pv: implement lazy destroy Message-ID: <86b114ef-41ea-04b6-327c-4a036f784fad@redhat.com> Date: Fri, 6 Aug 2021 09:10:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210804154046.88552-1-imbrenda@linux.ibm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZEJwu9F+; spf=none (imf29.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D33A0900803A X-Stat-Signature: d15p4p8i3qa1ea4y6tz9bfiy3sxqpcid X-HE-Tag: 1628233832-14130 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 04.08.21 17:40, Claudio Imbrenda wrote: > Previously, when a protected VM was rebooted or when it was shut down, > its memory was made unprotected, and then the protected VM itself was > destroyed. Looping over the whole address space can take some time, > considering the overhead of the various Ultravisor Calls (UVCs). This > means that a reboot or a shutdown would take a potentially long amount > of time, depending on the amount of used memory. >=20 > This patchseries implements a deferred destroy mechanism for protected > guests. When a protected guest is destroyed, its memory is cleared in > background, allowing the guest to restart or terminate significantly > faster than before. >=20 > There are 2 possibilities when a protected VM is torn down: > * it still has an address space associated (reboot case) > * it does not have an address space anymore (shutdown case) >=20 > For the reboot case, the reference count of the mm is increased, and > then a background thread is started to clean up. Once the thread went > through the whole address space, the protected VM is actually > destroyed. That doesn't sound too hacky to me, and actually sounds like a good=20 idea, doing what the guest would do either way but speeding it up=20 asynchronously, but ... >=20 > For the shutdown case, a list of pages to be destroyed is formed when > the mm is torn down. Instead of just unmapping the pages when the > address space is being torn down, they are also set aside. Later when > KVM cleans up the VM, a thread is started to clean up the pages from > the list. ... this ... >=20 > This means that the same address space can have memory belonging to > more than one protected guest, although only one will be running, the > others will in fact not even have any CPUs. ... this ... >=20 > When a guest is destroyed, its memory still counts towards its memory > control group until it's actually freed (I tested this experimentally) >=20 > When the system runs out of memory, if a guest has terminated and its > memory is being cleaned asynchronously, the OOM killer will wait a > little and then see if memory has been freed. This has the practical > effect of slowing down memory allocations when the system is out of > memory to give the cleanup thread time to cleanup and free memory, and > avoid an actual OOM situation. ... and this sound like the kind of arch MM hacks that will bite us in=20 the long run. Of course, I might be wrong, but already doing excessive=20 GFP_ATOMIC allocations or messing with the OOM killer that way for a=20 pure (shutdown) optimization is an alarm signal. Of course, I might be=20 wrong. You should at least CC linux-mm. I'll do that right now and also CC=20 Michal. He might have time to have a quick glimpse at patch #11 and #13. https://lkml.kernel.org/r/20210804154046.88552-12-imbrenda@linux.ibm.com https://lkml.kernel.org/r/20210804154046.88552-14-imbrenda@linux.ibm.com IMHO, we should proceed with patch 1-10, as they solve a really=20 important problem ("slow reboots") in a nice way, whereby patch 11=20 handles a case that can be worked around comparatively easily by=20 management tools -- my 2 cents. --=20 Thanks, David / dhildenb