Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1853316ybi; Wed, 17 Jul 2019 23:10:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIPDvtHoa6AoiuQjBO2QtW9KVjrTxvJZxNvhtHIi+E4mN/J3LmCfhopbHMou305ugINzMD X-Received: by 2002:a17:902:8489:: with SMTP id c9mr48598121plo.327.1563430205268; Wed, 17 Jul 2019 23:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563430205; cv=none; d=google.com; s=arc-20160816; b=Y4+yDqYc5dRU1lMRVyuRUyKZ9TNZDDvDWYzMeewqA1OiV+S6vVNVuGNjDlw9/ShAHU ZPKmuMZkWpbVOUBHz7fVOaWAb3kpReQSthp+uf05Fik+wXdl/CLy7ZAC77p26YKz4w8r LgPCsgZQF/OiGP5BzxNI11AF1Lo667OBuHAesJrtopnqMlZWQSXG7DBMVGeDL1E89agc O2dCXsRV0eQ8MSq4qGzkDAdcx/sv92PwH7U73U5PYcQRxyTP9f48MJDzai45kmQuOMvZ fInvasXgJWrpzRiWVLb5fEmAPZ5UUIP8W3oxGBKnQl4cU397bwsex34tFZHG7FXWJ1kW nI7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=pOaiHocYEhDQcJ6Gzk6K8WW2XuhI2quW6vRUEIWVag0=; b=0bC/GsMKgxKqey+n3RxGaq1A/syfdpqWEDsmzQ8/1GFeWY0DC+cxrgdZ9GHZLarBYq /TIBK4Coq+GypPmbY9paKs1n8B+/0EOcozpeJeV0JPuXcncwrmJHKsnZd+P7i6anurkc OkmeW/jNBaGEH0jl5YW19DUyCMYXb/cbmAz4I69lMYkhnl2S1hCkRmICJGLMHDoPHVJn /Vm/UIb+SaP7X8yikO3h5QvlQNgUVG2jlFYTdE442rI8DLLRjm8LXnnIcVzQ5UHTTz/G TfprN4go01fTjzZtYdy4e2kZ+m7sXztnlNCNi1FwSISoy8dpPHG3rV9Lwzv9TyTP4LHV y14g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b22si808731pjb.82.2019.07.17.23.09.48; Wed, 17 Jul 2019 23:10:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbfGRF6c (ORCPT + 99 others); Thu, 18 Jul 2019 01:58:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58538 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbfGRF6c (ORCPT ); Thu, 18 Jul 2019 01:58:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72475308FBAC; Thu, 18 Jul 2019 05:58:31 +0000 (UTC) Received: from redhat.com (ovpn-120-147.rdu2.redhat.com [10.10.120.147]) by smtp.corp.redhat.com (Postfix) with SMTP id C085E5D9D6; Thu, 18 Jul 2019 05:58:17 +0000 (UTC) Date: Thu, 18 Jul 2019 01:58:16 -0400 From: "Michael S. Tsirkin" To: Wei Wang Cc: Alexander Duyck , Nitesh Narayan Lal , kvm list , David Hildenbrand , "Hansen, Dave" , LKML , linux-mm , Andrew Morton , Yang Zhang , "pagupta@redhat.com" , Rik van Riel , Konrad Rzeszutek Wilk , "lcapitulino@redhat.com" , Andrea Arcangeli , Paolo Bonzini , "Williams, Dan J" , Alexander Duyck Subject: Re: use of shrinker in virtio balloon free page hinting Message-ID: <20190718015319-mutt-send-email-mst@kernel.org> References: <20190717071332-mutt-send-email-mst@kernel.org> <286AC319A985734F985F78AFA26841F73E16D4B2@shsmsx102.ccr.corp.intel.com> <20190718000434-mutt-send-email-mst@kernel.org> <5D300A32.4090300@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5D300A32.4090300@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 18 Jul 2019 05:58:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 18, 2019 at 01:57:06PM +0800, Wei Wang wrote: > On 07/18/2019 12:13 PM, Michael S. Tsirkin wrote: > > > > It makes sense for pages in the balloon (requested by hypervisor). > > However free page hinting can freeze up lots of memory for its own > > internal reasons. It does not make sense to ask hypervisor > > to set flags in order to fix internal guest issues. > > Sounds reasonable to me. Probably we could move the flag check to > shrinker_count and shrinker_scan as a reclaiming condition for > ballooning pages only? I think so, yes. I also wonder whether we should stop reporting at that point - otherwise we'll just allocate the freed pages again. > > > > > Right. But that does not include the pages in the hint vq, > > which could be a significant amount of memory. > > I think it includes, as vb->num_free_page_blocks records the total number > of free page blocks that balloon has taken from mm. Oh - you are right. Thanks! > For shrink_free_pages, it calls return_free_pages_to_mm, which pops pages > from vb->free_page_list (this is the list where pages get enlisted after > they > are put to the hint vq, see get_free_page_and_send). > > > > > > > > > > - if free pages are being reported, pages freed > > > > by shrinker will just get re-allocated again > > > fill_balloon will re-try the allocation after sleeping 200ms once allocation fails. > > Even if ballon was never inflated, if shrinker frees some memory while > > we are hinting, hint vq will keep going and allocate it back without > > sleeping. > > Still see get_free_page_and_send. -EINTR is returned when page allocation > fails, > and reporting ends then. what if it does not fail? > > Shrinker is called on system memory pressure. On memory pressure > get_free_page_and_send will fail memory allocation, so it stops allocating > more. Memory pressure could be triggered by an unrelated allocation e.g. from another driver. > > > Best, > Wei