From nobody Wed Oct 8 09:26:31 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 56BC628B7D4 for ; Mon, 30 Jun 2025 13:00:33 +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=1751288434; cv=none; b=k3hb/DjLEFu2g2zTggwdxBGSmTtAQafCR1++Z3EJEUZqgLZRhwxORuSSC6ogkKjZUe48urPZzffeN8rSrZzqEb1AHKN4jPb37in7HVLNHPcN+I1VHa7nMvctVne3/FiAJ0deRjHBDjU9uJGSQkd4amch564xlKMzEDatsW/OmG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288434; c=relaxed/simple; bh=RPaleElAAsDd8ZXcp7V7mHwwcGHXNcadS42UzjFFaPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t+/MhEJ6LEu1MSs4Y/ojLdJZ87eE2YOYB9iA8Fh1Qfn/zIjnGGt3F4hJpVtuLYDMWJpx+7u5aU5rT1kJXbGA1wcFR/j7UloNdmE9YcoapcDjj2J5skSfr2vVlsjl4Sks75k/IdT5aFpAznn8Gwd732DuCnSgiO7/74uXNuRwDGM= 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=SPk6McXY; 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="SPk6McXY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288432; 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=iLYHGg19bG0clXk7rQPjR4hvYWmeZvg7QKQ5c0snrQE=; b=SPk6McXY3w7qS4c+lXxWYLW6YP98whpIq+1CEoj4adjO7qg+0mnr+8N+956gND3Q+GcrGA /1MxMHnd2ujcVpm4Qeiie+nu5L4X5YaZ4B9LPiefOJMjwlS3p/SpBF3dpETDThMH8TZKXE IT9e8eIuDPLwFgc4OaAqwHFd0l8t2co= 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-540-sGckTeW8OnOODD5tVmDpzg-1; Mon, 30 Jun 2025 09:00:19 -0400 X-MC-Unique: sGckTeW8OnOODD5tVmDpzg-1 X-Mimecast-MFC-AGG-ID: sGckTeW8OnOODD5tVmDpzg_1751288418 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-451d5600a54so31263115e9.2 for ; Mon, 30 Jun 2025 06:00:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288418; x=1751893218; 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=iLYHGg19bG0clXk7rQPjR4hvYWmeZvg7QKQ5c0snrQE=; b=Y0mVj4ng/yUlHe8G50PjitZmInuEHvQaxu644fK1s7vSmQ6emQs6tRzniwBFcLmoYG yfw7sqLYEopxn+Kc+PmX957nJh7MoS6DQ/AXo5M2kxDK+K2zNVrjcgGMRCGXM8h4cR2O 2ZGL3rrVenC2rV+vDTqHgl83JtSkndPb9O9NESAJOcxNyXDR1InBTEYTsSPGXhxeNE72 FBKDdrcucm2pV8TO2nTNCj1FlUQzx7v/uSCI6JzPidX6u7COM5wKObKp7Pta7IOJJOWT nHyYGhh4Eo6ysu0+finKjkBRk8j0RUn8IJfIQVZHp3a/zU5JsY/d6qHKcnUS4RrHPm/L m5dg== X-Gm-Message-State: AOJu0YwxLhvLuymXKMVeJVXJnF7yUZwU+u4Shwtut8PdD+B8Dn9X2mXL AtElh5OxV5JniiGMKg2/iKaResRn7hy6xlLID+Qf8A6e2EHh1boeWm2FH3My9AGC8Cw7HMlfWe4 SQy1x/jH7hQi+QFNrNt7mCddlwBEl5BvuZrNoVwgZUS+HIk3TR1oYrKnot5pMJk50EORVl7lYRY f8mPeyPWVWyQlsciw7uQmHXybU8FmIg4gqrT2Iy7mnn7PwgH5E X-Gm-Gg: ASbGncvkBFKPP38hdrmKmMhalUZF7PRQ9t/aL+Gi7ibeaIJeE30cYbEoskqx6xH2eAh hqdpgfrx2dUrGyeUkok2lfKJd3wAymQ/OhXATgJQiuDBbposfL/T8zUe2tgLMYfj08LNHv2mJI6 xOe9NhoHYv/4lLTmocUj9tkU/xbhrDgzCyJT2qE8gIMlovvuoRRbYuPC8Fzh4sc6NOTWPRaEcqb K8Owg+MqbrAft06bOxT20YTfCR/mq6AXMduNCZmgmQmWmf0Mxw1Vw1GytaP0/iqEgx8+tKCSYEh qYQf/V4a2t90ddG7c0grnZFLRuU1XDOcswhfkzEsaVzmvvOOw6s35K/LKmJizupRG9/TH15KH7k Wjx+qCDQ= X-Received: by 2002:a05:600c:35c9:b0:453:608:a18b with SMTP id 5b1f17b1804b1-453947d8ff2mr103853475e9.9.1751288417789; Mon, 30 Jun 2025 06:00:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGb/NAxjgNou29rgmmNKmV3zZO0Mb6cYoPiX5R9Zf8/khrmrYWUc/XyFqJpcvry+rGAxO8smA== X-Received: by 2002:a05:600c:35c9:b0:453:608:a18b with SMTP id 5b1f17b1804b1-453947d8ff2mr103852575e9.9.1751288417169; Mon, 30 Jun 2025 06:00:17 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e59659sm10376420f8f.77.2025.06.30.06.00.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:16 -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 v1 01/29] mm/balloon_compaction: we cannot have isolated pages in the balloon list Date: Mon, 30 Jun 2025 14:59:42 +0200 Message-ID: <20250630130011.330477-2-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" The core will set PG_isolated only after mops->isolate_page() was called. In case of the balloon, that is where we will remove it from the balloon list. So we cannot have isolated pages in the balloon list. Let's drop this unnecessary check. Acked-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- mm/balloon_compaction.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index d3e00731e2628..fcb60233aa35d 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -94,12 +94,6 @@ size_t balloon_page_list_dequeue(struct balloon_dev_info= *b_dev_info, if (!trylock_page(page)) continue; =20 - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION) && - PageIsolated(page)) { - /* raced with isolation */ - unlock_page(page); - continue; - } balloon_page_delete(page); __count_vm_event(BALLOON_DEFLATE); list_add(&page->lru, pages); --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 3D5C5293457 for ; Mon, 30 Jun 2025 13:01:29 +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=1751288490; cv=none; b=nm0hjBjD0Lz/dwsjme2odzGa5Qw0DBNR3moDXUH2HJz4RzXlyN/tYBHKAq922qHBxaRWLdIlf43pIfamF2rYgdCW3YE4OJ8g2/ZtEEqw+JsM1H3YnqSJCUc/V65hMAUcWyub0vOL4kflxo4EgVEzkheNYpGGlQeDSQB+7qhT/Vw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288490; c=relaxed/simple; bh=HoU6IkwEzSx0bRpH46YFQR6C5ixdQUXKWK5iDFNMOt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=akm1h9SIsXtW6uyJvVqNsVp9oVFPT5PcLms0w0Q1Bk2roz+sslLT5Z10Z8yrxGnsuM9PLCDZbgtx3+29c/Mdc8MjUuRaC/76v7VJeO0MOdsR2RIaXw345zZlKu4T8+5/Rq5ss0vxnjria2HeQlcIbLyfsMGVGJLiiwCZV/VF0lY= 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=ioSE6Vfs; arc=none smtp.client-ip=170.10.129.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="ioSE6Vfs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288488; 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=hwmXAEBDYo8DkjDdp6VkbgoCuZIqYMKAJtJSkdjCkPU=; b=ioSE6VfsbT+rBAR/i+2wVff7rSEWhRUcLAeJLA/RfyWqAnrL6krQoJf7TsspzQKcrZlzcp 84dqniuuMB5spneDM9RRMSo3Y0G89qufgSDVUOPaoOzLaEBlL5NKfAdFnmjcH8UAtoXBFp Rvtli7JNJfVkzxEI7lB7h4hlvkiI+tY= 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-355-YbBW2880N7CDEDL-pn7FjA-1; Mon, 30 Jun 2025 09:00:22 -0400 X-MC-Unique: YbBW2880N7CDEDL-pn7FjA-1 X-Mimecast-MFC-AGG-ID: YbBW2880N7CDEDL-pn7FjA_1751288421 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-453691d0a1dso11767165e9.0 for ; Mon, 30 Jun 2025 06:00:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288421; x=1751893221; 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=hwmXAEBDYo8DkjDdp6VkbgoCuZIqYMKAJtJSkdjCkPU=; b=gS6gscqG2zZoK8i6vtRHlq7eiUmhB/F1smWXX/GOh5SPLMB88OJKrRzu13cdbohmfM 236TE1EbaolbYRhDdodOa9Iitw/2GgR3x0dEz5pR1C+ANUPQ8gwEoFT9gCKchQfBqg+q PbPOjr4dCdIO7/hT1Dtli54Reflf2VEGuDJGhyUsc4lXmhJDZ/lHnSbUd9N3edEK/jiL I73Nf6mDK9udgjuojwow0TckwcgBPLR5iRyQ1f0MzVQsvtfbK+8BaY+L0far0uGhR8Ns CZ/VAnlYpEiM/KfDALBHx03AEHnbraVAG/lrPfjPUkC7xrnuO1ParTitYIpR9YoMgcMJ jooQ== X-Gm-Message-State: AOJu0Yz/WylWqYQ6/j6qilmAliu5L+rayPjsOv/LLHTse4mGMTupLOxG LCvhiuFTgktitH5tKlQJs/egsZ0sftWKJ+/+az1QmDoaPpvhCCJ9uhKyrwpdXxd6B+uv8gRp9K5 VBcNeqh2OWOnlf/PUd2e3VB69tG5LirEehAxcLG1Tz5P9Zu5UBnSVSgzzMCdGBgv+eki0jHYAlL msBhKmvsiJbMSOHaohTA6p1tbhWGfl7ITgLy5tce0a563voDxP X-Gm-Gg: ASbGnctSolFPehMoabI8EyS/FwHwhbrbeLI1IgZJcevtjwkBkC465pKD3hRkNb2Fd5P /MJZw19H9f5r9s+Yyp8J1i2mlz0Hp9TWdiM0l2d1KfDp8h6ByHoxfwgToBDGBHrPF4E1PTU5rip y2vDRend+3C1+9buyN4n5kXmPS50ZhSFdwQIrCIxXWL5jKA4MQ1QuXFsVR6PjvstpJULOf8bzUN z9tC7yB2sZOvBNj9w0GYATGvbdPcFxog4VJctr0sXN9KyFLV99jpJBvcv2KAvI4GhMS85keqBrM CzTWSwft0iXAscCCBwELkMwrgA0f24247KAHwXKJ+TN71HX0b9IwVFugAIiL+hX2/Ztp0l8Y7gF BsUu8KBQ= X-Received: by 2002:a05:6000:4186:b0:3a4:db49:94aa with SMTP id ffacd0b85a97d-3a8f482c7a3mr12061903f8f.21.1751288420899; Mon, 30 Jun 2025 06:00:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0gb3C+C+LV4oU6wKBD78SFqxqmgRCphVWjbRDEuvh0xGGV6ZK62AjmpQKGwfy92kungebyQ== X-Received: by 2002:a05:6000:4186:b0:3a4:db49:94aa with SMTP id ffacd0b85a97d-3a8f482c7a3mr12061792f8f.21.1751288419988; Mon, 30 Jun 2025 06:00:19 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a88c7facf9sm10288204f8f.22.2025.06.30.06.00.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:19 -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 v1 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize() Date: Mon, 30 Jun 2025 14:59:43 +0200 Message-ID: <20250630130011.330477-3-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's move the removal of the page from the balloon list into the single caller, to remove the dependency on the PG_isolated flag and clarify locking requirements. We'll shuffle the operations a bit such that they logically make more sense (e.g., remove from the list before clearing flags). In balloon migration functions we can now move the balloon_page_finalize() out of the balloon lock and perform the finalization just before dropping the balloon reference. Document that the page lock is currently required when modifying the movability aspects of a page; hopefully we can soon decouple this from the page lock. Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- arch/powerpc/platforms/pseries/cmm.c | 2 +- drivers/misc/vmw_balloon.c | 3 +- drivers/virtio/virtio_balloon.c | 4 +-- include/linux/balloon_compaction.h | 43 +++++++++++----------------- mm/balloon_compaction.c | 3 +- 5 files changed, 21 insertions(+), 34 deletions(-) diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/= pseries/cmm.c index 5f4037c1d7fe8..5e0a718d1be7b 100644 --- a/arch/powerpc/platforms/pseries/cmm.c +++ b/arch/powerpc/platforms/pseries/cmm.c @@ -532,7 +532,6 @@ static int cmm_migratepage(struct balloon_dev_info *b_d= ev_info, =20 spin_lock_irqsave(&b_dev_info->pages_lock, flags); balloon_page_insert(b_dev_info, newpage); - balloon_page_delete(page); b_dev_info->isolated_pages--; spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); =20 @@ -542,6 +541,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_d= ev_info, */ plpar_page_set_active(page); =20 + balloon_page_finalize(page); /* balloon page list reference */ put_page(page); =20 diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index c817d8c216413..6653fc53c951c 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1778,8 +1778,7 @@ static int vmballoon_migratepage(struct balloon_dev_i= nfo *b_dev_info, * @pages_lock . We keep holding @comm_lock since we will need it in a * second. */ - balloon_page_delete(page); - + balloon_page_finalize(page); put_page(page); =20 /* Inflate */ diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloo= n.c index 89da052f4f687..e299e18346a30 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -866,15 +866,13 @@ static int virtballoon_migratepage(struct balloon_dev= _info *vb_dev_info, tell_host(vb, vb->inflate_vq); =20 /* balloon's page migration 2nd step -- deflate "page" */ - spin_lock_irqsave(&vb_dev_info->pages_lock, flags); - balloon_page_delete(page); - spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags); vb->num_pfns =3D VIRTIO_BALLOON_PAGES_PER_PAGE; set_page_pfns(vb, vb->pfns, page); tell_host(vb, vb->deflate_vq); =20 mutex_unlock(&vb->balloon_lock); =20 + balloon_page_finalize(page); put_page(page); /* balloon reference */ =20 return MIGRATEPAGE_SUCCESS; diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 5ca2d56996201..b9f19da37b089 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -97,27 +97,6 @@ static inline void balloon_page_insert(struct balloon_de= v_info *balloon, list_add(&page->lru, &balloon->pages); } =20 -/* - * balloon_page_delete - delete a page from balloon's page list and clear - * the page->private assignement accordingly. - * @page : page to be released from balloon's page list - * - * Caller must ensure the page is locked and the spin_lock protecting ball= oon - * pages list is held before deleting a page from the balloon device. - */ -static inline void balloon_page_delete(struct page *page) -{ - __ClearPageOffline(page); - __ClearPageMovable(page); - set_page_private(page, 0); - /* - * No touch page.lru field once @page has been isolated - * because VM is using the field. - */ - if (!PageIsolated(page)) - list_del(&page->lru); -} - /* * balloon_page_device - get the b_dev_info descriptor for the balloon dev= ice * that enqueues the given page. @@ -141,12 +120,6 @@ static inline void balloon_page_insert(struct balloon_= dev_info *balloon, list_add(&page->lru, &balloon->pages); } =20 -static inline void balloon_page_delete(struct page *page) -{ - __ClearPageOffline(page); - list_del(&page->lru); -} - static inline gfp_t balloon_mapping_gfp_mask(void) { return GFP_HIGHUSER; @@ -154,6 +127,22 @@ static inline gfp_t balloon_mapping_gfp_mask(void) =20 #endif /* CONFIG_BALLOON_COMPACTION */ =20 +/* + * balloon_page_finalize - prepare a balloon page that was removed from the + * balloon list for release to the page allocator + * @page: page to be released to the page allocator + * + * Caller must ensure that the page is locked. + */ +static inline void balloon_page_finalize(struct page *page) +{ + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { + __ClearPageMovable(page); + set_page_private(page, 0); + } + __ClearPageOffline(page); +} + /* * balloon_page_push - insert a page into a page list. * @head : pointer to list diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index fcb60233aa35d..ec176bdb8a78b 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -94,7 +94,8 @@ size_t balloon_page_list_dequeue(struct balloon_dev_info = *b_dev_info, if (!trylock_page(page)) continue; =20 - balloon_page_delete(page); + list_del(&page->lru); + balloon_page_finalize(page); __count_vm_event(BALLOON_DEFLATE); list_add(&page->lru, pages); unlock_page(page); --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 7F26828B3FA for ; Mon, 30 Jun 2025 13:00:29 +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=1751288431; cv=none; b=UOYyno6ltahkXt2y48njGJ6UJYPNkItILQe8V9u6gP9CLhN8WXwmzF2i5MWE3h5UMaPZfpHMi+WkEvg6i5glat/d8kmQF59seyt6H0TMPpO7wMQQ4jk3V7l2ge3QBlPxuCCFgjLNHOLrbpTX4ekHFIQiVI4PbqmHl3RjMI8KIsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288431; c=relaxed/simple; bh=g/Nn7yNLQF9bkumkJTFPBJ0/vMryjzBbswzQoi8SqSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=csoG7yLrGaL5c2o282Vqexb1DjzjxqX8Em7V6O6vmu0G5zA9VdGuF6tePZ5+uyFlthftLUDsg/ZICUz3tdklUIHzuky/eIbpqjYHJ6deu/5GJvHawiGZzQe43bDa59u5KlsfpqFMWE93eVZak9Gb17SVGJ4IUnfuvNy+V4MW5KE= 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=HqGczN6V; arc=none smtp.client-ip=170.10.129.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="HqGczN6V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288428; 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=/UC4605AtCeOAEiQnGvC6ua/uaOm0pT0/PRnxSFzekI=; b=HqGczN6VFd/D7S6TYuJG/6tTKfNELE4zc4sw/3Jk/qdoM0m7oXBo94D1g2pxh/Mm1ezTfc bgdxVMsk0Wg0C4p/A6ysiXYAWN+4qg+U2xPwMl9UEM8NH14/YdRwH6Ne2gu/FQBI7lqb5u o/SyIQJO2Xjf6dn2VYtdYCSuErdzOQw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-1U6ZZ3sENzCDTg2SVNpJ9A-1; Mon, 30 Jun 2025 09:00:25 -0400 X-MC-Unique: 1U6ZZ3sENzCDTg2SVNpJ9A-1 X-Mimecast-MFC-AGG-ID: 1U6ZZ3sENzCDTg2SVNpJ9A_1751288424 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4539b44e7b1so9205615e9.1 for ; Mon, 30 Jun 2025 06:00:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288424; x=1751893224; 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=/UC4605AtCeOAEiQnGvC6ua/uaOm0pT0/PRnxSFzekI=; b=h29QSi0cYrJDiwnvEVgsYReUurLiutGGidpbrWptgLu3MbG7Ax2Klzl1k0NkRx/yy9 tniWKwNePTQrvjAevDW2PzGdWdW9yw80B0dEZeuHRElZK2IUIp9iklFfUNyrU49hXY3o AgQ+G7OKIi4RcPOXwnAQolwMjMjLXgnYRq5XTau+3U/7FI6FRiwXSOZYLnZ2/Vo3yHOS yS3wVqSuTWz4SgbN8HVLr+truZs66AgK5qo5/3eY4l8Qo+LWcYVqTvYRx6lHI7tu1xQn KBtcb98/B0qFdOGKZgo9IrR1DY4O8S1/i2P+0DP6vIfCpxdAUCjuKHCJBNFk0IhhS61C bSVQ== X-Gm-Message-State: AOJu0Yw1iq8UMH168SdIdeo9MFGHhiwcbA82AGYbO5h5E4xwSt8kdVC/ eyCNszLmu7qQQM1lyRoGqcJUR0MxejR4bRY9G+jGgdquP5n3VtQUyz96+rCWl67Q/VnLnmm+N+B WPQvawIeDZhuo4xmpiAJToZvgM4vcewfDp3j5zZUFrk6+UnXBUxU+NT/Gjx1wqjvGvd2bQ0uwAB 8P/FiHiW86O+aUx5L24DNu4oZT7/qTPy2epaeWp0UqwTAsbjHV X-Gm-Gg: ASbGncsA3NJREzlP1rXCPYFmcT8aNxsTSQ4A9ALt+Cw97RlawSWH7w9bf85IhAyH/CT i7w27HciEhRnnOM5Wqr/Qxw3RVcnvIz9DBoCb+sPQmipBxc/zuLQrK+759JQUlUlwqgiYpU3XOy mnniQZMVOjc1Ojs3Vpse6uoyKVxUrZz3LeKy1KRztGQ/Gx3irK2JKZ05Cwwu8vWBu2hsrH+1tJL ZSjhCI8OnHPGGegOQd8YSMjlhoBs71esB9bVtCwUCTG6GS1xZ41TtCHbnAcu7YHkrh0lyxPmR4T l0Y3ORBJwE1c/aQphFDa6jc3Viz/6EUdOvRXP4DJAUG7rEk4Df4DG0qEoh5aO6qN7Sx2wtFYB4C zHvkP2rU= X-Received: by 2002:a05:6000:1786:b0:3a4:dc93:1e87 with SMTP id ffacd0b85a97d-3a8f577fdf7mr11727619f8f.1.1751288424288; Mon, 30 Jun 2025 06:00:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLO9PGgybCCYgBv54Fac4lQzN8FKYTlkGjVWntSI86PNTFg8laDwfPxXxOTUUP76xSqnQLIw== X-Received: by 2002:a05:6000:1786:b0:3a4:dc93:1e87 with SMTP id ffacd0b85a97d-3a8f577fdf7mr11727461f8f.1.1751288423060; Mon, 30 Jun 2025 06:00:23 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e595c6sm10642847f8f.66.2025.06.30.06.00.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:22 -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 v1 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs Date: Mon, 30 Jun 2025 14:59:44 +0200 Message-ID: <20250630130011.330477-4-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's drop these checks; these are conditions the core migration code must make sure will hold either way, no need to double check. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- mm/zpdesc.h | 5 ----- mm/zsmalloc.c | 5 ----- 2 files changed, 10 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index d3df316e5bb7b..5cb7e3de43952 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -168,11 +168,6 @@ static inline void __zpdesc_clear_zsmalloc(struct zpde= sc *zpdesc) __ClearPageZsmalloc(zpdesc_page(zpdesc)); } =20 -static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) -{ - return PageIsolated(zpdesc_page(zpdesc)); -} - static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) { return page_zone(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 999b513c7fdff..7f1431f2be98f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1719,8 +1719,6 @@ static bool zs_page_isolate(struct page *page, isolat= e_mode_t mode) * Page is locked so zspage couldn't be destroyed. For detail, look at * lock_zspage in free_zspage. */ - VM_BUG_ON_PAGE(PageIsolated(page), page); - return true; } =20 @@ -1739,8 +1737,6 @@ static int zs_page_migrate(struct page *newpage, stru= ct page *page, unsigned long old_obj, new_obj; unsigned int obj_idx; =20 - VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc)); - /* The page is locked, so this pointer must remain valid */ zspage =3D get_zspage(zpdesc); pool =3D zspage->pool; @@ -1811,7 +1807,6 @@ static int zs_page_migrate(struct page *newpage, stru= ct page *page, =20 static void zs_page_putback(struct page *page) { - VM_BUG_ON_PAGE(!PageIsolated(page), page); } =20 static const struct movable_operations zsmalloc_mops =3D { --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 83051285C90 for ; Mon, 30 Jun 2025 13:00:30 +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=1751288432; cv=none; b=Jbz/W8G4pBBq7QUTsghbP3Vg00eMZFRMpVejy0Byd5fpOxT/fbMsl7uLnyRtwQixc/hpQLoUuPFa+MoML7sJTxlYHwHXJqn8LLD1PsVwmEiZEUXBSfEGnjsfg7jXhbrRlvkNI+0xoufy8N4rrelnCOGZeB8rIyirZ1A3udgxQFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288432; c=relaxed/simple; bh=S3zLBPDhBdMrO+ksqFydENk2LB8FvPckKtc18Wgtb7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JbpqEfakrPh7byDQuRVpzr15SxDJkEaeqYpgbcQM/7leMe+xo51Ju2p0PSKRY7uDM9ZUr+0lrsRnDPISDPQCMiCHdvS6bpedeMH9NuekxpHWYfwXspmc40vWs1NUZRwPt0FzzxPSXYmInAE5OmKt1jyoDlAGIcc6rtmnpfdcQ0o= 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=d8uz3zHL; arc=none smtp.client-ip=170.10.129.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="d8uz3zHL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288429; 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=p0pHDGHZALCRdBpqrQ9hLtuju8zJ3QwGWTV045A4FRg=; b=d8uz3zHLLpgFvrb6RkYLTtB+YcBaO9A+wqCQpkBTiRRsz0xye3u5istyLRAt2F+oOJIocd 0fwGkVGxlDZZ3qFLWViVLjz+BYxo0EVEftv6yGE0MxyTIfvGeJ7RkyVH6JLLs2glaiQhwt qWgNdkjBx6wrnuROIGw3AkXAEzfmxT0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-AOm8AZETNe68vc1p0lgBqQ-1; Mon, 30 Jun 2025 09:00:27 -0400 X-MC-Unique: AOm8AZETNe68vc1p0lgBqQ-1 X-Mimecast-MFC-AGG-ID: AOm8AZETNe68vc1p0lgBqQ_1751288427 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f55ea44dso802228f8f.1 for ; Mon, 30 Jun 2025 06:00:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288426; x=1751893226; 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=p0pHDGHZALCRdBpqrQ9hLtuju8zJ3QwGWTV045A4FRg=; b=myW8dbrIbEiyqKwqIfFkX/R2diynn/wrmQ/wzTqEJ/GipUuj266v5Sg4kaG/FSOEMO xeFe7YP7QesXjRjC6eP6owpzb4hup/jW61LbePXZlIT0bVJgb5iu+B0iZuSk1fqd0+QN FNA1mmY5gz8skYSAJPfeh11OBzZ5ATjWnnV24JgT8RZ6TSaQusk1Mjv+Ct+/2yKvA1nb 6JsRd35aWI/61Kkw9y38OLPn6iWxqMIFZFQ0t9JNYHdh4BC+k/KSBVIFk2C7bZTZftXL KeofxCqReLe37Is4YlZSCZhjUJjGyyr7A9LPZQUG0wWa1eFWNsu3jzJuqLiTLP+9FLqY Fxlw== X-Gm-Message-State: AOJu0YxhfTExNqSUNXsENaDBpKS/Wdfl5BI70IEtmsL16lo5U+MPu030 6BS8Djhxub297cFVKrbY7g/dEtUKp3orIqKozJhTX3nKSvQEbw47vTUd/JgWskZ16i1ls3XbLKR lAMgu2rc6WqBwXcgxMOBUGdPZEnOx54V38PExzDbBJsQvF0yNNEMLPFCQxMsI5ljGdPdA+MZs42 1eC/uurTNO9RqzDYwls56WSuWKtMG05xL4u+QbX+VEs+xTb5+s X-Gm-Gg: ASbGncvrZO5UQdk4+zNACiBopoYDkYKzFdZcUJBbg11RUj8hNmSy6VBtY3E/KAoOg3G xuX0BX9VQclNdvDc5dD9VDx6eAXKjAJsqzfEP7aha1HnulxTE3nZQtfpcD3O6pOOG2Et3PkQcWv yeuuWlqZe/J3J1BV57iqmhxZFjG1lHVu4Uq3NowcvjEEIC7UqieZUOc7o8/DuwBJwYXtQRLA7CT qnVRnRD/0Yx1htBrZLToOXjYLdHO1IsuP6AHwfSZQ6YpBh8B8mgViZ+WqlS+U1O7R1sDsFF60tG LAxbvL/zCLB/JZ2atz9w6AvLVTeZkvXSIJMfNVEK0I92Q3jKlOt0L1aeh2hm2neEHSta8rhsZ+o rRoFYGt4= X-Received: by 2002:a5d:64e1:0:b0:3a6:d579:ec21 with SMTP id ffacd0b85a97d-3a8f577fd35mr10177790f8f.12.1751288426378; Mon, 30 Jun 2025 06:00:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwLhkxvJD2R8UoqRuajbGlVqpEQolWc/VBvsc1ZeiLSR5gPzKHixn/vDhyoe1JVlLg6TEErg== X-Received: by 2002:a5d:64e1:0:b0:3a6:d579:ec21 with SMTP id ffacd0b85a97d-3a8f577fd35mr10177695f8f.12.1751288425713; Mon, 30 Jun 2025 06:00:25 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a88c7e76e1sm10574554f8f.16.2025.06.30.06.00.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:25 -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 v1 04/29] mm/page_alloc: let page freeing clear any set page type Date: Mon, 30 Jun 2025 14:59:45 +0200 Message-ID: <20250630130011.330477-5-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Currently, any user of page types must clear that type before freeing a page back to the buddy, otherwise we'll run into mapcount related sanity checks (because the page type currently overlays the page mapcount). Let's allow for not clearing the page type by page type users by letting the buddy handle it instead. We'll focus on having a page type set on the first page of a larger allocation only. With this change, we can reliably identify typed folios even though they might be in the process of getting freed, which will come in handy in migration code (at least in the transition phase). In the future we might want to warn on some page types. Instead of having an "allow list", let's rather wait until we know about once that should go on such a "disallow list". Reviewed-by: Zi Yan Acked-by: Harry Yoo Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 858bc17653af9..44e56d31cfeb1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1380,6 +1380,9 @@ __always_inline bool free_pages_prepare(struct page *= page, mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); page->mapping =3D NULL; } + if (unlikely(page_has_type(page))) + page->page_type =3D UINT_MAX; + if (is_check_pages_enabled()) { if (free_page_is_bad(page)) bad++; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 A155A28B519 for ; Mon, 30 Jun 2025 13:00:32 +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=1751288434; cv=none; b=Zf0ENKFWyMz7ETFQYVrNbg16aw1YpsErJWuC49WQmo+9Nob2G6jl2MWAQOgSZi/yXsBnOkBRlPwSqcSW5PnJzO9dwIeZxDxC9VcO83FP5S6WVqhb54RpTwVbLDK4L9teL87GF9iwxYqy2VV8p2xCjDnP1n7sEX6vHBjObTKsIvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288434; c=relaxed/simple; bh=4MxWzYVQT6MaRWyD8DaQIwXKPr34x2kzXAmctRW17zM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QNiierCJYfWPIQqtjLtmGC+zxMeQx2kkmaO3SkE/CXHVSVwfVzLu/j2wTdSJBYSr7unH4mbAITqltB/oilBOLNB+yd0X/9dwljvZZam/H2laxcwZ63lHiBQG8hcE9TdCQmj/j+T45japxSrmApjbhUQXKBhoEblBmDb5je1DA6U= 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=YL1ueV3l; arc=none smtp.client-ip=170.10.129.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="YL1ueV3l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288431; 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=zonaY4DxD0y8MNMLsQ+Z7vSDV1xV1t770zE0DCe01j4=; b=YL1ueV3lc1htpNu3DOcnqiA6+6Ibra5y40drML+EwbXy9ogJ7g6rYd4JOdM7Qlk+HOyP3N R81paSK0QRl9RNgSUyRJIaVduSjfJyZ9QIDxSNsFRnkiokhar7ykWMy8OzUAl7CMFfa2TW CcInASjBhh/er0bGdMXw4EwgSoJi7qA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-eQjIIMptNEmZW2K1395HxQ-1; Mon, 30 Jun 2025 09:00:30 -0400 X-MC-Unique: eQjIIMptNEmZW2K1395HxQ-1 X-Mimecast-MFC-AGG-ID: eQjIIMptNEmZW2K1395HxQ_1751288429 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4530c186394so9153895e9.0 for ; Mon, 30 Jun 2025 06:00:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288429; x=1751893229; 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=zonaY4DxD0y8MNMLsQ+Z7vSDV1xV1t770zE0DCe01j4=; b=kW7hTFRYA0nIiqLMHTjHRN2WBq2tXts4cIahfwzpx7Rr/sG9Y2EWUkjHDKSds6E8fr tp11sN1s2ptsvfyxPe75tcrPJg1kq/ypC5E7JITX0MQWHm+8QvsQPdQYksjZ29jnBm7q pnhDpT/lcATw+fmRpCne51y56M4/jp8IXy6+UOMVzA/zmNAKtqFCSB9XyJ82hJOOyPVm yTWPJFiRzmmP1c6ZqjGQ1b5EmNN3LkaM/WW88MwxMFThIHEjuIU8ulfmgy0sFxJ5h/Zb PLZfq2BYB7vaw1PH6YYXFN+LUdqBC14i4V1jy+9wH2sXKd6dwXQw1Ou1odVV8T4LHqas b6ow== X-Gm-Message-State: AOJu0Yzr4Uraj4ZA177XXWNDeMAOcBT0dwxj0QucP6bPE1GmirODy2iH qailXEzzBck8fdwrPu7TN8yyGKxXMbFQOfwosl2CN+J/9RvA1If4RyI5UD0qqDLbcnnkzy47BSK 50dlBkbz35SmpT+2wWyXyROn4RI9cQFgxEeWWTuJgnpqu2nXJMgnxjMm1D4HyAAWjqtYdI6X+09 wBujw8aPMIlYaNNBuIqZD9k0t0OEL1GDi6ReQ+hsQps/0LNkW7 X-Gm-Gg: ASbGnctmEOT++FhD4wLmdNOu9k0lV3vqy+SLdYvXAntyYvDZF6VM4xRHCkUGZlWN+zi CwO7fHNketQdnERCyedhtimChWs5xGvu7/FsFsow4/tXgaCtJiVCTma99FlPFylbiXjjbLXw+wF F3R2Nvvnr/v4hD6CMOMeg1Pfksizbh62qVgtS/ssvjaK9Zy+9eGSmUXySBTU9ckcQJvLKVW/eKc adx2EI3z9UYAqg9tFNX1jHc/DP4+6YI1FakxUcbNn+XsgudPQyKljCr8DM8oY6DjYZ0RKjiPqIO H+fLqabXuVVzi9dsDENSeRnu2i93MrdZ7pFqNZt8jPSUlPMGkpz5JVMfqJ9ir2aRChkeJsOFhHl jKdNU9SI= X-Received: by 2002:a05:600c:3b8e:b0:43c:f513:9591 with SMTP id 5b1f17b1804b1-453913c5a63mr120767195e9.14.1751288428984; Mon, 30 Jun 2025 06:00:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQsOsTnGBejCVgyOLl0Qh2EVLJQ4G+kbMgNeqpJuJaGM9Kh9Xe41tPUK3+55dbuJ7ci0FJ3Q== X-Received: by 2002:a05:600c:3b8e:b0:43c:f513:9591 with SMTP id 5b1f17b1804b1-453913c5a63mr120766035e9.14.1751288428255; Mon, 30 Jun 2025 06:00:28 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823ad0fesm169262535e9.25.2025.06.30.06.00.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:27 -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 v1 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed Date: Mon, 30 Jun 2025 14:59:46 +0200 Message-ID: <20250630130011.330477-6-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let the page freeing code handle clearing the page type. Acked-by: Zi Yan Acked-by: Harry Yoo Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- include/linux/balloon_compaction.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index b9f19da37b089..bfc6e50bd004b 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -140,7 +140,7 @@ static inline void balloon_page_finalize(struct page *p= age) __ClearPageMovable(page); set_page_private(page, 0); } - __ClearPageOffline(page); + /* PageOffline is sticky until the page is freed to the buddy. */ } =20 /* --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 9E93B289E3D for ; Mon, 30 Jun 2025 13:00:35 +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=1751288437; cv=none; b=gJJGA9ui2eEzqxkMnoQG+09e522DSbYbKiGp1FgQkV9eqsqvZ7ECBjs3hwW2ZY10cHJN2FRC+hx0cc3s4zkyA67IUSHj4sNFC6Se2BmCeUht60NSd11cFAkd0ancrxovXcctRnz4cqO620O2bI5VL6pcyeGAVUQ6Anl+rbiTn2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288437; c=relaxed/simple; bh=19X4bQvLwR3+OfNQbpdo9I8RjESqqjGAQVBNJ6TpCho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tSDRxlvmT2IUUgMY4KlBX0azdKNHWEwWPcLjCtZPHqpnALGDZDQKel6gKWysSAY4VcSWFZ7Gr5Ow4poOruLO14M7M4G0+gNr2O1vLKdFBeIhlXWl1N2hXPkg7bCB1VO1lWpFfRJVhLA9VTTVMiORcqO0/Jsrt2fDpJfUmDy6Ei8= 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=ZZtiPm4C; arc=none smtp.client-ip=170.10.129.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="ZZtiPm4C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288434; 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=nJlezl1jqk1KHM/JmX+CbcKO2aiRBLF0rBMpUlNHwJA=; b=ZZtiPm4CRBEJXRO+ZdNFie79VtmD+a2dEM4gwhi+A4Egp8saFYdPIz5D0SJDMbY/GtxLOt dOYFAz8OjWo3etSx3Eao4doNb+1uu3RAQ9v3czBysn3PMhgH86vUbE9kkG2G8vU18/kaTH HC/wbAE8D9RPR6C30OWKvd2iYA3iNsc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-0n2B3X_fMV6VuXQ8N1jxUQ-1; Mon, 30 Jun 2025 09:00:33 -0400 X-MC-Unique: 0n2B3X_fMV6VuXQ8N1jxUQ-1 X-Mimecast-MFC-AGG-ID: 0n2B3X_fMV6VuXQ8N1jxUQ_1751288432 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a4f858bc5eso1529401f8f.0 for ; Mon, 30 Jun 2025 06:00:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288432; x=1751893232; 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=nJlezl1jqk1KHM/JmX+CbcKO2aiRBLF0rBMpUlNHwJA=; b=BA+F4Mc/g3QzuifWwywmk8Vuf3nR2VkCvQQad7pJ0nRIFiOz5pRM1OK8Z+fC1L+ZDV aIcwm1QOKsjcqY6VB09nPCzblx7Q161CicH2q1XZBNKF5rH1xpuXb7+AxNmKI1SD3uph Ja7oIVHoXNW+MRibpjHEXTF6iuHXI3IrqbJeiltgmU6ZC9JDXvy5iZ9N8lY1kiGLEQu8 UmJD912B/2fbNT5dL7lYTdr9GC9VdT6gTYELbuBUt5hoJHq9SUyrLjT3NKbgYwnlzgi9 0g0lXGApA1qysfGR3maDvF409DhEqG4oCy4x43r+LBNYVDUu6Y+o+30i7yVPBYzmpubP zMTA== X-Gm-Message-State: AOJu0YxkpU6ZZpbfJ7F2HqjO3+Ufly7L4zVk/wK5SDJt9BEyBZZYd2Yz p1kZnmLMmWRvgTosOcgNQ9F6GHtlJ3jhIwsFPULm3nODBN+D0C8jsiRKahWxHKgeoNK6BYqs/tM iow0OgEXR1R0yuuw1Jh9Wd2/jB2mMda6F/RzLA+XBFUKiFCPZRBHtEMOzjwyuBBroLZnHwEh8HT mV+o0zrMSdXKI21GdkIetn7tBBaYRxitOyzxb9n8UFG8GE480R X-Gm-Gg: ASbGncv6fINajQuz4EuujV4kA6MSKGfy2TZ+egLfWeG/N7yeZWdyEze814b902jya/Y GWpi1l8w76UZKspovYLU7v6v7yrV1rwxS1iCK5EnhXXD4ixHkiM79IUAsmqF+S4XdxtCIakzL+z BQoFahd0zzZKqeAoIomeLKgbvr5JBAYfbBkWZ0yKPJx3nsK7s4KFoLKgXlU21IkddqQ1gxtr1jP Iq/j01F4mXomxLfxMcRNcotsY9u16lu+KePk6UuDmZCJmpJPUPPQZORZL0jVeV/7b/OWxoQy3yw d/5rVgxkiDN+1WeL4dXAKvVD5+5jHjugJ6+QxgxerUBdFTCVR/lCrE+LPgpTwK3Att73EV3blqy N2aHkjNw= X-Received: by 2002:adf:e181:0:b0:3a4:f038:af76 with SMTP id ffacd0b85a97d-3a8feb844cemr10501301f8f.53.1751288431641; Mon, 30 Jun 2025 06:00:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGEarPHGaA16flG07pTm8Y+2ZoBRaEqSqyGzIU15EPr/yTHmV5lKxwKCSS//XnEer0oKPVNw== X-Received: by 2002:adf:e181:0:b0:3a4:f038:af76 with SMTP id ffacd0b85a97d-3a8feb844cemr10501216f8f.53.1751288430998; Mon, 30 Jun 2025 06:00:30 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a88c7fadf3sm10557609f8f.34.2025.06.30.06.00.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:30 -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 v1 06/29] mm/zsmalloc: make PageZsmalloc() sticky until the page is freed Date: Mon, 30 Jun 2025 14:59:47 +0200 Message-ID: <20250630130011.330477-7-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let the page freeing code handle clearing the page type. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- mm/zpdesc.h | 5 ----- mm/zsmalloc.c | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 5cb7e3de43952..5763f36039736 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -163,11 +163,6 @@ static inline void __zpdesc_set_zsmalloc(struct zpdesc= *zpdesc) __SetPageZsmalloc(zpdesc_page(zpdesc)); } =20 -static inline void __zpdesc_clear_zsmalloc(struct zpdesc *zpdesc) -{ - __ClearPageZsmalloc(zpdesc_page(zpdesc)); -} - static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) { return page_zone(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7f1431f2be98f..f98747aed4330 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -880,7 +880,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) ClearPagePrivate(page); zpdesc->zspage =3D NULL; zpdesc->next =3D NULL; - __ClearPageZsmalloc(page); + /* PageZsmalloc is sticky until the page is freed to the buddy. */ } =20 static int trylock_zspage(struct zspage *zspage) @@ -1055,7 +1055,6 @@ static struct zspage *alloc_zspage(struct zs_pool *po= ol, if (!zpdesc) { while (--i >=3D 0) { zpdesc_dec_zone_page_state(zpdescs[i]); - __zpdesc_clear_zsmalloc(zpdescs[i]); free_zpdesc(zpdescs[i]); } cache_free_zspage(pool, zspage); --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 6FB3328A73E for ; Mon, 30 Jun 2025 13:00:45 +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=1751288450; cv=none; b=B/Jq2h/b6aoj9M9ctlysuZI4YZNRRvFRpDmn1XE2r8IW3oA9m5AlhjknPTXmgINTsFsJ2boM7qi53e+iHMjfEKZLzW4AOgZxnDU88rMhM3+b3tl/zlJzL7jxzMZaKMKdzZv35X0H0XnAM9tAF4yM0ZSR9TQcF/HGuyZOX4S5kkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288450; c=relaxed/simple; bh=VUTFI3+8sn+Bo7jfgsxfJB7XgkCxxsX8WPCDC/hYNNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sRzu0pg2j3UvptfkEUgIfHk+zo2oxfEgLuJ5PfCSf3opwA2BtnNphrLh4V5z42V/tr+bburTM3BsFJWmO0PiFmr4DbXhSZHYVcx7shDkLrlcgA3s1NbXbf3ma5whUARj7VfpU4cokrjQB8p5GAN/lr+SbSyM07XFrrkX3GTHSUE= 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=jVOjgStH; arc=none smtp.client-ip=170.10.129.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="jVOjgStH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288444; 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=m9VQLTS9DDIxmZmB+neo2FcUhAnDYm//4qg3iAtoZVM=; b=jVOjgStHXjnr1MaRzzAwZtsh9S+pxk0w2cC9fg03WKL52+4Ia/MSTbx6jK1H1f1iZ91rQy XPoFfE+Al0PieIph4yDeAURl9ujDDR3hfPs81SUd3y2B3z0bczeUleyUUGamAtpe7JMZp9 uC6gDW6QHxIeoBO0QGW8702a+mc1F8o= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-BPuFg694NWCZ1g5ZwPZqLA-1; Mon, 30 Jun 2025 09:00:42 -0400 X-MC-Unique: BPuFg694NWCZ1g5ZwPZqLA-1 X-Mimecast-MFC-AGG-ID: BPuFg694NWCZ1g5ZwPZqLA_1751288439 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45320bfc18dso22225345e9.1 for ; Mon, 30 Jun 2025 06:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288439; x=1751893239; 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=m9VQLTS9DDIxmZmB+neo2FcUhAnDYm//4qg3iAtoZVM=; b=L1GGtKECnxweWej19/C6geUOUUSjbE6GeJFprUvrUNIGxW9cpw1j5nWWS0ctjzQOp2 3YHDzc4f4gN00ddYTtH9a+FoLprxHDOd3RtLNT3Ud9vUJ/AavDcidJBeCVzXUaGqApOC ttG+Y8DKSHgmIuoeVoKLHo86UXw8aTYT57avsuQHiKKpNXGNVgSLoS9tZA5Yp+QuO+MV fTMHtGy/GOgu8MLpEqhYwyi34egeuuGROUyK1GCw7woPxVpok3c28Zz9FK+2WbkTmmLD SSHRHseQWc7QMHj+wszPVJgnJ9TdK586Q+a6PXCsct/GXeE7hVE/d+unee9ImgJwMZFd Bw/A== X-Gm-Message-State: AOJu0Yzso9M8z71v5ocxHBeeyc4QPzYLw//nmZPrwS4cUqRj3MqJprTd 0PM1huSoE36ZrpyPCsSGscHSRTzQ3NjqzCOBgsoL//UkciJHH13XCIYwmv2XM0F5XD3SITsxP/D hEFseVSoZHxaH9bAHx4LFpw5kTm1J485bVBdq9kChPjMu+Mk7IqLhJMRWRM0q38YE6Osk0evXo1 uvj/uykg46arYyBx7q4C/lE1P27dCth0uJq8EUVChIpf570Qqp X-Gm-Gg: ASbGnct7zGn1VHyjsN8HN0VBBY07UZeyYOlgpgWgrQOZjX3uABhIBjpi6+/l+tbbn+u rD/r0OH4us4UIz2hFaTx99cc1Y1ZMGq4E67oRYSrpMs8bPSwnBcLFoa/gelo4VGu+6DiOrsCRHN uHnYt0nnZHHXvErH5iZQ89vpJmfYDUJgw1dP6y6az3HvTpSuuoCJ1mH5gpu1PLTNgvCSxL36wMu SUyfk4Ph5DstTcz+nTDkyWeRyhRYHebjWVGUDcFpMUc0Xr3QiUxx4nwBwCRadgUbJAkenWTC0fZ AMNmqicsxRqXVEIdivmTm+LbfFrLT3Y5uVQm9nxyBLStSve5GUqR1IFzBlrNvtRqkyVzp9vF/lX 98ZV5i/4= X-Received: by 2002:a05:600c:5251:b0:453:6c45:ce14 with SMTP id 5b1f17b1804b1-4538f2c6a5bmr116867965e9.4.1751288436224; Mon, 30 Jun 2025 06:00:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcKPudq4hAX3ZUQbBxj7a9OFNaExkIT0GfF2UdhGugpVpmsHfKtz6PBCtjyRSKpLMaHzgIYg== X-Received: by 2002:a05:600c:5251:b0:453:6c45:ce14 with SMTP id 5b1f17b1804b1-4538f2c6a5bmr116864905e9.4.1751288433794; Mon, 30 Jun 2025 06:00:33 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4538a406489sm136741305e9.27.2025.06.30.06.00.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:33 -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 v1 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page() Date: Mon, 30 Jun 2025 14:59:48 +0200 Message-ID: <20250630130011.330477-8-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" ... and start moving back to per-page things that will absolutely not be folio things in the future. Add documentation and a comment that the remaining folio stuff (lock, refcount) will have to be reworked as well. While at it, convert the VM_BUG_ON() into a WARN_ON_ONCE() and handle it gracefully (relevant with further changes), and convert a WARN_ON_ONCE() into a VM_WARN_ON_ONCE_PAGE(). Note that we will leave anything that needs a rework (lock, refcount, ->lru) to be using folios for now: that perfectly highlights the problematic bits. Reviewed-by: Zi Yan Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- include/linux/migrate.h | 4 ++-- mm/compaction.c | 2 +- mm/migrate.c | 39 +++++++++++++++++++++++++++++---------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index aaa2114498d6d..c0ec7422837bd 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -69,7 +69,7 @@ int migrate_pages(struct list_head *l, new_folio_t new, f= ree_folio_t free, unsigned long private, enum migrate_mode mode, int reason, unsigned int *ret_succeeded); struct folio *alloc_migration_target(struct folio *src, unsigned long priv= ate); -bool isolate_movable_page(struct page *page, isolate_mode_t mode); +bool isolate_movable_ops_page(struct page *page, isolate_mode_t mode); bool isolate_folio_to_list(struct folio *folio, struct list_head *list); =20 int migrate_huge_page_move_mapping(struct address_space *mapping, @@ -90,7 +90,7 @@ static inline int migrate_pages(struct list_head *l, new_= folio_t new, static inline struct folio *alloc_migration_target(struct folio *src, unsigned long private) { return NULL; } -static inline bool isolate_movable_page(struct page *page, isolate_mode_t = mode) +static inline bool isolate_movable_ops_page(struct page *page, isolate_mod= e_t mode) { return false; } static inline bool isolate_folio_to_list(struct folio *folio, struct list_= head *list) { return false; } diff --git a/mm/compaction.c b/mm/compaction.c index 3925cb61dbb8f..17455c5a4be05 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1093,7 +1093,7 @@ isolate_migratepages_block(struct compact_control *cc= , unsigned long low_pfn, locked =3D NULL; } =20 - if (isolate_movable_page(page, mode)) { + if (isolate_movable_ops_page(page, mode)) { folio =3D page_folio(page); goto isolate_success; } diff --git a/mm/migrate.c b/mm/migrate.c index 767f503f08758..d4b4a7eefb6bd 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -51,8 +51,26 @@ #include "internal.h" #include "swap.h" =20 -bool isolate_movable_page(struct page *page, isolate_mode_t mode) +/** + * isolate_movable_ops_page - isolate a movable_ops page for migration + * @page: The page. + * @mode: The isolation mode. + * + * Try to isolate a movable_ops page for migration. Will fail if the page = is + * not a movable_ops page, if the page is already isolated for migration + * or if the page was just was released by its owner. + * + * Once isolated, the page cannot get freed until it is either putback + * or migrated. + * + * Returns true if isolation succeeded, otherwise false. + */ +bool isolate_movable_ops_page(struct page *page, isolate_mode_t mode) { + /* + * TODO: these pages will not be folios in the future. All + * folio dependencies will have to be removed. + */ struct folio *folio =3D folio_get_nontail_page(page); const struct movable_operations *mops; =20 @@ -73,7 +91,7 @@ bool isolate_movable_page(struct page *page, isolate_mode= _t mode) * we use non-atomic bitops on newly allocated page flags so * unconditionally grabbing the lock ruins page's owner side. */ - if (unlikely(!__folio_test_movable(folio))) + if (unlikely(!__PageMovable(page))) goto out_putfolio; =20 /* @@ -90,18 +108,19 @@ bool isolate_movable_page(struct page *page, isolate_m= ode_t mode) if (unlikely(!folio_trylock(folio))) goto out_putfolio; =20 - if (!folio_test_movable(folio) || folio_test_isolated(folio)) + if (!PageMovable(page) || PageIsolated(page)) goto out_no_isolated; =20 - mops =3D folio_movable_ops(folio); - VM_BUG_ON_FOLIO(!mops, folio); + mops =3D page_movable_ops(page); + if (WARN_ON_ONCE(!mops)) + goto out_no_isolated; =20 - if (!mops->isolate_page(&folio->page, mode)) + if (!mops->isolate_page(page, mode)) goto out_no_isolated; =20 /* Driver shouldn't use the isolated flag */ - WARN_ON_ONCE(folio_test_isolated(folio)); - folio_set_isolated(folio); + VM_WARN_ON_ONCE_PAGE(PageIsolated(page), page); + SetPageIsolated(page); folio_unlock(folio); =20 return true; @@ -175,8 +194,8 @@ bool isolate_folio_to_list(struct folio *folio, struct = list_head *list) if (lru) isolated =3D folio_isolate_lru(folio); else - isolated =3D isolate_movable_page(&folio->page, - ISOLATE_UNEVICTABLE); + isolated =3D isolate_movable_ops_page(&folio->page, + ISOLATE_UNEVICTABLE); =20 if (!isolated) return false; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 8227828C2BD for ; Mon, 30 Jun 2025 13:00:50 +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=1751288455; cv=none; b=COMajjgGmaIGOB/DvjrGqCf57N+z4EQVeHZWfIP+kLpEz8xvDzuLPcsMXAO8z81SHR0NBASoL9Czl6NtJxvZtK9zqJkhFxD0t2uaMgQV7bPtB3CXaiXyWT10/X7KM7znx0q9UsOkAuosW5vcgYKajC4MMHr8o+bletoS3taUCJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288455; c=relaxed/simple; bh=QFR4ekfQkxloQewE0nsmyAbq1SFLKM7czL9sZhql/lw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eH9X6Ob6XPTCLmJuRJhEw4HXJvj/RLGHn9UPZah2HdHynpPyDDeXhxBeGVU2UseuqPQPTIow3BuPcup5avj+Lc5ClVW0fpd9jeU4zHq+SpfX7ipLQvdX5LvVPZfhmJlQYS4m44k3LZ69/sGJrf5XQI2AXecONLmtfaPqqds2QfI= 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=fPWft+kJ; 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="fPWft+kJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288449; 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=G4HyaliWLgvplqkgqKCCNJ5/P2ZKVlm1Wsjs2FxXnxE=; b=fPWft+kJ+ufKPz0uc9TR3XvTnixHZ3WiMXWto4GfXi8oM1CKOVTuTRiZ37Xonxr9zawEgJ ui0NGmMkAOQeVA7KJerbKF9pGQ14VgF+7HpfLcnKXCr35jseZrpUXk/qDUzXGGaGfHcflq 52VJdj4Q5k8JlkSH3p4buvZn3cy1eQY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-NAtwNT3eOdyaW5k_lYnfjg-1; Mon, 30 Jun 2025 09:00:43 -0400 X-MC-Unique: NAtwNT3eOdyaW5k_lYnfjg-1 X-Mimecast-MFC-AGG-ID: NAtwNT3eOdyaW5k_lYnfjg_1751288439 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a6da94a532so1367775f8f.2 for ; Mon, 30 Jun 2025 06:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288439; x=1751893239; 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=G4HyaliWLgvplqkgqKCCNJ5/P2ZKVlm1Wsjs2FxXnxE=; b=drj7nW2MmF82ysrLiniXvf2FwpAiUtcvjk/VHykHjgpSmSIfDNuI4knojoZSeJ+fUx cNY5VA2ry7fjmMFJu6C3HcUwdzlFnaxbhj+420MQwa5P9Fz63tAAL5eBRObSNSmauml8 sizk8tlawKv1GRV5eOlf1ZHaBLQ8pgYujnXLmTykVpAVk/ic28GNkej+/Yu4o22id4kp xqC0SmXMisSaWSKkQV0V6apSmUY4RnZFBmBSaGgikvkDAS+i/C2CWU+FH9e4tRdJ/7Yk tfxem6T4Pyk7Lztc5YYe960s9mdW8RUlQWevYdLBd/z7xjk9+Uh0e9oQL9BMCk0gcw6K XoHw== X-Gm-Message-State: AOJu0YxuHcLd48sUF5Q+MSQW1Nuv/EWMuF03syI5vVJ3XFs8QUZKrsfd /SqBBxtoQk3esvwMYVLzFEycHkH3j2MVOLYVBISL3UDxI9M75OOZITXgsF/VQaVeMnALzlQ1CPo dNxo8EuFozcbLy45UxSMnL3KVgGYZ8gx+88Gk0tNRVYKVUt0wxKbXH4w37LPr4xflSx/+46VkBo GPVoAL9ENUR9AVXW3qwUhQ/4lJCUCOOGv+IBaDLijAZPpxsTfG X-Gm-Gg: ASbGncv/BGASjxB31hQWVs32qg1I9CGE3ZPEnSxotQlsgXY8e3pZNSRiWVWapqhLcRc E4G7WQ1NBMvcSZ3DE7H0vFWyBtUU2lWBHLMUG/N2+1eS8oydLBivKGmWVNBAcCO9NI+eZ6hpx+T GJJQnXPggSo3+y8Ygo+uruT23VTLs7BPQtpS60xKe5iKwEvYFX6zwk2iHSDmpNyRAA8PO8eWeV1 /X95JmwqNQzL1Mz1ccIJ4q8gsRm8L69txJvzOzchB3AbPJDoaNhfy91CG+v86KGGQr0COaxZiRT XGK3vtUAkEl/5TxcFd+7vj/I4SPzqeyBmDwd3lgEMjOFE8X3CA2rKWJsWPP6XgHdueMrz4ZPss0 /SUJUqG4= X-Received: by 2002:adf:b649:0:b0:3a4:cf40:ff37 with SMTP id ffacd0b85a97d-3a8f45494cdmr9830802f8f.6.1751288437474; Mon, 30 Jun 2025 06:00:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEehlYPXkAQhWmsU6NKWbFkXt51tuHaEnt5gEo+HlKa0FWalrdKbSodH+fk72qwn9YuXcO6g== X-Received: by 2002:adf:b649:0:b0:3a4:cf40:ff37 with SMTP id ffacd0b85a97d-3a8f45494cdmr9830683f8f.6.1751288436787; Mon, 30 Jun 2025 06:00:36 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e5b2a7sm10408982f8f.69.2025.06.30.06.00.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:36 -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 v1 08/29] mm/migrate: rename putback_movable_folio() to putback_movable_ops_page() Date: Mon, 30 Jun 2025 14:59:49 +0200 Message-ID: <20250630130011.330477-9-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" ... and factor the complete handling of movable_ops pages out. Convert it similar to isolate_movable_ops_page(). While at it, convert the VM_BUG_ON_FOLIO() into a VM_WARN_ON_PAGE(). Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Reviewed-by: Zi Yan --- mm/migrate.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index d4b4a7eefb6bd..d97f7cd137e63 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -133,12 +133,30 @@ bool isolate_movable_ops_page(struct page *page, isol= ate_mode_t mode) return false; } =20 -static void putback_movable_folio(struct folio *folio) +/** + * putback_movable_ops_page - putback an isolated movable_ops page + * @page: The isolated page. + * + * Putback an isolated movable_ops page. + * + * After the page was putback, it might get freed instantly. + */ +static void putback_movable_ops_page(struct page *page) { - const struct movable_operations *mops =3D folio_movable_ops(folio); - - mops->putback_page(&folio->page); - folio_clear_isolated(folio); + /* + * TODO: these pages will not be folios in the future. All + * folio dependencies will have to be removed. + */ + struct folio *folio =3D page_folio(page); + + VM_WARN_ON_ONCE_PAGE(!PageIsolated(page), page); + folio_lock(folio); + /* If the page was released by it's owner, there is nothing to do. */ + if (PageMovable(page)) + page_movable_ops(page)->putback_page(page); + ClearPageIsolated(page); + folio_unlock(folio); + folio_put(folio); } =20 /* @@ -166,14 +184,7 @@ void putback_movable_pages(struct list_head *l) * have PAGE_MAPPING_MOVABLE. */ if (unlikely(__folio_test_movable(folio))) { - VM_BUG_ON_FOLIO(!folio_test_isolated(folio), folio); - folio_lock(folio); - if (folio_test_movable(folio)) - putback_movable_folio(folio); - else - folio_clear_isolated(folio); - folio_unlock(folio); - folio_put(folio); + putback_movable_ops_page(&folio->page); } else { node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio), -folio_nr_pages(folio)); --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 2D20919CCFC for ; Mon, 30 Jun 2025 13:00:47 +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=1751288452; cv=none; b=pnVlDPVbjPLmWd/kU35ayUiVZMxIkFfhktn2qjhMPoA5hgFk9ZjsRJEROjx6CfwfafQ5V3AOv17MeC3/Jm7uOtE3F+YRRcbAJoEUcBHBzWVIHUkdwLNDKxN7Y6e62PtiLvrqpFkA71VxrMrBUKHeKVnSBAEEYalcgI/cEBSPWWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288452; c=relaxed/simple; bh=eiWjuQAK343S0iGCo5U1CeA1xAD7ABzULSg4BICmapk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jh/i+VgRNJn7cF5mAOzrJSGq2njtpVRGi8nsJ8tAeOnl0/QkfgMhf0YEWhv7rdf7CcifdBTEj61xLQIYdce3GhzFYhqQ67cGB9uDG/Hf1Z2VUgCatTp0FL1THKnOV93Dq1DIctQGludn0NRALoEov0cecEMP3BiDIPzorQ7MiDo= 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=STO7u0ip; arc=none smtp.client-ip=170.10.129.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="STO7u0ip" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288447; 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=ZjlP0D3eY9tZf8Nb4qLq/i9Tdq3zqU6lo6GiM8rDh3E=; b=STO7u0ip5IVwggMYRutFBva7vjUZlVpf8g54xD9inUEG8YAzCOVP2emxWRcRhSCc/LyADY mmCPme0ZySC2wyfq4qWD9bzW0UUS8exKsvmn/v1T01LwQU9CZXqfEJbSXM0VFQGd/xqfaH CLgbIudg4rsclmN62ZtNjj1vF//Cglw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-MRD4eXtFMimEYyyLls0jQg-1; Mon, 30 Jun 2025 09:00:42 -0400 X-MC-Unique: MRD4eXtFMimEYyyLls0jQg-1 X-Mimecast-MFC-AGG-ID: MRD4eXtFMimEYyyLls0jQg_1751288441 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a56b3dee17so2651998f8f.0 for ; Mon, 30 Jun 2025 06:00:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288441; x=1751893241; 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=ZjlP0D3eY9tZf8Nb4qLq/i9Tdq3zqU6lo6GiM8rDh3E=; b=VcIH6N5WLzeHyQBhlJkqiXqeZDMECJTVbXMgmlVpD7u5fN1it3CQLeeatA3X1E19Tw fJBYUpYYYHorEdvpZ5WbNIjR7dPJOOhgIDpB3eQ6SsM8+Hfzt1uZ2CedDrMJRBV5Z3Eh l0/niFE4HzYlb1ux7VS4eN69Pi5a8/DkMymXOOgIU3JTtrBx7mnRVQQ7uP5sRuWh/5Tc P9Ib6zRwHHzX5JSNqXbxHRb/osNNrJaJMgwaXYFPj9rp05bVtHZFiwTcNdZEM4T74cLa 1ba7qYrefGuxtc8VquQafSPEaklCBME7aTwETDEqmmeU3fMuMgQzyByHz0MxTQDD7nzl pWdQ== X-Gm-Message-State: AOJu0Yzazae3EO0SXAJsM/faM0nd/2RiJBnd5SvtdHbZlXfLlllFggLD HCG0ta4nkYCkNNsOWiWxoQycEu2soW6NK8C5S4HLL3J/qQYc1fTBbL3KfcgKgQQu+echPNhuJvP 0Z0Qg7mVQzg6p88LWur5hHVrQls5di6hmXzFe7xA0V98YYA0C6rEMO5b580g/f/pKMsgolHUT/c HFook1dmVDwqGbK4UXW3ZzSHtJfPTAHp+bDkmtLL8bR7KFYl/Y X-Gm-Gg: ASbGncvi+awUpNmoX4MzplaCmH77mX2VvcOXJ2a/P+QojhkffmQ49cNCeEAs8B/cOEz dAFuZAPa3bMjc+xjGGOOWMBkxnVN4dCDMCDZyoJPpHboxn59DGb1vkbtNZYit9/Yt4UevwGsppp tRJ06NSaETFdpLp2WFh2t7PbBCImAgqKIlW90e2Kl5eoN0QYyMAArEW5OrfLHb1Ah8Nizw1ZxXD 46dNmfeX+b8FenDy0tjTXqGxjwVwX/3dC9v4WhjXi/VhImUrkJvkyBF55Km2ZXjy+pTmFhwUBh9 n2WfRcpv/R7cdko3dqbKP/BWAbTQNgxFT9lCp8pz5xvDLF+bIVz8WqCMzo9+mAYpJls3fKksGiw gMuAp1Qc= X-Received: by 2002:a05:6000:200e:b0:3a6:daff:9e5 with SMTP id ffacd0b85a97d-3a6f31023bdmr13743630f8f.7.1751288440773; Mon, 30 Jun 2025 06:00:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaNYb3ONKvqKvr320nfpncqFiQLJi8PiPIyho0Wzz9N7dVDIemJ3QiyBdfpFdZCgx38anKxQ== X-Received: by 2002:a05:6000:200e:b0:3a6:daff:9e5 with SMTP id ffacd0b85a97d-3a6f31023bdmr13743499f8f.7.1751288439567; Mon, 30 Jun 2025 06:00:39 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e52ca4sm10445235f8f.58.2025.06.30.06.00.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:39 -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 v1 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page() Date: Mon, 30 Jun 2025 14:59:50 +0200 Message-ID: <20250630130011.330477-10-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's factor it out, simplifying the calling code. The assumption is that flush_dcache_page() is not required for movable_ops pages: as documented for flush_dcache_folio(), it really only applies when the kernel wrote to pagecache pages / pages in highmem. movable_ops callbacks should be handling flushing caches if ever required. Note that we can now change folio_mapping_flags() to folio_test_anon() to make it clearer, because movable_ops pages will never take that path. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- mm/migrate.c | 82 ++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index d97f7cd137e63..0898ddd2f661f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -159,6 +159,45 @@ static void putback_movable_ops_page(struct page *page) folio_put(folio); } =20 +/** + * migrate_movable_ops_page - migrate an isolated movable_ops page + * @page: The isolated page. + * + * Migrate an isolated movable_ops page. + * + * If the src page was already released by its owner, the src page is + * un-isolated (putback) and migration succeeds; the migration core will b= e the + * owner of both pages. + * + * If the src page was not released by its owner and the migration was + * successful, the owner of the src page and the dst page are swapped and + * the src page is un-isolated. + * + * If migration fails, the ownership stays unmodified and the src page + * remains isolated: migration may be retried later or the page can be put= back. + * + * TODO: migration core will treat both pages as folios and lock them befo= re + * this call to unlock them after this call. Further, the folio refcounts = on + * src and dst are also released by migration core. These pages will not be + * folios in the future, so that must be reworked. + * + * Returns MIGRATEPAGE_SUCCESS on success, otherwise a negative error + * code. + */ +static int migrate_movable_ops_page(struct page *dst, struct page *src, + enum migrate_mode mode) +{ + int rc =3D MIGRATEPAGE_SUCCESS; + + VM_WARN_ON_ONCE_PAGE(!PageIsolated(src), src); + /* If the page was released by it's owner, there is nothing to do. */ + if (PageMovable(src)) + rc =3D page_movable_ops(src)->migrate_page(dst, src, mode); + if (rc =3D=3D MIGRATEPAGE_SUCCESS) + ClearPageIsolated(src); + return rc; +} + /* * Put previously isolated pages back onto the appropriate lists * from where they were once taken off for compaction/migration. @@ -1023,51 +1062,20 @@ static int move_to_new_folio(struct folio *dst, str= uct folio *src, mode); else rc =3D fallback_migrate_folio(mapping, dst, src, mode); - } else { - const struct movable_operations *mops; =20 - /* - * In case of non-lru page, it could be released after - * isolation step. In that case, we shouldn't try migration. - */ - VM_BUG_ON_FOLIO(!folio_test_isolated(src), src); - if (!folio_test_movable(src)) { - rc =3D MIGRATEPAGE_SUCCESS; - folio_clear_isolated(src); + if (rc !=3D MIGRATEPAGE_SUCCESS) goto out; - } - - mops =3D folio_movable_ops(src); - rc =3D mops->migrate_page(&dst->page, &src->page, mode); - WARN_ON_ONCE(rc =3D=3D MIGRATEPAGE_SUCCESS && - !folio_test_isolated(src)); - } - - /* - * When successful, old pagecache src->mapping must be cleared before - * src is freed; but stats require that PageAnon be left as PageAnon. - */ - if (rc =3D=3D MIGRATEPAGE_SUCCESS) { - if (__folio_test_movable(src)) { - VM_BUG_ON_FOLIO(!folio_test_isolated(src), src); - - /* - * We clear PG_movable under page_lock so any compactor - * cannot try to migrate this page. - */ - folio_clear_isolated(src); - } - /* - * Anonymous and movable src->mapping will be cleared by - * free_pages_prepare so don't reset it here for keeping - * the type to work PageAnon, for example. + * For pagecache folios, src->mapping must be cleared before src + * is freed. Anonymous folios must stay anonymous until freed. */ - if (!folio_mapping_flags(src)) + if (!folio_test_anon(src)) src->mapping =3D NULL; =20 if (likely(!folio_is_zone_device(dst))) flush_dcache_folio(dst); + } else { + rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); } out: return rc; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 7E62D28C03D for ; Mon, 30 Jun 2025 13:00:47 +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=1751288452; cv=none; b=X5kNeh0l6+rwEpzAxUcSulTU6ZtQMLzTPq7IDyy8AeTJJiwV5q0yqlBTMdIKo4+ekXCLAGkow/9QcDXky06m4NiHP9l1dWBSH/gfBhT3pJL2tjaZcU2iYHR9u+7yYlTmL0o3QgqnERieRJ/nO3r4cLvySaevYjXDfKgtx2NfNdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288452; c=relaxed/simple; bh=rcWuXS8i+J1+1NqCBG24FdrnWnU9/Zr9SBDXhHAAeFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JNgMOWlSHbxa6OKy/83MUI8HzNr75T9hf0cbjZJEHP/uNd8fRoDrdCeiU08zrQBRVtSf+TJBKt5cSDHqBNG5KAFT2ukEoMIgsrGCTn0SoF04jT1UiblKBZT9gIvJRpM6vtnCDAaCx3292kP2irux8y4guh47PQcF+IVt6C91m5c= 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=CdtbMg32; arc=none smtp.client-ip=170.10.129.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="CdtbMg32" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288446; 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=AOWsWuhFUlcALOXMJY1BPVzymTvYGz+UAPJ/r3JMpJ4=; b=CdtbMg32CABVZMySIuJYkWlfYQXxIj2iPixDmNN7eYvswEt6pfQgaGUaQEmLEBF4v9ILmR icFcEZx6zbC/sxQpoVyVX/Y9kL5rWpGA30EAUeIsZkkqS0HPYHLz+qbdXRCi3WrAYpEf5z WyOOt+alOTOlxYY8EQS9jOT+nDoYepE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-6CrPMQG4N0GDB36cNYyhnw-1; Mon, 30 Jun 2025 09:00:44 -0400 X-MC-Unique: 6CrPMQG4N0GDB36cNYyhnw-1 X-Mimecast-MFC-AGG-ID: 6CrPMQG4N0GDB36cNYyhnw_1751288444 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450eaae2934so15171705e9.2 for ; Mon, 30 Jun 2025 06:00:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288443; x=1751893243; 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=AOWsWuhFUlcALOXMJY1BPVzymTvYGz+UAPJ/r3JMpJ4=; b=pTS75n/1lrsYBrjobfHGCjy+ebtG8pnYE4I3+72FmZOD/tNiKOWI5Um+YaUog92RSK /TLqID6a5e+WtVZHIC1PN1ItTC2BgPJkxvhLX/uKgSjTxYlmt2zfwSyy71oEAyZXTV5i KpXK1WzZ4FTBT9rX/6YSRGU9pmESUFyfm62sILi28qTKs49iBOYZcgaYCNaoC4hHpTP8 Iv3aPwnIzpIO3dn5Ac4Im2ViMI+vKR8g+o0LZ1lIVQxMgFSAfkN95QaNlbADhvQ7Ah1n l3ydXaXmljTQVpm256KSfgetqz9z8PcMJBWEafofkRpjR6P9krbcybFa4+wK29Tj9dNc K6Rw== X-Gm-Message-State: AOJu0Yz40Na4L06otgR43tUyu968WCBe+LhaAYwGEHNGfRUy6iKMFF6b aFyljkYe0r77k7cXMcv4B5+Mwsvjia+4IoWa7hxtwsduLkAVeLmn29a/ScRds/m3RyeFhCgUK6q gJuHPzKuTZMdRyp2ur+MlogeEMbC9cDANvxv91aRWz4kBDsomPlN2iRwhFkhDh334rJjpQB0buo 37HWvExQekjPDjwPKGUwUZ2OuHs3SEXoaqVbyDRDtzqTywNWHs X-Gm-Gg: ASbGncsrkgfHace1zDONUYYsH2bRl40FGytzmxmDpqb1+LWs0c9q+VpUNqpRvSWNmdd Tr2wW2v/60gUHPRYynWdePEPNImtXXv8+xrftUgmVjB7w6dus6j0oDZoL83sssn/KQs7N5Xr1FZ OoWAG0SidC6hFkiPLqToEdRQDMYd2+b1jCaOx1NgnRidr2jpVJbT88/GPzUwCdBtCHcp5l4hCDg XbyTrOquAc2stl9pO7At3PU9SukcZquVqSHiu6xi0KL3ukNo8FviEvI0SnN9eiCn67ItL9fn7mT iQEC3xIVaXxLe15WsYavvJaZTJqn0MY4xuagt7drt5Y8idTO9YKxBLxAe3IzAJNrcsGzItH4XKC YAxjrSO4= X-Received: by 2002:a05:6000:2b03:b0:3a4:e6c6:b8bf with SMTP id ffacd0b85a97d-3a8ffeb382fmr7766148f8f.52.1751288443330; Mon, 30 Jun 2025 06:00:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx8UWJltFtDizxyihu6cXjhn3Ci52lQuk8tR1EGhsL0o4Tf/9IaaIN7lF9qzEV9dDz+LNV9w== X-Received: by 2002:a05:6000:2b03:b0:3a4:e6c6:b8bf with SMTP id ffacd0b85a97d-3a8ffeb382fmr7766023f8f.52.1751288442367; Mon, 30 Jun 2025 06:00:42 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4538a406489sm136745865e9.27.2025.06.30.06.00.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:41 -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 v1 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops() Date: Mon, 30 Jun 2025 14:59:51 +0200 Message-ID: <20250630130011.330477-11-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Folios will have nothing to do with movable_ops page migration. These functions are now unused, so let's remove them. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/migrate.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c0ec7422837bd..c99a00d4ca27d 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -118,20 +118,6 @@ static inline void __ClearPageMovable(struct page *pag= e) } #endif =20 -static inline bool folio_test_movable(struct folio *folio) -{ - return PageMovable(&folio->page); -} - -static inline -const struct movable_operations *folio_movable_ops(struct folio *folio) -{ - VM_BUG_ON(!__folio_test_movable(folio)); - - return (const struct movable_operations *) - ((unsigned long)folio->mapping - PAGE_MAPPING_MOVABLE); -} - static inline const struct movable_operations *page_movable_ops(struct page *page) { --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 86A07289E26 for ; Mon, 30 Jun 2025 13:00:52 +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=1751288457; cv=none; b=ITLUd59JG9oFKDEkV2OUtpKYplcxNPCe4d+uIyI6k2wVPZ5N26m2tdV4EHqK1iJ0+4oSyCihzrSH9gu/dFaL4GmHTySjgbDhMNpljOnZKDkIemjrqm44NqV1qJ994/jgAlzakUXe8HsxDeguvoEsmeiIMXKUB2G5pva9v+nbbKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288457; c=relaxed/simple; bh=bzT3f8SbOSFmP0mAT3t54D4YW+inx1tEVm83+OWEEC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZLFxtyxozNhqDTRQzSVpwsi28LZE/jZeAKALa+Wl12uewkO8ggVdEnzs4NCw7+6zRH8kG+mv9zpKOz8Eeto2VNNiRwM9GD5UhuPXe47qNsluEJPowaOYzpcb4FplOShU9qgWvULMOkvraODjinKiu9TQvrCIJsedJF9jcYxMuh4= 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=Ob88BWm7; 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="Ob88BWm7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288451; 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=rLSy27pHIWSaumHdHZbZB7d4Xse7WARvWeqJ4bM0kJg=; b=Ob88BWm76Gva0y+lg0gbSIeWphub1mTjXR7Mf3+arn9z+5U70GM0jLOvtWvGUfFKPZP5jD r976ZM9AZERElhmhFVHiWlJacfF0tO1DmMoDugMdvu8AfX6MzbG/Bl2ilAm9x7tbzah/7T sytN4qa3qfPucYxYjkIA2xzO9AcvgBU= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-_1nDWI0CPdi6myJveK2yLg-1; Mon, 30 Jun 2025 09:00:48 -0400 X-MC-Unique: _1nDWI0CPdi6myJveK2yLg-1 X-Mimecast-MFC-AGG-ID: _1nDWI0CPdi6myJveK2yLg_1751288447 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4f7f1b932so1198067f8f.2 for ; Mon, 30 Jun 2025 06:00:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288447; x=1751893247; 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=rLSy27pHIWSaumHdHZbZB7d4Xse7WARvWeqJ4bM0kJg=; b=I8mLvAtnFlsxpf5SExO5w/DP7qYqmVV3nCf5NFD8M8PMUDVIithFnEdEq1/G3fWg9c 87bR422cnCcq0mn8xY4y55POvEM6ibY2SuQwe52gSFD17VGDuY8wtut8OPsdaXl1DQfP SCMB/t9xhJlhbLA2YEwJsaT0EsRvbrA20sEKGuWUPrJCbfS7y0MZhPmsvD/9oeN3jHFE yeiaC9vqg5LHbpSQ2zQT0EdZbuK6XaHB5YMId9AtaLWhOwkib8mt8hwolyyW/C5QaJWH m21WewUB/80ui04HhZ9NfjTqhCpySvZVDh7wb+cD/7X2isd6g1FSTM+IeqQfcfMdHB9p Y2+g== X-Gm-Message-State: AOJu0YwLa4OvfZ85kJh4nChK9ZZxCAa+N2WbO2GBbQT8h77FdlDrZfis HZ6e2KLc6ZzY6FFO6t2nWmLoNc4tvdIvpket0MSkT7Wsaqe4LteQ1MpCG08UbrCYOXLPtxMXXkL 5QFOs2nl6120NHU1nojA/pQOH3r8BSYiGfVXG1lSDK9or5N9Tehyeky8rSZadKe0M4bmrcGpmIv ppB9MLimHZZstBTmoF/DIedRAiwPDj7RX5+AEF5Lm/lS6rPLgG X-Gm-Gg: ASbGncvj/RB/yCoy/a/ECjAGC2PL5yn4QVXRA4spVRgNBnXLLFMIBBQZv6U+Skp2JL2 xrsyP6CKR5094K1mRLJdxZ2U0nNTb7ggC/qiZnq/L243zozCgqL4DOUH6GAtYJyFaX9c5b11Rv1 vvCVZm2p/v4UvMnqoJXC2bmxaIdF4DGJJUJ4vL6AvJIkBPBCUY30/drrx+XGE3zqpL6yl+MY/5v qgICamDdXtOOHkbHLkwvuzbUSBOo8js6qNlzD0IsHOAazOi6q/rOhFdeKjQMtvFuIihB8PXBETR j/BKBl1XbtGUe0KByuc6q+Hb2WWDLLMqbnIaQKFWN1XfkqMnt47vGXNaC3kN/lGM4UraDAdVI0K cScm7Z30= X-Received: by 2002:a05:6000:440b:b0:3a5:287b:da02 with SMTP id ffacd0b85a97d-3a8fe4bd16fmr7883192f8f.40.1751288445961; Mon, 30 Jun 2025 06:00:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZT4aB5+IKBjQnh+yncb7ZFTxj1NuN2dDZeVwVJqvRnlRrWkNRGfP/el4NU32fGgywSRoLtA== X-Received: by 2002:a05:6000:440b:b0:3a5:287b:da02 with SMTP id ffacd0b85a97d-3a8fe4bd16fmr7883079f8f.40.1751288445063; Mon, 30 Jun 2025 06:00:45 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a88c7e72c1sm10293032f8f.1.2025.06.30.06.00.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:44 -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 v1 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio() Date: Mon, 30 Jun 2025 14:59:52 +0200 Message-ID: <20250630130011.330477-12-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's move that handling directly into migrate_folio_move(), so we can simplify move_to_new_folio(). While at it, fixup the documentation a bit. Note that unmap_and_move_huge_page() does not care, because it only deals with actual folios. (we only support migration of individual movable_ops pages) Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- mm/migrate.c | 63 +++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 0898ddd2f661f..22c115710d0e2 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1024,11 +1024,12 @@ static int fallback_migrate_folio(struct address_sp= ace *mapping, } =20 /* - * Move a page to a newly allocated page - * The page is locked and all ptes have been successfully removed. + * Move a src folio to a newly allocated dst folio. * - * The new page will have replaced the old page if this function - * is successful. + * The src and dst folios are locked and the src folios was unmapped from + * the page tables. + * + * On success, the src folio was replaced by the dst folio. * * Return value: * < 0 - error code @@ -1037,34 +1038,30 @@ static int fallback_migrate_folio(struct address_sp= ace *mapping, static int move_to_new_folio(struct folio *dst, struct folio *src, enum migrate_mode mode) { + struct address_space *mapping =3D folio_mapping(src); int rc =3D -EAGAIN; - bool is_lru =3D !__folio_test_movable(src); =20 VM_BUG_ON_FOLIO(!folio_test_locked(src), src); VM_BUG_ON_FOLIO(!folio_test_locked(dst), dst); =20 - if (likely(is_lru)) { - struct address_space *mapping =3D folio_mapping(src); - - if (!mapping) - rc =3D migrate_folio(mapping, dst, src, mode); - else if (mapping_inaccessible(mapping)) - rc =3D -EOPNOTSUPP; - else if (mapping->a_ops->migrate_folio) - /* - * Most folios have a mapping and most filesystems - * provide a migrate_folio callback. Anonymous folios - * are part of swap space which also has its own - * migrate_folio callback. This is the most common path - * for page migration. - */ - rc =3D mapping->a_ops->migrate_folio(mapping, dst, src, - mode); - else - rc =3D fallback_migrate_folio(mapping, dst, src, mode); + if (!mapping) + rc =3D migrate_folio(mapping, dst, src, mode); + else if (mapping_inaccessible(mapping)) + rc =3D -EOPNOTSUPP; + else if (mapping->a_ops->migrate_folio) + /* + * Most folios have a mapping and most filesystems + * provide a migrate_folio callback. Anonymous folios + * are part of swap space which also has its own + * migrate_folio callback. This is the most common path + * for page migration. + */ + rc =3D mapping->a_ops->migrate_folio(mapping, dst, src, + mode); + else + rc =3D fallback_migrate_folio(mapping, dst, src, mode); =20 - if (rc !=3D MIGRATEPAGE_SUCCESS) - goto out; + if (rc =3D=3D MIGRATEPAGE_SUCCESS) { /* * For pagecache folios, src->mapping must be cleared before src * is freed. Anonymous folios must stay anonymous until freed. @@ -1074,10 +1071,7 @@ static int move_to_new_folio(struct folio *dst, stru= ct folio *src, =20 if (likely(!folio_is_zone_device(dst))) flush_dcache_folio(dst); - } else { - rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); } -out: return rc; } =20 @@ -1328,20 +1322,23 @@ static int migrate_folio_move(free_folio_t put_new_= folio, unsigned long private, int rc; int old_page_state =3D 0; struct anon_vma *anon_vma =3D NULL; - bool is_lru =3D !__folio_test_movable(src); struct list_head *prev; =20 __migrate_folio_extract(dst, &old_page_state, &anon_vma); prev =3D dst->lru.prev; list_del(&dst->lru); =20 + if (unlikely(__folio_test_movable(src))) { + rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); + if (rc) + goto out; + goto out_unlock_both; + } + rc =3D move_to_new_folio(dst, src, mode); if (rc) goto out; =20 - if (unlikely(!is_lru)) - goto out_unlock_both; - /* * When successful, push dst to LRU immediately: so that if it * turns out to be an mlocked page, remove_migration_ptes() will --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 E59E428C841 for ; Mon, 30 Jun 2025 13:00:53 +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=1751288459; cv=none; b=M1eV6TruGcomQd/bd2kYxuX8Rj09DtH9i9Rb0yNK0isiBEkgk0bIUeCKcTdxXiyhNEZ4k6Ecwa23YLvzyOce6P3PjRGK4FgayJom7yemtmkp9TKzfebwCf2jW0QhOt2ZemWQMAWg0lfqqUrK0RyBj3QeYRJ7dk0+QVfINsgdAss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288459; c=relaxed/simple; bh=B4KdnntE/37K79ZPh7jyK3I0hRR/1p6A2DVmbrYflX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q5V8lPKO75Zit4a5wStMEAr9eIB9n6DX3SuMrMJMa7rLvTbfQOzd9EiilgVpRof7kND06fPG2a+bCuNjL51zEUStlJTgLjimeMh08AkS0nGtaC3XOR+B4FKGjdR49FZ+NiG6I4skUR3NjxQf9k3VnEU9+zVblNXAvvL9SI2oMoI= 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=gwaIciSy; arc=none smtp.client-ip=170.10.129.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="gwaIciSy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288453; 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=HE4ZFr/3yO/kcvQGBFxRWJWFhigh7sWDavgkH8Q96v8=; b=gwaIciSySWQNHly+vou9rQY7nvkZG8CMLLPyWVYwAeQdtPb317aguTtY+QU8ZhTicVfbbS u+cXjOVGDeiSa3yiYjS6DvE0W6bnD7PbAkpB/MAdGKuzbbESpgei4PISKE7NwHyygK7Hy/ GMPGZLUBdaefwRuaPm8GVWtWzpjJpio= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-ex0nRRL8Pz6lFs7z2iqhHQ-1; Mon, 30 Jun 2025 09:00:50 -0400 X-MC-Unique: ex0nRRL8Pz6lFs7z2iqhHQ-1 X-Mimecast-MFC-AGG-ID: ex0nRRL8Pz6lFs7z2iqhHQ_1751288450 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a56b3dee17so2652114f8f.0 for ; Mon, 30 Jun 2025 06:00:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288449; x=1751893249; 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=HE4ZFr/3yO/kcvQGBFxRWJWFhigh7sWDavgkH8Q96v8=; b=K617rkcjlqzDp6XjJ4Msx1E1lEB+JXaAhc4iwj1a6SsMTBJ3vJa2Cu1etWUaFfi2Vr jXNvC786s49ZeZW1hJmds9BbVY1Efb8I6rtAFqUzEIwIidbaPwgPjK709rNBqP/oKd4F 8XaIFY+/WjSWT26F55stNb49a19r+WwuS692nxE6VEeXXANAZc7azmrr0Xp2bX5o3Ymg fmkDiO+H9ZE+tMUi87aSpt7MBA636qrRRyI69lCXH+kFiav+2oy5TYIqCARt79Mq7VXA qIHfsyfXRFK6ZDnFD+BQIRDhZv2QQl99SZJbiBt/EkNfAWTllCUyUQ6lYRroKvvkLgsS UJLQ== X-Gm-Message-State: AOJu0YwCLK0HkB8vfHWom/zE9usMSA07aSROc0EpgGVMAFDyhbQ/hr2m 4oCGCzNktqM2LA+JllD9itEkdCBl4my254v2gGjFdIzh9jYCVVauWsc6DTYy/SzBuRiJnrFuWMN wApusRv7d9EAGJ4DTEG5vDMKrKuHlpInWY2x9NDZuMSjX2ENY5n3js19XJZLSa4UpL7fWYNzUs+ 9bz8JMvvWure5rHXvlpKL7UnQevHu4jEX0KXtqm5T/zxDwOnTq X-Gm-Gg: ASbGncspfaObC9ve+nEW5ogzFIhNKnSfTeys7sLBPbkWEEX2JVQmrzwywD0odfPsQaF WMmMgpYr5G+5Xw72XLqpIdE38oUZGH/eLzJnVbqlSW4PX9TLvjMFA+ZRUPg+PSGMSEW9KNJi9nj wqGmvDPZGwQfZ3WEZshojQMKQ5Vito+8ryeWihsVsdEnmrKtcxLg4IY7KKl77PfdI2ak3FZsGfy FyU2tQzEEssyeNXz48hQpH20qZ5LS1Kn65aG32/duXRDAHutJMPeA2eWw+M+VXD/H1fDUNSO50O F8/72YzrfMLhb7kXlYpdts3xVugPSscOkLTwVA/YbiLm5GKnJxNjX+dekZRv8QJ787F8cHjVW4K xqZ1WxtI= X-Received: by 2002:a05:6000:2186:b0:3aa:ac7b:705a with SMTP id ffacd0b85a97d-3aaac7b761amr5970086f8f.11.1751288449065; Mon, 30 Jun 2025 06:00:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB1TGCDIUZET9zX0pBSLAtGHjOK3AMuobCCTliN5r8xMP/2a92mQUobTb4bSUGBJMrG9p6Jg== X-Received: by 2002:a05:6000:2186:b0:3aa:ac7b:705a with SMTP id ffacd0b85a97d-3aaac7b761amr5969952f8f.11.1751288447748; Mon, 30 Jun 2025 06:00:47 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a88c80b5aesm10252042f8f.44.2025.06.30.06.00.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:47 -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 v1 12/29] mm/zsmalloc: stop using __ClearPageMovable() Date: Mon, 30 Jun 2025 14:59:53 +0200 Message-ID: <20250630130011.330477-13-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Instead, let's check in the callbacks if the page was already destroyed, which can be checked by looking at zpdesc->zspage (see reset_zpdesc()). If we detect that the page was destroyed: (1) Fail isolation, just like the migration core would (2) Fake migration success just like the migration core would In the putback case there is nothing to do, as we don't do anything just like the migration core would do. In the future, we should look into not letting these pages get destroyed while they are isolated -- and instead delaying that to the putback/migration call. Add a TODO for that. Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- mm/zsmalloc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index f98747aed4330..72c2b7562c511 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -876,7 +876,6 @@ static void reset_zpdesc(struct zpdesc *zpdesc) { struct page *page =3D zpdesc_page(zpdesc); =20 - __ClearPageMovable(page); ClearPagePrivate(page); zpdesc->zspage =3D NULL; zpdesc->next =3D NULL; @@ -1715,10 +1714,11 @@ static void replace_sub_page(struct size_class *cla= ss, struct zspage *zspage, static bool zs_page_isolate(struct page *page, isolate_mode_t mode) { /* - * Page is locked so zspage couldn't be destroyed. For detail, look at - * lock_zspage in free_zspage. + * Page is locked so zspage can't be destroyed concurrently + * (see free_zspage()). But if the page was already destroyed + * (see reset_zpdesc()), refuse isolation here. */ - return true; + return page_zpdesc(page)->zspage; } =20 static int zs_page_migrate(struct page *newpage, struct page *page, @@ -1736,6 +1736,13 @@ static int zs_page_migrate(struct page *newpage, str= uct page *page, unsigned long old_obj, new_obj; unsigned int obj_idx; =20 + /* + * TODO: nothing prevents a zspage from getting destroyed while + * isolated: we should disallow that and defer it. + */ + if (!zpdesc->zspage) + return MIGRATEPAGE_SUCCESS; + /* The page is locked, so this pointer must remain valid */ zspage =3D get_zspage(zpdesc); pool =3D zspage->pool; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 04B6A28C866 for ; Mon, 30 Jun 2025 13:00:55 +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=1751288461; cv=none; b=OOL8as4yUrrmD0+yOSnP8+f+Jv+Y7Aqn03Cr/mbK8SrQFMKxNYoMagwAesxwCEwLEIyO4lMtqWPI7KUU2uVaNT3LVrHoYYRtblEECxAn/t9pDnACplnOHGhRcmc2lx0I38or+nIquD0PTS1SW5jo8B/+biradt9/ok+2mYsQPCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288461; c=relaxed/simple; bh=h679pTWyf5chDo0jTdgc5eTOddfWMzqMz/6J3iuD7Gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hRZO5ntOuHKSt9fNiPa96TgJPkyS/gvBO4apntkcPrnGJ6hRp76iOL/vXiEqz1mxrcM2v9AWqUiIV79rfAw5V0Vcx9G0WB58w3lWYpsTvaQQQf5eDd80mSK5yUjIpG6MDeLc5kWr7QJPyZAbEib5pPJJijPCk6HOQPH21x9bERA= 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=Oa6NdQTT; 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="Oa6NdQTT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288454; 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=rZbSryMy27xk/lWuJyIeQilPAEeTxdVw8qHGMwbITkw=; b=Oa6NdQTTra/s7VD6JkH1KtIL38ChtfInLsPaa3Zf830UugvWNJLIMJKuLZ4KtxoMHDOjiQ 7URVym75qUHs/axL2joaxqhkayVOjxSM7cMXbxDmJFoBTW0MMXqz8igjpd1OppSbZUEc3I /VsRH++suMXO6gVhEE5Dd8NjL+qfaF8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-CTeGphwQMD-V-GaWZb6NJQ-1; Mon, 30 Jun 2025 09:00:53 -0400 X-MC-Unique: CTeGphwQMD-V-GaWZb6NJQ-1 X-Mimecast-MFC-AGG-ID: CTeGphwQMD-V-GaWZb6NJQ_1751288452 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a52bfda108so2046466f8f.3 for ; Mon, 30 Jun 2025 06:00:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288452; x=1751893252; 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=rZbSryMy27xk/lWuJyIeQilPAEeTxdVw8qHGMwbITkw=; b=Ke9ocHmGLONjM11gUTb2ilCML5ROX9lhbpo69I0LhSzAB6gCnBpNT2DHJe5IjYJNA5 RYxHkiTiU8cfiucPd1CwGbDqyl0P/OQvc3TaXygHGEuRHxhjvhUwcTbw8qLZY1Sgwk1T VcL0t2VUGx++msnpcXPxA2VcGn9Bg/TyAs6wzZt4lSmXJKUNwmd9JW8Ozeh+WIh0ImAq 608flpNDR35PUdFR07BhMLEA5Id2bHKzGSfdlMkCX0Y+DDdPZ268fm9o1rr3jCICzTDM B5bsrV+TXurwfHY1TGI+lhul1IBr+76xH2FqlxPXBytncf8oIPftla74BSVBNSCyaDii Ll9w== X-Gm-Message-State: AOJu0YwOnT2vkLw1DO5gVlHHVBzNx5FavC7nN5MSiww9qCv6sG8PDwrx IWq5I6PJT8zCHygM1Aq0R5qdHOnTcLb7slhR4KfZL7RuQ39jYeYfY1BbiJcHmNxRS4WfRqhRsVx Y3j6TwgWsLISbn46XyR/HThNvoZyESH6sIZM9jiVR0gUxOqltJ+sFwdcFaP90IRGNqV8K3T/swD kixJMyfTdWkX9I8KBAKcgoEH5VGQMN3JJ/e/AyQTYP+8QjJD0b X-Gm-Gg: ASbGncvzNgaaxt7zmUWvq3Ymptl5tir4HZjlu123ATOnggCuZn2TscFVjukk9H6AKwh n2Y6LLjBjZ9mSjoqjLAKgnEuiGAWwlEkXlBbdUzToXf+jldRDfzuFINI7VonsvtdvUxm9VU5qJn /+EVR44MBJRR2Y4sC0NIKS3lnqJo4ZkRkBAQg4MPyARyZEBkkbZwVC8UFTg5UFKA78iJ1a4sY9U ehHLkEl8kRfyZONbaZLC+UT1tC3Nn9CYJSSE7idC3Y0Y4oQeoTj9TBiu8xW4Cbgg2XlvrP3zt8S hd/YDz1DxZ/xPr31EiFV8iyKkGx4gnY7L3mvLO/9o8nqi0xc20nlNZ5bagdmtxSDjv1gnokJRB2 QKqeSQCA= X-Received: by 2002:adf:a143:0:b0:3a5:8565:44d1 with SMTP id ffacd0b85a97d-3a8fe8917d5mr8134413f8f.25.1751288451386; Mon, 30 Jun 2025 06:00:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcHR74Vg3fOLDK1bhOkeMb0O7J5iWXrvKqq6qclu6yGGjB1xdv/xPEmRceAckepewzfNXHQQ== X-Received: by 2002:adf:a143:0:b0:3a5:8565:44d1 with SMTP id ffacd0b85a97d-3a8fe8917d5mr8134296f8f.25.1751288450453; Mon, 30 Jun 2025 06:00:50 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823b6d50sm167133055e9.30.2025.06.30.06.00.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:49 -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 v1 13/29] mm/balloon_compaction: stop using __ClearPageMovable() Date: Mon, 30 Jun 2025 14:59:54 +0200 Message-ID: <20250630130011.330477-14-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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. Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- 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 From nobody Wed Oct 8 09:26:31 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 D332028D8C7 for ; Mon, 30 Jun 2025 13:00:58 +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=1751288463; cv=none; b=FKlACpxxTqgcIA+cnR7MUfo5LpK6Pubm9S4FCjqvIMZf6zoleQUxk3+BraV/nmjgH1y6Y81TPrNIJDTUGvcU+gRjNkUrq1u2NzRUyJnvOWEICGvFVJiu/vDONge2TRwHJVIuARVxITZVvHpMqG5usiGbdWWzqlJRhhj3PVA45Eo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288463; c=relaxed/simple; bh=UHifpKu5ufl8QF9rCxhzhbIhhsXhSiIoRV9644qN9BA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DQiD1WKNfqzpEfWIBSc/akhyxEUQwGMhk/zdY2wpZ7r1eR/gTIDWCxgjEMW7WW4+upMIN99I4lhefnISGYPXuC1qNCgFNNs8aoHDuQ4xJmP/9sRdBnRWeRTif1bHQtaFgPgNNzUrvyAfAI185oZFD2Ngj38tNJ9z0jToebj+PSQ= 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=KVImoVXv; 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="KVImoVXv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288458; 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=JRChIqxUOgPOieQj0YeNNw03RDlWoIXMOrbpFO40kH0=; b=KVImoVXvQXpUm2dM4Smpbn3UfyyJTtCAmOl2QzvA47ODqKYuVtLeUVCW+MCtcJOzVjFbCm Wg+RrbgRXh4XH+h57DaMklvKXQ6mPLYy19ctYFBMxRncqKrY4UxEejx8tsp8/c8V1LRCcJ qLOk1s4dfaFlDzKRqxxd0cTlfhDCcvQ= 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-622-Usm8KLfXOHuat5G6N8SfdQ-1; Mon, 30 Jun 2025 09:00:56 -0400 X-MC-Unique: Usm8KLfXOHuat5G6N8SfdQ-1 X-Mimecast-MFC-AGG-ID: Usm8KLfXOHuat5G6N8SfdQ_1751288455 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-450d6768d4dso13580775e9.2 for ; Mon, 30 Jun 2025 06:00:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288455; x=1751893255; 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=JRChIqxUOgPOieQj0YeNNw03RDlWoIXMOrbpFO40kH0=; b=w/xDGCZeWvfC0QrVciD+jhSxD8IryTScLF0PWeqJoFy8NFXaK3uxfwpRXwSy5uIl32 EqJTcbPQElk4XzxBj9NED+0w7e+eTSz/qLDJCYD4Z9WQo8JQ+MdYQgj0srJiepIiiORo h/p9A5iQDppFzkzIq2lNLPNULhYTFRzFuL0IfZgCUH6hCZu5D1fZxfkJlZ0D5uKVeDgw pmUBp/agRmNXGfFtJvbFN0uGjVgpqVq8Sip0JTc6N1DrR+l9ajPPOqrb9OSKEJzrLyTG Gp6NgvIHGNe34Ac2UwPs2AbN7JsAAc/19EVRJb9yXQVj3Dw5MDYy7QEZacgsEC8uS5oT YijQ== X-Gm-Message-State: AOJu0Yy9s3OZQvau2Op6EA0GHVXqw2yZ1ZHjx5wZDRNRYvUnXh8bmMRc bFYYWuySB+tdoVAmYrqgiX2Lb7RAwYTZFCo3uFDyQwSNyOVAN8v+3HhcUsR+85Q8uY6IX3xL0MK IvVXyNqWjDRjqg9MR648L01a4wcDX5R8VWocGF8+Vevrsld/pZE9uUXzME/TgQbCHPTb3V3LTBl M7VbWndMaZvskhequrasWaOS7pfoNAfGkuZtKxHzUzVLQPgg/u X-Gm-Gg: ASbGncthxjfTLS2J0wJIYRs9cI1fW59yRTKsoHMr8O1eHYyV6OHhQrXakzJCu6+8h8P 98d7BkBHuUufEp+TLv4ktEGN5E5VxWeMNCbSxcEXB32wKDZBTGRMwbO47CL+b2euFJlFJC/AJxK WiczxpuQllBtTapkwf4SB5Nqmnt6V1azsbXML05ey7vb1lYMoj0VTKrWHzq3WY37Dj0cAu1QJdl SfNDrhtde9DCYgri4KXG9htchwCWtMBYP31p1RGv34POAud7tUd/vFa52I0PQL/+1po4pX4u+4/ jMgRJ/ISLWVl6hhomvLz3IT4V2qcRYEKnyZu03+gmzJEWiwHkmd2Z0X7dNfQP8jrPG2mT04RWv1 UVpXN77M= X-Received: by 2002:a05:600c:3b8e:b0:43c:f513:9591 with SMTP id 5b1f17b1804b1-453913c5a63mr120799085e9.14.1751288454451; Mon, 30 Jun 2025 06:00:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZHtsc7XNjhOjxkvKCZ2uHLxZSkMRI4G1PqHHBjrp6rzXGUbjSQmg1iO1pCKPy78A7k9Rgqw== X-Received: by 2002:a05:600c:3b8e:b0:43c:f513:9591 with SMTP id 5b1f17b1804b1-453913c5a63mr120797265e9.14.1751288453316; Mon, 30 Jun 2025 06:00:53 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e59ab5sm10144896f8f.82.2025.06.30.06.00.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:52 -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 v1 14/29] mm/migrate: remove __ClearPageMovable() Date: Mon, 30 Jun 2025 14:59:55 +0200 Message-ID: <20250630130011.330477-15-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Unused, let's remove it. The Chinese docs in Documentation/translations/zh_CN/mm/page_migration.rst still mention it, but that whole docs is destined to get outdated and updated by somebody that actually speaks that language. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/migrate.h | 8 ++------ mm/compaction.c | 11 ----------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c99a00d4ca27d..6eeda8eb1e0d8 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -35,8 +35,8 @@ struct migration_target_control; * @src page. The driver should copy the contents of the * @src page to the @dst page and set up the fields of @dst page. * Both pages are locked. - * If page migration is successful, the driver should call - * __ClearPageMovable(@src) and return MIGRATEPAGE_SUCCESS. + * If page migration is successful, the driver should + * return MIGRATEPAGE_SUCCESS. * If the driver cannot migrate the page at the moment, it can return * -EAGAIN. The VM interprets this as a temporary migration failure and * will retry it later. Any other error value is a permanent migration @@ -106,16 +106,12 @@ static inline int migrate_huge_page_move_mapping(stru= ct address_space *mapping, #ifdef CONFIG_COMPACTION bool PageMovable(struct page *page); void __SetPageMovable(struct page *page, const struct movable_operations *= ops); -void __ClearPageMovable(struct page *page); #else static inline bool PageMovable(struct page *page) { return false; } static inline void __SetPageMovable(struct page *page, const struct movable_operations *ops) { } -static inline void __ClearPageMovable(struct page *page) -{ -} #endif =20 static inline diff --git a/mm/compaction.c b/mm/compaction.c index 17455c5a4be05..889ec696ba96a 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -137,17 +137,6 @@ void __SetPageMovable(struct page *page, const struct = movable_operations *mops) } EXPORT_SYMBOL(__SetPageMovable); =20 -void __ClearPageMovable(struct page *page) -{ - VM_BUG_ON_PAGE(!PageMovable(page), page); - /* - * This page still has the type of a movable page, but it's - * actually not movable any more. - */ - page->mapping =3D (void *)PAGE_MAPPING_MOVABLE; -} -EXPORT_SYMBOL(__ClearPageMovable); - /* Do not skip compaction more than 64 times */ #define COMPACT_MAX_DEFER_SHIFT 6 =20 --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 C029C28DEE7 for ; Mon, 30 Jun 2025 13:01:02 +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=1751288467; cv=none; b=tRRut+/jODFBazm/yPeD+hoDaVw8p/DOW62/iKOac2pB6sIhmf0Ccr7tg/+YSqLnW7zHvpfuJnYS060hkpXNe6iRAvnHO0goE17dz3L4yH3rBm8QZSGBRqMB1hCbpA+KKvlz46GoLPKG7fQoTnAqCudIjWDj3eb5cw6P3yrtHno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288467; c=relaxed/simple; bh=E2Kk/3B1Zvc/DrpiBo6mfnVkxxScIN5ozXUblSaxVOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fX2ySb8urkRDBovVDb9EEZY3c0B3X8bfB3vKHGDvFWwlq8KCzIHfOlK60vxWPnTUP9zFrOb+44PyAnlAL//YExh1LjcQiKL0by790pzU0fuDrzTWUnjaXgZwUc6lTsEO1kX2D5cIb//yE3GuXDT1dY3QWZLqhp1XAjoVYLzGq00= 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=bIAcm+B3; arc=none smtp.client-ip=170.10.129.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="bIAcm+B3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288462; 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=02uSef5lp6Y5cEfWyIGZlJA9ZbaH5mB3gdVPjlakXLo=; b=bIAcm+B34GjWwePDqYx9WgR+JjSRz7I8jNBY14eq4QQtpqtxHI2J94he/p0Rjt15Lwi44k Ul3q6Ej26xiMzbsbZIZp2ohZCEhl0IqzA02Y6+SSClhcy1pPM0JRYSQNnMreACdOZ7dnbq yXATAZ8j13uF3FuyFx8RHe0UAxV/B/E= 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-133-2k4Xv_p4PK6j9wb6-uaCng-1; Mon, 30 Jun 2025 09:01:00 -0400 X-MC-Unique: 2k4Xv_p4PK6j9wb6-uaCng-1 X-Mimecast-MFC-AGG-ID: 2k4Xv_p4PK6j9wb6-uaCng_1751288459 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4535ee06160so16096685e9.3 for ; Mon, 30 Jun 2025 06:01:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288459; x=1751893259; 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=02uSef5lp6Y5cEfWyIGZlJA9ZbaH5mB3gdVPjlakXLo=; b=Nb9UBZS5msP3pH3XmlyDhTk7miY0xKCxjjSypRxbhhZxChsi2F+dUSRcryotI6HBby eu9uaNe2Fi3talL+sgEEqhVMAbLo446p9aBYOpoy5HdtfCQAeDzTGvRH21mhH90mfNeX 3IemwlK7wFRPAyc5Vl+CGK99ci+UnTUxH5lImnwzfiMmuMviApMzf2uyyruW5FbQT8YN 97xs/b3EVPeHkIQmZv7I+iPh1LXJWrAT1I+AKTQce/dBPx8hD0SFQe8H/rsbspbsNI/v rgrugtdtp8V3+8NG+L7rvwfiMYVPwrdPC+mSAQ0LO46gTT+8k6VGXwVzYD9FoMzCSKyK AKvw== X-Gm-Message-State: AOJu0Ywsgy5Pbl8+oLAtIvOUcgLSoLm5GVaYs18DB8qJADcjghfkSmFp qrgChv9jmm2k52kN5XbEsCk67dRoSFDs0ZDy66og75lUJ9MtC7S4Hoim81CXXLAPtFZyP4HJfjy S0h3XYS+zu4zygsVDVe8YRhlVEswuJz5lVHjCiCgLkriNVNFnhgbGolYTC9aPkCeFJSwzIHoiV6 Qjmm9nXHtuicR2F+3d4w0/4fJaFWHfW75n7pzCuz7Xy5TeqOFf X-Gm-Gg: ASbGncsYTDI7p1wCxfkagOmpq0nKzWd8zlyALjY1Q9kh+OCU9UnotOpeNidnaiRbN1R Ara4KB2NLgjlVnb2NwGKdVuQevugcwhZH4zFacI+zL8FAS2TkW1CrplJzGtfopfYUw9PK76YHYX 9o5nhq68d7nveiTM1G0HD87K3YcMDAKalaHppEt/l9CYjzPn1crUHSuUTTmjgBJE/1xG653tO06 y1EVPCoTZ8jxZWq5jAapsrzTbrmnI6T0+JmHd5XU/3jR73RL0Q9HfsThL9ThawMQhkD0iux8Lne BxwyVOmr5oMoyGvqo84P0aagcbxffIxgHRPYTigG4sij5OklPQcoZnqsSJIv8AF8T2i3MJZiTmh MbbJeXmg= X-Received: by 2002:a05:600c:a46:b0:44d:a244:4983 with SMTP id 5b1f17b1804b1-4539726acc1mr92870085e9.3.1751288458679; Mon, 30 Jun 2025 06:00:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCs0m13Yqq4GukWpM+4uHJmOOd6amI/nvHYcsB4z72aw1swyUlytQ8Ivx43yHYvtcBEII8eg== X-Received: by 2002:a05:600c:a46:b0:44d:a244:4983 with SMTP id 5b1f17b1804b1-4539726acc1mr92865605e9.3.1751288455974; Mon, 30 Jun 2025 06:00:55 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e5f8absm10554612f8f.95.2025.06.30.06.00.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:55 -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 v1 15/29] mm/migration: remove PageMovable() Date: Mon, 30 Jun 2025 14:59:56 +0200 Message-ID: <20250630130011.330477-16-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" As __ClearPageMovable() is gone that would have only made PageMovable()=3D=3Dfalse but still __PageMovable()=3D=3Dtrue, now PageMovable() =3D=3D __PageMovable(). So we can replace PageMovable() checks by __PageMovable(). In fact, __PageMovable() cannot change until a page is freed, so we can turn some PageMovable() into sanity checks for __PageMovable(). Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/migrate.h | 2 -- mm/compaction.c | 15 --------------- mm/migrate.c | 18 ++++++++++-------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 6eeda8eb1e0d8..25659a685e2aa 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -104,10 +104,8 @@ static inline int migrate_huge_page_move_mapping(struc= t address_space *mapping, #endif /* CONFIG_MIGRATION */ =20 #ifdef CONFIG_COMPACTION -bool PageMovable(struct page *page); void __SetPageMovable(struct page *page, const struct movable_operations *= ops); #else -static inline bool PageMovable(struct page *page) { return false; } static inline void __SetPageMovable(struct page *page, const struct movable_operations *ops) { diff --git a/mm/compaction.c b/mm/compaction.c index 889ec696ba96a..5c37373017014 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,21 +114,6 @@ static unsigned long release_free_list(struct list_hea= d *freepages) } =20 #ifdef CONFIG_COMPACTION -bool PageMovable(struct page *page) -{ - const struct movable_operations *mops; - - VM_BUG_ON_PAGE(!PageLocked(page), page); - if (!__PageMovable(page)) - return false; - - mops =3D page_movable_ops(page); - if (mops) - return true; - - return false; -} - void __SetPageMovable(struct page *page, const struct movable_operations *= mops) { VM_BUG_ON_PAGE(!PageLocked(page), page); diff --git a/mm/migrate.c b/mm/migrate.c index 22c115710d0e2..040484230aebc 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -87,9 +87,12 @@ bool isolate_movable_ops_page(struct page *page, isolate= _mode_t mode) goto out; =20 /* - * Check movable flag before taking the page lock because + * Check for movable_ops pages before taking the page lock because * we use non-atomic bitops on newly allocated page flags so * unconditionally grabbing the lock ruins page's owner side. + * + * Note that once a page has movable_ops, it will stay that way + * until the page was freed. */ if (unlikely(!__PageMovable(page))) goto out_putfolio; @@ -108,7 +111,8 @@ bool isolate_movable_ops_page(struct page *page, isolat= e_mode_t mode) if (unlikely(!folio_trylock(folio))) goto out_putfolio; =20 - if (!PageMovable(page) || PageIsolated(page)) + VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); + if (PageIsolated(page)) goto out_no_isolated; =20 mops =3D page_movable_ops(page); @@ -149,11 +153,10 @@ static void putback_movable_ops_page(struct page *pag= e) */ struct folio *folio =3D page_folio(page); =20 + VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); VM_WARN_ON_ONCE_PAGE(!PageIsolated(page), page); folio_lock(folio); - /* If the page was released by it's owner, there is nothing to do. */ - if (PageMovable(page)) - page_movable_ops(page)->putback_page(page); + page_movable_ops(page)->putback_page(page); ClearPageIsolated(page); folio_unlock(folio); folio_put(folio); @@ -189,10 +192,9 @@ static int migrate_movable_ops_page(struct page *dst, = struct page *src, { int rc =3D MIGRATEPAGE_SUCCESS; =20 + VM_WARN_ON_ONCE_PAGE(!__PageMovable(src), src); VM_WARN_ON_ONCE_PAGE(!PageIsolated(src), src); - /* If the page was released by it's owner, there is nothing to do. */ - if (PageMovable(src)) - rc =3D page_movable_ops(src)->migrate_page(dst, src, mode); + rc =3D page_movable_ops(src)->migrate_page(dst, src, mode); if (rc =3D=3D MIGRATEPAGE_SUCCESS) ClearPageIsolated(src); return rc; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 CD9C528E5E2 for ; Mon, 30 Jun 2025 13:01:05 +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=1751288470; cv=none; b=u0Ho0tFqjmLGOozxQtFloUKvXwDPw2tSTniAcDcG+zrzgPVRFY/7R8CM2PJ2TtF0g+UW51FwvBxmZDbzaT5MzTVhadkLMrI9PX+k4NAGgGjn3zBZzHCxtzMlyzK2HIgBt0uvib3SVFRW7lPW4Rx7Eyb53pLwY4TaUVeUr+7rKm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288470; c=relaxed/simple; bh=GzR5XQuP8hkj7mwOZUU9SwkUyYIjmjhvq4wE9LLZiJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=loPCkwVbOrnE/8c5gHL14VStW6BHuNWrnrIRLIT30xXPtKbvG8MMhNFH91BjWuWOhzGx/OjWgQe/TyEW8kl4cIlzk9kasiOBgSzzy2InosTKK7VVNmRDMdXfm0LsUEdRO2G6mJnl3SSBmFJgLfa86C+vVHnwDIx7wjaQPYGx7tY= 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=ftGpCejr; 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="ftGpCejr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288464; 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=j9ZRLOTZa5PZrqGG8BB7XlQvd09DIcXAeCmmDpWukIA=; b=ftGpCejrRD+2Sp2NU2kt0CJOStvYynPnL4IgcWBLcZmOKZSlm8Lfp51tBh/FGHCFTsJXlo ucI8U2BBruC2GzEcSkU0lExr7lquXKHsTBBlAJajcgrHl472+RMXAoJv04s9rcs+P1PouD 9l14EI7cGBcfQTw+r5MdX29peiGkFZs= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-604-sdJYtXPPOLac9KNKroBaFw-1; Mon, 30 Jun 2025 09:01:03 -0400 X-MC-Unique: sdJYtXPPOLac9KNKroBaFw-1 X-Mimecast-MFC-AGG-ID: sdJYtXPPOLac9KNKroBaFw_1751288462 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a52bfda108so2046566f8f.3 for ; Mon, 30 Jun 2025 06:01:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288462; x=1751893262; 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=j9ZRLOTZa5PZrqGG8BB7XlQvd09DIcXAeCmmDpWukIA=; b=Hy0eI42ePE0lGMyuOEPyEYartPO6+fgBqQiFAjQAANd4EXfndVw2vFVcbskSajCWs5 wXJOExInCRvymQ37F2uBP1WS0yjwkDD21NRS8O0RoP+SW15jvY3tGE/4KycDyYQw+cHk 76NBtiCqrJ8D+OdU5I6F3xHmYvTk4ruuGD56wF2TtEO6w8mmJp6sMq7lhxKmmi2N8+/x Lym0OfgC8r3fYJgIIz4K7a4PDScboieP3Z8ks4Nv0bzdih+zgu05DFblCsPDycGs/DMm K1wQk7mrIqQlYWzMEJ+1Dhekfv8+5niql3jcUQLnhifGv+0nrT56T1hJZXlv2AI8mgCI Sd/A== X-Gm-Message-State: AOJu0Ywm476TgHIcVeL/VMO+Oag3YfAzJnUbiUlVZ4HbvDaPMYcsriET bAlaiuE+zJqMISYsemuvpJMQzrPjIkYFrjDxZgTsJEVZhibnDRXpFFxBCI/3Jx6CiMSwnIWINEX CNiGUqJxr646YsfpACLAnVwB+4mbgAKp8gmBF0+PzIFoG179k+q9ypXm6RxPemTf6TC+z7zsNuj 6gzF/CeI2m7kNSqwh1plDG0Ap6Z85tbZLHmHOgm3Qdx9AluU5p X-Gm-Gg: ASbGncufD15HAniEV0xCUwNhTgt5BKpkgJU3Bos75Eood5OeEpUGkUDm7HImQYYIyYs tUw9T9ycSXLM+eruFQV36+nyLkijI6IuwhugU5M0uq83ZBgUL+hqxxA1wWiwaXz0SwFtnZWxYKt PbPn/6RnAqa7tR3q7SWUE65l9Plgqls/0XeNBNDUelp2fxhzfv2vVh1flaKdWETDysHo5RHxejC dmbsXGKMMJdCH13MJUHd/uqUryHigSzfa/r/GpZBIy00FxUFAXJXwRl8+vvsipKWpAT3Nr2q+M6 Rfr0wl2bfPZLcsRNvf0N4EkEFYsai5p1lOH7EOhl9kTzXu50QYCE+D0854F8HjufV1duHBtsQB/ alZDNGDA= X-Received: by 2002:adf:e050:0:b0:3a5:2182:bd17 with SMTP id ffacd0b85a97d-3a8fe4bc79dmr6795166f8f.19.1751288461325; Mon, 30 Jun 2025 06:01:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHX2/qdHEQ8JHXpMdU+ERIflh/WNh5UuVnHM8RS5ZiXb7uiqYANr4p4OCvKgXi6OG7WHmrLuA== X-Received: by 2002:adf:e050:0:b0:3a5:2182:bd17 with SMTP id ffacd0b85a97d-3a8fe4bc79dmr6795028f8f.19.1751288460150; Mon, 30 Jun 2025 06:01:00 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e5979dsm10337527f8f.75.2025.06.30.06.00.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:00:59 -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 v1 16/29] mm: rename __PageMovable() to page_has_movable_ops() Date: Mon, 30 Jun 2025 14:59:57 +0200 Message-ID: <20250630130011.330477-17-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's make it clearer that we are talking about movable_ops pages. While at it, convert a VM_BUG_ON to a VM_WARN_ON_ONCE_PAGE. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/migrate.h | 2 +- include/linux/page-flags.h | 2 +- mm/compaction.c | 7 ++----- mm/memory-failure.c | 4 ++-- mm/memory_hotplug.c | 8 +++----- mm/migrate.c | 8 ++++---- mm/page_alloc.c | 2 +- mm/page_isolation.c | 10 +++++----- 8 files changed, 19 insertions(+), 24 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 25659a685e2aa..e04035f70e36f 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -115,7 +115,7 @@ static inline void __SetPageMovable(struct page *page, static inline const struct movable_operations *page_movable_ops(struct page *page) { - VM_BUG_ON(!__PageMovable(page)); + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); =20 return (const struct movable_operations *) ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4fe5ee67535b2..c67163b73c5ec 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -750,7 +750,7 @@ static __always_inline bool __folio_test_movable(const = struct folio *folio) PAGE_MAPPING_MOVABLE; } =20 -static __always_inline bool __PageMovable(const struct page *page) +static __always_inline bool page_has_movable_ops(const struct page *page) { return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) =3D=3D PAGE_MAPPING_MOVABLE; diff --git a/mm/compaction.c b/mm/compaction.c index 5c37373017014..41fd6a1fe9a33 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1056,11 +1056,8 @@ isolate_migratepages_block(struct compact_control *c= c, unsigned long low_pfn, * Skip any other type of page */ if (!PageLRU(page)) { - /* - * __PageMovable can return false positive so we need - * to verify it under page_lock. - */ - if (unlikely(__PageMovable(page)) && + /* Isolation code will deal with any races. */ + if (unlikely(page_has_movable_ops(page)) && !PageIsolated(page)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b91a33fb6c694..9e2cff1999347 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1388,8 +1388,8 @@ static inline bool HWPoisonHandlable(struct page *pag= e, unsigned long flags) if (PageSlab(page)) return false; =20 - /* Soft offline could migrate non-LRU movable pages */ - if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page)) + /* Soft offline could migrate movable_ops pages */ + if ((flags & MF_SOFT_OFFLINE) && page_has_movable_ops(page)) return true; =20 return PageLRU(page) || is_free_buddy_page(page); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 62d45752f9f44..5fad126949d08 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1739,8 +1739,8 @@ bool mhp_range_allowed(u64 start, u64 size, bool need= _mapping) =20 #ifdef CONFIG_MEMORY_HOTREMOVE /* - * Scan pfn range [start,end) to find movable/migratable pages (LRU pages, - * non-lru movable pages and hugepages). Will skip over most unmovable + * Scan pfn range [start,end) to find movable/migratable pages (LRU and + * hugetlb folio, movable_ops pages). Will skip over most unmovable * pages (esp., pages that can be skipped when offlining), but bail out on * definitely unmovable pages. * @@ -1759,9 +1759,7 @@ static int scan_movable_pages(unsigned long start, un= signed long end, struct folio *folio; =20 page =3D pfn_to_page(pfn); - if (PageLRU(page)) - goto found; - if (__PageMovable(page)) + if (PageLRU(page) || page_has_movable_ops(page)) goto found; =20 /* diff --git a/mm/migrate.c b/mm/migrate.c index 040484230aebc..587af35b7390d 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -94,7 +94,7 @@ bool isolate_movable_ops_page(struct page *page, isolate_= mode_t mode) * Note that once a page has movable_ops, it will stay that way * until the page was freed. */ - if (unlikely(!__PageMovable(page))) + if (unlikely(!page_has_movable_ops(page))) goto out_putfolio; =20 /* @@ -111,7 +111,7 @@ bool isolate_movable_ops_page(struct page *page, isolat= e_mode_t mode) if (unlikely(!folio_trylock(folio))) goto out_putfolio; =20 - VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); if (PageIsolated(page)) goto out_no_isolated; =20 @@ -153,7 +153,7 @@ static void putback_movable_ops_page(struct page *page) */ struct folio *folio =3D page_folio(page); =20 - VM_WARN_ON_ONCE_PAGE(!__PageMovable(page), page); + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); VM_WARN_ON_ONCE_PAGE(!PageIsolated(page), page); folio_lock(folio); page_movable_ops(page)->putback_page(page); @@ -192,7 +192,7 @@ static int migrate_movable_ops_page(struct page *dst, s= truct page *src, { int rc =3D MIGRATEPAGE_SUCCESS; =20 - VM_WARN_ON_ONCE_PAGE(!__PageMovable(src), src); + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src); VM_WARN_ON_ONCE_PAGE(!PageIsolated(src), src); rc =3D page_movable_ops(src)->migrate_page(dst, src, mode); if (rc =3D=3D MIGRATEPAGE_SUCCESS) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 44e56d31cfeb1..a134b9fa9520e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2005,7 +2005,7 @@ static bool prep_move_freepages_block(struct zone *zo= ne, struct page *page, * migration are movable. But we don't actually try * isolating, as that would be expensive. */ - if (PageLRU(page) || __PageMovable(page)) + if (PageLRU(page) || page_has_movable_ops(page)) (*num_movable)++; pfn++; } diff --git a/mm/page_isolation.c b/mm/page_isolation.c index ece3bfc56bcd5..b97b965b3ed01 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -21,9 +21,9 @@ * consequently belong to a single zone. * * PageLRU check without isolation or lru_lock could race so that - * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable - * check without lock_page also may miss some movable non-lru pages at - * race condition. So you can't expect this function should be exact. + * MIGRATE_MOVABLE block might include unmovable pages. Similarly, pages + * with movable_ops can only be identified some time after they were + * allocated. So you can't expect this function should be exact. * * Returns a page without holding a reference. If the caller wants to * dereference that page (e.g., dumping), it has to make sure that it @@ -133,7 +133,7 @@ static struct page *has_unmovable_pages(unsigned long s= tart_pfn, unsigned long e if ((mode =3D=3D PB_ISOLATE_MODE_MEM_OFFLINE) && PageOffline(page)) continue; =20 - if (__PageMovable(page) || PageLRU(page)) + if (PageLRU(page) || page_has_movable_ops(page)) continue; =20 /* @@ -421,7 +421,7 @@ static int isolate_single_pageblock(unsigned long bound= ary_pfn, * proper free and split handling for them. */ VM_WARN_ON_ONCE_PAGE(PageLRU(page), page); - VM_WARN_ON_ONCE_PAGE(__PageMovable(page), page); + VM_WARN_ON_ONCE_PAGE(page_has_movable_ops(page), page); =20 goto failed; } --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 D67B228EBFE for ; Mon, 30 Jun 2025 13:01:07 +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=1751288472; cv=none; b=MHd13sBIftt6bL5N2BhvV75DTUoUGbZXaJeG0Hsfc0BRl1bNW321h09pJI1y/knXi08c0lPoy1EXRRCxCQvvfwZuujX7brdfpLsYeZIqCb5p5s1yYvc7Tw06dImNYBkqQ3b6zcO0zASDtptJQdd4U+3DgT9s6ET5k4b4wcyHp2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288472; c=relaxed/simple; bh=iVcKD9ZKy+q0IZPfhKWFJvDMMmEVnhfUGzTuz3ApUIU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d6qeDOauclvpSjju+ea+pk55i97nqKR4/aDWWtFgq+6dNRHroZ6Q5++ndWQJP1P0sz4Hcb5ydbtqfAjUgYnhowexB9h4Kxfo6S/lLENvFT/0TKZpCx7zp8I9epbKN2+2KRVpWR90/sQ/y5FkxGChlPfKqNDsdyR5So6Btfpwlx4= 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=VDZzmIWS; arc=none smtp.client-ip=170.10.129.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="VDZzmIWS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288467; 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=IIzDkBhnyPsIOakhHuAsjx3fJM8m9J+HURfbhEZ1A0M=; b=VDZzmIWSbX3G9KlJMwOl3DbTqoYlps5DlVtS8ERMD/xpoZVArHNhIrhrEorgmYCSSIY9PJ ZgNJ/j8u2qCBzVICw/kRkQeBE4//2RzgUy5ClKkW2PVXQEIg7rYg6u4ipddUj72mPPuGIp hJjlZ/HdpRU1sS0QgeEt7Aqy54x4GvU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-l9odpnwaPeG4_JeKvLs3_A-1; Mon, 30 Jun 2025 09:01:05 -0400 X-MC-Unique: l9odpnwaPeG4_JeKvLs3_A-1 X-Mimecast-MFC-AGG-ID: l9odpnwaPeG4_JeKvLs3_A_1751288465 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45320bfc18dso22229305e9.1 for ; Mon, 30 Jun 2025 06:01:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288464; x=1751893264; 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=IIzDkBhnyPsIOakhHuAsjx3fJM8m9J+HURfbhEZ1A0M=; b=s5molGRVZbXEAPscojCiOnRkZGMXwZXflPraZrzm+pakUT3mNycDyMeNAKncT8mMfS WxbshI27DzZJJ42z3Vmv6uTyayKUMGtrPleScrxIYDW92o3JuPYGWimlFFMMvbiEj54b TK6j/L3FS4WUJHYHTkyrAsEjXZWmQ2N/HHoPQDSZZ5wmoOBZFLmV43daAQdpdqXiSBIK qrKFp5mNRDE44H0y1EwLKoxvt7r7kTVhJ1SGEO3XzJwpbIINv7fG4qsdCPFa3OrNDtOf b9ixJ2yg4JUvAEJPoGLXI0IlZXWa9ojplRU16yDYDQJB/gFehGY7WBYtyVsA5dYE9Alv V+gg== X-Gm-Message-State: AOJu0YzuPFfp+MC7aCqDxF+IM088C1B3Qdow07BxBo5pz1ncvQgz4wPL ehBuyCa7z2KilZejRCg+bgN6RwZ9QXX0qWpgCMRzejP1u8QCQFCkbnFo+y8UDcREdUkKZiq2jIx qbESpyAoexBk5/MNWrURG879RVnKWVGSr1bKWBsMcRazIDmyFnNjxqF3ql3jvKBcgvE9DuvWgUS M9q2qvuAGoZAIvwNKbT0+4p1aPXfKg54hK+5NAKjtEGfUXStlq X-Gm-Gg: ASbGnct05HhdJK8tdtC10bs1iYpxcOXW7B/3yC2lx8+zMrfidUSumRXU6TXjQxk+ygU /mapX4KSBm6XLuhqw8S69HtqAjNBHPmS7N+rn/R+cGfvM1cUdiTFCLhuE5XViUu6WVWNewbdlG/ QCvB//Cy6Icc+OTbn/Ij90ez6m8lgkldasuaLCkTCsTz9nOAk0kaR0xc3E8lyuJGNS76ZasaMSA 7d+9SJ6nyyi66ONZbQ8Z7tKtLOXLhR25D7I6fh3fej4C8GlHMfTsUS9q6RnYyI1oSdys4ra7gZX CEEWgnXuTBjpOJLKg2azMiXubf3OEznPGtFSgFTFZCfYc4mLXb4LR1KSBI0ki8u755FE0XKA0tD YTP5hUW4= X-Received: by 2002:a05:600c:1994:b0:450:d79d:3b16 with SMTP id 5b1f17b1804b1-4538f309394mr135241285e9.14.1751288463798; Mon, 30 Jun 2025 06:01:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7zExQWNaFUjIE00JTRK6K+i5BO8qjO8BpI1TRkHw1kVlVhDi4cL0K0LNLq7UFrw8vD2WvGA== X-Received: by 2002:a05:600c:1994:b0:450:d79d:3b16 with SMTP id 5b1f17b1804b1-4538f309394mr135239205e9.14.1751288462959; Mon, 30 Jun 2025 06:01:02 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823ad247sm170241515e9.26.2025.06.30.06.01.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:02 -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 v1 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios Date: Mon, 30 Jun 2025 14:59:58 +0200 Message-ID: <20250630130011.330477-18-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Currently, we only support migration of individual movable_ops pages, so we can not run into that. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- mm/page_isolation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index b97b965b3ed01..f72b6cd38b958 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -92,7 +92,7 @@ static struct page *has_unmovable_pages(unsigned long sta= rt_pfn, unsigned long e h =3D size_to_hstate(folio_size(folio)); if (h && !hugepage_migration_supported(h)) return page; - } else if (!folio_test_lru(folio) && !__folio_test_movable(folio)) { + } else if (!folio_test_lru(folio)) { return page; } =20 --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 A592428FFCF for ; Mon, 30 Jun 2025 13:01:13 +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=1751288478; cv=none; b=R5ihnUQmrHeEgUX+bP57HUs+Wn7x0bqPGgIgwGXlzPQLy08bpusZwUfsVpkW8+Q03cvzRFc33zBPPx2yVh4CH++yfmSUo9HeBIgIdWcEYjbDDPIGUyE3hrWGSM6YnPN5mR5/Xa61/OpAyz4rOpW4W/QZAUlq9MGfEiGmgRDfEFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288478; c=relaxed/simple; bh=JYH/x/ortLB+OYxymb8gQIrEBsMUH0D5wYAFvvj+W2Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gTkIXYnnBBp/Oa4bEfhgUBdZRrRzhAIdffKLCGkMxasI/Yv5RgiwLTEYH0ddUYZbw0DvbPHbHt55u8qR0ZdUMlevmvmFAYTDpmsU8ljK4EymJvUPLFX4a040joIcS4MqF8fw+ZhWg43yfMVvxV2/cwvq94z9vnXKH07gr4BDxx4= 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=aDXFOMAj; 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="aDXFOMAj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288472; 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=7h0E3JSTi0/tTXxhJU2J3wMLvxjdNIbt9+WrjT2dUzo=; b=aDXFOMAj4rNVeDo7xXLg/bSBPQfBIZyZK9eMIzQvqR78u+eQPHxRAaWd0Xe+g56NE5m7pq RduyngMk5Wl0JxjN0jfd2kvDmX+JZY/LZuvqKzVJ2VCtCOkXePPFW/2WWxtmR2Sqzjvfqz F1fVKjNeUKDE0Uf61XVBIaA0mZUqmIY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-71lSeK8QMOCKoEnqD8VoTg-1; Mon, 30 Jun 2025 09:01:09 -0400 X-MC-Unique: 71lSeK8QMOCKoEnqD8VoTg-1 X-Mimecast-MFC-AGG-ID: 71lSeK8QMOCKoEnqD8VoTg_1751288468 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a50816cc58so2335385f8f.3 for ; Mon, 30 Jun 2025 06:01:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288468; x=1751893268; 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=7h0E3JSTi0/tTXxhJU2J3wMLvxjdNIbt9+WrjT2dUzo=; b=tf38hLR91yZc1TOS+NmmCjsJnbkzsZbdcnOGUjm4Sn6Mtda5DOFoAc8pMuf3Dx5Kjm gP1GSmNuQ9egD0qVc81s8bMrEOIzrVafjZYhG4/sTDzMEL8Mgsa4XjFFxbmFy6Fo83Nm t/IRGEDHYvizWf6PXgWxf0VX+Ib3bExhj/bSC4o6xHy32br4ub8KTtHbDO71+xwmuI/T rimS95hJa26T3S1B1mWaipIyyjjGrsWNFmy2HdLoMw4kcKys8I99Qq1Y5qrfdZjL4L1z GQG9taprC23M2eABqz7AU/ANQCP49+Qjm4GSKC20/a45cEjlFVrhI+0CN+Aof3OihR7i Ut7A== X-Gm-Message-State: AOJu0YysrCZZASMDtRnq5VzZU4dJNelSW/OoTwGSUASGGXjhR0Vg2RNJ x9Aey3DaVNNi3YtzTmvIWTYpzxeecUzmMb44l8xRri3Iq4axq8rghfbj2E9gQ7KV8ICW/GuMT9P 9ZX1gYfXFK+5CA/3c/IHHOQbyyvj+T240zCotW56CoMwMybk8vRYb+7t8c0CiYID2GpgELasBXC SGavK0zBxM2HUT/+wXlV8CjifhEwp+UVHBBsK37LXfqSD/IgxY X-Gm-Gg: ASbGncuCLrJXKm96wUQrKGWt+VWgKZmA7dLNZesr3w9qOyhdnBVljeRVyjYo9LDKoNH amtiXtfFCosjYjKPIfy2gbWTjATRpa38gdAe+45mwQTxArPK8O8jG+SccST9X6M6dSGF4KvtIjZ WGqkqyCbuyVWCDQFvAucEZGYh1nJI96PYpYB7PDXlHtBgJTfUtJ964g/xRspS81Pgp1I4n9d+cy RB/PVBIuF6wjYE9YdqpX95JhtmmWymz72nxJ6+QqWQ+RoBL0+Te95R2T54pfXKzT2G9s9+uJ36E eWBVrQ1eqbGllC7F89V9rzuHeDQUjTFbmTU309ANyNfm3o2JomwSiM/Yvbq+UWmCv4+bEinzN1m SRA7omjw= X-Received: by 2002:a05:6000:1789:b0:3a4:dbdf:7154 with SMTP id ffacd0b85a97d-3a90be88de8mr11746796f8f.54.1751288467344; Mon, 30 Jun 2025 06:01:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJi8Mvk9HNQG/V6DvaTdZ9vax3u5pZXK1PzboQ8KoLkq4f/Yx4ezN8OGoebh91nmBSeSp6MQ== X-Received: by 2002:a05:6000:1789:b0:3a4:dbdf:7154 with SMTP id ffacd0b85a97d-3a90be88de8mr11746576f8f.54.1751288465725; Mon, 30 Jun 2025 06:01:05 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e52a26sm10500359f8f.51.2025.06.30.06.01.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01: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 v1 18/29] mm: remove __folio_test_movable() Date: Mon, 30 Jun 2025 14:59:59 +0200 Message-ID: <20250630130011.330477-19-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Convert to page_has_movable_ops(). While at it, cleanup relevant code a bit. The data_race() in migrate_folio_unmap() is questionable: we already hold a page reference, and concurrent modifications can no longer happen (iow: __ClearPageMovable() no longer exists). Drop it for now, we'll rework page_has_movable_ops() soon either way to no longer rely on page->mapping. Wherever we cast from folio to page now is a clear sign that this code has to be decoupled. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/page-flags.h | 6 ------ mm/migrate.c | 43 ++++++++++++-------------------------- mm/vmscan.c | 6 ++++-- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index c67163b73c5ec..4c27ebb689e3c 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -744,12 +744,6 @@ static __always_inline bool PageAnon(const struct page= *page) return folio_test_anon(page_folio(page)); } =20 -static __always_inline bool __folio_test_movable(const struct folio *folio) -{ - return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) =3D=3D - PAGE_MAPPING_MOVABLE; -} - static __always_inline bool page_has_movable_ops(const struct page *page) { return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) =3D=3D diff --git a/mm/migrate.c b/mm/migrate.c index 587af35b7390d..15d3c1031530c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -219,12 +219,7 @@ void putback_movable_pages(struct list_head *l) continue; } list_del(&folio->lru); - /* - * We isolated non-lru movable folio so here we can use - * __folio_test_movable because LRU folio's mapping cannot - * have PAGE_MAPPING_MOVABLE. - */ - if (unlikely(__folio_test_movable(folio))) { + if (unlikely(page_has_movable_ops(&folio->page))) { putback_movable_ops_page(&folio->page); } else { node_stat_mod_folio(folio, NR_ISOLATED_ANON + @@ -237,26 +232,20 @@ void putback_movable_pages(struct list_head *l) /* Must be called with an elevated refcount on the non-hugetlb folio */ bool isolate_folio_to_list(struct folio *folio, struct list_head *list) { - bool isolated, lru; - if (folio_test_hugetlb(folio)) return folio_isolate_hugetlb(folio, list); =20 - lru =3D !__folio_test_movable(folio); - if (lru) - isolated =3D folio_isolate_lru(folio); - else - isolated =3D isolate_movable_ops_page(&folio->page, - ISOLATE_UNEVICTABLE); - - if (!isolated) - return false; - - list_add(&folio->lru, list); - if (lru) + if (page_has_movable_ops(&folio->page)) { + if (!isolate_movable_ops_page(&folio->page, + ISOLATE_UNEVICTABLE)) + return false; + } else { + if (!folio_isolate_lru(folio)) + return false; node_stat_add_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio)); - + } + list_add(&folio->lru, list); return true; } =20 @@ -1140,12 +1129,7 @@ static void migrate_folio_undo_dst(struct folio *dst= , bool locked, static void migrate_folio_done(struct folio *src, enum migrate_reason reason) { - /* - * Compaction can migrate also non-LRU pages which are - * not accounted to NR_ISOLATED_*. They can be recognized - * as __folio_test_movable - */ - if (likely(!__folio_test_movable(src)) && reason !=3D MR_DEMOTION) + if (likely(!page_has_movable_ops(&src->page)) && reason !=3D MR_DEMOTION) mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + folio_is_file_lru(src), -folio_nr_pages(src)); =20 @@ -1164,7 +1148,6 @@ static int migrate_folio_unmap(new_folio_t get_new_fo= lio, int rc =3D -EAGAIN; int old_page_state =3D 0; struct anon_vma *anon_vma =3D NULL; - bool is_lru =3D data_race(!__folio_test_movable(src)); bool locked =3D false; bool dst_locked =3D false; =20 @@ -1265,7 +1248,7 @@ static int migrate_folio_unmap(new_folio_t get_new_fo= lio, goto out; dst_locked =3D true; =20 - if (unlikely(!is_lru)) { + if (unlikely(page_has_movable_ops(&src->page))) { __migrate_folio_record(dst, old_page_state, anon_vma); return MIGRATEPAGE_UNMAP; } @@ -1330,7 +1313,7 @@ static int migrate_folio_move(free_folio_t put_new_fo= lio, unsigned long private, prev =3D dst->lru.prev; list_del(&dst->lru); =20 - if (unlikely(__folio_test_movable(src))) { + if (unlikely(page_has_movable_ops(&src->page))) { rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); if (rc) goto out; diff --git a/mm/vmscan.c b/mm/vmscan.c index 098bcc821fc74..103dfc729a823 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1658,9 +1658,11 @@ unsigned int reclaim_clean_pages_from_list(struct zo= ne *zone, unsigned int noreclaim_flag; =20 list_for_each_entry_safe(folio, next, folio_list, lru) { + /* TODO: these pages should not even appear in this list. */ + if (page_has_movable_ops(&folio->page)) + continue; if (!folio_test_hugetlb(folio) && folio_is_file_lru(folio) && - !folio_test_dirty(folio) && !__folio_test_movable(folio) && - !folio_test_unevictable(folio)) { + !folio_test_dirty(folio) && !folio_test_unevictable(folio)) { folio_clear_active(folio); list_move(&folio->lru, &clean_folios); } --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 6FED328B7C8 for ; Mon, 30 Jun 2025 13:01:18 +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=1751288483; cv=none; b=Fxg9d3yEtIqQsL6G44bDZgOXMpE3gHtsUoIdXe+NX//LEYpAMILG7Sjo7zP3ps0iY8lJQ8aLbzlyL+trWiOj3Nyx0ukexhoOwFWRJFaOq8ep87BFeKglnwKJRCMnbYkzyEaw20YI96CBh3DXLs+Ru14msPT5KfX9D5R9ZqtLE4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288483; c=relaxed/simple; bh=7xJKM0wHRvJlTPEV4a7GEQ9RPiMSBfT28nYx22hkvv4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=REuO2Ej3gIwHqISPKMJ4WBEbAyHUAlyTgkBnLBOj3byxUxg5U03UhdoNt1hq0TdeFqIsjKDl11N0NZ3vgRFFLhLPNEEEmE7bXLKHSH7Ehzx74QRN1g9twizV/GI1028HLCOKUIik20ACxFQQgmHjILH3E9o8kIWfSaHVJEuQ9A8= 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=UhzyM+SF; arc=none smtp.client-ip=170.10.129.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="UhzyM+SF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288477; 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=oFoZ+ZWQ3WhLHAA9oaT1biVSgyM158tXM490LDGSwpg=; b=UhzyM+SFAGFmxSVNzshl86G//E5ScevoHVJs6UTfqUexpjeJnGBjVT2fr1ziQaa/OzbDcT NL3/L3GoAUG9ltCPHm7g7GB8izJwK6MOytBxSZDR9L3HVx0WEvYfHBd/YGOTcJSw60OPVr 3K0YNZRdEbBatnLdw2mPVPy1y5CyDBc= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-2xcv_oj4PR2hFeeDUraerw-1; Mon, 30 Jun 2025 09:01:14 -0400 X-MC-Unique: 2xcv_oj4PR2hFeeDUraerw-1 X-Mimecast-MFC-AGG-ID: 2xcv_oj4PR2hFeeDUraerw_1751288469 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4eb6fcd88so1588408f8f.1 for ; Mon, 30 Jun 2025 06:01:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288469; x=1751893269; 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=oFoZ+ZWQ3WhLHAA9oaT1biVSgyM158tXM490LDGSwpg=; b=kpQszsQTyUxO2XYw355epeMgD91tceT6VUfUnEePFK+u2fH2x7SECYkUnlNs8fZz0x ulDhto7V6ohTKUYIz5p1AQhGBvG8Qnu3wE9z94hD2Yy1Os4lhnuHj3t/gOCYOqKif1P+ vlfGSRvXfp6xVJ9dRUL4+AAK2ko+nMaXpbfqz4d5l0vVTFsGnWu6Il1KQiP2NGa9BAB6 LYmSHC6ifWkpxaBJrPmftswcfn8TVTq6z04B60h/KT+cy4svOg5/3sTPW2asBbLCfqlC 2Zgkzwp5c+AoestmMd2K1C/gZgHFVQxnV3+qbOMOG3C/CwR8lsX0XLb5VVQb/XoAwv8q /yFg== X-Gm-Message-State: AOJu0Yyvh8ipD5SHxL491UvWHMkzAZ6vYHXnaq9ER3KG2WUKMPHFCJWk FIqN9M2WWMFg81Sqhj0OqPFtjxHpRX2tHW6bZbohB8m3/xcytaaeyO5luiWijSihu/WCwsvaPz3 oBD/1q8dCAlC7XWOSoafvGX57kuxYkcBZR16UGpR0XCSrHz4m5r4Csir1LibN73aKt8vI5YUoGz el19o6Pz3Atr/28u7HTtUUHMd0GogwBUMDYEU8KTNSfXIAJjsm X-Gm-Gg: ASbGncuSMO3MPd85olKpA4u1bd7cTk9nkt8wkzjfSu3PRfwnAIymJNG3Dtt52HC3Hhd 4YW6o/LW8l1BISK5IlQmiFiDG7+3Plm8JzCTVK14xqTwF9yYL5GpkSUqFlWE7pObhFqoOHcvWJ9 mfA0McKKVVWiSHD8h5rY7Y5tKCiiljzWTqkjGJtO/1u0sXhhlMb9+yhwdr9L7bgcfwUFXs0ftHC Mjhyv4HqxG0I+8Hy4E4ELwEBw0ZdhEva9Oz60oFYeTEJRcrcO6RdzPy22xoiKKrcGTv4xIQMKOP 4u/Hc6dP76nQc+ceXdo7eaHYyew0cAIE6KTWA9SHS6GZPFDhREflY5psxelr2PP1g/zwVTu7O5V 2VlXuVqk= X-Received: by 2002:adf:b301:0:b0:3a6:e1e7:2a88 with SMTP id ffacd0b85a97d-3a8ff05093dmr8389717f8f.57.1751288469223; Mon, 30 Jun 2025 06:01:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5PkTKThngrkuXzEjagSlsXbjs5Ldlq7ssFfZO6/XI6tZJegQpsM73QRMndkrSs09mr6FuKQ== X-Received: by 2002:adf:b301:0:b0:3a6:e1e7:2a88 with SMTP id ffacd0b85a97d-3a8ff05093dmr8389609f8f.57.1751288468412; Mon, 30 Jun 2025 06:01:08 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e52c23sm10479813f8f.52.2025.06.30.06.01.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:07 -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 v1 19/29] mm: stop storing migration_ops in page->mapping Date: Mon, 30 Jun 2025 15:00:00 +0200 Message-ID: <20250630130011.330477-20-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" ... instead, look them up statically based on the page type. Maybe in the future we want a registration interface? At least for now, it can be easily handled using the two page types that actually support page migration. The remaining usage of page->mapping is to flag such pages as actually being movable (having movable_ops), which we will change next. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h | 14 ++------------ include/linux/zsmalloc.h | 2 ++ mm/balloon_compaction.c | 1 - mm/compaction.c | 5 ++--- mm/migrate.c | 23 +++++++++++++++++++++++ mm/zpdesc.h | 5 ++--- mm/zsmalloc.c | 8 +++----- 8 files changed, 35 insertions(+), 25 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 9bce8e9f5018c..a8a1706cc56f3 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -92,7 +92,7 @@ static inline void balloon_page_insert(struct balloon_dev= _info *balloon, struct page *page) { __SetPageOffline(page); - __SetPageMovable(page, &balloon_mops); + __SetPageMovable(page); set_page_private(page, (unsigned long)balloon); list_add(&page->lru, &balloon->pages); } diff --git a/include/linux/migrate.h b/include/linux/migrate.h index e04035f70e36f..6aece3f3c8be8 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -104,23 +104,13 @@ static inline int migrate_huge_page_move_mapping(stru= ct address_space *mapping, #endif /* CONFIG_MIGRATION */ =20 #ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page, const struct movable_operations *= ops); +void __SetPageMovable(struct page *page); #else -static inline void __SetPageMovable(struct page *page, - const struct movable_operations *ops) +static inline void __SetPageMovable(struct page *page) { } #endif =20 -static inline -const struct movable_operations *page_movable_ops(struct page *page) -{ - VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); - - return (const struct movable_operations *) - ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); -} - #ifdef CONFIG_NUMA_BALANCING int migrate_misplaced_folio_prepare(struct folio *folio, struct vm_area_struct *vma, int node); diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h index 13e9cc5490f71..f3ccff2d966cd 100644 --- a/include/linux/zsmalloc.h +++ b/include/linux/zsmalloc.h @@ -46,4 +46,6 @@ void zs_obj_read_end(struct zs_pool *pool, unsigned long = handle, void zs_obj_write(struct zs_pool *pool, unsigned long handle, void *handle_mem, size_t mem_len); =20 +extern const struct movable_operations zsmalloc_mops; + #endif diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index e4f1a122d786b..2a4a649805c11 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -253,6 +253,5 @@ const struct movable_operations balloon_mops =3D { .isolate_page =3D balloon_page_isolate, .putback_page =3D balloon_page_putback, }; -EXPORT_SYMBOL_GPL(balloon_mops); =20 #endif /* CONFIG_BALLOON_COMPACTION */ diff --git a/mm/compaction.c b/mm/compaction.c index 41fd6a1fe9a33..348eb754cb227 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,11 +114,10 @@ static unsigned long release_free_list(struct list_he= ad *freepages) } =20 #ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page, const struct movable_operations *= mops) +void __SetPageMovable(struct page *page) { VM_BUG_ON_PAGE(!PageLocked(page), page); - VM_BUG_ON_PAGE((unsigned long)mops & PAGE_MAPPING_MOVABLE, page); - page->mapping =3D (void *)((unsigned long)mops | PAGE_MAPPING_MOVABLE); + page->mapping =3D (void *)(PAGE_MAPPING_MOVABLE); } EXPORT_SYMBOL(__SetPageMovable); =20 diff --git a/mm/migrate.c b/mm/migrate.c index 15d3c1031530c..c6c9998014ec8 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include =20 #include =20 @@ -51,6 +53,27 @@ #include "internal.h" #include "swap.h" =20 +static const struct movable_operations *page_movable_ops(struct page *page) +{ + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); + + /* + * If we enable page migration for a page of a certain type by marking + * it as movable, the page type must be sticky until the page gets freed + * back to the buddy. + */ +#ifdef CONFIG_BALLOON_COMPACTION + if (PageOffline(page)) + /* Only balloon compaction sets PageOffline pages movable. */ + return &balloon_mops; +#endif /* CONFIG_BALLOON_COMPACTION */ +#if defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) + if (PageZsmalloc(page)) + return &zsmalloc_mops; +#endif /* defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) */ + return NULL; +} + /** * isolate_movable_ops_page - isolate a movable_ops page for migration * @page: The page. diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 5763f36039736..6855d9e2732d8 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -152,10 +152,9 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long = pfn) return page_zpdesc(pfn_to_page(pfn)); } =20 -static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, - const struct movable_operations *mops) +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc) { - __SetPageMovable(zpdesc_page(zpdesc), mops); + __SetPageMovable(zpdesc_page(zpdesc)); } =20 static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 72c2b7562c511..7192196b9421d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1684,8 +1684,6 @@ static void lock_zspage(struct zspage *zspage) =20 #ifdef CONFIG_COMPACTION =20 -static const struct movable_operations zsmalloc_mops; - static void replace_sub_page(struct size_class *class, struct zspage *zspa= ge, struct zpdesc *newzpdesc, struct zpdesc *oldzpdesc) { @@ -1708,7 +1706,7 @@ static void replace_sub_page(struct size_class *class= , struct zspage *zspage, set_first_obj_offset(newzpdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) newzpdesc->handle =3D oldzpdesc->handle; - __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); + __zpdesc_set_movable(newzpdesc); } =20 static bool zs_page_isolate(struct page *page, isolate_mode_t mode) @@ -1815,7 +1813,7 @@ static void zs_page_putback(struct page *page) { } =20 -static const struct movable_operations zsmalloc_mops =3D { +const struct movable_operations zsmalloc_mops =3D { .isolate_page =3D zs_page_isolate, .migrate_page =3D zs_page_migrate, .putback_page =3D zs_page_putback, @@ -1878,7 +1876,7 @@ static void SetZsPageMovable(struct zs_pool *pool, st= ruct zspage *zspage) =20 do { WARN_ON(!zpdesc_trylock(zpdesc)); - __zpdesc_set_movable(zpdesc, &zsmalloc_mops); + __zpdesc_set_movable(zpdesc); zpdesc_unlock(zpdesc); } while ((zpdesc =3D get_next_zpdesc(zpdesc)) !=3D NULL); } --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 8105F28FFCF for ; Mon, 30 Jun 2025 13:01:24 +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=1751288489; cv=none; b=DDSXC9KVugBFWrGbp2HzUhe0CvwMUr0TvSjsvpR7DgRacOJapQLqBAZgkncEF5LT0T4BdVGwxjT4yTRpyeOawkzYqjP3IhlPt+g06E3EnhcKJZIAWQHAYfm2gmBCrZkTImmP/ElFKm9OCnHaFdbEBMHqrSAxxB4ifIozQzEdBhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288489; c=relaxed/simple; bh=D2PbFe0TDfmvy4F7QksDSc2nDP/2ml7oXT564/tmyrg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CDuhAZjXIbmnB4iOYpEN0estuEUa8r6bWQPqLXuuurZzf3+JGA7SuBamrXUzJEVDgAob8CZj20pa3enPMlYsEa5y2/kxGJ6/fX0/ERC3oum6zArVS0a+64Rn6Ue2Oqrcu4duy2Rc7be4Ohi926mUsRV2nv/lvS5JbVrjcg1gv10= 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=VrRMlK7J; 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="VrRMlK7J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288483; 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=5CWZGmTCKoL1hvQ/VyDOYb4tfyG8bAvHTQtdKrki7q8=; b=VrRMlK7JxTf3tYzuaRKtyawbmFkVC7L9KZAcx5laMie1QrLYLL85ynGh0b+AIY1PCtupXR mB2gHbT56txgQGnaPBlqXqa8qJn5EB2gU64B4w0fucYBL/V8ybnE/GV5m8z1067aG/qpLT kYqd2YNN+Y88OCpwDBG27y5Bo0EDsTg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-13Wa-D2zN2y25FaMgbw0RA-1; Mon, 30 Jun 2025 09:01:15 -0400 X-MC-Unique: 13Wa-D2zN2y25FaMgbw0RA-1 X-Mimecast-MFC-AGG-ID: 13Wa-D2zN2y25FaMgbw0RA_1751288474 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4fac7fa27so723548f8f.0 for ; Mon, 30 Jun 2025 06:01:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288474; x=1751893274; 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=5CWZGmTCKoL1hvQ/VyDOYb4tfyG8bAvHTQtdKrki7q8=; b=U4tNpNAN419VE0qifpJdiRO/kUOlQFpB2m/CQwMRmF4BBTnbGYMUBA+oNDeSyYQUih io6xEleb8gAu3BNGxnCSoxaukzCKJSJ6UFyv0u54ozHkkz85tpiUZcdm1G9mkdDdwPZW v/3pceyNJYf8ng1Sqiu285uy20hnR0LRdDv123Lz8iS8cAPvAPGl3c6QcFYi6swu3JTt ei8KCyNT28HqLFPVBjJlKf6amTrDW0kXJ7mTqud5J8U5GWAJFteJxzx1ZVg+T50b42Bp ZMSNT7q8yHyH5yKZObGRv01ZwD1ohKj5kdhuOKEVrquw1Yv8m0uWo0lNOPi9lK4P8VIR 4iuA== X-Gm-Message-State: AOJu0Yz/MW0HD0nYcDu9h7gTAfRFy3i50cw8JiunCSX+C4RRY9Hbne8G KUzdVQdqHZ78ZowwKsMHdETerESXDuONadp9Z1dL6/W+0Axg8z/iC6IlVo0XPeceDVm5XeNPX0S xfRz8Dw7Kg+JMue50EfeZEh4NbNsNQ1GAbRJrRb+4qT5A/xNaUmw7yBGYKzWuz6u2su0dwFQXNk kWuz3HFo56EsAPzP411zsx17rRci4pNP0uIxB+ewJxrB9e7GzY X-Gm-Gg: ASbGncstY+Q3zoXdJRggj3LBmWmGOKBl4uEb4AhflPrCm+hxhAsONfM6LIL0Hrt2ay+ EnD3VScAll+4IT7euQU2U7hQeAKT1PMIu9skL1sgLlf1NH8aJw+zfe3/NeGGAMeah94QP2IgIhH DkpKTQVcpjDSppjwbiFE3EE03jLvoKHKX2EY6+biE1nmO4KhPWz9O19uZlEQNVEXJUDfEt80JPW At/TDawqpf6gX2ba0OjtrR2Hxl5qEnDGJI9NAmN2ZYD7mhNmQveuMo54kZvmhXekptBHc5tdJpi DEoMqiJHgzJXV7w0UuhcFcILZQXJ0Wyb778jrRyZQT9l9TZRYUYtkJe1PRRdQ1OOGAdBxVisgZa O7kCey4E= X-Received: by 2002:a05:6000:2389:b0:3a4:e54c:adf2 with SMTP id ffacd0b85a97d-3a8f577fdc6mr12847957f8f.5.1751288473450; Mon, 30 Jun 2025 06:01:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJ/9NZM6h/Hx4c51fxjBgSM5e1fSGf05yUg5gzNhGMoVHxQHOqc17Ov8/o/Ak8l4p0X+gKZQ== X-Received: by 2002:a05:6000:2389:b0:3a4:e54c:adf2 with SMTP id ffacd0b85a97d-3a8f577fdc6mr12847789f8f.5.1751288472235; Mon, 30 Jun 2025 06:01:12 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4538a3fe592sm131954105e9.21.2025.06.30.06.01.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:11 -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 v1 20/29] mm: convert "movable" flag in page->mapping to a page flag Date: Mon, 30 Jun 2025 15:00:01 +0200 Message-ID: <20250630130011.330477-21-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Instead, let's use a page flag. As the page flag can result in false-positives, glue it to the page types for which we support/implement movable_ops page migration. The flag reused by PageMovableOps() might be sued by other pages, so warning in case it is set in page_has_movable_ops() might result in false-positive warnings. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h | 8 ----- include/linux/page-flags.h | 52 ++++++++++++++++++++++++------ mm/compaction.c | 6 ---- mm/zpdesc.h | 2 +- 5 files changed, 44 insertions(+), 26 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index a8a1706cc56f3..b222b0737c466 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -92,7 +92,7 @@ static inline void balloon_page_insert(struct balloon_dev= _info *balloon, struct page *page) { __SetPageOffline(page); - __SetPageMovable(page); + SetPageMovableOps(page); set_page_private(page, (unsigned long)balloon); list_add(&page->lru, &balloon->pages); } diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 6aece3f3c8be8..acadd41e0b5cf 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -103,14 +103,6 @@ static inline int migrate_huge_page_move_mapping(struc= t address_space *mapping, =20 #endif /* CONFIG_MIGRATION */ =20 -#ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page); -#else -static inline void __SetPageMovable(struct page *page) -{ -} -#endif - #ifdef CONFIG_NUMA_BALANCING int migrate_misplaced_folio_prepare(struct folio *folio, struct vm_area_struct *vma, int node); diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4c27ebb689e3c..016a6e6fa428a 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -170,6 +170,11 @@ enum pageflags { /* non-lru isolated movable page */ PG_isolated =3D PG_reclaim, =20 +#ifdef CONFIG_MIGRATION + /* this is a movable_ops page (for selected typed pages only) */ + PG_movable_ops =3D PG_uptodate, +#endif + /* Only valid for buddy pages. Used to track pages that are reported */ PG_reported =3D PG_uptodate, =20 @@ -698,9 +703,6 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) * bit; and then folio->mapping points, not to an anon_vma, but to a priva= te * structure which KSM associates with that merged page. See ksm.h. * - * PAGE_MAPPING_KSM without PAGE_MAPPING_ANON is used for non-lru movable - * page and then folio->mapping points to a struct movable_operations. - * * Please note that, confusingly, "folio_mapping" refers to the inode * address_space which maps the folio from disk; whereas "folio_mapped" * refers to user virtual address space into which the folio is mapped. @@ -743,13 +745,6 @@ static __always_inline bool PageAnon(const struct page= *page) { return folio_test_anon(page_folio(page)); } - -static __always_inline bool page_has_movable_ops(const struct page *page) -{ - return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) =3D=3D - PAGE_MAPPING_MOVABLE; -} - #ifdef CONFIG_KSM /* * A KSM page is one of those write-protected "shared pages" or "merged pa= ges" @@ -1133,6 +1128,43 @@ bool is_free_buddy_page(const struct page *page); =20 PAGEFLAG(Isolated, isolated, PF_ANY); =20 +#ifdef CONFIG_MIGRATION +/* + * This page is migratable through movable_ops (for selected typed pages + * only). + * + * Page migration of such pages might fail, for example, if the page is + * already isolated by somebody else, or if the page is about to get freed. + * + * While a subsystem might set selected typed pages that support page migr= ation + * as being movable through movable_ops, it must never clear this flag. + * + * This flag is only cleared when the page is freed back to the buddy. + * + * Only selected page types support this flag (see page_movable_ops()) and + * the flag might be used in other context for other pages. Always use + * page_has_movable_ops() instead. + */ +PAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL); +#else +PAGEFLAG_FALSE(MovableOps, movable_ops); +#endif + +/** + * page_has_movable_ops - test for a movable_ops page + * @page The page to test. + * + * Test whether this is a movable_ops page. Such pages will stay that + * way until freed. + * + * Returns true if this is a movable_ops page, otherwise false. + */ +static inline bool page_has_movable_ops(const struct page *page) +{ + return PageMovableOps(page) && + (PageOffline(page) || PageZsmalloc(page)); +} + static __always_inline int PageAnonExclusive(const struct page *page) { VM_BUG_ON_PGFLAGS(!PageAnon(page), page); diff --git a/mm/compaction.c b/mm/compaction.c index 348eb754cb227..349f4ea0ec3e5 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,12 +114,6 @@ static unsigned long release_free_list(struct list_hea= d *freepages) } =20 #ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page) -{ - VM_BUG_ON_PAGE(!PageLocked(page), page); - page->mapping =3D (void *)(PAGE_MAPPING_MOVABLE); -} -EXPORT_SYMBOL(__SetPageMovable); =20 /* Do not skip compaction more than 64 times */ #define COMPACT_MAX_DEFER_SHIFT 6 diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 6855d9e2732d8..25bf5ea0beb83 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -154,7 +154,7 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long p= fn) =20 static inline void __zpdesc_set_movable(struct zpdesc *zpdesc) { - __SetPageMovable(zpdesc_page(zpdesc)); + SetPageMovableOps(zpdesc_page(zpdesc)); } =20 static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 A60A1291C0F for ; Mon, 30 Jun 2025 13:01:22 +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=1751288487; cv=none; b=f5tY7jHwwXVdl4JdH+V1KxtIodrZV+nDUxmsMcFhZDhUKI2dPWvQjkbNvy86qbMYj17Vu7m/IOQwLjhJPY/K1010j+rJKky6tbungEP5K5/U9ISQ292cht8FDVF8EI72Ke4nGDJcMyxkufn0e/mxl2c6oXJNDb4Qrk73UHBXu3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288487; c=relaxed/simple; bh=spRVtsrXQeSiPctpyfXJIwnWB6OKPlVJ51M2oKx7H3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J5bag+aiUStdQlbN6lUuWljX84cz+xvhz2OTE88nhxrdcQICOiOQ/JmGymUowJ6kcCuM+8mqswQzB+yzEmkGAgfV5ZXNFBjJtpAfIc6sO72z0SvOa62L74wMO8jZJ0IOootSAZw8YsWOVIRFcGftoBbtseh5171pSA/nVLo1rps= 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=PYNOPmKV; arc=none smtp.client-ip=170.10.129.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="PYNOPmKV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288481; 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=Uh556eqkqkK5IlF5dOoZ8tKW5iYbjU9GjHiIRIfOQPo=; b=PYNOPmKVqA5gV7JKoyFAR2N6ea6FGKaFjCn1TK2mWgq9AYM4KC4uVxI1nX5WLRgXEVTgut 8i5GNTBjCBB5979Gb106HpeByt3HG/gA7veU+ht0+y3Hkc/UfuR7UKaHtxUZE56K1Mkt1Y NMZt2AO/4UUionj/lRNMYoDhTGskBG8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-133-eQOped5JNfiYHgPD21gmRQ-1; Mon, 30 Jun 2025 09:01:19 -0400 X-MC-Unique: eQOped5JNfiYHgPD21gmRQ-1 X-Mimecast-MFC-AGG-ID: eQOped5JNfiYHgPD21gmRQ_1751288478 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a6da94a532so1368427f8f.2 for ; Mon, 30 Jun 2025 06:01:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288478; x=1751893278; 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=Uh556eqkqkK5IlF5dOoZ8tKW5iYbjU9GjHiIRIfOQPo=; b=TcHSawMTa6KtIm1bi0/aSVzreM+QBmd1UPU5I/hFP/RN3lYvjADj6fDxC0pdaoKM4r 8GXq9N/93HF0QL4p6oII7pNt4ehOABSWad7RNAzB+q+evEzRzWH8VYWkf6xwUgxW6Pnt egXMfXmg7MwC2s5Hiwovu8LWBhO+E1PFpFZB+JtZ7MsDcAghEn5/5FTnv/+0dVnd90Yq SH78hP75T354WwRpVdxo5HOdiP+bqrMeOarKrMIPRcNNXbiFcaVX/Vnq+ZHi1ypfxUIE YlfMbiYib7qOeDp0lXRbnDb1QfEQma9RttHUI25NzV7YTklaa4SdU8TNe+8tsznCPlzW ufaw== X-Gm-Message-State: AOJu0YyCU/WPu/GzJ5FwqhjEz/pp1SxT1p0Shf4ZmJwwJ8M1HuT22j2j GKih2uyWveHAdVay3+iC/5fJBuGjkhDSNt1oT4OvXzC1563/Prw0AEmTxhWt139e6fx6Bgk67gC KOF0Z8PTwtwfNBYRGaryzHsCUKaOkjXHyQu4PqkLXkywxdZiG/N0rjvWax6bJto/ywQgR63KR8o sVp44mGerCXe7237x4/JBSbhbcilhhPHd3V5YwU7UFSlcGhsUi X-Gm-Gg: ASbGnctl7/pDaLKFc9mRx0TYafVTwtxnctN4u9nOx2jsSzb1IMahkLlcVvLF6xi+ujo 5ZBqcTcqPSpOJEm+2f5r7dnce1j7wGbMovyF/jONlXS2OG67BhRTF4ePuL9hRQ6dzkRVhYlkEn7 n4oS736mSUmC8k1GuE2mNFtGTHEq+shgdqvxnwyD5AoRnzTRwjoQ+RGtPMU//7H9Z/C8C2KOA9j Kq4Aa6J7OEHyDm8f8puHBBcAOqUlxkq6T5zNiVlqwrr2Y8SdeeNFyNbazguD6ko5CblnJJhKabb F3cgRZdZw5VE22ZCz1BIMHO6+xhv0NbLPgISGlUTgJjo03FLyfiTCnLUp3dUWYGwvhQATcFNZ9P PfKB5Rmg= X-Received: by 2002:a05:6000:2112:b0:3a5:298a:3207 with SMTP id ffacd0b85a97d-3a8ffadfademr8628989f8f.48.1751288477359; Mon, 30 Jun 2025 06:01:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY9r1p0u/0kcCjG+nghTpHrdk2mNLfE9z/HI6liANtRmtIL3dMCa2Pbf5hTgLV/B0o5eULaw== X-Received: by 2002:a05:6000:2112:b0:3a5:298a:3207 with SMTP id ffacd0b85a97d-3a8ffadfademr8628767f8f.48.1751288474943; Mon, 30 Jun 2025 06:01:14 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e52a35sm10528754f8f.57.2025.06.30.06.01.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:14 -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 v1 21/29] mm: rename PG_isolated to PG_movable_ops_isolated Date: Mon, 30 Jun 2025 15:00:02 +0200 Message-ID: <20250630130011.330477-22-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's rename the flag to make it clearer where it applies (not folios ...). While at it, define the flag only with CONFIG_MIGRATION. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/page-flags.h | 16 +++++++++++----- mm/compaction.c | 2 +- mm/migrate.c | 14 +++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 016a6e6fa428a..aa48b05536bca 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -167,10 +167,9 @@ enum pageflags { /* Remapped by swiotlb-xen. */ PG_xen_remapped =3D PG_owner_priv_1, =20 - /* non-lru isolated movable page */ - PG_isolated =3D PG_reclaim, - #ifdef CONFIG_MIGRATION + /* movable_ops page that is isolated for migration */ + PG_movable_ops_isolated =3D PG_reclaim, /* this is a movable_ops page (for selected typed pages only) */ PG_movable_ops =3D PG_uptodate, #endif @@ -1126,8 +1125,6 @@ static inline bool folio_contain_hwpoisoned_page(stru= ct folio *folio) =20 bool is_free_buddy_page(const struct page *page); =20 -PAGEFLAG(Isolated, isolated, PF_ANY); - #ifdef CONFIG_MIGRATION /* * This page is migratable through movable_ops (for selected typed pages @@ -1146,8 +1143,17 @@ PAGEFLAG(Isolated, isolated, PF_ANY); * page_has_movable_ops() instead. */ PAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL); +/* + * A movable_ops page has this flag set while it is isolated for migration. + * This flag primarily protects against concurrent migration attempts. + * + * Once migration ended (success or failure), the flag is cleared. The + * flag is managed by the migration core. + */ +PAGEFLAG(MovableOpsIsolated, movable_ops_isolated, PF_NO_TAIL); #else PAGEFLAG_FALSE(MovableOps, movable_ops); +PAGEFLAG_FALSE(MovableOpsIsolated, movable_ops_isolated); #endif =20 /** diff --git a/mm/compaction.c b/mm/compaction.c index 349f4ea0ec3e5..bf021b31c7ece 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1051,7 +1051,7 @@ isolate_migratepages_block(struct compact_control *cc= , unsigned long low_pfn, if (!PageLRU(page)) { /* Isolation code will deal with any races. */ if (unlikely(page_has_movable_ops(page)) && - !PageIsolated(page)) { + !PageMovableOpsIsolated(page)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); locked =3D NULL; diff --git a/mm/migrate.c b/mm/migrate.c index c6c9998014ec8..62a3ee590b245 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -135,7 +135,7 @@ bool isolate_movable_ops_page(struct page *page, isolat= e_mode_t mode) goto out_putfolio; =20 VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); - if (PageIsolated(page)) + if (PageMovableOpsIsolated(page)) goto out_no_isolated; =20 mops =3D page_movable_ops(page); @@ -146,8 +146,8 @@ bool isolate_movable_ops_page(struct page *page, isolat= e_mode_t mode) goto out_no_isolated; =20 /* Driver shouldn't use the isolated flag */ - VM_WARN_ON_ONCE_PAGE(PageIsolated(page), page); - SetPageIsolated(page); + VM_WARN_ON_ONCE_PAGE(PageMovableOpsIsolated(page), page); + SetPageMovableOpsIsolated(page); folio_unlock(folio); =20 return true; @@ -177,10 +177,10 @@ static void putback_movable_ops_page(struct page *pag= e) struct folio *folio =3D page_folio(page); =20 VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); - VM_WARN_ON_ONCE_PAGE(!PageIsolated(page), page); + VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(page), page); folio_lock(folio); page_movable_ops(page)->putback_page(page); - ClearPageIsolated(page); + ClearPageMovableOpsIsolated(page); folio_unlock(folio); folio_put(folio); } @@ -216,10 +216,10 @@ static int migrate_movable_ops_page(struct page *dst,= struct page *src, int rc =3D MIGRATEPAGE_SUCCESS; =20 VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src); - VM_WARN_ON_ONCE_PAGE(!PageIsolated(src), src); + VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(src), src); rc =3D page_movable_ops(src)->migrate_page(dst, src, mode); if (rc =3D=3D MIGRATEPAGE_SUCCESS) - ClearPageIsolated(src); + ClearPageMovableOpsIsolated(src); return rc; } =20 --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 C14DA293B53 for ; Mon, 30 Jun 2025 13:01:29 +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=1751288491; cv=none; b=N4aN+DoRmd972Txpmfd2XFMVNZbtfEIz3nCM6EJkOv1C8G/U4QdeyxPXGn5XUFJLLfdPn6GsJ7UdVmVvYPBetueh3TiLgsD+aA99XXGMzy0ypwo+JI2hhl6+syxAtE0GPf0IUzcqhWVEkhar5kpphK75aSenj15cNHMGi7NNAac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288491; c=relaxed/simple; bh=bX2O32zo3eRkpyjOPjcPSMjPx5jynwq3pH5hPVFisUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pjPnC9HAijbvt4WAZl/JdXpSTQpawKwmmFcCFoNuZSGR+D1neuSbsYsmD8fb67Xkwl0RZCJuVkkumn+ILIqHvyaX1b+SM03sinzeWZ0aDjeRJmOKYzXdjo1wMfg6mLrKyRE8UTuteo58i0zIZN4rS3FFwzEzx9Ja1KKwMuK9KKE= 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=cLYI1Ifd; arc=none smtp.client-ip=170.10.129.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="cLYI1Ifd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288489; 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=lqdlPSrzqUfx0/Anfl8VFepfeUNo5Gqwl7mCFswBHro=; b=cLYI1Ifdq87OfqHzL97m/GJ5+7HTHc6hl5jekhY9fUVbudZQxSnHvMgiWPmEWu59QIMoal tVTYMebiAoNunQquUoYO4patmtB2DQFkAFwAClw1CxjaqtNIRIu1LsMV4b3PPTi4sskqw7 jEYG2N0r+fSbfAyFUa7WU+2sM2cVP7s= 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-473-vmdBftSbPuq10TCJxlxShg-1; Mon, 30 Jun 2025 09:01:24 -0400 X-MC-Unique: vmdBftSbPuq10TCJxlxShg-1 X-Mimecast-MFC-AGG-ID: vmdBftSbPuq10TCJxlxShg_1751288480 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-453691d0a1dso11776525e9.0 for ; Mon, 30 Jun 2025 06:01:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288480; x=1751893280; 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=lqdlPSrzqUfx0/Anfl8VFepfeUNo5Gqwl7mCFswBHro=; b=Kmlsv1anFu/DG5yIcUZuOfGxLetNR7nMgQs8/Tc9grO5dPocHvpak8Ven5VkuMRq8Y osmz3XVw8xJ3bRuhbZplzukGfB78R7YDmeoAQ236t/mxSlA5i1Pqrldkw+APh1TnC82/ XYXI2kr4vpm5X08rTf5T7moCV79V118TFzXjRNNPykVpnUcI37ivQGONS3JKfkVjs0O1 YlQ9Yvqk7uEpj/LkYtgUaqlBkGUfIbtmxcReJN/lNzCGlg+FNq3vY9JwGil7G71LU7tN 8+5NeEtwW/8Glokn7+56LZVHCLmz6m1prh8IQDzJfCBDAIakE8zWoYFjId7pACUmmR5I kdqw== X-Gm-Message-State: AOJu0Yxr9yL3H0Invd6xAz6vEnc4+Osx2PFnB+GqD5YGYxkTUBmKv/lm sd7kNxQmRqjHXTFl2NX5b/UhItQ6Sao8FsXfLez/3Yy4nuO/7QxHURdLlsnW8VfC5V9l8PbYz9K zFb1KPgwlEUZqsphmVHF0dpefVOEfm9hePjBm57o3RiVXY5IOkmvQ2951ehk1bFO5M1snEx/FGS vmudhWSxKfm88FpsR+Vr4EGTFvdEldUS7HdZCxmmOEUpyoPA2X X-Gm-Gg: ASbGncsL+nvchr3VWCjg4TAxTEl4PRmP4IJZjVJnOMpaKCJNcyGDzbmNWfe47gnbJAE N19g9FpvxQyC7yz512CvHCxKJSRZZvrOt+V2DkMk2P6QuTO0VNRAEbXk0pg5j0ohEe0NetiIm/o 75LUZCx3HexGQ1dEIQbHYbzC+zCeiMbjg2XHa6NIsL1m5X+/d4LXsY95j+IvAOi1JOZNzz8cKBV b2hUj0vNJje56dtqOcjMu/Vnjo6zJlB6JMq9mShr2FuU08BGAMOKLZ4O6DLhSf2LETXtkYlxCD0 bnxLA3JF4N73XwA5jlUNBwCFT9DCLyC80rjxL5NmBpcopiJwCIyGAhr82E1QQZwKyANHGvEzt2G ia+gaaeI= X-Received: by 2002:a05:600c:190b:b0:440:6a1a:d89f with SMTP id 5b1f17b1804b1-4538ee4fd6cmr142843235e9.4.1751288479382; Mon, 30 Jun 2025 06:01:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIe1HafHWQMdBGxTE/8gmXCwDECQtvb4nkW8MYtHAgLmX5UxDUSKKTFebF7rirr8hhXGCxDA== X-Received: by 2002:a05:600c:190b:b0:440:6a1a:d89f with SMTP id 5b1f17b1804b1-4538ee4fd6cmr142840675e9.4.1751288477814; Mon, 30 Jun 2025 06:01:17 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e528a9sm10541491f8f.60.2025.06.30.06.01.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:17 -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 v1 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM Date: Mon, 30 Jun 2025 15:00:03 +0200 Message-ID: <20250630130011.330477-23-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" KSM is the only remaining user, let's rename the flag. While at it, adjust to remaining page -> folio in the doc. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/page-flags.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index aa48b05536bca..abed972e902e1 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -697,10 +697,10 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) * folio->mapping points to its anon_vma, not to a struct address_space; * with the PAGE_MAPPING_ANON bit set to distinguish it. See rmap.h. * - * On an anonymous page in a VM_MERGEABLE area, if CONFIG_KSM is enabled, - * the PAGE_MAPPING_MOVABLE bit may be set along with the PAGE_MAPPING_ANON + * On an anonymous folio in a VM_MERGEABLE area, if CONFIG_KSM is enabled, + * the PAGE_MAPPING_ANON_KSM bit may be set along with the PAGE_MAPPING_AN= ON * bit; and then folio->mapping points, not to an anon_vma, but to a priva= te - * structure which KSM associates with that merged page. See ksm.h. + * structure which KSM associates with that merged folio. See ksm.h. * * Please note that, confusingly, "folio_mapping" refers to the inode * address_space which maps the folio from disk; whereas "folio_mapped" @@ -714,9 +714,9 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) * See mm/slab.h. */ #define PAGE_MAPPING_ANON 0x1 -#define PAGE_MAPPING_MOVABLE 0x2 -#define PAGE_MAPPING_KSM (PAGE_MAPPING_ANON | PAGE_MAPPING_MOVABLE) -#define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_MOVABLE) +#define PAGE_MAPPING_ANON_KSM 0x2 +#define PAGE_MAPPING_KSM (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) +#define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) =20 static __always_inline bool folio_mapping_flags(const struct folio *folio) { --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 654312949F6 for ; Mon, 30 Jun 2025 13:01:31 +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=1751288493; cv=none; b=tYP2UZ35L9XGN7bjzjOiFQncmjPpJ71jgOeIgNwbxJZounXyqKxPfQ7LRhF/tDic6bzAsD+pisCKuH9hYmSCLBgLI/6h/pm/+CW5s9lrWxHTmxC6OZuGcKUad1ZGK2Vp8F+MKY0CqrCE5+Dmfku9UBniDMu7mL6pRYNbnQ2xGvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288493; c=relaxed/simple; bh=dmz2lbFNKy/5bI6qe76v2+ePPpX7/2WN9a22IrkHZ0c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o5uSiGhCuzDIeMtnQRXeaS6cqiuchYlyjsKARjX8w2ylg0TcHvOsd6z3wv1ZSMczt1RsPQ6NKGPg5uxcIzluv7x+WvTCFEIwaSypiPJHcY1Qsjg/R6ENUeeYAmfb2EOV4HaOr/eXLpbSFaG4ZfzucIh0O/GVof5SDs6yF6zDd+Y= 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=K3aaQIvo; arc=none smtp.client-ip=170.10.129.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="K3aaQIvo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288490; 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=1QasDl39udqF142inQM/Baaw9xGb/E/13xzKchOHRQc=; b=K3aaQIvoZPp6kNfNJDxLdSk7hiho1D1pxq90gvuaNECRXS9ampc2unXC3Zf2RahykzcBBx M4uBYaMr1P/b7TMg5HZoYe/CE0+a7yjH4Z1pOpGWSLeUo+3AElJdsxI/JItTzOF5cjmNEC tgjUm4e10ZeUUZaz6+l8k4ZZnaUXth4= 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-245-ESyXFydYNcGKiSIrXd4WHQ-1; Mon, 30 Jun 2025 09:01:24 -0400 X-MC-Unique: ESyXFydYNcGKiSIrXd4WHQ-1 X-Mimecast-MFC-AGG-ID: ESyXFydYNcGKiSIrXd4WHQ_1751288483 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-451d7de4ae3so21219605e9.2 for ; Mon, 30 Jun 2025 06:01:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288483; x=1751893283; 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=1QasDl39udqF142inQM/Baaw9xGb/E/13xzKchOHRQc=; b=vGe2zkJJQACBBvZU5HKNA//5CR3mLdGZ7iXTzc/Ut8rgseyjJP3OGNPVssYOo2IP2R k4ij/hOSulvst6yqYSq46N/ABM4rza5omLJl1AIyCd90JQNwZXKmcIpWkg2Sg4CAMqvu c21daLDIGfWv9PU6tDoVyWQY3N6bgbqfdA3eKmTSmKd6Zzh13THroqL6MZpoyaHJ/Ku0 gZEsyZIOOJdalru28IGFhnLHx8U4rtp91jFlgNEf5qeNxpWaYfYLbi+8pN0NDcLaiYls GNKeToRJlesS4cWsasOe88XR7jtHYBKmljVtWXwPY3f+6JR+keQ9Clp85WHXTIMjuI8o x6sg== X-Gm-Message-State: AOJu0YyTq//THdwbuT5S7rsidTvV5vf1g/2Wehxitt8dCFLRC/oLbXdB HD3D/jTr4onONRvfmZg9fT1HyArMmfuuHhpuyI3T6So77EfoTdqwHStThmIlXAXjH2PMkIs6mI4 0zw/XY9FWBvYviAYyCU0POY9FGrTnO5R5s/Q3LmvhqMRSgkl+7gDnGG+caSy1QHNrPN4KRiFCyT /rg8MkI8o74zl83doRZx7Fjk/n2qXXZym4jebh8aF7aAKta9A2 X-Gm-Gg: ASbGnctgV3Xh3RY9XKjf5JtERw885e0Vf0eXVCvUP1AbbSkGqaMAgczqxMNnZk2P79g k6v+eQTVSxnXYZQPyN6qZpRH+mZ7+DT8s6RnELAyR9cL5Hr1xd+oy7cPDO54Kwd4FulEjLBrEPx jAQmztWuh8JbrBXnO0fhKyHrAFLaLDl67efS/EIDxPx7qkc0vd7ATHvCWj3g/yZhlw2tHM5iGI5 dtm01ueUhbdRk3pxnls5I/RW0V1yMUGgsNJKn2VEu4MjNC4kV9PQP8787ewKJsPO0iZLDjoRklx uUUJ9UbmarYhUZGHkTPY/N3vEpgNj+rMZOr1rHbjVbPsisGEfid+FXFj/8HblGMFrH5f0QwZpnp /Z3c9EBs= X-Received: by 2002:a05:600c:8b6f:b0:43c:fe15:41dd with SMTP id 5b1f17b1804b1-4538f9b3107mr110835685e9.6.1751288481992; Mon, 30 Jun 2025 06:01:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBR/gPcUn8RUWOgibmcJHz2SRyFZ4ktYe9xvVAqHy7XBBioQHhn6lWeSN3C2mJi+xEdsRK1w== X-Received: by 2002:a05:600c:8b6f:b0:43c:fe15:41dd with SMTP id 5b1f17b1804b1-4538f9b3107mr110833985e9.6.1751288480607; Mon, 30 Jun 2025 06:01:20 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823ad0fesm169286405e9.25.2025.06.30.06.01.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:20 -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 v1 23/29] mm/page-alloc: remove PageMappingFlags() Date: Mon, 30 Jun 2025 15:00:04 +0200 Message-ID: <20250630130011.330477-24-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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 now simply check for PageAnon() and remove PageMappingFlags(). ... and while at it, use the folio instead and operate on folio->mapping. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/page-flags.h | 5 ----- mm/page_alloc.c | 7 +++---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index abed972e902e1..f539bd5e14200 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -723,11 +723,6 @@ static __always_inline bool folio_mapping_flags(const = struct folio *folio) return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) !=3D 0; } =20 -static __always_inline bool PageMappingFlags(const struct page *page) -{ - return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) !=3D 0; -} - static __always_inline bool folio_test_anon(const struct folio *folio) { return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) !=3D 0; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a134b9fa9520e..a0ebcc5f54bb2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1375,10 +1375,9 @@ __always_inline bool free_pages_prepare(struct page = *page, (page + i)->flags &=3D ~PAGE_FLAGS_CHECK_AT_PREP; } } - if (PageMappingFlags(page)) { - if (PageAnon(page)) - mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); - page->mapping =3D NULL; + if (folio_test_anon(folio)) { + mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); + folio->mapping =3D NULL; } if (unlikely(page_has_type(page))) page->page_type =3D UINT_MAX; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 AB3BA28B7FE for ; Mon, 30 Jun 2025 13:01:31 +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=1751288493; cv=none; b=Cra7quxUisWV8pvOwDCEsp81jOZQQZqj9jzkkX0R3/5QgDHADxgLs8k3BWdGxjwdFsWXYrvN4+FSdmuS9YrLyhsyTDAzH1cBt2+zXzwtaGLhmxuEAHc5EQhyhmiH+hugdWc39RMejSumbdJSi9ivx1zW6NMIw+uoNqzLMQMKHyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288493; c=relaxed/simple; bh=isaI58t0kWAv0VvFIE40k9qBORzA058ggEZ88nMmJIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oLNvC84ckBuwhXH5xoYL/3wKrKMfivG9DbMlkuuCrIkUZWoWxN4OyvGUetDJB0zvAUCKOo6RKuHvJnIG4E+VvPLm+UhfgtszhcSzrWVYO0rOP5kiU5oQucoN7hpror3uIUtV1UEdFTRTDN474m4R2b3tDwl/tOiuz1//cEjLhJY= 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=DjcjmF5Q; arc=none smtp.client-ip=170.10.129.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="DjcjmF5Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288490; 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=olXYTUdhc5G5HcwZfX2j4qOOcGFF0hDyepBOzPt910g=; b=DjcjmF5QXc4e4sCCO+Y+sKXbONV97BF2T9CM950rqRPpWxOAFha0su0cBeKrUKFT4O3zek tPuCDnGPtAM4yhMwCO8zBLKvf3exzFrVygM/cL05QObO4JzmPuojvE6Y5Lt8wlsqzlrfbT BAVEQiDEjJ5JFncrracmQSku/rd4Hko= 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-481-12c2_6HIPl6J9-uC3n7dKw-1; Mon, 30 Jun 2025 09:01:28 -0400 X-MC-Unique: 12c2_6HIPl6J9-uC3n7dKw-1 X-Mimecast-MFC-AGG-ID: 12c2_6HIPl6J9-uC3n7dKw_1751288487 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45320bfc18dso22231915e9.1 for ; Mon, 30 Jun 2025 06:01:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288487; x=1751893287; 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=olXYTUdhc5G5HcwZfX2j4qOOcGFF0hDyepBOzPt910g=; b=F0WC+GHbFMIXloZu1BSw47RZs5ykWkaQ2MnonAF3sjv/hannmlhNOsELQ3E1OcKH71 rh+K8nSY7DNlfFRaoWY03bmhv4XoO3r/iaYJIa9c080r9DZSu/zIIERi2g+AUNHEFvpR hP9DLssxDOe3WyW40654YeDl/iZe+8Ppw4Nom4zeNrw1ihvM4J3EnLyb541h4V6z3Ubi 0Q2E/eRfjbXAdcmxmjAPvUlwyuZ25VaiEuyligiKq6oWDbHJf0/BPIMNiDBOsLiXLgn9 nrqakA4BcdCs9roZB6eO0Q3bTHG9f4nFwjDrnqSsiv/nBVY39OL0szIqBiihtuMsa/d/ xukw== X-Gm-Message-State: AOJu0YzHjCxvVCqtxekSx0tHsi9DfOqAqU0pPckEM1k9iHxIF98eYRdD aK9L32N3Q31j7Yz64SmlzsezsIzbQ49bdm1Yv2kKj5kDToVa61m9oc0y2mXonZM2BBawc0CIHWh odG5AutjLroFuTKQpnvRzld9vJd7FrBsC8Gh86qA98uYR6rfXtB642Ii1o+RuPQrSc3IwN511Cm 9+m75eGrbit75JejT4gkMfbP688MLDnx+tdqYwm6XSo4iibIYS X-Gm-Gg: ASbGncuV77BwM7kWGVIeM4Ni9pevutC7uLSEgS5lxH1y/TDw3rDHe4cmqw1l9rqjvug y69XF0uz3tkej1IhrHHLNkdl4LemzdiRLKtZYoO4/gs/jILyLkrBhyEtnEWOgfpmSRWSr0W2eAH pTSowJKxVlPDsDaCI21QIu5XXb7loLx5qIYKVicOH1U0rmJB4ChEh1zrWOAq5xeV7XX6sby0T15 rKvlQeduBsFISmZuFL1xLaMXAsHOMBFHavLHDWcvKR3XweydR3EIMGdRylajMNGsadkMoLCG0aL RQh0p0f/pRZodPH5+Y/GC1x26MKLPYfpSGntionK9dzIsx0h71Z0U46LRRdPnC8VqWWYV+QSp4Q YKjg7zCo= X-Received: by 2002:a05:600c:5306:b0:442:f4a3:a2c0 with SMTP id 5b1f17b1804b1-4538f308f2amr124064825e9.13.1751288486413; Mon, 30 Jun 2025 06:01:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9JbLrxBujZu2VjgMn1mCOlcQzRUhKdRhzGdc0P5pPEt9jKXPpDvx4Rwh6D/+Yae/APwbOBQ== X-Received: by 2002:a05:600c:5306:b0:442:f4a3:a2c0 with SMTP id 5b1f17b1804b1-4538f308f2amr124062795e9.13.1751288484673; Mon, 30 Jun 2025 06:01:24 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823b913esm162071665e9.33.2025.06.30.06.01.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:24 -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 v1 24/29] mm/page-flags: remove folio_mapping_flags() Date: Mon, 30 Jun 2025 15:00:05 +0200 Message-ID: <20250630130011.330477-25-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" It's unused and the page counterpart is gone, so let's remove it. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/page-flags.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index f539bd5e14200..b42986a578b71 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -718,11 +718,6 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) #define PAGE_MAPPING_KSM (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) #define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) =20 -static __always_inline bool folio_mapping_flags(const struct folio *folio) -{ - return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) !=3D 0; -} - static __always_inline bool folio_test_anon(const struct folio *folio) { return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) !=3D 0; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 A7A4D29A336 for ; Mon, 30 Jun 2025 13:01:35 +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=1751288500; cv=none; b=VEUvHOQL+rHVAVgHVrcg2BtniWcyYQtbQKHI/TEqyTGZblu+aIM6qOv40tfs0LTJJbBW2/aoQkTTjjVpLfGPOtkfbUq+2VUX8nlWqvUAHY+RHyNLLzAtDnUC4w9KNy2EDhawyvtdjlN4smQ76CiucAuBjO9iZpmyd48jfTivhds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288500; c=relaxed/simple; bh=WVagca6sn8mP5NDz3wa45UlfrVOPRD5IKy9vkw5Bh+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CIDLfkW4fbG5bQfV8zV48lkkKAtTXH6Ab7vAgLHrRjvQ8WosgjIJ4ZnPhqAC84GQ9oiT0RobssfMuffauKVJYmVPa2EI7opWPx1ggNJLxNkCnMTr0/XN0sPGIiPwyOPUolJKgp/wq2VdzlzlI+8sD2Ir4LaUHqaCeSrn7JGTiY0= 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=NUky5LuC; 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="NUky5LuC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288494; 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=sNIKdrm33pmadL5+MWfVmqXzrIDEGwSSahCLerJeLDg=; b=NUky5LuCMXqWY91+cZAlpEDAns7VdR4IsqaoXmZ9YpsxTkayaCztvThogQvxvpS5Ogh5QS Ib2QaQTEz0vbtImw+viQvFL8qmY9kJnX4UaJRjQv1a7d/kzwoTNWv/MI+yXjtxqDv/5/fB E1mWz8wMzBvSXOf9FZ4GCRwmgqVwaQU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-r4eUJxvfMxO2LyxwFDaIMg-1; Mon, 30 Jun 2025 09:01:32 -0400 X-MC-Unique: r4eUJxvfMxO2LyxwFDaIMg-1 X-Mimecast-MFC-AGG-ID: r4eUJxvfMxO2LyxwFDaIMg_1751288492 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-450d6768d4dso13586485e9.2 for ; Mon, 30 Jun 2025 06:01:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288491; x=1751893291; 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=sNIKdrm33pmadL5+MWfVmqXzrIDEGwSSahCLerJeLDg=; b=jGyU0k7VCbMlaY6IotJYrrW1CDoL95sPNe0G1zcOOM53wBvXBsu0ISpVyEhF3fp8CX VnWZlvZnZ8AN0YSXT4CLnrjK4ae8KrHyCnHvyvtQL2wbRht5Igr29+iZoGw/8KMNzCIr dNyfahR/Jncj1KVjIe0f39T+XoB2RNGwmhBSqHobU9N75p49Tl7eyqTt8TcdZRhBiQKr hL8o9jjOoNjA6FDF7Do1VBkt1JgvZ1ng4kzTOCXwiG6/NIf/PpPDpypsgzGsEeh8T3a8 /HAnmUkGT07N8IymO1EItG5XOUPNrqjUTYAM2oJp7AYesfZiBf4qAGanhbuT7ECWu570 wQlg== X-Gm-Message-State: AOJu0YzJ+Jd7/k61cNKqgdTfJN38XIGWW1ANgBf2NvM5l9Z9yxgIe0Nz x5X5Us8rk2Q6LWSIZVZfKYfUxaUchv3U6TQkVy2Qjb7xhySuG5TMfOV3shlb55qyCkADBntZwJe Nl8TKC/I+f/BOArY/XhH7kBZiKZbleHWgagco0GhHsv/4MG9ZTIuqi7YBQSDJpdgtrunpZr+V2A Tp0dU14IliJbnRsMUexMV81m0H15tuPWS8qz6LLPjihM7/y0g5 X-Gm-Gg: ASbGncvTCaYUdrK04A1NXCuGrwYiJ9B+KXPn0DpTJZf0LK5GJoAjg3QWKUn8o3UyCR8 HXKvzd9p2eJ824LxkdvdFPnaTrv/tphHv2ez0oKgtpTHMndLPQetsPdvMwLYqUAMssSBw576edq k74JknSHIoY23MA88zvWAfEA7XVO5l/F1feKGNzxPkg1aF8a1yu01oFXiInZLjNjCyzTS2gWXGY 8l2V3be69+HZrgZeKKY3aUX+w1rs0IrDsyahGbAxc41Y7VEupUqx7vwUZ8kS9OyfII3B6M1K+9e ydZz6tUX5JpwQ/26nBLb+KErGnTmZmqZHUOg/0oAXNDuh/KXiULWA7Cjm9caLhEzrRYhL0pdi3Q FZVGDhLw= X-Received: by 2002:a05:600c:4fd1:b0:453:6f1:bdba with SMTP id 5b1f17b1804b1-4538ee60a60mr107461805e9.20.1751288490946; Mon, 30 Jun 2025 06:01:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvKPbKK01jDGKdO7HMFpJHGVfeP34xEfryqVjaTqeCy8FfNy/5uAgcgaE7N6g1euFItwJ1Ng== X-Received: by 2002:a05:600c:4fd1:b0:453:6f1:bdba with SMTP id 5b1f17b1804b1-4538ee60a60mr107459575e9.20.1751288488983; Mon, 30 Jun 2025 06:01:28 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823ad01csm166146565e9.22.2025.06.30.06.01.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:28 -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 v1 25/29] mm: simplify folio_expected_ref_count() Date: Mon, 30 Jun 2025 15:00:06 +0200 Message-ID: <20250630130011.330477-26-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Now that PAGE_MAPPING_MOVABLE is gone, we can simplify and rely on the folio_test_anon() test only. ... but staring at the users, this function should never even have been called on movable_ops pages. E.g., * __buffer_migrate_folio() does not make sense for them * folio_migrate_mapping() does not make sense for them * migrate_huge_page_move_mapping() does not make sense for them * __migrate_folio() does not make sense for them * ... and khugepaged should never stumble over them Let's simply refuse typed pages (which includes slab) except hugetlb, and WARN. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- include/linux/mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6a5447bd43fd8..f6ef4c4eb536b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2176,13 +2176,13 @@ static inline int folio_expected_ref_count(const st= ruct folio *folio) const int order =3D folio_order(folio); int ref_count =3D 0; =20 - if (WARN_ON_ONCE(folio_test_slab(folio))) + if (WARN_ON_ONCE(page_has_type(&folio->page) && !folio_test_hugetlb(folio= ))) return 0; =20 if (folio_test_anon(folio)) { /* One reference per page from the swapcache. */ ref_count +=3D folio_test_swapcache(folio) << order; - } else if (!((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS)) { + } else { /* One reference per page from the pagecache. */ ref_count +=3D !!folio->mapping << order; /* One reference from PG_private. */ --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 79E6228BA99 for ; Mon, 30 Jun 2025 13:01:38 +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=1751288500; cv=none; b=TTRlSv4YsQzWtMxqW1ddp/bpq81YUcMlLBFCNngkUcLKX/LUZ6P1vree7yhLe06x/LTIIkDKom6Dkp6MG9nijLNRyOlcZyF5gWPraQrSJmIjV+PqO36eKxHfzeQuB8fvxgf48r4gGJesZxRaE0d6kjfxQzWhagdwIW8h2wH2dCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288500; c=relaxed/simple; bh=sY41E8QlryNIz/N60cOOIdEBgQ2GOqTNOd7DJG88wKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YfIbyuoFMsXECdZ21Mhv88ERFN4tjiV3iSVvouPD/e5qvIrEs9ikz97ProonFNAj1R9Ycib3zDhnC03nbD8FuG5CKes0wntmMBTXjt6oEaY0n6PVL/UJVeYWU4aYeEHZoqYD4lIvi5QOx6D4CyhrgPkJQB0otKYukfvCUE6tMH4= 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=Q05XlrYh; 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="Q05XlrYh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288497; 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=BiKNy1Je5I/aSf6ESo6pQ+N6U0Nvk4b2III6Kq4QTYQ=; b=Q05XlrYh/05J9X9K9Xhpj2kwFtNh4a6Ky8ZPWYKSD20X5Z2vRTYh6/Bb8/+ppV2M/MmWyV wpQqT86zo7uzqN+6w4UFLz3n+chY4qvXalh9bw77oHn+Y7oOIevGoccfT03/EO3S/q5ylX Z6w/Qsfstk0/VAgJr6oYTFPP+9tYW0E= 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-178-74aLucCJNE6t5aGSYOWnsw-1; Mon, 30 Jun 2025 09:01:36 -0400 X-MC-Unique: 74aLucCJNE6t5aGSYOWnsw-1 X-Mimecast-MFC-AGG-ID: 74aLucCJNE6t5aGSYOWnsw_1751288495 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-450d244bfabso18182865e9.0 for ; Mon, 30 Jun 2025 06:01:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288495; x=1751893295; 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=BiKNy1Je5I/aSf6ESo6pQ+N6U0Nvk4b2III6Kq4QTYQ=; b=Na8J5XjPMWDfRRqt1xzp8VZ2wWIGwGSIF354r8K+DNNM6z0sk3LE/hrV61xxx8fT9N CcOW3VU7o9Jz07sxXZMyvtNhaqOsJahUvhdyqAo34wu3k6WaJP0XGWyKdo85M8ptvEZc kjclzXuLgvtDZgGKWiXM+w1G4zh10y/1M/3VT5lSkDG2zSkcdpKW5fpejBM/a/BEhLr4 zFWOIpKsvQdkHYZSfwirX1PWC1aLV7/uvfGqN/O8qBOnnf31rcLXBFPR7t+ndNgzuHRw sULKwfmdGVVkDxvL8TEsXNBl7zY+faz6KqQR82VrIIMDNkX7D/h3jjOscUGdM2CaFwQ7 H3Vw== X-Gm-Message-State: AOJu0YzQYNn+oO+/OB9v0XZ/PXPVlEn8RgwEXkJoarUKIybF3AOH10l/ NrbwB/jgE7M99XwNNsmoN411SLUWflqemLMjK/WkhCxbTX0VFUT3F2/u59soI9l0C/a1m+EWGz4 NN4yIAlQxJvFN8zVBRfBf/WE2pwZGNnI7W4CPB/r5cHL/LANubp6zFY5WfY+GU90W9d9GvZrCqK QF3fJ+dpMGzYW4Cjj3BI6/lf2ufVLOLgkar9PKnUTpKDpe663K X-Gm-Gg: ASbGncsZC+Q0JlMSm04bxiVvUeyvB1gfSiV4SFf79qDJOyDd0FOTqm3QnyFVD4K5Kiy J/dGHKu/ZUI9xPHWqgcwpmbROEkqfgtg4rb2xW/yAOXV4WPToLSwxP13VNtnwZ7o6HCA/9+oMuv lPmQDg5L5DN/vk8XSyQeR7MUsaKgVRey9SBS2H7wQtZdBsLLVUzyuKs7rpqfbwZOCbnI3Q+hvcg 9iJTvlWJakN1qZDz+wTdVyYNP809M33UuHDswtIBGb2bFweNVOluy/ynBnTmjnGEAV3FznFR8J1 IO+kr5joBH1RsCRz1+9MtEfzzjgLo1YCY+7PA4Ep7g3Lhed260ipmrNvMnbtoWetEgnlyyP7ZoS 6xZu2sWU= X-Received: by 2002:a05:600c:4589:b0:453:6ca:16b1 with SMTP id 5b1f17b1804b1-4538ee8c469mr119764985e9.26.1751288494156; Mon, 30 Jun 2025 06:01:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiJmwoKLZcCxWychQade1/84yFZ9EU0gll620+fxkzbn8N5oVEpXl6i+ceDpg9b8O44fsYZg== X-Received: by 2002:a05:600c:4589:b0:453:6ca:16b1 with SMTP id 5b1f17b1804b1-4538ee8c469mr119763175e9.26.1751288492802; Mon, 30 Jun 2025 06:01:32 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453823b6fa2sm165793365e9.27.2025.06.30.06.01.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:32 -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 v1 26/29] mm: rename PAGE_MAPPING_* to FOLIO_MAPPING_* Date: Mon, 30 Jun 2025 15:00:07 +0200 Message-ID: <20250630130011.330477-27-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Now that the mapping flags are only used for folios, let's rename the defines. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- fs/proc/page.c | 4 ++-- include/linux/fs.h | 2 +- include/linux/mm_types.h | 1 - include/linux/page-flags.h | 20 ++++++++++---------- include/linux/pagemap.h | 2 +- mm/gup.c | 4 ++-- mm/internal.h | 2 +- mm/ksm.c | 4 ++-- mm/rmap.c | 16 ++++++++-------- mm/util.c | 6 +++--- 10 files changed, 30 insertions(+), 31 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 999af26c72985..0cdc78c0d23fa 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -149,7 +149,7 @@ u64 stable_page_flags(const struct page *page) =20 k =3D folio->flags; mapping =3D (unsigned long)folio->mapping; - is_anon =3D mapping & PAGE_MAPPING_ANON; + is_anon =3D mapping & FOLIO_MAPPING_ANON; =20 /* * pseudo flags for the well known (anonymous) memory mapped pages @@ -158,7 +158,7 @@ u64 stable_page_flags(const struct page *page) u |=3D 1 << KPF_MMAP; if (is_anon) { u |=3D 1 << KPF_ANON; - if (mapping & PAGE_MAPPING_KSM) + if (mapping & FOLIO_MAPPING_KSM) u |=3D 1 << KPF_KSM; } =20 diff --git a/include/linux/fs.h b/include/linux/fs.h index c68c9a07cda33..9b0de18746815 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -526,7 +526,7 @@ struct address_space { /* * On most architectures that alignment is already the case; but * must be enforced here for CRIS, to let the least significant bit - * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. + * of struct folio's "mapping" pointer be used for FOLIO_MAPPING_ANON. */ =20 /* XArray tags, for tagging dirty and writeback pages in the pagecache. */ diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 804d269a4f5e8..1ec273b066915 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -105,7 +105,6 @@ struct page { unsigned int order; }; }; - /* See page-flags.h for PAGE_MAPPING_FLAGS */ struct address_space *mapping; union { pgoff_t __folio_index; /* Our offset within mapping. */ diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index b42986a578b71..23b1e458dfeda 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -695,10 +695,10 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) /* * On an anonymous folio mapped into a user virtual memory area, * folio->mapping points to its anon_vma, not to a struct address_space; - * with the PAGE_MAPPING_ANON bit set to distinguish it. See rmap.h. + * with the FOLIO_MAPPING_ANON bit set to distinguish it. See rmap.h. * * On an anonymous folio in a VM_MERGEABLE area, if CONFIG_KSM is enabled, - * the PAGE_MAPPING_ANON_KSM bit may be set along with the PAGE_MAPPING_AN= ON + * the FOLIO_MAPPING_ANON_KSM bit may be set along with the FOLIO_MAPPING_= ANON * bit; and then folio->mapping points, not to an anon_vma, but to a priva= te * structure which KSM associates with that merged folio. See ksm.h. * @@ -713,21 +713,21 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) * false before calling the following functions (e.g., folio_test_anon). * See mm/slab.h. */ -#define PAGE_MAPPING_ANON 0x1 -#define PAGE_MAPPING_ANON_KSM 0x2 -#define PAGE_MAPPING_KSM (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) -#define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) +#define FOLIO_MAPPING_ANON 0x1 +#define FOLIO_MAPPING_ANON_KSM 0x2 +#define FOLIO_MAPPING_KSM (FOLIO_MAPPING_ANON | FOLIO_MAPPING_ANON_KSM) +#define FOLIO_MAPPING_FLAGS (FOLIO_MAPPING_ANON | FOLIO_MAPPING_ANON_KSM) =20 static __always_inline bool folio_test_anon(const struct folio *folio) { - return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) !=3D 0; + return ((unsigned long)folio->mapping & FOLIO_MAPPING_ANON) !=3D 0; } =20 static __always_inline bool PageAnonNotKsm(const struct page *page) { unsigned long flags =3D (unsigned long)page_folio(page)->mapping; =20 - return (flags & PAGE_MAPPING_FLAGS) =3D=3D PAGE_MAPPING_ANON; + return (flags & FOLIO_MAPPING_FLAGS) =3D=3D FOLIO_MAPPING_ANON; } =20 static __always_inline bool PageAnon(const struct page *page) @@ -743,8 +743,8 @@ static __always_inline bool PageAnon(const struct page = *page) */ static __always_inline bool folio_test_ksm(const struct folio *folio) { - return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) =3D=3D - PAGE_MAPPING_KSM; + return ((unsigned long)folio->mapping & FOLIO_MAPPING_FLAGS) =3D=3D + FOLIO_MAPPING_KSM; } #else FOLIO_TEST_FLAG_FALSE(ksm) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index e63fbfbd5b0f3..10a222e68b851 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -502,7 +502,7 @@ static inline pgoff_t mapping_align_index(struct addres= s_space *mapping, static inline bool mapping_large_folio_support(struct address_space *mappi= ng) { /* AS_FOLIO_ORDER is only reasonable for pagecache folios */ - VM_WARN_ONCE((unsigned long)mapping & PAGE_MAPPING_ANON, + VM_WARN_ONCE((unsigned long)mapping & FOLIO_MAPPING_ANON, "Anonymous mapping always supports large folio"); =20 return mapping_max_folio_order(mapping) > 0; diff --git a/mm/gup.c b/mm/gup.c index 30d320719fa23..adffe663594dc 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2804,9 +2804,9 @@ static bool gup_fast_folio_allowed(struct folio *foli= o, unsigned int flags) return false; =20 /* Anonymous folios pose no problem. */ - mapping_flags =3D (unsigned long)mapping & PAGE_MAPPING_FLAGS; + mapping_flags =3D (unsigned long)mapping & FOLIO_MAPPING_FLAGS; if (mapping_flags) - return mapping_flags & PAGE_MAPPING_ANON; + return mapping_flags & FOLIO_MAPPING_ANON; =20 /* * At this point, we know the mapping is non-null and points to an diff --git a/mm/internal.h b/mm/internal.h index e84217e27778d..c29ddec7ade3d 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -149,7 +149,7 @@ static inline void *folio_raw_mapping(const struct foli= o *folio) { unsigned long mapping =3D (unsigned long)folio->mapping; =20 - return (void *)(mapping & ~PAGE_MAPPING_FLAGS); + return (void *)(mapping & ~FOLIO_MAPPING_FLAGS); } =20 /* diff --git a/mm/ksm.c b/mm/ksm.c index ef73b25fd65a6..2b0210d41c553 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -893,7 +893,7 @@ static struct folio *ksm_get_folio(struct ksm_stable_no= de *stable_node, unsigned long kpfn; =20 expected_mapping =3D (void *)((unsigned long)stable_node | - PAGE_MAPPING_KSM); + FOLIO_MAPPING_KSM); again: kpfn =3D READ_ONCE(stable_node->kpfn); /* Address dependency. */ folio =3D pfn_folio(kpfn); @@ -1070,7 +1070,7 @@ static inline void folio_set_stable_node(struct folio= *folio, struct ksm_stable_node *stable_node) { VM_WARN_ON_FOLIO(folio_test_anon(folio) && PageAnonExclusive(&folio->page= ), folio); - folio->mapping =3D (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM= ); + folio->mapping =3D (void *)((unsigned long)stable_node | FOLIO_MAPPING_KS= M); } =20 #ifdef CONFIG_SYSFS diff --git a/mm/rmap.c b/mm/rmap.c index 34311f654d0c2..de14fb6963c24 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -503,12 +503,12 @@ struct anon_vma *folio_get_anon_vma(const struct foli= o *folio) =20 rcu_read_lock(); anon_mapping =3D (unsigned long)READ_ONCE(folio->mapping); - if ((anon_mapping & PAGE_MAPPING_FLAGS) !=3D PAGE_MAPPING_ANON) + if ((anon_mapping & FOLIO_MAPPING_FLAGS) !=3D FOLIO_MAPPING_ANON) goto out; if (!folio_mapped(folio)) goto out; =20 - anon_vma =3D (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON); + anon_vma =3D (struct anon_vma *) (anon_mapping - FOLIO_MAPPING_ANON); if (!atomic_inc_not_zero(&anon_vma->refcount)) { anon_vma =3D NULL; goto out; @@ -550,12 +550,12 @@ struct anon_vma *folio_lock_anon_vma_read(const struc= t folio *folio, retry: rcu_read_lock(); anon_mapping =3D (unsigned long)READ_ONCE(folio->mapping); - if ((anon_mapping & PAGE_MAPPING_FLAGS) !=3D PAGE_MAPPING_ANON) + if ((anon_mapping & FOLIO_MAPPING_FLAGS) !=3D FOLIO_MAPPING_ANON) goto out; if (!folio_mapped(folio)) goto out; =20 - anon_vma =3D (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON); + anon_vma =3D (struct anon_vma *) (anon_mapping - FOLIO_MAPPING_ANON); root_anon_vma =3D READ_ONCE(anon_vma->root); if (down_read_trylock(&root_anon_vma->rwsem)) { /* @@ -1334,9 +1334,9 @@ void folio_move_anon_rmap(struct folio *folio, struct= vm_area_struct *vma) VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_VMA(!anon_vma, vma); =20 - anon_vma +=3D PAGE_MAPPING_ANON; + anon_vma +=3D FOLIO_MAPPING_ANON; /* - * Ensure that anon_vma and the PAGE_MAPPING_ANON bit are written + * Ensure that anon_vma and the FOLIO_MAPPING_ANON bit are written * simultaneously, so a concurrent reader (eg folio_referenced()'s * folio_test_anon()) will not see one without the other. */ @@ -1367,10 +1367,10 @@ static void __folio_set_anon(struct folio *folio, s= truct vm_area_struct *vma, /* * page_idle does a lockless/optimistic rmap scan on folio->mapping. * Make sure the compiler doesn't split the stores of anon_vma and - * the PAGE_MAPPING_ANON type identifier, otherwise the rmap code + * the FOLIO_MAPPING_ANON type identifier, otherwise the rmap code * could mistake the mapping for a struct address_space and crash. */ - anon_vma =3D (void *) anon_vma + PAGE_MAPPING_ANON; + anon_vma =3D (void *) anon_vma + FOLIO_MAPPING_ANON; WRITE_ONCE(folio->mapping, (struct address_space *) anon_vma); folio->index =3D linear_page_index(vma, address); } diff --git a/mm/util.c b/mm/util.c index 0b270c43d7d12..20bbfe4ce1b8b 100644 --- a/mm/util.c +++ b/mm/util.c @@ -670,9 +670,9 @@ struct anon_vma *folio_anon_vma(const struct folio *fol= io) { unsigned long mapping =3D (unsigned long)folio->mapping; =20 - if ((mapping & PAGE_MAPPING_FLAGS) !=3D PAGE_MAPPING_ANON) + if ((mapping & FOLIO_MAPPING_FLAGS) !=3D FOLIO_MAPPING_ANON) return NULL; - return (void *)(mapping - PAGE_MAPPING_ANON); + return (void *)(mapping - FOLIO_MAPPING_ANON); } =20 /** @@ -699,7 +699,7 @@ struct address_space *folio_mapping(struct folio *folio) return swap_address_space(folio->swap); =20 mapping =3D folio->mapping; - if ((unsigned long)mapping & PAGE_MAPPING_FLAGS) + if ((unsigned long)mapping & FOLIO_MAPPING_FLAGS) return NULL; =20 return mapping; --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 E51382C08A2 for ; Mon, 30 Jun 2025 13:01:48 +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=1751288511; cv=none; b=jARvvqruxvnbe+99gybV3n1O/8j9pG/mdI4g/8ZpL/3sBAOUqk2X0sVZvC5ZYmDxGI/7JNaTGsL9YNOyH4xexj5QwYdfZobU3OoJBk/G5Nq96G/96GFTyhHB4tNRGZIvTzM3HOP4g3Z72jsC6jTigNF1fPWlYst2ZEYgQ3RzAtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288511; c=relaxed/simple; bh=UE0+puqslU6Vod0/Tnuw7OVCa6Yv44yCJDBwHPhWm7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oFstUyH9Kd4VxHgVZVeD/AGtNSrGL8fFTWZOP1dEwsJdE30xM2FhXZazlBqtLKAxhmaMiNkb0VX1N4R8E6KQ881NaejbX9vuEBzNtWnmP1LjdIuL5lDcFr2lOm3DseueYNLD/jDcREcJdpfUu/mpIkzocgVkS791SPaC1Rlgh40= 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=T9VmMpqS; 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="T9VmMpqS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288507; 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=Zjoj4LwixqS2sGyUbKyFkbKZVx00WcQgc8KQk63N+Nk=; b=T9VmMpqSJt/eeItmZxPTVZazxs0kGx+t2F+9Xzyod2jRKUdGoEHDSU+tDauNNnu5DkKgNL pD4G2eaCAke6I1Z3Yk1mTk5JrglMQEVh6cQkuW7oiRYB4mnxx5tB+0T/n+8T2Mu+w/ivO0 7pUv+m7Fedtop83kV1zWV+0UGFeL+iE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-94XEVamWNXakPjTPNpgkqw-1; Mon, 30 Jun 2025 09:01:43 -0400 X-MC-Unique: 94XEVamWNXakPjTPNpgkqw-1 X-Mimecast-MFC-AGG-ID: 94XEVamWNXakPjTPNpgkqw_1751288497 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f65a705dso1185511f8f.2 for ; Mon, 30 Jun 2025 06:01:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288497; x=1751893297; 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=Zjoj4LwixqS2sGyUbKyFkbKZVx00WcQgc8KQk63N+Nk=; b=s5jv+MnWxnXFSStW4cbDae/9rR7jtsIJjF+ezYLo7O3pokKrjq/Gd6Q5sh9/eTvcCc xrDeWB6KIFfnbAQNetbFhbTvDaCxEfVPNOhXP7rThBEvCgzXi7oF7JlnXnNawxFpk1tN L52/CIvUcBn460C0Z21jD+LkKTf7vq3QgGpTDFiQOuTB96gM7KaWqVmUsLxFFoMqCG6B cRD6MZW+BgCNy5zilQ6OhK+8Ptsot/06DkULZLqeBX2sMc7IKvUx+JP0yfYsfRz+uyjS BxDQCInO/aV0ny4JZiJZeO/J8/SNYr0Wj78SxmV/PZ+3GYIv6/fYVpeMp3gd8WchumsQ okYQ== X-Gm-Message-State: AOJu0YzaGG7O1+O6jjLPyKFcHpC1eWT/zBRjtp1qDPdBjNp0SpC1agg3 9+bov0a/FFA9QSBwJ42AB+1uLfvUTnXQ+1Ci/wyfNYjt13VQsxDXU1nmTgp/ItQHSd0ZN1yyat0 b+AwnErFQZNXvy6WpyriE03Y40CkUnvLwSQNEGyLGnhH5ypwV4JD81MDTM0HMkRo1DbjPB0J2vy Q3JQYV3lprEvD0Gy4bh0gT112kEHZlPrATr0auWC/datg31Wb+ X-Gm-Gg: ASbGncsyzpYvmziRyvr4B+rDSjHgsQ6FJc3EP8e2iCHTjBWmoCvuKNy1kdP7pDX5ip+ k3gbJD8nJLHpzwHcvt0xG/tTbTD14Jb4lghFoFqftEFpufbcUDv7jgS0jJBtc86l4J0alIdOzfJ 11wkSXhH3mm3MJ+ifeNa/kkhTx/xzkqgmUu7HB1drELG8YWwNQqcmmqpAZ6dy6BJditXr/3rTdq vc+ASvJj1w2R59MBwHLn0fYoxFQ2u7mCTrlsGir2JgCmFYSfnmDLocI1MUe6luDunRzDxI7HUqk v01fVQDryYXlIK82H79Afatawmcb0xcFUjQ7m98jTFdpdpwLQFcB0wpXZxuvuk6U010CaXw0wux msIedszc= X-Received: by 2002:a05:6000:41f2:b0:3a4:efc0:c90b with SMTP id ffacd0b85a97d-3a8f482bd78mr11299202f8f.15.1751288496622; Mon, 30 Jun 2025 06:01:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUx6MnmvL38m+UjxsSHRmCnwJ9csff/jtPLhL/sKkb+ObakA6KxkyBM5ParmF0iwuWxCWprQ== X-Received: by 2002:a05:6000:41f2:b0:3a4:efc0:c90b with SMTP id ffacd0b85a97d-3a8f482bd78mr11299087f8f.15.1751288495708; Mon, 30 Jun 2025 06:01:35 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3ac6ee0d0b9sm4643102f8f.18.2025.06.30.06.01.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:35 -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 v1 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration" Date: Mon, 30 Jun 2025 15:00:08 +0200 Message-ID: <20250630130011.330477-28-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's bring the docs up-to-date. Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes --- Documentation/mm/page_migration.rst | 39 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Documentation/mm/page_migration.rst b/Documentation/mm/page_mi= gration.rst index 519b35a4caf5b..d611bc21920d7 100644 --- a/Documentation/mm/page_migration.rst +++ b/Documentation/mm/page_migration.rst @@ -146,18 +146,33 @@ Steps: 18. The new page is moved to the LRU and can be scanned by the swapper, etc. again. =20 -Non-LRU page migration -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -Although migration originally aimed for reducing the latency of memory -accesses for NUMA, compaction also uses migration to create high-order -pages. For compaction purposes, it is also useful to be able to move -non-LRU pages, such as zsmalloc and virtio-balloon pages. - -If a driver wants to make its pages movable, it should define a struct -movable_operations. It then needs to call __SetPageMovable() on each -page that it may be able to move. This uses the ``page->mapping`` field, -so this field is not available for the driver to use for other purposes. +movable_ops page migration +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +Selected typed, non-folio pages (e.g., pages inflated in a memory balloon, +zsmalloc pages) can be migrated using the movable_ops migration framework. + +The "struct movable_operations" provide callbacks specific to a page type +for isolating, migrating and un-isolating (putback) these pages. + +Once a page is indicated as having movable_ops, that condition must not +change until the page was freed back to the buddy. This includes not +changing/clearing the page type and not changing/clearing the +PG_movable_ops page flag. + +Arbitrary drivers cannot currently make use of this framework, as it +requires: + +(a) a page type +(b) indicating them as possibly having movable_ops in page_has_movable_ops= () + based on the page type +(c) returning the movable_ops from page_has_movable_ops() based on the page + type +(d) not reusing the PG_movable_ops and PG_movable_ops_isolated page flags + for other purposes + +For example, balloon drivers can make use of this framework through the +balloon-compaction infrastructure residing in the core kernel. =20 Monitoring Migration =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 9941A2C178D for ; Mon, 30 Jun 2025 13:01:49 +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=1751288512; cv=none; b=ctSWu36j0JMvjX6Yjaf8fB0LVCgpSHvJ1cSTOIKSEdR/B90kywGfo5R27m77g7znMOdMsUEkPfzeOBB/q/wIvcUtWtwn5iuOrcuw1rSJseyYCidraYBoC9fdncbfpXO/fell4KZ9kxIoV3l36UKsjg3J1MeqHKuq2HWFn+8EYLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288512; c=relaxed/simple; bh=xmAX6FaG7PwzByxdVNWIboeTPGW5tjq2c62uEFet5m4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GtaQfuIbCHHlymSOTutyRypdgMCAeIO/LxZVgoCEQ2wh6yhxQUy6EcdJOvRKErTD49SIJNtYw7Fc9VeMIwjJMuuXFWgBa8s0exEchVFIM0Gl9osULxDug4kigvjBRRA/TY9Ht91UvVJfung2k2x8JtSViWG1is0WBmKm5geKWNk= 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=WRhiDl0s; arc=none smtp.client-ip=170.10.129.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="WRhiDl0s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288507; 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=EpLhIwgxSmOTAUjcHZTQRVGXB1xFFa6Mgym/mVDU2pw=; b=WRhiDl0sMm3VJwehlYNZzfSVx1qMjwtMVfBSlg0yxuOsZsiCLP5+90Ctt1q3gL45jWOWtL ZcwFhFrvo1vHnAHo41e7nsRg2+ZL2U0Erw72SnQr4jc/S4iMwucYvU0udW+3H7FaU3lByG Acdv4tpXKB+tl+mHElHMsqQKxwNVPCs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-41A0PjZAPq6zAVoKGDBC5A-1; Mon, 30 Jun 2025 09:01:41 -0400 X-MC-Unique: 41A0PjZAPq6zAVoKGDBC5A-1 X-Mimecast-MFC-AGG-ID: 41A0PjZAPq6zAVoKGDBC5A_1751288500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f858bc5eso1530458f8f.0 for ; Mon, 30 Jun 2025 06:01:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288500; x=1751893300; 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=EpLhIwgxSmOTAUjcHZTQRVGXB1xFFa6Mgym/mVDU2pw=; b=Zht6VbiL5pEswphHlDlCvbyOwH8hC92t9Sgen8SWLZ9f70PqYXfrgEvYIzH9ABSeTV BQEMsVHRYhnw7fAkRThDg8saWcXGllx6LN0PhNYiWfYNyhgeJ41iZST8cLBplKc/o1yE 8jXbdEIgLWOnVWB72sAEMR3OFh1J4l17didHK4soIfFZgil3cz8deQSvVKv7p/Tc46Cd Olw2BZNeVTJP1wTXxxrbRgnIvufcm5hZ/KdFNWNQy8fDvNYi2LZopPuDCPPWcg3VGnNo dSqTfxlV3lbywGF7WlNGMC90u9ierN3T7iGYv9jzrNLwMQVfm2cG+IJtM8fOq4TEX142 jVBA== X-Gm-Message-State: AOJu0Yxu+j9GuBKwUbrfB9ngUTjr9VAMVrWVgQasYaaoKEJfRC0Kz4MW oNvX+RdIG2pZ2SdrZyUT1nIS1ZTW20c/i8h7ruWSrhrWevK+JWVGcZzHJKvLPfm+ae79ljTQiwb yUSrx0ubkAwtlgizyF2YDK7BQnKHIvmHK1kR42i7A2/eN3KaouYWWbzg7RloTFqxst7nLbGS5AP b0/rUl/UjLgOd2ATEK1OtQ/q4TULn5eplQ77QzzpsKpRNMIMlK X-Gm-Gg: ASbGncv0zNnZz8QQjVXoMj5L6sRBKHhtx2SirbicvMfTGBxcz8eMoWFcBgTjnQ/nGWE 6mge89fj+FG2EMdXkDAeIwz57jZZ0HLdoEOprG7aoZkUYwW5QAgVZ45pluvq1dPKgI1LrgqEObB UOYtuimqUQpS4kaA5KrryOzOPvFTnVNcGHxBqMthnwAhGm4UWQ7BjVl6l0DfVW0DKzVj6AW6185 P0zdqI5ejIqC3ZwWjuosCN7cXHATbFWsc5BY3vbA/ECxT5R53/IbcS8WJqiOxNZeJiz8seuNqNJ GTuy4CjeJmOAbxKyE6SK+r9vKXafqUSu9UDBQ8deLDS7mcsaiCWw7C9tjZvUwQ3/l6Q4T5IgERp rzjgf4aY= X-Received: by 2002:a5d:5849:0:b0:3a5:8934:4940 with SMTP id ffacd0b85a97d-3a8feb70269mr11468396f8f.50.1751288499332; Mon, 30 Jun 2025 06:01:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFU/EidvqQvGX4HPGBQwVJZ7hXZfY7F5Qe2rCBAm3bwMmXiBwrV5rV1e++rVLkevEN+RDkRKg== X-Received: by 2002:a5d:5849:0:b0:3a5:8934:4940 with SMTP id ffacd0b85a97d-3a8feb70269mr11468280f8f.50.1751288498410; Mon, 30 Jun 2025 06:01:38 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e5f92esm10485904f8f.90.2025.06.30.06.01.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:37 -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 v1 28/29] mm/balloon_compaction: "movable_ops" doc updates Date: Mon, 30 Jun 2025 15:00:09 +0200 Message-ID: <20250630130011.330477-29-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's bring the docs up-to-date. Setting PG_movable_ops + page->private very likely still requires to be performed under documented locks: it's complicated. We will rework this in the future, as we will try avoiding using the page lock. Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- include/linux/balloon_compaction.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index b222b0737c466..2fecfead91d26 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -4,12 +4,13 @@ * * Common interface definitions for making balloon pages movable by compac= tion. * - * Balloon page migration makes use of the general non-lru movable page + * Balloon page migration makes use of the general "movable_ops page migra= tion" * feature. * * page->private is used to reference the responsible balloon device. - * page->mapping is used in context of non-lru page migration to reference - * the address space operations for page isolation/migration/compaction. + * That these pages have movable_ops, and which movable_ops apply, + * is derived from the page type (PageOffline()) combined with the + * PG_movable_ops flag (PageMovableOps()). * * As the page isolation scanning step a compaction thread does is a lockl= ess * procedure (from a page standpoint), it might bring some racy situations= while @@ -17,12 +18,10 @@ * and safely perform balloon's page compaction and migration we must, alw= ays, * ensure following these simple rules: * - * i. when updating a balloon's page ->mapping element, strictly do it u= nder - * the following lock order, independently of the far superior - * locking scheme (lru_lock, balloon_lock): + * i. Setting the PG_movable_ops flag and page->private with the followi= ng + * lock order * +-page_lock(page); * +--spin_lock_irq(&b_dev_info->pages_lock); - * ... page->mapping updates here ... * * ii. isolation or dequeueing procedure must remove the page from balloon * device page list under b_dev_info->pages_lock. --=20 2.49.0 From nobody Wed Oct 8 09:26:31 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 C98512BEFF9 for ; Mon, 30 Jun 2025 13:01:45 +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=1751288507; cv=none; b=GuVQku0e6fTk8FbFX+5vFrUiQswyDIfroj9GckI4NI53eWtTO8LN6phJHRPPKaKg4J216cUEke/w5+0q5xxmPr/DCZYd0Zf8nqT23AcF2Ieplzs4qvaZzBx7KUovyNHFLCD3W295uLyht1y6G4++GqWK1o0tsFFfMk3D1s1XD0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751288507; c=relaxed/simple; bh=VLtr/75+OgLg5UKJqAhr4SPpTHq3QNsAl+8ocPk3Nhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BDkEe6ZhdAeAVND7cIJsSOAbLNm+pObQ51xf2Sb5T10GvaNRsnPQz1eUa39IRLKXCTAAOJJXhFusuqnqw+7vAQQFioE0YLvkkyTDXtg2MnitoGmp0Hf7lAap+5d8RcidZ5rhTvqzdWWfUKF/kjA8tzt2tC7x4pNhpoX0VklXAzw= 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=eO5Ns51a; 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="eO5Ns51a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751288505; 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=cBlqU3v31THD5gXpB9nn15wD9nofG3PBMtxlPOPDIeI=; b=eO5Ns51aDvdeyZqjjDiN/dQAyzOiQnjXJWZPC5YqXZt1TkIiSwWWjQULOz1zKJbRf2L/sN zqpqxmx7j7Zjsp+WbTHh1FW8PkupdWmAv6MHN+N6P7L0KFBe9dWO7LvsiyqwC+l08hQnYg IcsuVokwET5BDQTToM2Ty+OxUWmaerY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-kDLl99H6MBi3PjupvYGleg-1; Mon, 30 Jun 2025 09:01:43 -0400 X-MC-Unique: kDLl99H6MBi3PjupvYGleg-1 X-Mimecast-MFC-AGG-ID: kDLl99H6MBi3PjupvYGleg_1751288502 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a54a8a0122so2169683f8f.2 for ; Mon, 30 Jun 2025 06:01:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751288502; x=1751893302; 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=cBlqU3v31THD5gXpB9nn15wD9nofG3PBMtxlPOPDIeI=; b=T1I9M6bIZhQ4zq5vV8Ps+qPoLHZMaciPiyhMSe/QEDEs1/gLIzjSJMo0Uzgil2bIJ7 mzTbK/FFAYHAzwu1+ClRrDEpMPNiNrQ9gXJznIc2yy8q/hGUKhi+Wq/AnZSpTifGsOSp wVn8pReCIHQOp5vVCi8s3R86ui3+9tybAs1HvKksehClzDvg53zQCtV1/wUmnZ1cmKwN qH7c5yMhVybtyNX/Nh8zDG2nd8KAq34o5B31T4D7ENtAvThlFbxLYQu0nqstWI1njpEt cnfMq1e2VKNILXZEgFsYpTmPxYjvn1ZGShK1MWaM43lHQ/817oFvSlb94oKNWtgeHej+ fDmA== X-Gm-Message-State: AOJu0YwE5SteCuh/j+HvLkf73HLOtA6oexZZ82hYdPMfQ161P5SHpTnU QmSZGouPH9rIRHIqg/+vYvTNXXA5en184oyzp+ZynECQYfDY75m7UOOXGCLZ70YcGM183dbj9yO cHFzAO6ru3HBEw/1We0tLxpWIZhiHu2aYfY/mBiEz6g3WySuQjcpYFSq4tVl72FhcoUohjrG9yK dQ0qOqptrTnJC5wbAVd0tWku0hHu2rye2rlmBGgkcXX3ZhCVwZ X-Gm-Gg: ASbGncs/zJkuX+oIEpZ26Mx6nZnhw70d68VWmk555wEpaJYSZZujNMN8kgrpRy/BeAx R9b3j1BiYwiNtwnNvng+fhB4lf3vFwMd4Y/dPN057LNFcY91rVZdT1z+PW3SlLAgzQ5JPov9Mnq MeFB0+RiDLflUoCYu7zhoGuazhY5xmzkZxiJmhXegydFpF5mtLaPJwZhe+6I9tjC4uBIcsP2+9Q rD3FV7l3uRlkS9UbJXYb28+lkbpIO4dJyXPSXHP4zvopOF4TdLJ6nSDMqHCrDUWoWyNsCeeIn5i +apt1gI/nw2bSigtpKOz5r+2bCD0qoSv9djburmkJIn0jDARzuhqk69KKZ4GuB4Q+P46uEmFRLB OLqVbDyk= X-Received: by 2002:adf:9c85:0:b0:3a4:f90c:31e3 with SMTP id ffacd0b85a97d-3a8ffcca245mr9545930f8f.31.1751288501906; Mon, 30 Jun 2025 06:01:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmBHmttdmK2eq+WBU1B9I2DDaPMLfI/76nbXYnXDHgExr/7iQPmKv6fPJxJBiz140zN+RyvQ== X-Received: by 2002:adf:9c85:0:b0:3a4:f90c:31e3 with SMTP id ffacd0b85a97d-3a8ffcca245mr9545827f8f.31.1751288501169; Mon, 30 Jun 2025 06:01:41 -0700 (PDT) Received: from localhost (p200300d82f40b30053f7d260aff47256.dip0.t-ipconnect.de. [2003:d8:2f40:b300:53f7:d260:aff4:7256]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a892e5f943sm10337130f8f.101.2025.06.30.06.01.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jun 2025 06:01:40 -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 v1 29/29] mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask() Date: Mon, 30 Jun 2025 15:00:10 +0200 Message-ID: <20250630130011.330477-30-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250630130011.330477-1-david@redhat.com> References: <20250630130011.330477-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" Let's just special-case based on IS_ENABLED(CONFIG_BALLOON_COMPACTION like we did for balloon_page_finalize(). Signed-off-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes --- include/linux/balloon_compaction.h | 42 +++++++++++------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 2fecfead91d26..7cfe48769239e 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -77,6 +77,15 @@ static inline void balloon_devinfo_init(struct balloon_d= ev_info *balloon) =20 #ifdef CONFIG_BALLOON_COMPACTION extern const struct movable_operations balloon_mops; +/* + * balloon_page_device - get the b_dev_info descriptor for the balloon dev= ice + * that enqueues the given page. + */ +static inline struct balloon_dev_info *balloon_page_device(struct page *pa= ge) +{ + return (struct balloon_dev_info *)page_private(page); +} +#endif /* CONFIG_BALLOON_COMPACTION */ =20 /* * balloon_page_insert - insert a page into the balloon's page list and ma= ke @@ -91,41 +100,20 @@ static inline void balloon_page_insert(struct balloon_= dev_info *balloon, struct page *page) { __SetPageOffline(page); - SetPageMovableOps(page); - set_page_private(page, (unsigned long)balloon); - list_add(&page->lru, &balloon->pages); -} - -/* - * balloon_page_device - get the b_dev_info descriptor for the balloon dev= ice - * that enqueues the given page. - */ -static inline struct balloon_dev_info *balloon_page_device(struct page *pa= ge) -{ - return (struct balloon_dev_info *)page_private(page); -} - -static inline gfp_t balloon_mapping_gfp_mask(void) -{ - return GFP_HIGHUSER_MOVABLE; -} - -#else /* !CONFIG_BALLOON_COMPACTION */ - -static inline void balloon_page_insert(struct balloon_dev_info *balloon, - struct page *page) -{ - __SetPageOffline(page); + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { + SetPageMovableOps(page); + set_page_private(page, (unsigned long)balloon); + } list_add(&page->lru, &balloon->pages); } =20 static inline gfp_t balloon_mapping_gfp_mask(void) { + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) + return GFP_HIGHUSER_MOVABLE; return GFP_HIGHUSER; } =20 -#endif /* CONFIG_BALLOON_COMPACTION */ - /* * balloon_page_finalize - prepare a balloon page that was removed from the * balloon list for release to the page allocator --=20 2.49.0