Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp708261imn; Tue, 26 Jul 2022 07:18:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u+Cr8i5NLDv8B07jtQaKwrDwYaHoK5+YhcfIaDrunHv0hVxOBvyXtNNC+K3yajYxVj63SR X-Received: by 2002:a05:6870:581d:b0:101:dc4f:51 with SMTP id r29-20020a056870581d00b00101dc4f0051mr17467351oap.247.1658845128331; Tue, 26 Jul 2022 07:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658845128; cv=none; d=google.com; s=arc-20160816; b=d2aGqWMIvZludkDnKhhGDlIeiperAjcYJFLnr90poX4X5iGmVrAZAVtgh9Jx7vUK4H cFf2tktVP6/9EhTJLIPFMChBgz+6ITpmMJqQpi90rEaxiLiHrcKsyz09+gnLTGumckwQ kvQcpaS+hjxS3GYyB3l4snE2nV/yix8F0mD6piddASdJctAJXw4KY+w7Eb9epAkE5A2B nyWtwtrXiEwDoccVJryBZOekcGl8RJufJCyIn0n7qcwEiLOsGTEFmswS/mcI1MBzMg6x hTVKZcM7h0ja2Zo0Yn5gh0xJnC3s0Gv1bLwm1YSMSanVmmyr0guHRyQ7nz6UQQ6q46wY UBgA== 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=NIl8J3BrDyxBi80rWAgdzAsfy/SWm3JF5QWP4FiR9fw=; b=fJT1A8NdvxEdkoURKssooTp3Q/soI69qE25oN4gJSZ5RbQvlMu5xMkbntYokP/fyJ4 d5XphkAwSi6fiIaZbC2GzPHFISx6ghbXoaTfnnczuC0wfhT3AyK4cj6Oh/Xhisa5yAfv F+AFvDm9dp7JLpObSKOpyH0TFu2gjBPmOzURO8+ZyIwLcubTllKZq1KZtX9qP5z2gLL4 XRbbWUVrhLw+T8o+TfMh/YamNSM4RHN0fkWY5HwAdtUaig4y+aa2KBFuNyaMI31DPemq aWkilApROWPzJG5TBrYVvzr54X2Wjk/5hU0xp5zREUtL7O9IcuLnx2sKODn2FOlD8zTp oiWA== 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 l17-20020a9d7091000000b0061c833f81absi12545876otj.62.2022.07.26.07.18.34; Tue, 26 Jul 2022 07:18:48 -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 S239038AbiGZOLG (ORCPT + 99 others); Tue, 26 Jul 2022 10:11:06 -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 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 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