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 1AEE1C35247 for ; Mon, 3 Feb 2020 17:04:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C16AA2080C for ; Mon, 3 Feb 2020 17:04:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="azhHO75f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C16AA2080C 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 5AAFA6B0690; Mon, 3 Feb 2020 12:04:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 55C326B0691; Mon, 3 Feb 2020 12:04:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 471256B0692; Mon, 3 Feb 2020 12:04:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 2F6EE6B0690 for ; Mon, 3 Feb 2020 12:04:16 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B17A6181AEF00 for ; Mon, 3 Feb 2020 17:04:15 +0000 (UTC) X-FDA: 76449438870.13.end88_42329cff25939 X-HE-Tag: end88_42329cff25939 X-Filterd-Recvd-Size: 8093 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 17:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580749454; 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=xt+i8u6L+8Ya+gEOA/+qIbcP82Z7yRwzHXlut9nD1b4=; b=azhHO75f52qmgI8caLnJZ4HZtIlrhcuGmdUdise0r4CHg6kbT/HM9Ob6hRypI2U2Fi41tr X0IveXqTNEWaSWJHAcZyti9x4UrQfdGnz1/df7tAZMLAAqLkQP/R58/0Q8DYqRJM99GqFG ruyZ5foKx4bs//WOS0K0+Yd11nYLynA= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-Kfol_CVTNO6KjXRfL3C6ag-1; Mon, 03 Feb 2020 12:04:03 -0500 Received: by mail-qt1-f200.google.com with SMTP id g26so10292178qts.16 for ; Mon, 03 Feb 2020 09:04:03 -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=Y44gayMdvWxI/WSWNYy85+9/6qvmbHxSyq8pt+fDbBA=; b=R6bY1WQGbzlAi5DS2Zn9MH3b1REevz4qdBrbmrWimmyxiCpsHuvHQkWDXa9fvG2AMB xkswIaC95o/rXoThpHimTK/gwj1V/ULoGSrJT629mf+q51Bp5u45yXfEBaiVgnzFV6lZ QSGEv3KEROMNcKbzDXpZmGrWnAfDohjB7/RZnqj+eGlIt7rWd2cfGRNEAI0Csbrw5XEo i2pXkyIl2Ma62ofFuhfVPlDs0Fwx4EwAy+2xhm34dCcfuHIxmMXjKxFRWwmytXjqqV2D 5H/bAiuGUzw1aR/WXIcBscOoY89HFMHpY14F0f/xsLo5e4gZ3WIcEl55i5fACfk9C1rY a6gg== X-Gm-Message-State: APjAAAV47ghfryEJcje/OwDSUwEdfaPyP6/rzIW3svJlP+WXpv8r/NW2 Nf99ERSdglqK9A+bh1Qo3e3LxFnQr97x1K2xiKp95MeR1zbQhQ2H4wD3nfMxWfN2Xgk3XINNNaf WJRIqwPjp7XM= X-Received: by 2002:a37:9dc8:: with SMTP id g191mr24371856qke.171.1580749442456; Mon, 03 Feb 2020 09:04:02 -0800 (PST) X-Google-Smtp-Source: APXvYqziT6dDdzBZ5/VpRxQBOrjZwjAcJQbt0FjvLNXCg1NJioS7wYmUvlg7/2Y1knb3p3SASCDaxg== X-Received: by 2002:a37:9dc8:: with SMTP id g191mr24371833qke.171.1580749442075; Mon, 03 Feb 2020 09:04:02 -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 c186sm3870988qke.124.2020.02.03.09.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 09:04:01 -0800 (PST) Date: Mon, 3 Feb 2020 12:03:56 -0500 From: "Michael S. Tsirkin" To: David Hildenbrand Cc: Alexander Duyck , Tyler Sanderson , "Wang, Wei W" , "virtualization@lists.linux-foundation.org" , David Rientjes , "linux-mm@kvack.org" , Michal Hocko Subject: Re: Balloon pressuring page cache Message-ID: <20200203120225-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> <20200203080520-mutt-send-email-mst@kernel.org> <5ac131de8e3b7fc1fafd05a61feb5f6889aeb917.camel@linux.intel.com> MIME-Version: 1.0 In-Reply-To: X-MC-Unique: Kfol_CVTNO6KjXRfL3C6ag-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 Mon, Feb 03, 2020 at 05:34:20PM +0100, David Hildenbrand wrote: > On 03.02.20 17:18, Alexander Duyck wrote: > > On Mon, 2020-02-03 at 08:11 -0500, Michael S. Tsirkin wrote: > >> On Thu, Jan 30, 2020 at 11:59:46AM -0800, Tyler Sanderson wrote: > >>> > >>> On Thu, Jan 30, 2020 at 7:31 AM Wang, Wei W wr= ote: > >>> > >>> 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: > >>> > > > >>> > > On 29.01.20 01:22, Tyler Sanderson via Virtualization wro= te: > >>> > > > A primary advantage of virtio balloon over other memory= reclaim > >>> > > > mechanisms is that it can pressure the guest's page cac= he into > >>> > > shrinking. > >>> > > > > >>> > > > However, since the balloon driver changed to using the = shrinker > >>> API > >>> > > > > >>> > > > >>> > >>> > e99a28e355255a#diff-fd202acf694d9eba19c8c64da3e480c9> this > >>> > > > use case has become a bit more tricky. I'm wondering wh= at the > >>> > intended > >>> > > > device implementation is. > >>> > > > > >>> > > > When inflating the balloon against page cache (i.e. no = free > >>> memory > >>> > > > remains) vmscan.c will both shrink page cache, but also= invoke > >>> the > >>> > > > shrinkers -- including the balloon's shrinker. So the b= alloon > >>> driver > >>> > > > allocates memory which requires reclaim, vmscan gets th= is memory > >>> > by > >>> > > > shrinking the balloon, and then the driver adds the mem= ory back > >>> to > >>> > the > >>> > > > balloon. Basically a busy no-op. > >>> > >>> Per my understanding, the balloon allocation won=E2=80=99t invoke= shrinker as > >>> __GFP_DIRECT_RECLAIM isn't set, no? > >>> > >>> I could be wrong about the mechanism, but the device sees lots of act= ivity 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 > > I would say reverting probably makes sense. I'm not sure there is much > > value to having a shrinker running deflation when you are actively tryi= ng > > to increase the balloon. It would make more sense to wait until you are > > actually about to start hitting oom. >=20 > I think the shrinker makes sense for free page hinting feature > (everything on free_page_list). >=20 > So instead of only reverting, I think we should split it up and always > register the shrinker for VIRTIO_BALLOON_F_FREE_PAGE_HINT and the OOM > notifier (as before) for VIRTIO_BALLOON_F_MUST_TELL_HOST. OK ... I guess that means we need to fix shrinker to take VIRTIO_BALLOON_F_MUST_TELL_HOST into account correctly. Hosts ignore it at the moment but it's a fragile thing to do what it does and ignore used buffers. > (Of course, adapting what is being done in the shrinker and in the OOM > notifier) >=20 > --=20 > Thanks, >=20 > David / dhildenb