Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2297619rwa; Mon, 22 Aug 2022 05:40:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR5m/V4ALqytOJFaueFarmrVpLLIGK7WIBAXLa9+dT5WPoALIJPn2gZezymS3Yz2FTag8aZh X-Received: by 2002:a17:90a:64c1:b0:1fa:d891:adc0 with SMTP id i1-20020a17090a64c100b001fad891adc0mr20961584pjm.147.1661172026634; Mon, 22 Aug 2022 05:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661172026; cv=none; d=google.com; s=arc-20160816; b=pPAT2gt6Ry9MnvXjRc9kPzFgvpglukB9NP0Exg+73eLHklXmsV1xUYH0F6wnsE8y7P Kd/IO9JdGxJtwlZNAGU9G6HBbKcLhymAuj9k+MO6tDK+CoHBrXw3/2DXDY6SAw7XAlET D1YOIYHJCzjn90LxdLtQkdEqzXjjnlcU5hq1p8QexQZXKktBj0jpJpFEX7WzH447yU6E Dw0CVGKCXw2pPxZ809nCMKJl7F0S1RpTosnXltzXS48QcwlBnKPfNzdIBPLjH9Ndol/Z eT6wjaAzwkOMs+UpqKkzuXBT+4vrKJSzU8UquJ5zq0THFf1gskuWlHp7riIIDnHg55TK sDpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LuHVaKtd+0oWKZDMWHBUTo8hhKcjPDHGtwdVVFf0UWY=; b=Q1DnFKPqgcUyuhuNvt+g5MFZphByJpOff2Fc8Ih0aYld8vM3rt5Aoh40Sp8H2XfAbG zOxVb7gAqkmU6zNQliIZsGokyPZzxk0kqVeKnxBxheBUa36xt3brrtZnLWEFa6npA5Xn Q5icjbYXwn9+ySI341rungqITZhR88ZDQO41cPoImp0ijEHJdl9EGALz/tfxN0/I8BLP mo/jyNpDhjkuLDh3Xdairr7k5CBMVXvqM6XNLynebGOYkfxTKIxrlecEkHfB/cebz6/r DRmXZSg4OoWhF+gnYwyRMaMxTxcXhESd7Lv/Jtr+kSdJby9faWIj/NBZgLHFtIc6I4tU 9zRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a056a00241100b0050ad2c9d507si13058986pfh.170.2022.08.22.05.40.13; Mon, 22 Aug 2022 05:40:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234583AbiHVLin (ORCPT + 99 others); Mon, 22 Aug 2022 07:38:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234679AbiHVLim (ORCPT ); Mon, 22 Aug 2022 07:38:42 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 704EC18374 for ; Mon, 22 Aug 2022 04:38:40 -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 1oQ5jh-00Gyo9-CM; Mon, 22 Aug 2022 13:38:16 +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: [PATCH v3 4/4] drivers: virtio: balloon - update inflated memory Date: Mon, 22 Aug 2022 14:37:47 +0300 Message-Id: <20220822113747.3630776-5-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220822113747.3630776-1-alexander.atanasov@virtuozzo.com> References: <20220822113747.3630776-1-alexander.atanasov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the inflated memory 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