From patchwork Wed Oct 19 09:56:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp273707wrs; Wed, 19 Oct 2022 04:42:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64DUgrArQXaYlt+oHwCdCAuMFE73QhbiRQmPfWG6FsVxOYUOVRuy4TIFlEmla8JrhvK5if X-Received: by 2002:a63:5b58:0:b0:452:2ba4:f86b with SMTP id l24-20020a635b58000000b004522ba4f86bmr6638666pgm.223.1666179774574; Wed, 19 Oct 2022 04:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179774; cv=none; d=google.com; s=arc-20160816; b=Ke1oTFyqpzn9VIz9QM55wAbRHV41dtJ5MpLI+1Q135WiAc2AnjF+vaPnd26DE9CjJw 7YiKnRNCAUw5f4SeHBZQb3Mh3BNLPwcYzhYWjV53xraBt6QeG74QmbgOped/54n8UAel NMj4gUYxCAnivv6h497H7Wwh2qT74+k5er6EZ+ylbjaSnRyilDUqUsamigKNvtXE0cAp 5Sfn+rA7gawIOsrzBnB/6qXM4NnyrJY7XBwGC3KOLR9pnavztQEdBxzdDjgKsKJUHUpP dkXa3QMig/j3HXnxlVhGEpJjUTxRCQI+GqC9Ud74dup0fmq5z3M3uZ0P9HkI9IH7AiQl 5RbQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a638c0a000000b00439f6781389si22758118pgd.662.2022.10.19.04.42.41; Wed, 19 Oct 2022 04:42: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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747116123566441633?= X-GMAIL-MSGID: =?utf-8?q?1747116123566441633?= 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)