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 72EE9C00140 for ; Tue, 26 Jul 2022 14:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239164AbiGZOLH (ORCPT ); Tue, 26 Jul 2022 10:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238631AbiGZOK7 (ORCPT ); Tue, 26 Jul 2022 10:10:59 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C5D210A3 for ; Tue, 26 Jul 2022 07:10:58 -0700 (PDT) Received: from [192.168.16.236] (helo=vzdev.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1oGLGB-00C6W6-At; Tue, 26 Jul 2022 16:10:30 +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 v6 2/2] Unify how inflated memory is accounted in virtio balloon driver Date: Tue, 26 Jul 2022 14:10:47 +0000 Message-Id: <20220726141047.72913-1-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220726140831.72816-1-alexander.atanasov@virtuozzo.com> References: <20220726140831.72816-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 Always account inflated memory as used for both cases - with and without deflate on oom. Do not change total ram which can confuse userspace and users. Signed-off-by: Alexander Atanasov --- drivers/virtio/virtio_balloon.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 97d3b29cb9f1..fa6ddec45fc4 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -244,9 +244,6 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) set_page_pfns(vb, vb->pfns + vb->num_pfns, page); vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE; - if (!virtio_has_feature(vb->vdev, - VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) - adjust_managed_page_count(page, -1); vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE; } @@ -265,9 +262,6 @@ static void release_pages_balloon(struct virtio_balloon *vb, struct page *page, *next; list_for_each_entry_safe(page, next, pages, lru) { - if (!virtio_has_feature(vb->vdev, - VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) - adjust_managed_page_count(page, 1); list_del(&page->lru); put_page(page); /* balloon reference */ } @@ -750,12 +744,9 @@ static void report_free_page_func(struct work_struct *work) static int virtio_balloon_debug_show(struct seq_file *f, void *offset) { struct virtio_balloon *vb = f->private; - s64 num_pages = vb->num_pages << (VIRTIO_BALLOON_PFN_SHIFT - 10); + u64 num_pages = vb->num_pages << (VIRTIO_BALLOON_PFN_SHIFT - 10); - if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) - num_pages = -num_pages; - - seq_printf(f, "inflated: %lld kB\n", num_pages); + seq_printf(f, "inflated: %llu kB\n", num_pages); return 0; } -- 2.25.1