From nobody Tue Dec 16 03:20:49 2025 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 CD0621FDE1A for ; Fri, 14 Mar 2025 21:38:23 +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=1741988305; cv=none; b=mISvijqWqywKpGaHVHR+L0qhACcSZxQl0z70ZnGZYM+mkVFNyzYQmYTzlwLFsSF0nDvvgKI4lfXuvmYexi2R8j6bsl79Idsj6SdgbJe29XFCb4Of/yLCZjK2lrQS6fCgtPZci45FGhjj+ieZ6QPVdIdiezAipcIw4I8YVZehQqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988305; c=relaxed/simple; bh=KR7Rgigui5nMqE+lqkr212HsL5acvMFEx4PkGQEmMBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UDV+dDElBqPP1/NjM3geG8IEMaJJn46OoI4l3rlvMazBcqG4MtzIXrWAPCvd1Ngh7o7Anr8XDgTVneZcAieS9lkE3leFxezbWCEEsPaiTLsNjdjJIgNGfvKHeSngBBamJmqq3Cp3C9xH9PfenWcFPlfzCSdR/HE6a3UMMrICl8Y= 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=KhyOWeGk; 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="KhyOWeGk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988302; 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=KhyOWeGkfPVROf2IyQ9sxI/mNtzHDzW1I1J0der5AKPyTMb6oEYAjqDYe89GaXZvi/zmHP YahiX9kCPM3fFBbFq/731x8Bw0HNgV26S5YQ5fRIaX0dkmQhz9tFuJTTaoMilju29PVMhA Hb3vE1UGIDCwhMeaHSPuoDnQJ8oWxkM= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" 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)); =20 hugetlb_report_meminfo(m); =20 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 }; =20 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, nodema= sk_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, nodema= sk_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 >=3D MAX_RECLAIM_RETRIES)); + str_yes_no(pgdat->kswapd_failures >=3D MAX_RECLAIM_RETRIES), + K(node_page_state(pgdat, NR_BALLOON_PAGES))); } =20 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[] =3D { #ifdef CONFIG_HUGETLB_PAGE "nr_hugetlb", #endif + "nr_balloon_pages", /* system-wide enum vm_stat_item counters */ "nr_dirty_threshold", "nr_dirty_background_threshold", --=20 2.48.1 From nobody Tue Dec 16 03:20:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1741988337; cv=none; d=zohomail.com; s=zohoarc; b=JCTYwxNm8mDkpB8r+wqcbiPArDPwJ+KmuluyrWi7f72ji9dYp0e+jN3gGi/E1DLfsUwrTdDP4zWzSXKheGB+TPF+T/w3H88fthEvywVkLJ12zyBn+WxwVFtKAWbP8fR1/tuaoaOBTI244padTXxsy6LR2vfms5IS+5u4e14C6iI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741988337; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3RXL+coJsdtD8dzVN3au7Q2NbBlOYxUwoHTJ/KoQPU4=; b=gIME2ncrwVkYz4PlgqLOW524hWiyEpi85BAC7Z1y459+iMquFhQLQWHXiW7zbrCr0533Fqo+Gy/oKNrUM+t2ZxzUmiHHs7I975OS8Xuy6aQglswVAK/n1Kd21u2FN/xulwBuoLZ3ABDlkJopv21uPiIW9tga17ghNaMW9GOfai4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1741988337139438.34429485069313; Fri, 14 Mar 2025 14:38:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.915465.1320999 (Exim 4.92) (envelope-from ) id 1ttCjm-0008Nc-DH; Fri, 14 Mar 2025 21:38:38 +0000 Received: by outflank-mailman (output) from mailman id 915465.1320999; Fri, 14 Mar 2025 21:38:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ttCjm-0008NT-AD; Fri, 14 Mar 2025 21:38:38 +0000 Received: by outflank-mailman (input) for mailman id 915465; Fri, 14 Mar 2025 21:38:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ttCjl-000827-06 for xen-devel@lists.xenproject.org; Fri, 14 Mar 2025 21:38:37 +0000 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id af13fe1c-011c-11f0-9ab9-95dc52dad729; Fri, 14 Mar 2025 22:38:36 +0100 (CET) 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 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) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: af13fe1c-011c-11f0-9ab9-95dc52dad729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988315; 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=DI/0F6cdNKPnPLBqukHBXVa5rFs6vXRJriXpiLIanfhiv9rIRXWELF9e9oqlnZHXYFXowF pTIYWg0QnhP76BrUyTurfg7Fnco06zBf9/o5noftNo0VG0jtW/5OfxZ+4xxpXP7iYlkxjg puSmDYjwuteCj28N5eULfMOs7nw9tU4= X-MC-Unique: 0r6UKT9IMtuF-Il_bN2UWQ-1 X-Mimecast-MFC-AGG-ID: 0r6UKT9IMtuF-Il_bN2UWQ_1741988303 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1741988339043019100 Content-Type: text/plain; charset="utf-8" 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_i= nfo *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); } =20 /** @@ -103,6 +104,7 @@ size_t balloon_page_list_dequeue(struct balloon_dev_inf= o *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); --=20 2.48.1 From nobody Tue Dec 16 03:20:49 2025 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 6C88918A6C5 for ; Fri, 14 Mar 2025 21:38:34 +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=1741988315; cv=none; b=UcGNA7OL9aIVIQC65KBQZ8EQ+FMqddAINRe4DVpm6vJE7YrRgv1j7lfAREnsbf2T94JWbKmRBn2N9FlWfnHv2bQpIc9LfEmM20Xv51q2rvXEoBSqvGz0uc6dBaeS8b6YKOmR8Pqbatw8BiDZmSpnFeWdS6tScIQjhOMHi/mv+yc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741988315; c=relaxed/simple; bh=AzqFum6Agw13RjN3Fu1tKvuI6gP3XBpPLw2tmwLYzUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FlwY6nG9K/kwTKDvxQfP8P/pGcQ6xFlFQrXuCx5qdKP3idl1SdNJawqpZdpy5YmmQGmooLqVaRAZBsJthfAtLYxEr9KaLerJN6/UELJN0SOP1bbJdUnuqLn1ysGUdS/PcBQ7dKks1t3sF9s8oXJMX/S7+hfOWj5b/AZDglyps/s= 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=AGI3rzV/; 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="AGI3rzV/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988313; 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=AGI3rzV/y9Pjccue7SZAqO0enUG/mnvGUgeSghsKkQUWIGYz22v2CPQoz8R+U6uUL4olMs rTyiYX+V10RIkj98DuVTrk8DMovr+qiI9Squ5PMlW/uCcUk4jHisTB2SizIGxU7KFQ126u 37PG7YJtIW8UoRP4mcyzI5pVPJgcU3o= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" 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_devic= e *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_dyn= mem_device *dm, return i * alloc_unit; =20 dm->num_pages_ballooned +=3D alloc_unit; + mod_node_page_state(page_pgdat(pg), NR_BALLOON_PAGES, alloc_unit); =20 /* * If we allocatted 2M pages; split them so we --=20 2.48.1 From nobody Tue Dec 16 03:20:49 2025 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 6462A1C84C9 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Update the NR_BALLOON_PAGES counter when pages are added to or removed from the Xen balloon. Signed-off-by: Nico Pache Reviewed-by: Juergen Gross --- 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); } =20 @@ -179,6 +181,8 @@ static struct page *balloon_retrieve(bool require_lowme= m) balloon_stats.balloon_low--; =20 __ClearPageOffline(page); + dec_node_page_state(page, NR_BALLOON_PAGES); + return page; } =20 --=20 2.48.1