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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB471C433FE for ; Wed, 19 Oct 2022 11:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbiJSLao (ORCPT ); Wed, 19 Oct 2022 07:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbiJSLaT (ORCPT ); Wed, 19 Oct 2022 07:30:19 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E28089958 for ; Wed, 19 Oct 2022 04:04:53 -0700 (PDT) Received: from dev011.ch-qa.sw.ru ([172.29.1.16]) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1ol5ld-00B8K8-RP; Wed, 19 Oct 2022 11:56:32 +0200 From: Alexander Atanasov To: "Michael S. Tsirkin" , David Hildenbrand , Jason Wang Cc: kernel@openvz.org, Alexander Atanasov , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 5/8] drivers: virtio: balloon - report inflated memory Date: Wed, 19 Oct 2022 12:56:17 +0300 Message-Id: <20221019095620.124909-6-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221019095620.124909-1-alexander.atanasov@virtuozzo.com> References: <20221019095620.124909-1-alexander.atanasov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the inflated memory in the mm core when it changes. Signed-off-by: Alexander Atanasov --- drivers/virtio/virtio_balloon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index d0c27c680721..e9c3642eef17 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -450,10 +450,15 @@ static void virtballoon_changed(struct virtio_device *vdev) static void update_balloon_size(struct virtio_balloon *vb) { u32 actual = vb->num_pages; + long inflated_kb = actual << (VIRTIO_BALLOON_PFN_SHIFT - 10); /* Legacy balloon config space is LE, unlike all other devices. */ virtio_cwrite_le(vb->vdev, struct virtio_balloon_config, actual, &actual); + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) + balloon_set_inflated_free(inflated_kb); + else + balloon_set_inflated_total(inflated_kb); } static void update_balloon_stats_func(struct work_struct *work) -- 2.31.1