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=-8.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 89811C35247 for ; Tue, 4 Feb 2020 23:59:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2ED5520731 for ; Tue, 4 Feb 2020 23:59:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="npj8cSKu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2ED5520731 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B88956B0003; Tue, 4 Feb 2020 18:59:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B39376B000C; Tue, 4 Feb 2020 18:59:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B1FB6B000D; Tue, 4 Feb 2020 18:59:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 77BC06B0003 for ; Tue, 4 Feb 2020 18:59:05 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 26C12181AC9C6 for ; Tue, 4 Feb 2020 23:59:05 +0000 (UTC) X-FDA: 76454113050.30.time44_6c5cec179610b X-HE-Tag: time44_6c5cec179610b X-Filterd-Recvd-Size: 13760 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 4 Feb 2020 23:59:04 +0000 (UTC) Received: by mail-vs1-f47.google.com with SMTP id p6so177931vsj.11 for ; Tue, 04 Feb 2020 15:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TcS54X5u3D35EncQnOa2Vb4A59aceDi9bYhggZgDUb0=; b=npj8cSKumskrUZJXMYe8rKypauap/2OZX4VWAgKX+i1Cw0RMSNH3LxEU/IDgd4J9yW bwmn1OPJsazPRVmgW7/IDyzajz7CNEnRERGrK/K9HYT3+VrOEje4xY4owv4I/j0ImxiW ePvuzRJhJvRgDWyLcTmGkJDYuOWyrTEOYAjftJvrp3lsPmhJdpAoJ6/CXq9vmoHZmKA/ WA+B3t03pWFcSti0vAovXJJoaEObnm0lbL7bQG2hjE4/JR5yHLGfnzN6kqOURnsQxdDB 75fduPTYUJGaRk5X5cA55mwGZdw2Ujs2sl7kJ8WpMp6SyJ3H/gixjTA+8u84n1MRpYLc jULA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TcS54X5u3D35EncQnOa2Vb4A59aceDi9bYhggZgDUb0=; b=e/AnFCPH2cJfGrQWaO9pN5pSgGvW4LAEnGjmIKv7S952/D4g1z4h6RThonIrjPlPT/ chzrOB1iNoyn+yH5zDmbuS/rtQMGapAX5VptHEuvsTY3KNNkQHvxQNdW7+QtWb09UZJQ K8tGT5mlcx6SPYoLdLGNJ+JOOFbse86m9u1MXw4HU9e+TyQkmC5YlCyXJhKTpwH2JN0W RNUvxzHTWDgctZA3qSonr59qSAtTJOn3Wt+bv72afLcnN53CsaLCbl18VQWX0njav6D0 Ue+PJw7tFXj0wekKm4Zd6r42PNP4ysoqUFGdAVeqy17CMvJFVpvSGn1NXjR9HHAK51U8 o+gA== X-Gm-Message-State: APjAAAUvh43QUhqjjR7f8i1YAUo+FTjvU4XmCP+ur6RWYMsW0SK04KfA RifMHyx7/IakxauP3vpf4W3qk+Q7OyzcLVLGiT5MXQ== X-Google-Smtp-Source: APXvYqwuI0TWTA/lGraii2n5o5puu/XY0aXxlExXu1Fz9TikGZ0zvSoceW3IJGcVdeyfmnpSzbZE4xjlydCECb1RiYg= X-Received: by 2002:a05:6102:72b:: with SMTP id u11mr20212328vsg.69.1580860743752; Tue, 04 Feb 2020 15:59:03 -0800 (PST) MIME-Version: 1.0 References: <91270a68-ff48-88b0-219c-69801f0c252f@redhat.com> <75d4594f-0864-5172-a0f8-f97affedb366@redhat.com> <286AC319A985734F985F78AFA26841F73E3F8A02@shsmsx102.ccr.corp.intel.com> <20200203080520-mutt-send-email-mst@kernel.org> <5ac131de8e3b7fc1fafd05a61feb5f6889aeb917.camel@linux.intel.com> <20200203120225-mutt-send-email-mst@kernel.org> <74cc25a6-cefb-c580-8e59-5b76fb680bf4@redhat.com> In-Reply-To: From: Tyler Sanderson Date: Tue, 4 Feb 2020 15:58:51 -0800 Message-ID: Subject: Re: Balloon pressuring page cache To: David Hildenbrand Cc: "Michael S. Tsirkin" , Alexander Duyck , "Wang, Wei W" , "virtualization@lists.linux-foundation.org" , David Rientjes , "linux-mm@kvack.org" , Michal Hocko , namit@vmware.com Content-Type: multipart/alternative; boundary="00000000000012761a059dc8d3cb" 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: --00000000000012761a059dc8d3cb Content-Type: text/plain; charset="UTF-8" On Tue, Feb 4, 2020 at 11:17 AM David Hildenbrand wrote: > On 04.02.20 19:52, Tyler Sanderson wrote: > > > > > > On Tue, Feb 4, 2020 at 12:29 AM David Hildenbrand > > wrote: > > > > On 03.02.20 21:32, Tyler Sanderson wrote: > > > There were apparently good reasons for moving away from OOM > notifier > > > callback: > > > https://lkml.org/lkml/2018/7/12/314 > > > https://lkml.org/lkml/2018/8/2/322 > > > > > > In particular the OOM notifier is worse than the shrinker because: > > > > The issue is that DEFLATE_ON_OOM is under-specified. > > > > > > > > 1. It is last-resort, which means the system has already gone > through > > > heroics to prevent OOM. Those heroic reclaim efforts are > expensive > > > and impact application performance. > > > > That's *exactly* what "deflate on OOM" suggests. > > > > > > It seems there are some use cases where "deflate on OOM" is desired and > > others where "deflate on pressure" is desired. > > This suggests adding a new feature bit "DEFLATE_ON_PRESSURE" that > > registers the shrinker, and reverting DEFLATE_ON_OOM to use the OOM > > notifier callback. > > > > This lets users configure the balloon for their use case. > > You want the old behavior back, so why should we introduce a new one? Or > am I missing something? (you did want us to revert to old handling, no?) > Reverting actually doesn't help me because this has been the behavior since Linux 4.19 which is already widely in use. So my device implementation needs to handle the shrinker behavior anyways. I started this conversation to ask what the intended device implementation was. I think there are reasonable device implementations that would prefer the shrinker behavior (it turns out that mine doesn't). For example, an implementation that slowly inflates the balloon for the purpose of memory overcommit. It might leave the balloon inflated and expect any memory pressure (including page cache usage) to deflate the balloon as a way to dynamically right-size the balloon. Two reasons I didn't go with the above implementation: 1. I need to support guests before Linux 4.19 which don't have the shrinker behavior. 2. Memory in the balloon does not appear as "available" in /proc/meminfo even though it is freeable. This is confusing to users, but isn't a deal breaker. If we added a DEFLATE_ON_PRESSURE feature bit that indicated shrinker API support then that would resolve reason #1 (ideally we would backport the bit to 4.19). In any case, the shrinker behavior when pressuring page cache is more of an inefficiency than a bug. It's not clear to me that it necessitates reverting. If there were/are reasons to be on the shrinker interface then I think those carry similar weight as the problem itself. > > I consider virtio-balloon to this very day a big hack. And I don't see > it getting better with new config knobs. Having that said, the > technologies that are candidates to replace it (free page reporting, > taming the guest page cache, etc.) are still not ready - so we'll have > to stick with it for now :( . > > > > > I'm actually not sure how you would safely do memory overcommit without > > DEFLATE_ON_OOM. So I think it unlocks a huge use case. > > Using better suited technologies that are not ready yet (well, some form > of free page reporting is available under IBM z already but in a > proprietary form) ;) Anyhow, I remember that DEFLATE_ON_OOM only makes > it less likely to crash your guest, but not that you are safe to squeeze > the last bit out of your guest VM. > Can you elaborate on the danger of DEFLATE_ON_OOM? I haven't seen any problems in testing but I'd really like to know about the dangers. Is there a difference in safety between the OOM notifier callback and the shrinker API? > > -- > Thanks, > > David / dhildenb > > --00000000000012761a059dc8d3cb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Feb 4, 2020 at 11:17 AM David= Hildenbrand <david@redhat.com&g= t; wrote:
On 04.= 02.20 19:52, Tyler Sanderson wrote:
>
>
> On Tue, Feb 4, 2020 at 12:29 AM David Hildenbrand <david@redhat.com
> <mailto:david= @redhat.com>> wrote:
>
>=C2=A0 =C2=A0 =C2=A0On 03.02.20 21:32, Tyler Sanderson wrote:
>=C2=A0 =C2=A0 =C2=A0> There were apparently good reasons for moving = away from OOM notifier
>=C2=A0 =C2=A0 =C2=A0> callback:
>=C2=A0 =C2=A0 =C2=A0> https://lkml.org/lkml/2018/7/12/314<= /a>
>=C2=A0 =C2=A0 =C2=A0>
https://lkml.org/lkml/2018/8/2/322
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0> In particular the OOM notifier is worse than t= he shrinker because:
>
>=C2=A0 =C2=A0 =C2=A0The issue is that DEFLATE_ON_OOM is under-specified= .
>
>=C2=A0 =C2=A0 =C2=A0>
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 1. It is last-resort, which means the sy= stem has already gone through
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0heroics to prevent OOM. Tho= se heroic reclaim efforts are expensive
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0and impact application perf= ormance.
>
>=C2=A0 =C2=A0 =C2=A0That's *exactly* what "deflate on OOM"= ; suggests.
>
>
> It seems there are some use cases where "deflate on OOM" is = desired and
> others where "deflate on pressure" is desired.
> This suggests adding a new feature bit "DEFLATE_ON_PRESSURE"= that
> registers the shrinker, and reverting DEFLATE_ON_OOM to use the OOM > notifier callback.
>
> This lets users configure the balloon for their use case.

You want the old behavior back, so why should we introduce a new one? Or am I missing something? (you did want us to revert to old handling, no?)
Reverting actually doesn't help me because this has = been the behavior since Linux 4.19 which is already widely in use. So my de= vice implementation needs to handle the shrinker behavior anyways. I starte= d this conversation to ask what the intended device implementation was.

I think there are reasonable device implementations t= hat would prefer the shrinker=C2=A0behavior (it turns out that mine doesn&#= 39;t).
For example, an implementation that slowly inflates th= e balloon for the purpose of memory overcommit. It might leave the balloon = inflated and expect any memory pressure (including page cache usage) to def= late the balloon as a way to dynamically right-size the balloon.
=
Two reasons I didn't go with the above implementation:
1. I need to support guests before Linux 4.19 which don't have= the shrinker behavior.
2. Memory in the balloon does not appear = as "available" in /proc/meminfo even though it is freeable. This = is confusing to users, but isn't a deal breaker.

If we added a DEFLATE_ON_PRESSURE feature bit that indicated shrink= er API support then that would resolve reason=C2=A0#1 (ideally we would bac= kport the bit to 4.19).

In any case, the shrinker= =C2=A0behavior when pressuring page cache is more of an inefficiency than a= bug. It's not clear to me that it necessitates reverting. If there wer= e/are reasons to be on the shrinker=C2=A0interface then I think those carry= similar weight as the problem itself.
=C2=A0

I consider virtio-balloon to this very day a big hack. And I don't see<= br> it getting better with new config knobs. Having that said, the
technologies that are candidates to replace it (free page reporting,
taming the guest page cache, etc.) are still not ready - so we'll have<= br> to stick with it for now :( .

>
> I'm actually not sure how you would safely do memory overcommit wi= thout
> DEFLATE_ON_OOM. So I think it unlocks a huge use case.

Using better suited technologies that are not ready yet (well, some form of free page reporting is available under IBM z already but in a
proprietary form) ;) Anyhow, I remember that DEFLATE_ON_OOM only makes
it less likely to crash your guest, but not that you are safe to squeeze the last bit out of your guest VM.
Can you elaborate o= n the danger of DEFLATE_ON_OOM? I haven't seen any problems in testing = but I'd really like to know about the dangers.
Is there a dif= ference in safety between the OOM notifier callback and the shrinker API?
=C2=A0

--
Thanks,

David / dhildenb

--00000000000012761a059dc8d3cb--