From nobody Wed Oct 8 00:39:50 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 6E1B32F6F8B for ; Fri, 4 Jul 2025 10:26:09 +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=1751624772; cv=none; b=OFU3yEqsRCGEQfDlcjBBilddSrmPdH9z/RRTPykZxPmiqL4xdhQxSigUTSW7QZqSt/zPRae3sJt9M/EgDg+FsTXyPZycxKylHOzUKkRDVIgSZSq6ZNPsqoshusEPkeRgm4GLv5ZJ0XNFdQr4tzqPczBOoQRh5YCcpkqG6jQkabM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624772; c=relaxed/simple; bh=oaSTbzQ3dv0aK/zBA0y8w/GgIiybny/jYiHjyAxnR0o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JA/+BhWqTnz1g7jJ6Rx6oNJikhsFqOSnNXqYw6qWWOqeoosRglZqmVprqG5KUVFEZ7jGIy8BZfkV7FdVfKZVx2MDHl5fcwDC5y9SjJqmyFPJMYhFGj0tl7/6bvbuKnGTLX5UFGkARacz9AIu1UWSuDNcw/qPtcUDklm5hy+csTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=blUE6qi0; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="blUE6qi0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624768; 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=NMn47cTQVrdLq38vaZj//jvNYLvXfWrM/D4yqUNgXk8=; b=blUE6qi02WQHKJbTYH5D66fp7uR1atjjlhkcwXv+H163Sv/lbKZ9GWi0EG9lO48iW5kNnI DyNF/EILjNAWawzXhfMVI+FpCKsdrA7YYA35gQZUVoKr2W0S7n+ZZcQOIZOrmU4efxZjPo fq+ONp9FTsZ04NkFpY+YwItAY8RzPmM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-34kTjpTdNIeKzOA26B_Nog-1; Fri, 04 Jul 2025 06:26:07 -0400 X-MC-Unique: 34kTjpTdNIeKzOA26B_Nog-1 X-Mimecast-MFC-AGG-ID: 34kTjpTdNIeKzOA26B_Nog_1751624766 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4530ec2c87cso6379185e9.0 for ; Fri, 04 Jul 2025 03:26:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624766; x=1752229566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMn47cTQVrdLq38vaZj//jvNYLvXfWrM/D4yqUNgXk8=; b=RIZCHVMqnK6PB4L7n31YVYDdd1AHGIpbblwJLJT5f9/B/csZxiCmYz+qRyJS7tlOAX jFlpmm11ZrhU1msYrs7sb6TZnjqnIA37DGek5hFVDPvhreQCoQanUDhC2iGtbIPzj3Yt ApG2qtDLoimbleMojA3cUV9Owyyf/YhAalGyoW1R9G36Rf3BsTBJyxElurXpYy40uwBg K4rHj5bAVWfB9+UrZD6iNxIPdZArMeGvFTBpx2sHvI8rU8bD/pzKBcC9i1pFVcZEN7Q4 RWd6mfQzWE8hjK+GFPCqHi0Iqphn6lM+9McHVJfX1JUWQ3TYx0kGz+xjq85bUAxAcrQu +wkA== X-Gm-Message-State: AOJu0Yycehcol7oPoAC9BS3+o7ui7F+2TwsuiAM6d8wKCWHbxixaC3SN KUQskUh4DIFthOYKfvarNOm1REx/ba51PXfdSxyCTQG/5BLJ+SEhejXVtoTmN/G5YQnJ3TL6uq+ KT7Z8mwgQP+G8PnjXLBn8Cli58oTdQo+SDH4WKLvK/zj6TlrLOeo6etVV1klDhkhkDVNzHc6Uxw iHRoRJaHRBNeJSVYj1pN/TN2OtVU3SkyWqAeIfYR23XHUp8Q== X-Gm-Gg: ASbGncuIV+lanHm0kL8jWqsfDg7/8hzzaaH+GmxJJkASAADOXtKq67zyZ0XTPfbumXC 5Y+tq/y/XP4dq8E0hZksC2ZG1EmCxs5W9oJo2JdXHE8LKFTBX4C8IIBHGNjnzmBe1ie/+DhTxW+ u+eQyGV1J1OLwnocIzNm8lwjaKU2DFdrdDj1nZH2E0BkjTU11OYg4G6cA2mCHtYRF9VCuOP26r9 nRnmHGmzKOKl8urUrZpcyfhi4tj05w7e8Zowl1PVgNJerPa1nMDQ/01dBU7UVuuOaCXAtnK/ykL K0YtC4xpq1O8vvZuY65Z3/9Bx0ElAVdXYk9w2LKz2iFuKLgLNRiChlPoh4DpidpPPAb9HdEzwZd AclNh/g== X-Received: by 2002:a05:600c:34d2:b0:441:b3eb:574e with SMTP id 5b1f17b1804b1-454b306a0efmr19575995e9.5.1751624766067; Fri, 04 Jul 2025 03:26:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOOTyF2MeOIC1dyzcwecIwxCxQh4QIfn5IAcyJ3Cqp147OZBgMH5DYs267rEpv1i04qDIM8Q== X-Received: by 2002:a05:600c:34d2:b0:441:b3eb:574e with SMTP id 5b1f17b1804b1-454b306a0efmr19575125e9.5.1751624765503; Fri, 04 Jul 2025 03:26:05 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454b1628ff9sm22617005e9.11.2025.07.04.03.26.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:05 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 13/29] mm/balloon_compaction: stop using __ClearPageMovable() Date: Fri, 4 Jul 2025 12:25:07 +0200 Message-ID: <20250704102524.326966-14-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@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 Content-Type: text/plain; charset="utf-8" We can just look at the balloon device (stored in page->private), to see if the page is still part of the balloon. As isolated balloon pages cannot get released (they are taken off the balloon list while isolated), we don't have to worry about this case in the putback and migration callback. Add a WARN_ON_ONCE for now. Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 4 +--- mm/balloon_compaction.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index bfc6e50bd004b..9bce8e9f5018c 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -136,10 +136,8 @@ static inline gfp_t balloon_mapping_gfp_mask(void) */ static inline void balloon_page_finalize(struct page *page) { - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { - __ClearPageMovable(page); + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) set_page_private(page, 0); - } /* PageOffline is sticky until the page is freed to the buddy. */ } =20 diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index ec176bdb8a78b..e4f1a122d786b 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -206,6 +206,9 @@ static bool balloon_page_isolate(struct page *page, iso= late_mode_t mode) struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); unsigned long flags; =20 + if (!b_dev_info) + return false; + spin_lock_irqsave(&b_dev_info->pages_lock, flags); list_del(&page->lru); b_dev_info->isolated_pages++; @@ -219,6 +222,10 @@ static void balloon_page_putback(struct page *page) struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); unsigned long flags; =20 + /* Isolated balloon pages cannot get deflated. */ + if (WARN_ON_ONCE(!b_dev_info)) + return; + spin_lock_irqsave(&b_dev_info->pages_lock, flags); list_add(&page->lru, &b_dev_info->pages); b_dev_info->isolated_pages--; @@ -234,6 +241,10 @@ static int balloon_page_migrate(struct page *newpage, = struct page *page, VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); =20 + /* Isolated balloon pages cannot get deflated. */ + if (WARN_ON_ONCE(!balloon)) + return -EAGAIN; + return balloon->migratepage(balloon, newpage, page, mode); } =20 --=20 2.49.0