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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 D055CC76191 for ; Thu, 18 Jul 2019 05:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD8282077C for ; Thu, 18 Jul 2019 05:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfGRFvf (ORCPT ); Thu, 18 Jul 2019 01:51:35 -0400 Received: from mga02.intel.com ([134.134.136.20]:11596 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbfGRFvf (ORCPT ); Thu, 18 Jul 2019 01:51:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2019 22:51:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,276,1559545200"; d="scan'208";a="367248561" Received: from unknown (HELO [10.239.13.7]) ([10.239.13.7]) by fmsmga006.fm.intel.com with ESMTP; 17 Jul 2019 22:51:30 -0700 Message-ID: <5D300A32.4090300@intel.com> Date: Thu, 18 Jul 2019 13:57:06 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" 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 References: <20190717071332-mutt-send-email-mst@kernel.org> <286AC319A985734F985F78AFA26841F73E16D4B2@shsmsx102.ccr.corp.intel.com> <20190718000434-mutt-send-email-mst@kernel.org> In-Reply-To: <20190718000434-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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? > > 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. 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. Shrinker is called on system memory pressure. On memory pressure get_free_page_and_send will fail memory allocation, so it stops allocating more. Best, Wei