From patchwork Fri Mar 14 21:37:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 14017482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D15AC282EC for ; Fri, 14 Mar 2025 21:38:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66ED0280009; Fri, 14 Mar 2025 17:38:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F547280004; Fri, 14 Mar 2025 17:38:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4970B280009; Fri, 14 Mar 2025 17:38:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 282B0280004 for ; Fri, 14 Mar 2025 17:38:21 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E9BE7C0507 for ; Fri, 14 Mar 2025 21:38:21 +0000 (UTC) X-FDA: 83221470402.28.4DF9C4D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 2A19D1C0009 for ; Fri, 14 Mar 2025 21:38:20 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h5OiqEXG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741988300; a=rsa-sha256; cv=none; b=jmI3SpZMns4b8F9WnhrEFk46+SUP40rOclj/4m2K3kAMr0CjspxgHRnRBjjJwEE9YqtLa/ w4eBW06F9nhbc64+Hk3PPLETo6Zs/ncMYlERbtUSK2N6XgZfln0FvezmnJ4NpN/y7ngEFu Qr1OE7vQlzRXdR2KzXgUSmwA6nS5IYA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h5OiqEXG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of npache@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741988300; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=x8R8SnT0xlNk6NOCsego5+xxOFgcolEZepoyw3FUxJU=; b=PPJ1YdrrlTlKrD9A66r00MUNR7EMaH6CfDHPFKgszktPuVDD56mktk26OHFuDR4NEO/RIJ wpt3b8VB+UbsaH00cju04Cl2YAwZkgaMtu/yduu+D2zQ6pvVdkFzBEw/aIfbTTRR8LJfnC JVFWOQzTH6AgTUuYY5ovHgPVRfvsFn4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741988299; 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; bh=x8R8SnT0xlNk6NOCsego5+xxOFgcolEZepoyw3FUxJU=; b=h5OiqEXGWEM34HI+0a/PVB+PHZLnV8ef6/6T6sgdcj3hTGA89rbEJR1zO4QSvW3eXzqnX0 wrOjHMMg0vl1fwIYad78kminmIv/V9MPoXPQihRC1/Nro0FCdQglWgQQGTybkYXyN5uLhe 6Z/2drm8V9Ch4RUCvpKpHN/3BbJOUEU= 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-546-Z7N13xufNW6XUwaNZpccyg-1; Fri, 14 Mar 2025 17:38:15 -0400 X-MC-Unique: Z7N13xufNW6XUwaNZpccyg-1 X-Mimecast-MFC-AGG-ID: Z7N13xufNW6XUwaNZpccyg_1741988292 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 898481800258; Fri, 14 Mar 2025 21:38:11 +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 20D901944E42; Fri, 14 Mar 2025 21:38:03 +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 0/4] track memory used by balloon drivers Date: Fri, 14 Mar 2025 15:37:53 -0600 Message-ID: <20250314213757.244258-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Rspamd-Queue-Id: 2A19D1C0009 X-Stat-Signature: u4o56odr96969cffrduk943ohr7hryct X-Rspamd-Server: rspam06 X-HE-Tag: 1741988300-748009 X-HE-Meta: U2FsdGVkX1+tsDFMVwPXYwDosAWyks7vScNJ9Q+oZjQLdhIHUW5+lBuWnig+5mY17axzEyQ9wuXfopp7uSmrRZC8siyBaBltmrtS9/x1RFUggp5OgfOxPxW16zrryyRzct0zGBrsJBUUXj12w+CqQsDe2YGv/IFltzB70wB8N+hxtlW0fh257qcIrxefsdcrJVRlQTYDxPj0SRg4QwTdZUlJsQVVzMNCTlGfkVDsUiS0mDFj/IFTSJob3y4vdoPtpRkKAM78m0CAuQCed8TrrAZhFOJIOfDSHD+NWkYPJdHmwpDZQnZWrDjbvu+hRdO0uwhUAUEYcAfX0Re5joDpT3CMhy0GJ1l6Xkpf/oKlPtecP39uNsFNy+9Mtp0a4TZD5r/W9Zfd+eeUQEURpoM2tJocuVT3BdJpJ3/k7SN1/y0lkIgr1cTmUPnUAFroGxpbiruDPmi1uL6dGA/KoSGcO9gFDxNJToS9vkKsewuI7Nh2WrcphKXonit7z9G26otzkA6qqQ3jdKvW+OjMJ2fyONjyX2ERD8YYiF9LZdjpF1MUYFZqbo8RD7zil5Q/NTitiYsKuB3XXmAA18PVSOeNHn3LXYUoZvmsadCMFVQFLHxKYNlG0yUciz+OFbD8W1cipe3Be7VHDUho4lB+BWsQmogOfN0Vpni+26KC1pTRm6w+2UJnMK9gSXWWRQTBZ8l1hCBthQ9saC4QJw2NuRHHhlBPLx6Foao/WNE1UXQNFV74II1Lv4GEWpKTkBnhqnMfIIRoEsKSwn+Zm4kRymWUM7QK1s1YTWr3Wf3usqz1EAgwMnTjGsmSo7RfZhWJwdQ6vvyuTGeAF7Jb82ZA/lkdK6OVBvk+HJLx0ud/67qhYUBjzOdmlFrhEz+Q1utzihRQOFjIfxfufgKyQ8FtE1dJ1W88tMFzm8umYIMRTAoUzcNme9cvAjE0hn6gEDcHcpXkGNaFp9rnW6WfN1d+zRU xzXFjR2j KiXp2h6Zo2lw+RuUuSjUr/E0wSEa1OWu4zv7iDCKUhKKBfN0kpYBg2yHiCiqnSugEQrxQhty1B8GuIrMeinyFr7GFaRDj2ooNLo7jp25mF+Uk/o2xsO925i5FXVHR7LzcIti0ItPdUHWOvdRLlVddH0nZJEVGl3jJzyjaH0CcMdJvuF7VDZxNPo70HOv4J02TKytrHwZpPtxUgwVZAs4ACmFsX2briOgOKay353PnwUGAXTTcXvnHpv2KFUTSB90BQ/zjL8+xanzxp/DLeMicsFOSTba3AdnttDf9ifllPljNmuLpfdF2C+H2JSAl1EUou2hJ59au3MyiEmE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This series introduces a way to track memory used by balloon drivers. Add a NR_BALLOON_PAGES counter to track how many pages are reclaimed by the balloon drivers. First add the accounting, then updates the balloon drivers (virtio, Hyper-V, VMware, Pseries-cmm, and Xen) to maintain this counter. 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. This makes the information visible in memory reporting interfaces like /proc/meminfo, show_mem, and OOM reporting. This provides admins visibility into their VM balloon sizes without requiring different virtualization tooling. Furthermore, this information is helpful when debugging an OOM inside a VM. V2 changes: - Add counter to the balloon_compaction interface - Dropped patches for virtio and VMware as they use balloon_compaction interface Tested: virtio_balloon, run stress-ng, inflate balloon, oom prints Signed-off-by: Nico Pache Nico Pache (4): meminfo: add a per node counter for balloon drivers balloon_compaction: update the NR_BALLOON_PAGES state hv_balloon: update the NR_BALLOON_PAGES state xen: balloon: update the NR_BALLOON_PAGES state drivers/hv/hv_balloon.c | 2 ++ drivers/xen/balloon.c | 4 ++++ fs/proc/meminfo.c | 2 ++ include/linux/mmzone.h | 1 + mm/balloon_compaction.c | 2 ++ mm/show_mem.c | 4 +++- mm/vmstat.c | 1 + 7 files changed, 15 insertions(+), 1 deletion(-)