Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp934011rwi; Wed, 19 Oct 2022 04:57:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM69xuyXBvIc0gHE4YQqSWKCnRPkorqkL2VH1dBq/GZQYuzRefZacqrdAzZ8DV6Z39aGWfX5 X-Received: by 2002:a17:907:3e9c:b0:78d:ce8b:8548 with SMTP id hs28-20020a1709073e9c00b0078dce8b8548mr6547385ejc.427.1666180674717; Wed, 19 Oct 2022 04:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180674; cv=none; d=google.com; s=arc-20160816; b=j/Pe6SjMupziuw2gwWeAFl7TyDIKwjtPYXx/5KHoUPAO2G5owA5mge0jN/+2Makk1S lMDpU5aLDnRkY229DhLqyvjfwydY9KTMvPJwLmGwKHI2gb0Bw6GN7lC3DefgRu/imdqU dKi0w/MOvSU3EWqBw6ZSgCEaGV3w/Z61kV5gE3PDKWKH17VowikGo7QOwxcHiFm3Ltq6 DukRW7xnB0JudDPjCGIgM4hnWZcjPSD5+fscFCUtqTHt9FDlCsQEli4KtvZzHlgvQE2H FcAX/mWiWPVgY3Q9QWVdq+UcG7moiNwEF6dCtne3sGc4gxJ4IfKHiFuGBtzIhDOaN13Y A6qA== 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=sYj27dKX8Rv12ooaEz8IuPPdzjjPlZMP20coOWWqT5g=; b=PzpQ9XxNrYp2EREuF+6H/bJeSFdjRm9Fj88dV6pCf0qmvTGxO9/FqO7/WtP+kS4FYX HvOyxfhz8EROUHq3Gc/aLGZQDgu/U5EkdUP7cL6+CASOWSdfP/BCYuhYhSHrE6HC970j H29+/JPnxFdj3cxiJfEVzl0WhxGFXTlQ/j0ma2+OXyd6bQPzjDrz106Q7woEAh/ZMN+c aUdMkVE9+7qaDW37Mcww2Mn7aDPWOZDy6E8DaVAwJ6vU6lNfwgmgrzOQRJipk5CBe5et Hd+SKNCBlerudjXFB253dV+VpVyhs5z/71NgOwWnz5xDKz9hUznaZT3pvIOoNZsNuLXU 7ArQ== 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 hc35-20020a17090716a300b0078081036bdasi15482577ejc.501.2022.10.19.04.57.28; Wed, 19 Oct 2022 04:57:54 -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 S231536AbiJSLao (ORCPT + 99 others); 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 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 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