From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751381AbdJXB4c (ORCPT ); Mon, 23 Oct 2017 21:56:32 -0400 Received: from mga04.intel.com ([192.55.52.120]:21598 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbdJXB4a (ORCPT ); Mon, 23 Oct 2017 21:56:30 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,424,1503385200"; d="scan'208";a="912985510" Message-ID: <59EE9E4C.3030207@intel.com> Date: Tue, 24 Oct 2017 09:58:36 +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: penguin-kernel@I-love.SAKURA.ne.jp, mhocko@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v1 3/3] virtio-balloon: stop inflating when OOM occurs References: <1508500466-21165-1-git-send-email-wei.w.wang@intel.com> <1508500466-21165-4-git-send-email-wei.w.wang@intel.com> <20171022062159-mutt-send-email-mst@kernel.org> In-Reply-To: <20171022062159-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23/2017 01:13 AM, Michael S. Tsirkin wrote: > On Fri, Oct 20, 2017 at 07:54:26PM +0800, Wei Wang wrote: >> This patch forces the cease of the inflating work when OOM occurs. >> The fundamental idea of memory ballooning is to take out some guest >> pages when the guest has low memory utilization, so it is sensible to >> inflate nothing when the guest is already under memory pressure. >> >> On the other hand, the policy is determined by the admin or the >> orchestration layer from the host. That is, the host is expected to >> re-start the memory inflating request at a proper time later when >> the guest has enough memory to inflate, for example, by checking >> the memory stats reported by the balloon. > Is there any other way to do it? And if so can't we just have guest do > it automatically? Maybe the issue is really that fill attempts to > allocate memory aggressively instead of checking availability. > Maybe with deflate on oom it should check availability? > I think it might not be easy to do it in the guest in practice. For example, the host asks for 4G from the guest, and the guest checks that it has 4G that can be inflated at that point. While it is inflating and 2G is done inflating, another new task on the guest comes out and takes the remaining 2G to use. Now the guest has nothing to inflate. This would raise the questions: 1) what is the point of checking the availability? Maybe we could just let the guest inflate as much as it can, that is, till balloon_page_enqueue() returns NULL, then stop inflating. 2) How long would the host has to wait for this guest to get the remaining 2G? If I understand "guest do it automatically" correctly: now the guest is responsible for giving another 2G, which he owes to the host in this case - not giving up inflating whenever there is some free memory. Maybe in the next 1 hour it wouldn't have any memory available to give to the host. The time seems non-deterministic. If we leave it to the host to define the policy, I think it would be easier. Once the host finds that the guest can only offer 2G, then it can just give up asking for memory from this guest, and continue to check other guests to see if it can get some memory there to satisfy the needs. Best, Wei