From patchwork Thu Jan 16 16:24:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 3499491 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7AD3CC02DC for ; Thu, 16 Jan 2014 16:26:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7CE5420170 for ; Thu, 16 Jan 2014 16:26:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5868F20165 for ; Thu, 16 Jan 2014 16:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752650AbaAPQZU (ORCPT ); Thu, 16 Jan 2014 11:25:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752214AbaAPQYn (ORCPT ); Thu, 16 Jan 2014 11:24:43 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0GGOVkW023493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 16 Jan 2014 11:24:32 -0500 Received: from localhost (ovpn-113-136.phx2.redhat.com [10.3.113.136]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0GGOUXs021041; Thu, 16 Jan 2014 11:24:31 -0500 From: Luiz Capitulino To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, riel@redhat.com, aarcange@redhat.com, aquini@redhat.com, mst@redhat.com, rusty@rustcorp.com.au, vdavydov@parallels.com, amit.shah@redhat.com, dfediuck@redhat.com, agl@us.ibm.com Subject: [RFC PATCH 4/4] virtio_balloon: skip inflation if guest is under pressure Date: Thu, 16 Jan 2014 11:24:05 -0500 Message-Id: <1389889445-3855-5-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1389889445-3855-1-git-send-email-lcapitulino@redhat.com> References: <1389889445-3855-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luiz capitulino This is necessary for automatic ballooning. If the guest gets under pressure while there's an on-going inflation operation, we want the guest to do the following: 1. Stop on-going inflation 2. Notify the host we're under pressure 3. Wait for host's acknowledge While the guest is waiting the host has the opportunity to reset num_pages to a value before the guest got into pressure. This will cancel current inflation. Signed-off-by: Luiz capitulino --- drivers/virtio/virtio_balloon.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 1c3ee71..7f5b7d2 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -188,8 +188,13 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num) mutex_lock(&vb->balloon_lock); for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) { - struct page *page = balloon_page_enqueue(vb_dev_info); + struct page *page; + if (guest_under_pressure(vb)) { + break; + } + + page = balloon_page_enqueue(vb_dev_info); if (!page) { dev_info_ratelimited(&vb->vdev->dev, "Out of puff! Can't get %u pages\n",