Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp308632rwl; Fri, 4 Nov 2022 00:07:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hSIN8hGWbgmSOgAF0TN21EeqZlT3cVK5lL6P/yWUqnXENVnsFxtViyZBMqBiRWofCnpfZ X-Received: by 2002:a17:907:86a1:b0:7ac:c5c3:9c80 with SMTP id qa33-20020a17090786a100b007acc5c39c80mr33962698ejc.37.1667545629475; Fri, 04 Nov 2022 00:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667545629; cv=none; d=google.com; s=arc-20160816; b=F6WjCsE8Iy91JQdY+jVMLBgpsHurftwV8BhzgvbB5Tonjy1+PPBM/+bTnpa1Jo2QyQ gLHOWAHXasQiLhYWbG1ZVBsLeWDaN8tLLDWBAIrEKGJmEf2Tzqdvq3C5vGGNVV8n5Ed/ Pg7ldYtUtZ+Bb9coKby1l9wNxUIWUBRsJ6aNOLPkWaQagbYVmKwIWD4va9oaGCkTDIBV hKR4gZEA4v53AeIJlzpqBQWVxDQNUX72aql7VDjO//OnjtO0fbMjGa0JimwQsP6OGvoU pYeLTQ98BZHeGxfbaGaJOxFdiosXWDv9wye135JvAVcCjzKek8gS96ZXdb3+Crcs/SDE YRFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=jb6l497PPbm1hNScY6pLdfDwqz1lLgbCVQL62N7ST2w=; b=LzhpdqUErxtjd58jOl6bw+06gXSq2ZBSRCMcYIcrChQVnEB2jbku0YuSWE/XBHm4FA pmGPd59YiwDL0dvLNuxMyTjwm8E0Vp5sPQVxcYp3AQem4ps4bvwlTD42lW1ak2W4DFb3 Z9wRu1quB9UcyKKh77GgW3mJInTJOZCGDxbXbIl7HKMQLFxkyr+YEXW4/2MZ/286xeDa V+f8FklLc3+2x4Z9ohqxmXhjqLCvLL+5pP915Mq1DhCnhWIR2gUlByekDXDjT/OTgApk Rh0nM6jEYeUjmqHLS/a0C0nHz+0jcuNfPcEIdJfhopKsXQ7qzhnudDnIp0U6ifm4No9g ZRNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=dd4z5rhE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a056402440400b0046382109edbsi5050991eda.395.2022.11.04.00.06.45; Fri, 04 Nov 2022 00:07:09 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=dd4z5rhE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbiKDGxA (ORCPT + 97 others); Fri, 4 Nov 2022 02:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbiKDGw6 (ORCPT ); Fri, 4 Nov 2022 02:52:58 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0934D292; Thu, 3 Nov 2022 23:52:58 -0700 (PDT) Received: by linux.microsoft.com (Postfix, from userid 1134) id C66D820C3338; Thu, 3 Nov 2022 23:52:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C66D820C3338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667544777; bh=jb6l497PPbm1hNScY6pLdfDwqz1lLgbCVQL62N7ST2w=; h=From:To:Cc:Subject:Date:From; b=dd4z5rhEOCCgbd/WRAVLY7yoA2m04/GkgGrMz0g7VLTsdLI2jW4JbrfTfVX/VRIFn sAkezacDQDGg+thfyg4jQcJI47Q9FqEVCDm+t8OKZF/d79jy/fB7sWeoNHtwUKkiHx asLthUl0vRztG7P2lAQjCmi74Kds2wUDXi4raaj8= From: Shradha Gupta To: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: Shradha Gupta , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Long Li , Michael Kelley Subject: [PATCH] hv_balloon: Fix committed value in post_status() if dynamic memory is disabled Date: Thu, 3 Nov 2022 23:52:50 -0700 Message-Id: <1667544770-31377-1-git-send-email-shradhagupta@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 If Dynamic memory is disabled for VM, the committed value reported by the post_status() call by hv_balloon driver includes compute_balloon_floor(). This is not needed if balloon_up operations or hot_add operations were never requested on the VM(or if Dynamic memory was disabled for the VM) Signed-off-by: Shradha Gupta --- drivers/hv/hv_balloon.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index fdf6decacf06..a6f5321d4a2e 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -1129,11 +1129,23 @@ static unsigned long compute_balloon_floor(void) static unsigned long get_pages_committed(struct hv_dynmem_device *dm) { - return vm_memory_committed() + - dm->num_pages_ballooned + - (dm->num_pages_added > dm->num_pages_onlined ? - dm->num_pages_added - dm->num_pages_onlined : 0) + - compute_balloon_floor(); + unsigned long pages_committed; + + pages_committed = vm_memory_committed(); + + /* + * If no balloon_up or hot_add operation was performed do not add + * num_pages_ballooned, number of pages offline or + * compute_balloon_floor() to the pages_committed value + */ + if (dm->num_pages_ballooned || dm->num_pages_added) { + pages_committed += dm->num_pages_ballooned + + (dm->num_pages_added > dm->num_pages_onlined ? + dm->num_pages_added - dm->num_pages_onlined : 0) + + compute_balloon_floor(); + } + + return pages_committed; } /* -- 2.37.2