Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp147008ybc; Mon, 18 Nov 2019 22:10:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxKU99butkjYaJz86Y8x1PaKg3U0HJ/vOEM+DjAKDtm/ZCZWbpI3rl6nYfmOv4/g8LkZfrV X-Received: by 2002:a17:906:bfe3:: with SMTP id vr3mr32172433ejb.273.1574143839828; Mon, 18 Nov 2019 22:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574143839; cv=none; d=google.com; s=arc-20160816; b=Ql4WZaO4mZXLnnkOrGEO+EaeGN46EIdVi3yblOsMv+iWaZYusj60qSheegprnkL5GZ RUzIPn+CgHD5n4OGjdIfFUc7XET2BFHLOOMX+/IRirCN6r1gASFEjCrejCcZOJ23O9yJ rXc03qXIN32a/esVLU6i0ax+QLdDF51Ydsxjwk51FozNBjHVPU4W528SuoycKe911m7i wEu2NA7hSxmls7Ib9pBXc7gNEjzi2QSbejGgrhwJ2NAF5m0acYk6s5zR4P9iqWqwNC5K ELHwOuSupDb1yzNym6jWEtPFPCn8iPojg4xvNWcRQD95BKFF4jX7NyYYT/ep/3KnO37X a6lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=4CWQGvpPKQ6FvvJI+akh47G+U7Jfc/O8gB34WH5BX6Y=; b=KCcoNURYjIsg/cZH/t6vkGy7AH6ofzhNn/Uoad/4mcUvhGrEexm6AXYrF1g5Szqge9 bmfrCxNQperuS3EFtiay+Y1vo/mIY8Gas2IzGDZmT8SwYHcDLzg+7perTLjGgIdRCudq 28f2lll9PDMDKZN8M56eOoKQea+d5XRnrh3wHrCCOwaYqBW2lBjbdFw93AFUGkCflY6r 7ZRG8/Xhdor31vS4/jjtFrXBCk3s0WWogFx7ZRpWpe/++gWOQsrm9152JdjpSxaNKGjr 0L2USrXJUD4JoRuEWybB3SIJ624uIWB4TbS4WNo2lZRXWQZFXn0NQKc9F/yzhrolWYFf jq+w== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si5071237edw.338.2019.11.18.22.10.14; Mon, 18 Nov 2019 22:10:39 -0800 (PST) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729334AbfKSFb7 (ORCPT + 99 others); Tue, 19 Nov 2019 00:31:59 -0500 Received: from mga03.intel.com ([134.134.136.65]:42535 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728238AbfKSFb6 (ORCPT ); Tue, 19 Nov 2019 00:31:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2019 21:31:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,322,1569308400"; d="scan'208";a="204411168" Received: from unknown (HELO [10.239.13.7]) ([10.239.13.7]) by fmsmga007.fm.intel.com with ESMTP; 18 Nov 2019 21:31:56 -0800 Message-ID: <5DD37FE4.4000407@intel.com> Date: Tue, 19 Nov 2019 13:38:44 +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" , Khazhismel Kumykov CC: jasowang@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH 1/2] virtio_balloon: fix pages_to_free calculation References: <20191118213811.22017-1-khazhy@google.com> <20191118175648-mutt-send-email-mst@kernel.org> In-Reply-To: <20191118175648-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/2019 07:08 AM, Michael S. Tsirkin wrote: > So I really think we should do something like the below instead. > Limit playing with balloon pages so we can gradually limit it to legacy. > Testing, review would be appreciated. > > Signed-off-by: Michael S. Tsirkin > > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 226fbb995fb0..7cee05cdf3fb 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -772,6 +772,13 @@ static unsigned long shrink_free_pages(struct virtio_balloon *vb, > return blocks_freed << VIRTIO_BALLOON_FREE_PAGE_ORDER; > } > > +static unsigned long leak_balloon_pages(struct virtio_balloon *vb, > + unsigned long pages_to_free) > +{ > + return leak_balloon(vb, pages_to_free * VIRTIO_BALLOON_PAGES_PER_PAGE) / > + VIRTIO_BALLOON_PAGES_PER_PAGE; > +} > + Looks good to me, too. (just a reminder that the returning type of leak_balloon is "unsigned int", we may want them to be consistent). Reviewed-by: Wei Wang Best, Wei