From patchwork Fri Mar 14 21:37:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 14017449 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 544571A5B82 for ; Fri, 14 Mar 2025 21:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988307; cv=none; b=o6pRvr4Of7eaNOS/X9LMENC5O0nx99srkETtTeG+mOirUeSxqtND0xKbN4/pFPI7FFlse+CNYzbe2/NJB6hyyvpb1nZ+ZH8kU84qnqXx9uD+DgLGoFF296eQwdMtodSoI/yUh+DC33yxKh0GQj3aSe5M1gCOpN22irNxWzuoX6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988307; c=relaxed/simple; bh=KR7Rgigui5nMqE+lqkr212HsL5acvMFEx4PkGQEmMBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tW1c2XxnXfbu8lQD0OEujKn4WPlQvITEaUDrgR1KuvfLurZNJXsj+MG+H9uNMds7fC3HiBzjeztnRgNd9EkxURWu5ycjxcLrGfSJAPjEH2Bjfvt+O2CsE9zHmHEWUttJDcLY5u3GuiVn3XICXSBPo9o+faqj6+WcJwd2Ua2CYSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XP0ejiBY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XP0ejiBY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Syhhy4ulIUlWqTYydvlvGA6nZmvGM1l/r4DiZeh/SB8=; b=XP0ejiBYDdD8oyssUKQjtjXfAeXN8qIphonnq71+/3G5R6Pq0X4g7V3AqEBjX0bfAIZYQ2 /6z8rpzH9ERz5PqG2BPBGo2dv4FQOVRVpLeHoQzWOuIXGeKv6D0o2etM+TP505gg7ssoQd pIzm3OGVq1EiKoNzwvVlqWVli/HzmMY= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-ltqb4lcePE69hcWXSe8vYA-1; Fri, 14 Mar 2025 17:38:21 -0400 X-MC-Unique: ltqb4lcePE69hcWXSe8vYA-1 X-Mimecast-MFC-AGG-ID: ltqb4lcePE69hcWXSe8vYA_1741988298 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 28885180034D; Fri, 14 Mar 2025 21:38:17 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.88]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B05D41944DC5; Fri, 14 Mar 2025 21:38:11 +0000 (UTC) From: Nico Pache To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux.dev Cc: alexander.atanasov@virtuozzo.com, muchun.song@linux.dev, roman.gushchin@linux.dev, mhocko@kernel.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, jgross@suse.com, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, akpm@linux-foundation.org, mst@redhat.com, david@redhat.com, yosry.ahmed@linux.dev, hannes@cmpxchg.org, nphamcs@gmail.com, chengming.zhou@linux.dev, kanchana.p.sridhar@intel.com, llong@redhat.com, shakeel.butt@linux.dev Subject: [PATCH v2 1/4] meminfo: add a per node counter for balloon drivers Date: Fri, 14 Mar 2025 15:37:54 -0600 Message-ID: <20250314213757.244258-2-npache@redhat.com> In-Reply-To: <20250314213757.244258-1-npache@redhat.com> References: <20250314213757.244258-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Add NR_BALLOON_PAGES counter to track memory used by balloon drivers and expose it through /proc/meminfo and other memory reporting interfaces. Signed-off-by: Nico Pache --- fs/proc/meminfo.c | 2 ++ include/linux/mmzone.h | 1 + mm/show_mem.c | 4 +++- mm/vmstat.c | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 8ba9b1472390..83be312159c9 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -162,6 +162,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v) show_val_kb(m, "Unaccepted: ", global_zone_page_state(NR_UNACCEPTED)); #endif + show_val_kb(m, "Balloon: ", + global_node_page_state(NR_BALLOON_PAGES)); hugetlb_report_meminfo(m); diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 9540b41894da..71d3ff19267a 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -223,6 +223,7 @@ enum node_stat_item { #ifdef CONFIG_HUGETLB_PAGE NR_HUGETLB, #endif + NR_BALLOON_PAGES, NR_VM_NODE_STAT_ITEMS }; diff --git a/mm/show_mem.c b/mm/show_mem.c index 43afb56abbd3..6af13bcd2ab3 100644 --- a/mm/show_mem.c +++ b/mm/show_mem.c @@ -260,6 +260,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z " pagetables:%lukB" " sec_pagetables:%lukB" " all_unreclaimable? %s" + " Balloon:%lukB" "\n", pgdat->node_id, K(node_page_state(pgdat, NR_ACTIVE_ANON)), @@ -285,7 +286,8 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z #endif K(node_page_state(pgdat, NR_PAGETABLE)), K(node_page_state(pgdat, NR_SECONDARY_PAGETABLE)), - str_yes_no(pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES)); + str_yes_no(pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES), + K(node_page_state(pgdat, NR_BALLOON_PAGES))); } for_each_populated_zone(zone) { diff --git a/mm/vmstat.c b/mm/vmstat.c index 16bfe1c694dd..d3b11891a942 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1276,6 +1276,7 @@ const char * const vmstat_text[] = { #ifdef CONFIG_HUGETLB_PAGE "nr_hugetlb", #endif + "nr_balloon_pages", /* system-wide enum vm_stat_item counters */ "nr_dirty_threshold", "nr_dirty_background_threshold", From patchwork Fri Mar 14 21:37:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 14017450 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 166FD1E8327 for ; Fri, 14 Mar 2025 21:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988316; cv=none; b=ofP+bzpU5JaegBMbVv9tdtDOD5g2CdHnPYeHOuMCnh5ojaPstNpPkIxjeFkToS1A/M7Vkm6oLIwBd9t/2r4afseztgRIGsN5MJYpC3ds1xRDPp5IzTyiDrw6Zy2+cYoLAA9xS1AiGB+Pp3Fqvt5eNMwiLZSTxxhVxcAJ7csMalI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988316; c=relaxed/simple; bh=aL6XpG6waIwRsJU0cAQlfQb9j2y/yn0NcY83ozborHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=smFGRBmOkZxO3BPRf806no4vI4QfWCZnPUdK07xe5iaMmU50anMweUUiYnfHEXcQfkFfRYRQ5gBUmIbTmsJOR+53w7FWQgODRdrhaJq3x+x6rt9WMFY6SGh+IjOll1czy/2Y6iNNoUylCtPjazyhjajoVlaSTag2TEi+MwUH02Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Yid/BI6G; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yid/BI6G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3RXL+coJsdtD8dzVN3au7Q2NbBlOYxUwoHTJ/KoQPU4=; b=Yid/BI6G5Z51PR+EjAgOz1CKMB2IGMXXCnah5+meB+JXGzV8X3eqYCd1OdbOWc/fcNw+E2 Fku9tJzBLUepyNBNMp9IrvpjZOwOs/ziLIDYZRbFsPt6Dqd3tjJkFEKqWoEmpXKrRYdcJV FqKy2O++o+ZgR1telTQVtqDgdwBVtkw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-0r6UKT9IMtuF-Il_bN2UWQ-1; Fri, 14 Mar 2025 17:38:30 -0400 X-MC-Unique: 0r6UKT9IMtuF-Il_bN2UWQ-1 X-Mimecast-MFC-AGG-ID: 0r6UKT9IMtuF-Il_bN2UWQ_1741988303 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A8BDC195608D; Fri, 14 Mar 2025 21:38:22 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.88]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6352D1944E42; Fri, 14 Mar 2025 21:38:17 +0000 (UTC) From: Nico Pache To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux.dev Cc: alexander.atanasov@virtuozzo.com, muchun.song@linux.dev, roman.gushchin@linux.dev, mhocko@kernel.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, jgross@suse.com, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, akpm@linux-foundation.org, mst@redhat.com, david@redhat.com, yosry.ahmed@linux.dev, hannes@cmpxchg.org, nphamcs@gmail.com, chengming.zhou@linux.dev, kanchana.p.sridhar@intel.com, llong@redhat.com, shakeel.butt@linux.dev Subject: [PATCH v2 2/4] balloon_compaction: update the NR_BALLOON_PAGES state Date: Fri, 14 Mar 2025 15:37:55 -0600 Message-ID: <20250314213757.244258-3-npache@redhat.com> In-Reply-To: <20250314213757.244258-1-npache@redhat.com> References: <20250314213757.244258-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Update the NR_BALLOON_PAGES counter when pages are added or removed using the balloon compaction interface. The virtio, Vmware, and pseries-cmm balloon drivers utilize the balloon_compaction interface to allocate and free balloon pages. Other balloon drivers will have to maintain this counter manually. Signed-off-by: Nico Pache --- mm/balloon_compaction.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 6597ebea8ae2..d3e00731e262 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -24,6 +24,7 @@ static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, balloon_page_insert(b_dev_info, page); unlock_page(page); __count_vm_event(BALLOON_INFLATE); + inc_node_page_state(page, NR_BALLOON_PAGES); } /** @@ -103,6 +104,7 @@ size_t balloon_page_list_dequeue(struct balloon_dev_info *b_dev_info, __count_vm_event(BALLOON_DEFLATE); list_add(&page->lru, pages); unlock_page(page); + dec_node_page_state(page, NR_BALLOON_PAGES); n_pages++; } spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); From patchwork Fri Mar 14 21:37:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 14017451 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3EC92054E8 for ; Fri, 14 Mar 2025 21:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988319; cv=none; b=RNtPsQfJIzpL/ndRmHC2r+YNMclK08uP+P7OxPyT+bGBVUC1wmRButR6OxzbdkM+NQZbV7NEU/GADedX8t4BugvRcdzQqwJ9B+iYKTAIKMzyOnikTnGo3cdbtI0j4fo0qqhE6smF8wbRkS88XrwcfVUkie1xQ9F9Q2SnAv5SI9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988319; c=relaxed/simple; bh=AzqFum6Agw13RjN3Fu1tKvuI6gP3XBpPLw2tmwLYzUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mpD1vPq2Hi6BCNy8tMdFqJWsY6Mcm6wxT/qVw8uXU8oe8D507QYkfN3HsXvi7002DVQiLPF7agDoo3C45VZAGO0Kh6k/DMZo+sCLX/0e0meod/iKTYKA/UxITqR9XvQjacz/fYsEimXXMjNCExtcbeTMyxuFJxFUnrOVQLdAj3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=A9nT4vhK; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A9nT4vhK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vPsYu1/Zt9JxInUUfAbvJhaRjTUPwV0c8VAQrmxs/V8=; b=A9nT4vhKfJj3q8lQGPsvhX8OI8PnZInfBCF3sWHrkXxFfEwpogB0uH2iyBHtA4fkbRg12C 0M4Uh35PdUbUlAMGZ/Y+5k7yL4SLrfxQEOICh5EdnDK7y+g69scarrxpn8kBPIxrzsKFr+ SkHcmidXZGC+LZWdESjltunOe5+hfaY= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-Q0pkQj-lPNqdUoh8sMEMxQ-1; Fri, 14 Mar 2025 17:38:31 -0400 X-MC-Unique: Q0pkQj-lPNqdUoh8sMEMxQ-1 X-Mimecast-MFC-AGG-ID: Q0pkQj-lPNqdUoh8sMEMxQ_1741988308 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5CFF81955E95; Fri, 14 Mar 2025 21:38:28 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.88]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CD5E61943582; Fri, 14 Mar 2025 21:38:22 +0000 (UTC) From: Nico Pache To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux.dev Cc: alexander.atanasov@virtuozzo.com, muchun.song@linux.dev, roman.gushchin@linux.dev, mhocko@kernel.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, jgross@suse.com, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, akpm@linux-foundation.org, mst@redhat.com, david@redhat.com, yosry.ahmed@linux.dev, hannes@cmpxchg.org, nphamcs@gmail.com, chengming.zhou@linux.dev, kanchana.p.sridhar@intel.com, llong@redhat.com, shakeel.butt@linux.dev Subject: [PATCH v2 3/4] hv_balloon: update the NR_BALLOON_PAGES state Date: Fri, 14 Mar 2025 15:37:56 -0600 Message-ID: <20250314213757.244258-4-npache@redhat.com> In-Reply-To: <20250314213757.244258-1-npache@redhat.com> References: <20250314213757.244258-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Update the NR_BALLOON_PAGES counter when pages are added to or removed from the Hyper-V balloon. Signed-off-by: Nico Pache Reviewed-by: Michael Kelley --- drivers/hv/hv_balloon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index fec2f18679e3..2b4080e51f97 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -1192,6 +1192,7 @@ static void free_balloon_pages(struct hv_dynmem_device *dm, __ClearPageOffline(pg); __free_page(pg); dm->num_pages_ballooned--; + mod_node_page_state(page_pgdat(pg), NR_BALLOON_PAGES, -1); adjust_managed_page_count(pg, 1); } } @@ -1221,6 +1222,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm, return i * alloc_unit; dm->num_pages_ballooned += alloc_unit; + mod_node_page_state(page_pgdat(pg), NR_BALLOON_PAGES, alloc_unit); /* * If we allocatted 2M pages; split them so we From patchwork Fri Mar 14 21:37:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 14017452 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97F5F2040A1 for ; Fri, 14 Mar 2025 21:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988323; cv=none; b=jIWIxrI+urnF2p0UJg2Mlsl28eHjFn2AdsKUPul5UWKUVI9Cx8IuWxUq/BGJeCMw25xxKPwI6qauNpuJZT8xy4t1V8RWiMEmIC9G2O/qWCNT7Yt+UslPNA34Yw2U6iTCcbwE4hWCG5lUouka2GAEKr/o8gv/8DQi4qco+BGccYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988323; c=relaxed/simple; bh=7JAKR1B2EJs5OMc3kDKDyMYaNnMBEQeVe+0pTH470+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fOtJZ8dc+7Rf0xhK7dHIfdzVt6E8G7WOA+hvlrHn0lZhutPkA3LsMR3WrkOW9euRGlnRYULaWyKZTqDVUOkJcNncyOWyZTQos0IKsDLpb2EIg2priFjB9yP1M2hKsM415vuV8uXx+xbW0ijIeYOVTBf03rv2n+B64b1L/6eOc64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N1KiB4sC; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N1KiB4sC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dGPxM9RdXtkX+Els8nvXOJm60GkYwZd/fztNUeVaxvI=; b=N1KiB4sC3veL8yihY/K7w70PEUapQvZnYNJOxn00MX4IkqAvvXInzqGpxiFnRN3lT4JJW6 IP+fjhE1uNnCkPswfRlQ76q4V50CCDYc1X9QcBQMsxpYb1Ambma43PLZhuFuyvs1qqXvAI SvcAwlSOU9u/3aCDEZS5GAbTZBLmY+g= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-171-4j3QuXoCNQOrm0DeJ5-F4Q-1; Fri, 14 Mar 2025 17:38:37 -0400 X-MC-Unique: 4j3QuXoCNQOrm0DeJ5-F4Q-1 X-Mimecast-MFC-AGG-ID: 4j3QuXoCNQOrm0DeJ5-F4Q_1741988314 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B7E419560BB; Fri, 14 Mar 2025 21:38:34 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.88]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A74201944E42; Fri, 14 Mar 2025 21:38:28 +0000 (UTC) From: Nico Pache To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux.dev Cc: alexander.atanasov@virtuozzo.com, muchun.song@linux.dev, roman.gushchin@linux.dev, mhocko@kernel.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, jgross@suse.com, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, akpm@linux-foundation.org, mst@redhat.com, david@redhat.com, yosry.ahmed@linux.dev, hannes@cmpxchg.org, nphamcs@gmail.com, chengming.zhou@linux.dev, kanchana.p.sridhar@intel.com, llong@redhat.com, shakeel.butt@linux.dev Subject: [PATCH v2 4/4] xen: balloon: update the NR_BALLOON_PAGES state Date: Fri, 14 Mar 2025 15:37:57 -0600 Message-ID: <20250314213757.244258-5-npache@redhat.com> In-Reply-To: <20250314213757.244258-1-npache@redhat.com> References: <20250314213757.244258-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Update the NR_BALLOON_PAGES counter when pages are added to or removed from the Xen balloon. Signed-off-by: Nico Pache --- drivers/xen/balloon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 163f7f1d70f1..65d4e7fa1eb8 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -157,6 +157,8 @@ static void balloon_append(struct page *page) list_add(&page->lru, &ballooned_pages); balloon_stats.balloon_low++; } + inc_node_page_state(page, NR_BALLOON_PAGES); + wake_up(&balloon_wq); } @@ -179,6 +181,8 @@ static struct page *balloon_retrieve(bool require_lowmem) balloon_stats.balloon_low--; __ClearPageOffline(page); + dec_node_page_state(page, NR_BALLOON_PAGES); + return page; }