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 5A55C2F5C5F 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-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-O_WqZrFeOviyjXqlhG7vMw-1; Fri, 04 Jul 2025 06:26:07 -0400 X-MC-Unique: O_WqZrFeOviyjXqlhG7vMw-1 X-Mimecast-MFC-AGG-ID: O_WqZrFeOviyjXqlhG7vMw_1751624766 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-450df53d461so6214635e9.1 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=BNERyBW652BVJYIlpimoMkQ+d7/ki0C6B88tNsTPyVlrfCuZ6+ZHggnGzO+7jo3KBp 4mkU6lzCnRUl8F0+e2yYzLro3ycqEKJ2CNauI8Bf66hhQashatsAJiBSmRXYhI5r/oNn QMfY6MDfiCpYI81F6t9v0PcvBTK0nSoLFoBDne8nq3GD/MQjKzwWPgyk6Q6Fb90nt2F/ tH5SNmEEGCcjEhICqKZVzS2k0wuiZjq/RZjkGu2LRG6lU3k7CqRfzMWouKI519zbpu21 yYCVJvaTSqzHM+QvItnbdH3HTrOLVIsL6r/+Er9XrKCQdBnat4Vpa1u0ik+n09nbCJ8l y90w== X-Forwarded-Encrypted: i=1; AJvYcCX6LK+xgNSCUyPYTkWRyYEbaaV8lwvfqw5d/i5alFgK+Gh50uLYUYuIiQvWcv0/YnSqdrzNKeSBxFQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwCzlw1Do30ydSRwI7AutplZvneTPrhUVP5Y8J06aWTGPsqivUm Edvitx/GmH44Rm+ZmwUOPh/9EaWGOu0r50FOW4iz13IvdT0P03tQdIVs27cGU1lrLYBvuGv9W/K 0ECEoDydextlm6JNJPDCwK9+pM17Fd8dYkwlG6X/5NuM6g9jg5kmiO58fBARsnQ== X-Gm-Gg: ASbGncvTbS27yhPvFym8m86K5lUqVABrXMd78oqnc5euGXLDGhgUVyTh+MVS+elGh2h IGwRDQ/NCFcalkXZJ1wzrg47JPbvYDHIt+++NYF81FToWN4tL8Fz/jewic1f8Lxga+qsL68NjUf SapFlLit6EVhEsw+UaWQXsHxGe024HN9g0yn3yrvroVPf3pdIGWN6g3VzY3rO7RwkF2jIlL4vi1 Bz92pDNWCz1K7JrWxISsEANWTK6mrvgIpCYU+EC7JJe9rqFKyz7Gw3kOjtQXTfGbumx5+AJtePX UZ1e5P+nLKXyg0JpdjGmJBl3ahz7gWwGCLp+U7pbME9IvwLgraHlcbRawQAzvazh3bzlyTF+JRT srXwzjw== X-Received: by 2002:a05:600c:34d2:b0:441:b3eb:574e with SMTP id 5b1f17b1804b1-454b306a0efmr19575625e9.5.1751624765950; Fri, 04 Jul 2025 03:26:05 -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-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_compaction.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. */ } 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, isolate_mode_t mode) struct balloon_dev_info *b_dev_info = balloon_page_device(page); unsigned long flags; + 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 = balloon_page_device(page); unsigned long flags; + /* 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); + /* Isolated balloon pages cannot get deflated. */ + if (WARN_ON_ONCE(!balloon)) + return -EAGAIN; + return balloon->migratepage(balloon, newpage, page, mode); } -- 2.49.0