Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1659726rwb; Wed, 5 Oct 2022 02:54:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Chmq3rJeDv90R109PkhZYTTBiNc9t1pvQW1TmygnzYpT9VFnF5wM8ATy3oU0Z0Mq3WQ/s X-Received: by 2002:a05:6402:5189:b0:451:791e:f328 with SMTP id q9-20020a056402518900b00451791ef328mr27443714edd.282.1664963669797; Wed, 05 Oct 2022 02:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664963669; cv=none; d=google.com; s=arc-20160816; b=KMaYblXL8+W0xpD6XeI0O+3S7szM/rFTftd9E5fpjWB+7momr8ydtIAdSz0ZWu8ZVN vvgDKWG4+6hG5TlR84iDf5zlx6FP1STxWvAe/7SZMqsjuzBEbbpuD4zP1z/MLY8Vd7be 4i/UKUFJCGo0/+tEcQGx8ei98b3EPtagflzMjWlJL4KGn9BFOpoER8nc8tsnWAJ+nlzp b5CUSmGZd3uswRSd/tDT6EPR9yuMwe6gyDJspfDUC9IS0p0678dX03RobsUa+dnrZmJb TWrFVC3Vf4qnN2MfLlizRXmr0GK/z9kdL2DHjmrN0QMCmgf6161X1PlaCr4j2uNxaUbS KEhA== 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=UGELwKwWpKvx5z4Q3W8URUlPrDmQ/cd+RQgmWngiTQXCFYcyQ3eg9idZRaef8QfV9R /mufE2ayBQ4Ew0Ch2mK88MlyE/wxI4Hm4TladHHRMyqpVrFXHBAsfk2TMhxxmcuEpke1 5INUxlwLW2moHswcISADtuao2gyI3nHdmHbmtvVPMP+w9yYRJGllo6E0ZnNzfCEA+k// zrKsZTpm7mtHJghhG4VsqBU5t2sfxvbVnS4xsv3ei+jw0fNrVLrGSutJdlrmr94nPvFU HsHlGNgPKVYneFoWi+J4qxb1BR5dzKcNx7KK30yzFZIpiIsqt1JshLcmCpGeuRyRWudL es4g== 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 gt14-20020a1709072d8e00b00778aa522d8fsi13912082ejc.350.2022.10.05.02.54.02; Wed, 05 Oct 2022 02:54:29 -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 S230050AbiJEJEG (ORCPT + 99 others); Wed, 5 Oct 2022 05:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbiJEJD6 (ORCPT ); Wed, 5 Oct 2022 05:03:58 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3A37644F for ; Wed, 5 Oct 2022 02:03:52 -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 1og0GO-007ckN-DT; Wed, 05 Oct 2022 11:02:49 +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 v4 4/7] drivers: virtio: balloon - update inflated memory Date: Wed, 5 Oct 2022 12:01:54 +0300 Message-Id: <20221005090158.2801592-5-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221005090158.2801592-1-alexander.atanasov@virtuozzo.com> References: <20221005090158.2801592-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 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