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,URIBL_BLOCKED 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 D29DCC33CAC for ; Mon, 3 Feb 2020 13:11:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 85E9B20658 for ; Mon, 3 Feb 2020 13:11:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HzSlyQTj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85E9B20658 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 34D0C6B0644; Mon, 3 Feb 2020 08:11:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FC376B0645; Mon, 3 Feb 2020 08:11:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 212326B0646; Mon, 3 Feb 2020 08:11:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id 0D3366B0644 for ; Mon, 3 Feb 2020 08:11:36 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D0D6D8248047 for ; Mon, 3 Feb 2020 13:11:35 +0000 (UTC) X-FDA: 76448852550.04.tank22_48197a05b043c X-HE-Tag: tank22_48197a05b043c X-Filterd-Recvd-Size: 7779 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 13:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580735494; 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=dxDZ6ZofCbqMp8VV8hpSUY0knlQWz/mwsOS3UIC+P+Y=; b=HzSlyQTjl85iZsX5swMPU6pYXp3z69ws/vjLGMtVRv4rN7TFSe4u2qMOg0RqOXekRsBftk F4wxA/YEgtekSu1tdxiVxQsvHDp2RZUNn+EFhHf82S5SybnoRHx1vap1IG1JD+yZeTin6i 28hTrOZYzMRGlFhVzG5JbKJ5WTB4CeY= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-oYpW7RSlPACfCFXKBV80TA-1; Mon, 03 Feb 2020 08:11:31 -0500 Received: by mail-qv1-f71.google.com with SMTP id dr18so9406005qvb.14 for ; Mon, 03 Feb 2020 05:11:31 -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=0bDzdNKtMnDJd7woVNalLK6TuNo4TJSUhpMmpxrJALY=; b=fXjTgr9mZlny5IKEH0ERRGEAMnj6sDE/Cthj13uVBTFKZjlIKh4bIGgnhVb73J1bL9 eJA6NWAJJUaZZk7La/iuy5Dr59iDbhGXhRi41mippEoF/GHVcie6gYWEj+1X/IE/lbr5 eXVwD9qkfCXsSkZwnr7Iaj51Pzd874OlU4lEv/KOvKtbxXn9o/YrJreH+znJ9N0uVE58 v0kc2A6RG24bKGi1/HkCfMd+eaqP84pDt+Cn9W3TzF9ccSsWAJEBjwkSs1UP13vp2K0w +OjXVSethPYNGu8R1BhJdbQTQ5q2cf1i55iybHCf8s5zfwAZhqxDFy3np3SeYJgKv6Mf M49w== X-Gm-Message-State: APjAAAVXQ2ZUPR0g63UWLeNbY8PSfHz3nWNMeCVIzD9hyR+2fYNgMsdd Dn44kSV8DsqTsHTY789A2MoVhnoNQMxS4YQBL9gDKaZuLt1rnNgjQDLrUCTOszgbxZb0GGnZZbY fee9HMdBA/3E= X-Received: by 2002:a05:6214:1494:: with SMTP id bn20mr13183208qvb.43.1580735491414; Mon, 03 Feb 2020 05:11:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxHSBpXmLZKuyScZ8w7dxOq5vQmmMIYOltjH4OVYLPpP6LVTrqrQA6eDy89xiojH1/J71aAdg== X-Received: by 2002:a05:6214:1494:: with SMTP id bn20mr13183181qvb.43.1580735491140; Mon, 03 Feb 2020 05:11:31 -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 t23sm9698104qto.88.2020.02.03.05.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 05:11:30 -0800 (PST) Date: Mon, 3 Feb 2020 08:11:26 -0500 From: "Michael S. Tsirkin" To: Tyler Sanderson Cc: "Wang, Wei W" , David Hildenbrand , "virtualization@lists.linux-foundation.org" , David Rientjes , "linux-mm@kvack.org" , Michal Hocko , alexander.h.duyck@linux.intel.com Subject: Re: Balloon pressuring page cache Message-ID: <20200203080520-mutt-send-email-mst@kernel.org> References: <91270a68-ff48-88b0-219c-69801f0c252f@redhat.com> <75d4594f-0864-5172-a0f8-f97affedb366@redhat.com> <286AC319A985734F985F78AFA26841F73E3F8A02@shsmsx102.ccr.corp.intel.com> MIME-Version: 1.0 In-Reply-To: X-MC-Unique: oYpW7RSlPACfCFXKBV80TA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 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 11:59:46AM -0800, Tyler Sanderson wrote: >=20 >=20 > On Thu, Jan 30, 2020 at 7:31 AM Wang, Wei W wrote: >=20 > On Thursday, January 30, 2020 11:03 PM, David Hildenbrand wrote: > > On 29.01.20 20:11, Tyler Sanderson wrote: > > > > > > > > > On Wed, Jan 29, 2020 at 2:31 AM David Hildenbrand > > > wrote: > > > > > >=C2=A0 =C2=A0 =C2=A0On 29.01.20 01:22, Tyler Sanderson via Virtual= ization wrote: > > >=C2=A0 =C2=A0 =C2=A0> A primary advantage of virtio balloon over o= ther=C2=A0memory reclaim > > >=C2=A0 =C2=A0 =C2=A0> mechanisms is that it can=C2=A0pressure the = guest's page cache into > > >=C2=A0 =C2=A0 =C2=A0shrinking. > > >=C2=A0 =C2=A0 =C2=A0> > > >=C2=A0 =C2=A0 =C2=A0> However, since the balloon driver changed to= using the shrinker > API > > >=C2=A0 =C2=A0 =C2=A0> > > > > > > e99a28e355255a#diff-fd202acf694d9eba19c8c64da3e480c9>=C2=A0this > > >=C2=A0 =C2=A0 =C2=A0> use case has become a bit more tricky. I'm w= ondering what the > > intended > > >=C2=A0 =C2=A0 =C2=A0> device implementation is. > > >=C2=A0 =C2=A0 =C2=A0> > > >=C2=A0 =C2=A0 =C2=A0> When inflating the balloon against page cach= e (i.e. no free > memory > > >=C2=A0 =C2=A0 =C2=A0> remains) vmscan.c will both shrink page cach= e, but also invoke > the > > >=C2=A0 =C2=A0 =C2=A0> shrinkers -- including the balloon's shrinke= r. So the balloon > driver > > >=C2=A0 =C2=A0 =C2=A0> allocates memory which requires reclaim, vms= can gets this memory > > by > > >=C2=A0 =C2=A0 =C2=A0> shrinking the balloon, and then the driver a= dds the memory back > to > > the > > >=C2=A0 =C2=A0 =C2=A0> balloon. Basically a busy no-op. >=20 > Per my understanding, the balloon allocation won=E2=80=99t invoke shr= inker as > __GFP_DIRECT_RECLAIM isn't set, no? >=20 > I could be wrong about the mechanism, but the device sees lots of activit= y on > the deflate queue. The balloon is being shrunk. And this only starts once= all > free memory is depleted and we're inflating into page cache. So given this looks like a regression, maybe we should revert the patch in question 71994620bb25 ("virtio_balloon: replace oom notifier with = shrinker") Besides, with VIRTIO_BALLOON_F_FREE_PAGE_HINT shrinker also ignores VIRTIO_BALLOON_F_MUST_TELL_HOST which isn't nice at all. So it looks like all this rework introduced more issues than it addressed ... I also CC Alex Duyck for an opinion on this. Alex, what do you use to put pressure on page cache? >=20 >=20 > > >=C2=A0 =C2=A0 =C2=A0> > > >=C2=A0 =C2=A0 =C2=A0> If file IO is ongoing during this balloon in= flation then the page > > >=C2=A0 =C2=A0 =C2=A0cache > > >=C2=A0 =C2=A0 =C2=A0> could be growing which further puts "back pr= essure" on the > balloon > > >=C2=A0 =C2=A0 =C2=A0> trying to inflate. In testing I've seen peri= ods of > 45 seconds > where > > >=C2=A0 =C2=A0 =C2=A0> balloon inflation makes no net forward progr= ess. >=20 > I think this is intentional (but could be improved). As inflation doe= s not > stop when the allocation fails (it simply sleeps for a while and resu= mes.. > repeat till there are memory to inflate) > That's why you see no inflation progress for long time under memory > pressure. >=20 > As noted above the deflate queue is active, so it's not just memory alloc= ation > failures. > =C2=A0 >=20 >=20 >=20 > Best, > Wei >=20