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=-5.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 714BCC33CB3 for ; Thu, 30 Jan 2020 15:20:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1BB2020CC7 for ; Thu, 30 Jan 2020 15:20:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RoFT8nYs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BB2020CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AF23E6B0366; Thu, 30 Jan 2020 10:20:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC8906B0368; Thu, 30 Jan 2020 10:20:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 991906B0369; Thu, 30 Jan 2020 10:20:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 81C806B0366 for ; Thu, 30 Jan 2020 10:20:27 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1DE71181AEF10 for ; Thu, 30 Jan 2020 15:20:27 +0000 (UTC) X-FDA: 76434662094.03.boats70_5b134ad441661 X-HE-Tag: boats70_5b134ad441661 X-Filterd-Recvd-Size: 6867 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Thu, 30 Jan 2020 15:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580397625; 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=4yOWp3viUJL7WpPtNkAvcUGpegFSE4/EDnwIIegUA7I=; b=RoFT8nYs/J5bChDNGd1F1k7moQP883IVI9k4vD+TbOhtMKvEwSPaKV6RNY6ZH06qXxFiqH pAC3Af1QIY/53hBCObggI0jfP37doEVa1KkW4JGIHtIodEsupcNJE6YAjMxdoy/d2Vcbuy Juei1JvIAMH1w9HWO5ZvSqpjB+2Il+k= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-h8VKIX_WNnO1PUVRta1xig-1; Thu, 30 Jan 2020 10:20:22 -0500 Received: by mail-qk1-f198.google.com with SMTP id p1so2133725qkh.3 for ; Thu, 30 Jan 2020 07:20:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=la3GHA8M1dPMBzf5EtBXkrQ0aslvqY4b2xiAgn9DNVw=; b=iukuFBe5iBc35OBc9eIhU9J+0S2H/AZJ1LrTe236AAMUA+/fek1MCg8/N3dx7Hhxvf ym5kFbvmTcahDzJd3rv8CkaHs3SW+zsPJJAyiaj4YN5fiA4Yi0CquMy5Ws7mGqEYYpxC +Gko4bTSPa4UE5vtmsmSwla+GK5M2yTlOmtKjbEoqNwkr9SOUaVbu5I67xrShxJc64a9 8rFAOBsAhGRBTFnMLkTNyGuak1sf15D51iNPQaUMVQJBknmRAKlLwlTaPdohqaSG2Sxb uaA7CZD7OsXU4wzIm/OrbkN/za1bkyzg/cs3n3vUtYLZ0V4RWtp7VN/eDlGP1FExNkJn jQYw== X-Gm-Message-State: APjAAAU9s+RXQPHerS8akDm3xJtsBFGRYyq0Ie9NLAtLoclwHW5Gifjl k8j6kNU0/OjPWliF+zfdF8xHFijJt6DTo33AYsPAc+RjbTnSZjpVINMvUvlY9hKEZK+RnIUeTmC R/IHM5eAWXUs= X-Received: by 2002:ac8:6e83:: with SMTP id c3mr5457797qtv.346.1580397622400; Thu, 30 Jan 2020 07:20:22 -0800 (PST) X-Google-Smtp-Source: APXvYqynCGgwDYzo/1lIuI49GtkxI2vA5iqze8qOR8lxw2JhiVKjUL8Oyy3cMY8ClJfX00HXBUZcMw== X-Received: by 2002:ac8:6e83:: with SMTP id c3mr5457768qtv.346.1580397622115; Thu, 30 Jan 2020 07:20:22 -0800 (PST) Received: from redhat.com (bzq-109-64-11-187.red.bezeqint.net. [109.64.11.187]) by smtp.gmail.com with ESMTPSA id r185sm2945434qke.102.2020.01.30.07.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 07:20:21 -0800 (PST) Date: Thu, 30 Jan 2020 10:20:17 -0500 From: "Michael S. Tsirkin" To: David Hildenbrand Cc: Tyler Sanderson , virtualization@lists.linux-foundation.org, Wei Wang , David Rientjes , "linux-mm@kvack.org" , Michal Hocko Subject: Re: Balloon pressuring page cache Message-ID: <20200130101710-mutt-send-email-mst@kernel.org> References: <91270a68-ff48-88b0-219c-69801f0c252f@redhat.com> <75d4594f-0864-5172-a0f8-f97affedb366@redhat.com> MIME-Version: 1.0 In-Reply-To: <75d4594f-0864-5172-a0f8-f97affedb366@redhat.com> X-MC-Unique: h8VKIX_WNnO1PUVRta1xig-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 Thu, Jan 30, 2020 at 04:02:34PM +0100, David Hildenbrand wrote: > On 29.01.20 20:11, Tyler Sanderson wrote: > >=20 > >=20 > > On Wed, Jan 29, 2020 at 2:31 AM David Hildenbrand > > wrote: > >=20 > > On 29.01.20 01:22, Tyler Sanderson via Virtualization wrote: > > > A primary advantage of virtio balloon over other=A0memory reclaim > > > mechanisms is that it can=A0pressure the guest's page cache into > > shrinking. > > > > > > However, since the balloon driver changed to using the shrinker A= PI > > > > > =A0this > > > use case has become a bit more tricky. I'm wondering what the int= ended > > > device implementation is. > > > > > > When inflating the balloon against page cache (i.e. no free memor= y > > > remains) vmscan.c will both shrink page cache, but also invoke th= e > > > shrinkers -- including the balloon's shrinker. So the balloon dri= ver > > > allocates memory which requires reclaim, vmscan gets this memory = by > > > shrinking the balloon, and then the driver adds the memory back t= o the > > > balloon. Basically a busy no-op. > > > > > > If file IO is ongoing during this balloon inflation then the page > > cache > > > could be growing which further puts "back pressure" on the balloo= n > > > trying to inflate. In testing I've seen periods of > 45 seconds w= here > > > balloon inflation makes no net forward progress. > > > > > > This wasn't a problem before the change to the shrinker API since > > forced > > > balloon deflation only occurred via the OOM notifier callback > > which was > > > invoked only after the page cache had depleted. > > > > > > Is this new busy behavior working as intended? > >=20 > > Please note that the shrinker will only be registered in case we ha= ve > > VIRTIO_BALLOON_F_DEFLATE_ON_OOM - (which is AFAIK very rare) - to > > implement automatic balloon deflation when the guest is under memor= y > > pressure. > >=20 > >=20 > > Are you actually experiencing issues with that or did you just stum= ble > > over the code? > >=20 > >=20 > > We have a use case that is encountering this (and that registers > > DEFLATE_ON_OOM). We can work around this, but it does seem inefficient. > > I understand there were good reasons for moving away from the OOM > > notifier callback, but I'm wondering if the balloon driver could specif= y > > a "nice" level to the shrinker API that would cause it to be reclaimed > > from only as a last resort? > > =A0 >=20 > Cc-ing linux-mm, Michal and Michael. Interesting. VIRTIO_BALLOON_F_DEFLATE_ON_OOM is really underspecified in a bunch of ways. I'll wait to see what does Michal say from Linux POV. > Just wondering, how does your workaround look like? >=20 > --=20 > Thanks, >=20 > David / dhildenb