Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3479084rwb; Tue, 16 Aug 2022 03:57:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR5kXzsV1BJ32sGYCSwwWVLUl8SQkmRBxT1WO3YK/jZK8GrOd2z2ZT20ZsfyLuMMN4nffWyV X-Received: by 2002:a17:906:7304:b0:730:c3a8:cd7a with SMTP id di4-20020a170906730400b00730c3a8cd7amr12638151ejc.575.1660647466826; Tue, 16 Aug 2022 03:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660647466; cv=none; d=google.com; s=arc-20160816; b=VGvA1F8fGxRXAaKfDc816BUq79xtoVBW/B+DG24DBjvJKn53lQ+h1ZoQeOQogwp3ct vRpEzHnarhkT4aiuSuENaenKp17ZZSw2ZglC9zdpO5lq+sWLInVtncpjrpNw/wUBLbmZ +QfhemrMTsn1P4dFI4arcdrKa9A4NnRwSEH20YwPEM6sLX4W1FJEgGm5rxuimkT4nAeD I/Q5MrAl+mEp8IYWb52IrkRwfST86JuilubxUFzvmQ1oAAdckKKJJ5P233dkI6M19NSo 9GpKf3VbPZI047ha9yKlkL60zhyG3R8piDVO0dEcCQ84GEniC8dWIqaM+gWJApJMIx0m +9Ow== 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=0m/+Zn7tiL6T01h/2zHc/KGewvgNxhPvBh6F+ny6cvE=; b=qk1Iksap8LSbQAHvMHMzT9LWwhGe3odI+Fwm/YyHAl5q1vniJ0nHMdnQ0zzds6r37I xX6sr1BQDH38W5amcG8ooLBVUwE8DUCE4YNZKOf2QkMrSOQB/ZE5eCkKtyjq7UPHpFuh FEDygiOa05XlORx5HeRBxRpfKNq3m7XlRR0I+LaKX6YH0SXWfm+9r/VxaqOy2uVgKmbZ Ti3OdNYbDjNKs84JG4AYYfioeRcuqKr3n0vbYYIrWsZfE4xAaciTYUCroKvRodBqPloX J/yPPANFAOeGeeuWplDzKV0MHrwyNEbWkDfIL37ZPvlnlQ72X8D3p3X79lE1j12qEII+ ZJFA== 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 z15-20020a05640235cf00b0043be8c8a743si11382018edc.35.2022.08.16.03.57.21; Tue, 16 Aug 2022 03:57:46 -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 S235026AbiHPKrH (ORCPT + 99 others); Tue, 16 Aug 2022 06:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235146AbiHPKqG (ORCPT ); Tue, 16 Aug 2022 06:46:06 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ED6ADEA7B for ; Tue, 16 Aug 2022 02:54:39 -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 1oNt3t-00FxfB-7a; Tue, 16 Aug 2022 11:41:48 +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 v2 4/4] drivers: virtio: balloon - update inflated memory Date: Tue, 16 Aug 2022 12:41:17 +0300 Message-Id: <20220816094117.3144881-5-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220816094117.3144881-1-alexander.atanasov@virtuozzo.com> References: <20220816094117.3144881-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 6f69e483d98a..c8093c704c2f 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