Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp397716pxt; Fri, 6 Aug 2021 04:53:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPbfswlj4FFPkqCRUga9qbxTs4UFVeegHYMFcNZMejmg/iHs85WrThRsakw4ijDCD7Sc8Q X-Received: by 2002:a17:907:2058:: with SMTP id pg24mr9520287ejb.315.1628250797505; Fri, 06 Aug 2021 04:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628250797; cv=none; d=google.com; s=arc-20160816; b=zZDzptYxmfZJbTyu9QXoHDVjsDHMxH1DjhMnhenOLnKJEDZAgI9PZGh9I1ipyIN2vl N5OJakO/dlTs9eGGPaEDZwA6vVD44BgmVjdYrOd25GKe2VdB6K2mIMbSrIIbNRlkX+/2 wTON7/SDlbvNxZ7b/pE8AKt5iikVt10n6wWw8CSKa4yd6M/LKFSPj0VILqflYakc+Xc/ uKwVfX+f+bmPK75uV9RY0mlrzQ4/s1K287MRDVs+Zyxndr7AEB6rRB0XkaWEnAJFNr5C EORn+RJHR69TqTPPa1e7JZtPooVedde1AjGsQKaNh6F8muJMxy29qiZHy+2IO/ETScHB T7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject :organization:from:references:cc:to:dkim-signature; bh=OdiX91xZyqhCMWTD+e1a7203Hh2iiQFW1H/jHSgMREc=; b=JC69nVZmJDiEgvChlx9kPvIGBCducNmAmGMpRhqZMJjZKoJLWz2s9UAv7W7zYWjOao FIjoo8xVssdVOp1gDEZbfAdTw5EuMctI0EKSK8OSC+yfhePw8oWVCrR7puyj++l3i8D7 bDdbWk7ZfOe1ORYfJViQ98lWLjZA626TvfFGMJDbW5Vahg43Cpznm4Xi+8KmqeYlRZF0 FkZMQtXme6js6QytzG1ThxkGQg0a6CAMyZVRqprEmAyYdQFHyUdPZEpJm6jSbn5imeh4 1kvqn6XBuHYBaRMUxa5aTuYuJ+vhs7ld/Asfz+2gpvyjCkyoALE9adZw40naXWFb3yiy q61w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ESGSkGtc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m23si8618419edr.595.2021.08.06.04.52.51; Fri, 06 Aug 2021 04:53:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ESGSkGtc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243499AbhHFHKs (ORCPT + 99 others); Fri, 6 Aug 2021 03:10:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47534 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239010AbhHFHKr (ORCPT ); Fri, 6 Aug 2021 03:10:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628233831; 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=ESGSkGtcN6ex7yLt92AhtpaIxJTmoP6RN9VA1TnmJjM0/TYdPsa35HhBloqoba0BG8+oeE 1KUfpn+mgdksYCmnkNhJAq5XCiSbiITmpI+ahRefZy05uXxarc7AuSyrN+9k8P/NA/a9Vw sncxFCtxsPAG91fiy3auJxwHI+qyZt0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-QMvtQx2MNyK2yzmdou3xiQ-1; Fri, 06 Aug 2021 03:10:30 -0400 X-MC-Unique: QMvtQx2MNyK2yzmdou3xiQ-1 Received: by mail-wm1-f69.google.com with SMTP id r125-20020a1c2b830000b0290197a4be97b7so2135756wmr.9 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=Z4nDQjaBzESBV2k42VBQHrC2rZI7fMU2D5bUPYQLWWBeOFwP+lXMdlNBdA0/ZniLrL YhCafb+nQBnczxyeUYRdeJf5AhXqC4E8rOS0gEKKCw5iUHOCU+Vb7rTCOixOP+FHSMkP MFdB6l80i/qZJ0gswCqwVUwCTvldNW4zU3j6pky/xAU7B7N3rqTAlcmyGocgLrCpOBxl cC1vh674AtFYMu91m+2y5kE4tPLN1TdDB3wkXlvSPOF5SQp5MxMyvsaMUKNuBpHxtvZ6 Bl8AT6j9hDhHUwXYUtlcpBsn5HMMrj+tg/9stnpTf6F8UVV9TqDnPsjkKk20B8lEgbde uaSg== X-Gm-Message-State: AOAM533uGOz3p8NMIEh6RJ/kpdEstSpNQfzvtRfAD+nx6YnyaGbisNnX oo73OZqAc7ojakAzmcpnWXLVIvOeUzKS9uzz58/4bDOm/DPoVOID3xe/TNgw7E8BIX3R+FhQoje FzOawwoOCr8TVbz3lzFD/ozVI X-Received: by 2002:a1c:7402:: with SMTP id p2mr18778753wmc.111.1628233829542; Fri, 06 Aug 2021 00:10:29 -0700 (PDT) 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> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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. > > 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) > > 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 idea, doing what the guest would do either way but speeding it up asynchronously, but ... > > 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 ... > > 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 ... > > When a guest is destroyed, its memory still counts towards its memory > control group until it's actually freed (I tested this experimentally) > > 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 the long run. Of course, I might be wrong, but already doing excessive GFP_ATOMIC allocations or messing with the OOM killer that way for a pure (shutdown) optimization is an alarm signal. Of course, I might be wrong. You should at least CC linux-mm. I'll do that right now and also CC 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 important problem ("slow reboots") in a nice way, whereby patch 11 handles a case that can be worked around comparatively easily by management tools -- my 2 cents. -- Thanks, David / dhildenb