From nobody Thu Oct 9 09:03:18 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 A2C6D2F3C3F for ; Wed, 18 Jun 2025 17:40:23 +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=1750268425; cv=none; b=ZxijqajYaRSet9yJuhgmGiOYTBefViW7NuuFhgy7GrDeNuSiFF5S6c4xhT/+rv/BJS67bfIFoh6KOSSuveE9nHPQ62gg59Nza3umYge7gTnY7838vSXoKZctXRrxlfYDT7/dQQqRLzp4NjpLBjztYS7H13jlE6pMIJZD5kgO5yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268425; c=relaxed/simple; bh=LfUaIY7XKmkW22E2CA7zcjn2zCtCLb3wGZMadkbbvUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rOFJ1+C2oSam01SpPdIzVHc2XrRuKAVom45X4Em9u6sW+xDyYELtTWHaOKds4oNNu7fGGyRu0vpxYpJDCXRmzQ1m71ay6WpZMXIy914yZcLDkJgwkFOB9LVgfdbwrN/Mup3vVlmlLDf3+AXaliX46jjty+t8+wRZ6Z+1NX792fc= 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=BBdzmE9s; 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="BBdzmE9s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268422; 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=ztkVXhL49uhBZn35+Dz91j/1BkEFGTeWr88qG2zBn1I=; b=BBdzmE9skDUR9PXrrfZSGKNCO2KuWFlBjWWdfrIv0KrfhjDWFY41eCBTQND5+K/MRm2Wur z+o1ym/WmFbHHDlaqJl/cQwjCH/JowQ/Vt2ZiVjsqH6eiz+EjDJrIWZrdLREi8nvcs05hT 93a4fyWBBlQXy4mu0gci4x6WTkFXKw0= 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-537-wKU506dBOOCGcMOYuPHjPQ-1; Wed, 18 Jun 2025 13:40:21 -0400 X-MC-Unique: wKU506dBOOCGcMOYuPHjPQ-1 X-Mimecast-MFC-AGG-ID: wKU506dBOOCGcMOYuPHjPQ_1750268420 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a56b3dee17so508821f8f.0 for ; Wed, 18 Jun 2025 10:40:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268420; x=1750873220; 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=ztkVXhL49uhBZn35+Dz91j/1BkEFGTeWr88qG2zBn1I=; b=RsL18fxB7SmAsiqBldSVoO6GoNWBOt+O6RF+QSoeFus78gxNRftoj1fg35Pngg5asr Hyu4GpDp99kPjmoIX537+jpWEYxEd+tt7qv0CxR5mGB5dMXALaSBuPzimqFblN70qtIk VXOEg8hm25R8vUFFmEV7nqLdj9xc4G4LxqD3UsjR1qQTx/5Si+BHEcaxAOVwIoUnhU60 AjHHfZHPsFwry0Q2sSRMrRoVWjd/MukPdAiqJr6W4spJMghp+/mdI7uZDvpER0p/MC2a gXccbciemFtpAXTDJyrJb5KIiq7c82o0jnIxuUzfjvaJnDsaMBlvm+rk0Va8CyaC7/gR g7Mg== X-Gm-Message-State: AOJu0Yzx+A7Ls2Joc7PVEz68HQIrSgpdXZQ3f43/02VXtyLCZKLeb6wW YbwdiKfSYOhubjt0HHwYxtLT5Z4ljwOis4ezdiWCc6+jxFqPCEjsRvlFkDwGrqq1ey7bb3NySJy low5jD8iZkr8JMO4w7yuzeR5mNwVW+dSG9wQ9VfznmJTik1UtABHa0hh9ZTXpQIw02X9A/H9ZZ3 wy/APLRsuHk2hEEHYVal264iXznHV0m0FkVksqOEpbESGaIq/p X-Gm-Gg: ASbGnctdm+i5yGY3fbwHpO7xPYUsjiHn/+GxmbENwYN7HlK2/loXU6mvEB8ef5lIhrW rH854UpwRoXidr6ZXJgudNTBY/EjdxXXysPUa0LnhsG39HBU8lchs14scIONP8elKSQAnV6z6so SV2MMHfSSsnnDxvjMQFCYIZpGTZJpngJu9LE5m3ZBerstlEGxxAie+ETf9sybyLSiYw94FCzzOY vdhicxGITWdS9f5PF41YJkFjGIIeL+tz3Me1OT9JZgtntBYlqv+xKA3mlvdiBNx+E2ogjEJN0+Y duUjrg2UkUjssyZgvS5AHBDlJi1SuUYBrPGapz+TiFBtcM9p6/1BDMxKoMwQjdZrTWYOb3oe/FZ Qhpi7Hw== X-Received: by 2002:a05:6000:22c1:b0:3a4:f7dd:6fad with SMTP id ffacd0b85a97d-3a6c96bde70mr478051f8f.14.1750268420178; Wed, 18 Jun 2025 10:40:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdKc/sogX7P8eUPuNrS35oj8SOpb+inlndXsECh3VUw/sMAlaRsKTNBWIAReSnT0M7eOt7jg== X-Received: by 2002:a05:6000:22c1:b0:3a4:f7dd:6fad with SMTP id ffacd0b85a97d-3a6c96bde70mr477976f8f.14.1750268419626; Wed, 18 Jun 2025 10:40:19 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b0898fsm17901600f8f.54.2025.06.18.10.40.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40: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 RFC 01/29] mm/balloon_compaction: we cannot have isolated pages in the balloon list Date: Wed, 18 Jun 2025 19:39:44 +0200 Message-ID: <20250618174014.1168640-2-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Acked-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 57B412F5463 for ; Wed, 18 Jun 2025 17:40:27 +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=1750268435; cv=none; b=Ug5AfOOsQwp5i37eebdY0w1QWFyUvhKEiZLJ54SfCM5Ksn1bPf6ecieJjd08fEuWi+Y6B3VqLRcMNtpIxrAP0VseM6Dh/nnA8g3kzjgL5dT2j6f3w14A2gv1ZLgLZBar+bSuoIM+R50thb4Gj98zvgkDHETAHD2Ibb0uyJ5oP3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268435; c=relaxed/simple; bh=HoU6IkwEzSx0bRpH46YFQR6C5ixdQUXKWK5iDFNMOt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mH/4MlAwBXKuD7C1wjBzGaDcpdT9V1jQqKCtSfAU48q205XLccopd3mzI25ErkjlDpRoZOoh4bUw24zYETSOZT3x0QWvS9xXfTJJhPE/gCtWO2rzyVjOvx+67B/tjOP04Ud0/+EqSNg8oZlwcRMGkHlzCU2HU89IEHoYpfmuHTI= 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=bcl6EE/8; 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="bcl6EE/8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268426; 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=bcl6EE/87rvRp2sZY3yW4TyWvzk+gmZwkzmagzxpSpSK/sTRlNmotlfC3TIHjL58iqfkgP 9takqlkn78UYG4U+Vl6ry6jCiPK/XJVJn7lNEQdplqiRcXmEF+tg1NnxCboZJnEG2meVtQ qD/m52Uznopwjtwf7L1z4f1F7qPfuxY= 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-257-N7_vIxtROFiJYOy3St1EbA-1; Wed, 18 Jun 2025 13:40:24 -0400 X-MC-Unique: N7_vIxtROFiJYOy3St1EbA-1 X-Mimecast-MFC-AGG-ID: N7_vIxtROFiJYOy3St1EbA_1750268423 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4535ad64d30so7580475e9.3 for ; Wed, 18 Jun 2025 10:40:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268423; x=1750873223; 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=JVoS1KMkm5MTGFv3Q+2Fp3NAF78YgEe+JozEk9Rk07JhbCWQN0sDtU43qvDFZKnA4i IkcMubdx21Lwc24uZprA1kvEUsdJP6Em92btH79IwLpuIuabywnkyrUkZj4erASrnG+k 5+wEkDTGHCl2plM1mNHjrC0qMW9AtX6JDj4PHNtj9ulw/vDYMZhC5Ll+sHYDGs97XWBI OeRrW5eE/iTV12iYJLXValtyXkLZ8RPD/cPXsMM2gpZE9zXVkbfYOeFnD23H/1WdR8iN WKaJaWZLT6I7yqq2htAZ5nMVE9UZMZhBJZu+mUfNriAAr4RyQvvQ90awmQj1GauNGIxP s7Fw== X-Gm-Message-State: AOJu0Yz8YO/9C7uOw/Za2NSKdz+Y8KUKa9bQL1FMHPaV2DA+OMjiGJ2E 7nOsCXpr2aK0QBxzK4NfpH7kEIInNp36DNES56zRQLa2n2hV4tbWHPbQKMznu7TdqLMXLgsro5I 8O+q/XEAB5NhWRhhKqsZJYLIclpH5LP6A6eKfnTY1XlhC4xqNeVWjJxOW1uEheKlu3o+51boGgC 5jqPk7QbbljbDjUCFbvygkkynyVlN4heoE1LzGhLQuatgBapoQ X-Gm-Gg: ASbGncsMAgNd+A061+b+Q35PN++vsvJyVZckK2QhMNMR/X9V7yDvnhWvHNS799BrOlp zTbGHOoSQkAzS2FedOLTnqa/61EAydR+//eBR5aMipPKXm/1lY+X0A1UQGUT/41msBHaU9+9D7a UJHgXEAkbZIgiHfYvg/gddNbb+ICDS8CdPgL3alBUOeSNJYxZVm38fM6A+NHfNvQZRNbxv+cCpn E65/phiy/HtyEdFrx07qQ5TShNE7VhjfeAQJDeHgyyXTlOdKZX7PcmJdxRX6nAazmqhJVaFqmMB VZjQnxcSpJzvN5O6/qIUGKSIMGYRnVTLugfPqOMPPCnAl9LwHOHsz0m0ywxE3vACsEoREkYkriR FOYoG1g== X-Received: by 2002:a05:600c:1d8c:b0:43c:e70d:44f0 with SMTP id 5b1f17b1804b1-4533caad0aemr171055925e9.19.1750268423071; Wed, 18 Jun 2025 10:40:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFNY4J8Mn4IFBBexw6iB/8oHFBQjZ0Pcfadu7y3OlxCDXC24glKPTWmaukP08KWSs+L7QyIw== X-Received: by 2002:a05:600c:1d8c:b0:43c:e70d:44f0 with SMTP id 5b1f17b1804b1-4533caad0aemr171055095e9.19.1750268422300; Wed, 18 Jun 2025 10:40:22 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535ebcecdcsm3339075e9.36.2025.06.18.10.40.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:21 -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 RFC 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize() Date: Wed, 18 Jun 2025 19:39:45 +0200 Message-ID: <20250618174014.1168640-3-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 --- 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 Thu Oct 9 09:03:18 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 EBD692F5469 for ; Wed, 18 Jun 2025 17:40:28 +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=1750268433; cv=none; b=CKD4TsYsorTuYnqJv/IFmNZtEiqkNgPeoXHqKwhCeYSJ3mVoSkhj0Kgtua7gIjevwREz+AkKbwq9+cnTTs0MWWeptytq6woONbPPcPW2Ube8TRRp+ey8NnoaYPSP+DCDCo+neIjadnHlMnTAsGN4CZOQbABpqmaN5Brp+dT9ZUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268433; c=relaxed/simple; bh=LoSKhKhxUdNaBIY5unlgO/URzAbM3vnT3E6jz3vT77c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tQDZk5A+UXthJR6v8bRtVNS4Np9oZIS4WVDN0us5TvaFqBqJfIVZzjYYprLyeZVq56nqRG3oxCSbXmOoMyDDjEzOWlWKwFvbgPlqhOUdzt2iUF++J7Za+S7dCesZCh+/kn8TZLFMKeLycuA28s4upea0G4K4y4+HiNGiqHSw12g= 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=bnw2ItgY; 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="bnw2ItgY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268428; 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=S7FgUVlGmmQh/Fden7VOoWF093l0D6F2nUhdFZr7YaQ=; b=bnw2ItgYneYTNugiLoSh7womXWjhX7+jJWrkBqyrZdc8ohR7pEJXeVxJqQ2msEcWaOJS/n UVThEk+LyVvoi/WLXYIuRbRG34RzwtYUC9NsZMSxmCLhlIhWOYif551WXUUYi4KCNAes+B v3+hKeGfvq1dpbR4tpQSAjTwz3Ix9mA= 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-652-uLJIvNE8MLuQRqeo8GstSw-1; Wed, 18 Jun 2025 13:40:26 -0400 X-MC-Unique: uLJIvNE8MLuQRqeo8GstSw-1 X-Mimecast-MFC-AGG-ID: uLJIvNE8MLuQRqeo8GstSw_1750268425 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4535ad64d30so7580695e9.3 for ; Wed, 18 Jun 2025 10:40:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268425; x=1750873225; 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=S7FgUVlGmmQh/Fden7VOoWF093l0D6F2nUhdFZr7YaQ=; b=bCcQpcnIItIuYk0dMOPyCbW2ew11AR46kZuVEsuJJgZZ8+1fr+lTyV92XK1fcx+R6a 7jORZi2dlilVoTxbk5E3s4dgU79PTvgGUOa/wU/SAEYGPwug4pRgKopBSJDY3RhO2B7v aVFfGKkjp9KqNwyOWy6wRPkbcJv30bRLl0pu3WYXbskumUAQmW0Yme+a0wjyX7BsOV6v v+ba/vsMsmYpiuN8S0nPqQfvAlkP4zYcdj6jAINBAldaOTYUWr4xIAu9aFI34K2ERRrp LbBTdprF+B2P9fGGGfB1FpF929toxPNEXYDHBYNq5NSXyupgrkW48208JHkXK9mgQ1Fc 5VoQ== X-Gm-Message-State: AOJu0YwTOC4nImq8AZ/P/JO4PBWgxckbvx/RFf14+kB84zJXIqSG7jlW xhP4lQ17FNRfc6IPN/nD1dRBopLI93NuqgqXsQ7J3edvre6dAiL3vZwcVPuDtbV1Hdr6QBvhGcS IWwycBiTCQWISm3AERUAY3K1/C4QEj5W4iA9i0wfbmkQlGW568EvLKwQ6TgED9AzkjLmEgboFfn ZRSXW3/gor0AomMx/r00kUL0bzimVURI7Cs71RVIxV5LSO+i6F X-Gm-Gg: ASbGnctqq0/rBxWDYF2f+BpXIuiCq9drAAWPBQu4Kjr11yPSqbNHDRTpNzZUBvbTQzU pGB4iC8W1S6WCeE1FFvWsNrIARQypWu9jwFCehtIlgsIgJaAlNsjjDABNViyyIbe82gsgsjPUbP 1AJHJ8QNieM+XJ2f8Kw/3wctMS0Wdfvatzgogr8ElG1WvG2wY0CtCRrcZu20S4jGMQ4hD4tdJae 5KcTsktxkINdCHNuuqbZoQqtptqMAXRaiJuOr6aatWwnyoN3ia3kZqSLafJUvjpVBhHcNlFDrOZ e15hy7AnaC/sEyd5IX4xOJA3QDGEcSwSTOWsV3Bn40dMS5gG0C3cKGR8q+he2PKVD2BzMFc0n4U u5n6fig== X-Received: by 2002:a05:6000:2c0f:b0:3a4:ed2f:e80c with SMTP id ffacd0b85a97d-3a5723a3f92mr15706308f8f.31.1750268425425; Wed, 18 Jun 2025 10:40:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEayKPP2LeH5F/Ng3XTSzlfhGIAIvFkyNEolXxAmF4Ok7MzyUOG21uTMpu2qvZTdT619UlY2Q== X-Received: by 2002:a05:6000:2c0f:b0:3a4:ed2f:e80c with SMTP id ffacd0b85a97d-3a5723a3f92mr15706239f8f.31.1750268424824; Wed, 18 Jun 2025 10:40:24 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568a547ecsm17734777f8f.17.2025.06.18.10.40.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40: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 RFC 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs Date: Wed, 18 Jun 2025 19:39:46 +0200 Message-ID: <20250618174014.1168640-4-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Acked-by: Harry Yoo Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky --- 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 Thu Oct 9 09:03:18 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 CADE52F5478 for ; Wed, 18 Jun 2025 17:40:31 +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=1750268436; cv=none; b=Lq1kbgmf7mALCMSvEZMoXL/2FHPGAj5fZRUCoiJkN/p6HIWPn2DqpMHwxQaRFnNq3jkJT4uQtkBpCXV+rLutGb1mkCHTOK46aDFAfgSEm5iPfugcbvE0GPm0DXd1uQXMgBUGAKtGLPCBp6k2RJ0LfjbrlBlOX65YbZyuT8rU5Hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268436; c=relaxed/simple; bh=/qlovm8p0zMtgfIRyfEk2trttNuw5S14EvQzs1QPFl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Px34ImHmlQN7ns4l69GsOXQZLe3LbWDl9dbbnsePQIn30+iJiqfQtX9jiesgic40/EM9UiJzCc2u6s9VCXWBy2htx5e/jgYDGsXikhToQZHachVeMNT6+jqgT9Bav7+BsaILIF7/WseRSMKeFeUI/wZrgBwBahe2DaweCURoYfg= 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=H9lNKl9G; 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="H9lNKl9G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268430; 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=nTkPO9qqkPL3+EL3rvp7Awl5YkqXAjOFp3B2ZpZgv4c=; b=H9lNKl9G71TX/Xm36Zp99AJjpIJ6HE2CvKVcWwLq+YZL6TomGkVGY/QbJyY1lw/M6D4+Ok F5aWLMLOow8naKsR9DpEorTF66HP+Gsp/8NOWyAfXEHeo3GkXWzASzt3z9xE5VF/fyxc3P 9elk1grsZ08b2GG5zNOLQfvkszRJ7g8= 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-446-cZgNEBNXP8WNxNgWLpAzHA-1; Wed, 18 Jun 2025 13:40:29 -0400 X-MC-Unique: cZgNEBNXP8WNxNgWLpAzHA-1 X-Mimecast-MFC-AGG-ID: cZgNEBNXP8WNxNgWLpAzHA_1750268428 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43e9b0fd00cso5758155e9.0 for ; Wed, 18 Jun 2025 10:40:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268428; x=1750873228; 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=nTkPO9qqkPL3+EL3rvp7Awl5YkqXAjOFp3B2ZpZgv4c=; b=stG8t538bbRqCmFyoKhhXTxLzGjnJ/H0ACPyofO5ZY3uubDmvEPSrEAb8DnQvC0Dyp 2bUpOxZ8c5oDz9dbpOSaupOw1HakCawaTryHoV0O5Tlb79MCI9ZM3jcOj6W0eE519+Py xbVfVRaDrg8BtJyWkT1bgydXznFLIdmTpFgWVJzvpms7DU6c4rK4FGp80vRmqK2fYy6g xa6QGV5iq6wIxdhp1dwCkVGDU8GcNk5jKFza5LhvabMZdMGyukoh3fpnByuqD7JqRGxv jQoQ/t1GCQE4J1fKCJiYFnOobngBJD63hOnnDRG4ymEcYGgPCRtAfbwF5CRgliJb+WOE v0+A== X-Gm-Message-State: AOJu0YxPipVNQsKilTDDsRlGRRrweMRef5zre7Ydjjfe9vV5ssxYtJng KtBYhSj8NUoquxcV9RagB0bzY+IIBhhYEfTOW/riqUVmd0IjMPuoRtRgGxCqci4m4pbuSD3biLl 4GRI2YxNx9CZSxHMG6UYoU+UyF1EJVr1w7gOmDek3EDtb//tCkn4UrRTMN7A6fA0vPia615E0Zq q6b/67Edj80b27qmit7Ten/ZoBPF2XYqxL6vmuJyGx57R1Jjpt X-Gm-Gg: ASbGnctXkHN/fFsfGFCEJNSM4Kuyk+FH9i8XWHfSWMRdeuJtyC77ruCr6pZfHLVmXHM ttLvjN5ISyLltJnYStHa+n+X9oiB6z2ntujE4dMOAhKydC8yvw3G4cr09r7TJZt9RuD7U8GO1uM ihg5w+dSnoQWX56Kx4sMy7I7wWop1l4EzC3Q99/V+zoCgmb2QxYmafUSANKlKNHC/Xjvo1LGhK6 Z8LIDT9zIreVhdapUE/C9GYcru8zdFmxlSZkxHQ07MNDUtYFFRW/UQ+ys6smdfoxlvmEaZD9U9l pGQBIoqSlpuA94otczLrH2l1bufRf7Nf2wXK6NMA29feNm0VOUaxR4BsPDWRUqEXk4q4b/AOhIZ DVbkRRg== X-Received: by 2002:a05:600c:4b16:b0:453:92e:a459 with SMTP id 5b1f17b1804b1-4535ec85c23mr3140095e9.16.1750268427870; Wed, 18 Jun 2025 10:40:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkzVO1ODwNAxaNuTK2n5Qmy81cmyi9pmESLWNLzISSPT37JEqPUHdRyxt0ThuYLp1iDunnjA== X-Received: by 2002:a05:600c:4b16:b0:453:92e:a459 with SMTP id 5b1f17b1804b1-4535ec85c23mr3139385e9.16.1750268427286; Wed, 18 Jun 2025 10:40:27 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568a5407csm17710458f8f.12.2025.06.18.10.40.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:26 -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 RFC 04/29] mm/page_alloc: allow for making page types sticky until freed Date: Wed, 18 Jun 2025 19:39:47 +0200 Message-ID: <20250618174014.1168640-5-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 allow for not clearing a page type before freeing a page to the buddy. We'll focus on having a 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). Signed-off-by: David Hildenbrand Acked-by: Harry Yoo Reviewed-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 8E00E2F49EB for ; Wed, 18 Jun 2025 17:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268439; cv=none; b=QGbBsDmta90gm4DMOAPkN3K/BYdNAs6epRXlZisRCRXTH96i+sjrCKEGI90nYTjevpUIesCYxYgaC9iF6Wpq3Bjh/VU+cyrM1nP+gJbrw4vz/WM0SDto2s4FwCxOj2iYFN8VB2ELCw5TCA8CzY/v8Vu9moTq/UN1rExYjKbB4fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268439; c=relaxed/simple; bh=qK/hSpqxPHXWhlFplYYMa5g7zmr2Q/EzGHQmEAB7ZSY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nzFLylRS3EVuCHGN/3I6wUMHY6qvZK7grEO/CHR/3etDzvnzP8tiFUduyRCnpiWCD14MxjKiZC/Uv7VG2eBaoVp/0M+7mq1n97NinjgKQ2vOc4j0dFz76J5b5CVkTZqKLG1NUxyqzwf5if8OAenZbJKgmGemUio/2G/UOPf//Mk= 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=EhtLsgzf; 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="EhtLsgzf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268433; 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=fkYbA0acVo3UX9Us91PPuYxLoMCXI95NEZ07wm0hikY=; b=EhtLsgzfMZkgE5F0oWe6t92jj8EvCV5QPrIEAA2XI23MHq7o/UlGBzCWlwaYninRVD6j4e ojK4KnQ6Ho4L2lBEAMVqSqpBtHeq8FQ43VWuCxkXt2YQH+5sM9B+J5omI5RgMScd5zUWdK f6cnQZW5NjLs1Bvgch2kz0ks0+baWio= 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-621-Drez3u-nP5-id_iZxdEzcA-1; Wed, 18 Jun 2025 13:40:31 -0400 X-MC-Unique: Drez3u-nP5-id_iZxdEzcA-1 X-Mimecast-MFC-AGG-ID: Drez3u-nP5-id_iZxdEzcA_1750268430 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4e713e05bso3281477f8f.3 for ; Wed, 18 Jun 2025 10:40:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268430; x=1750873230; 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=fkYbA0acVo3UX9Us91PPuYxLoMCXI95NEZ07wm0hikY=; b=VX2snBaKzKpP/hBwTRwR3uxo+iqiPyZRBbnbsFmzT9QziIltMXUX0U4N83HJ431RLD KpW/Kr021DaEkD7jX8YLQv7+yb/drgognPY+HCdu964Fih7lrtVfegI/knzUI+y8SvxK NZDVvQITbfACRnLXhfNH9zpOb+++z6jN8WlTmpKHnYkAmPnchMpqvuLnJbo1roJZL/a1 fqksTNMkAaa0NmzCI2Q/dio86J9o5WpOg8SelfceSB6fr8u5Ap/4CpnLFb2m63OGQpzU CXk89FqF6vAbO9m9a0ld0nRAIusuoTW+q2SGQiHjNszJVehenL77Mvqu1oL5/dT5BgEE egWw== X-Gm-Message-State: AOJu0YxjSM12xlvTYG9aN3Km7/+Kr/GAO8yfZ9wYcieKJGJPBD7YXlKz SqdK7VNeA5zFuvQtqWjjq7esmkfrtshSmTcjeSWXcuRK6GyBqShpeiosmA/ND7hf2Co4UPCyYdI eTPEA+ahtlogDXK7MCIDSOyPn4VwabAupPo2mYD84Xmx6268YBSkt9OFSWkPkHxdp15NDrqthqo Ca2LBHQgdiMWnYXUVhQDcBJax4IeaPh/AsNuLHMmrfU8BIr1TN X-Gm-Gg: ASbGnctkjdK9ar8DXOiiW5B6gw3U7zoOnPt6b3ErueEdKf4OztpRMlIaO/B9zshUw5W RjwcpBIZx+EgE28wKMcluLolYVrqIkZ0pcJDzgPDy4RnlRkK+nA0HKb7NpUiQnMj+vYCxjYLtmF 453Uku1l2CYaXguiIjuFXkPCvexp0kMVXIhotIugNhoFgzS1fDX64erSD2cKdFfPJ+Dr5QtfKob yUURiGLuUV2xJ4TO02GlXX3Hh7NhwMYHyvtg5/ch/f0xteRBkIUqC86lGp3fnBB3LL9++hv3qsU gn9MKEZHeJEIy+c+cBebZPTWa6r+wt69XYrINTwh+QYvMdlPq5PFb334mi4JHGZBiNrQiktREsn ZDoQSCQ== X-Received: by 2002:a05:6000:71c:b0:3a4:dc93:1e87 with SMTP id ffacd0b85a97d-3a572367972mr13745254f8f.1.1750268430503; Wed, 18 Jun 2025 10:40:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzzxL/ng01qs/lSRwaNlZPiY9y2+iVmfz3gXJp3VGo7LunL2znQ2yg0q95yDx7nL6kngLoWg== X-Received: by 2002:a05:6000:71c:b0:3a4:dc93:1e87 with SMTP id ffacd0b85a97d-3a572367972mr13745179f8f.1.1750268430076; Wed, 18 Jun 2025 10:40:30 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b62ba7sm17864640f8f.91.2025.06.18.10.40.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:29 -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 RFC 05/29] mm/balloon_compaction: make PageOffline sticky Date: Wed, 18 Jun 2025 19:39:48 +0200 Message-ID: <20250618174014.1168640-6-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 buddy handle clearing the type. Signed-off-by: David Hildenbrand Acked-by: Harry Yoo Acked-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 B05A62FE36C for ; Wed, 18 Jun 2025 17:40:40 +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=1750268445; cv=none; b=clKV0w7CZmnXa+LBNLf/CEVusjvjj4FWqZYKk8zXKW7m0GEq0UrMlrv92FnWrtcIyq1QYS3NYnv+osnZOctX+gLGYZXeGYg11N8wlC7r15Dd+UWG33jWA/LI2lMc/Gjd+btYnuY7ZKHHWMGqN2SXAEO0YOwGyRKXcIA5/Wytl6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268445; c=relaxed/simple; bh=9PSofqRI4P1+E7gv4s7LsRbrQULLczAgLmwV7OUNB6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XcOpBXYmEIZ5JsmhrekPEYlGlmqYlrt+n8nCDU4Gaw6MKo7r3GNIPZXKbg3ZkUhsyfN03d9vQB9jWZBMkyYjMAl4MzFjmj0Yv/BURZm9rSk5FyRspeAVI9N0Z+D/Kj7armxquMuXaOGtDF5TTtLK1h5ksgqQ5RGq/CrE1zZ2LZ4= 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=JeCXRN5w; 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="JeCXRN5w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268439; 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=piFGbpStSQJy+mcXr4hbLewWyhEioJRgfJ7dmrDuxBM=; b=JeCXRN5w84YfLVOpry5aR6Hi5Hn2fxKjsPq7+n3oT+NCzgzgkFNAJbS/FjHl2WG5OK7zow RILXDNdMMjueWr21xdJJqJwGaHRX7jsoGXctHLtYmh8a25RMnfO+44GawBJZcOHi1G1Jbx lfwX2wchOWPwVnZ50JIe6kE2h1Uum3M= 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-283-rIxraZ5APweA0Cl-85Ue9A-1; Wed, 18 Jun 2025 13:40:35 -0400 X-MC-Unique: rIxraZ5APweA0Cl-85Ue9A-1 X-Mimecast-MFC-AGG-ID: rIxraZ5APweA0Cl-85Ue9A_1750268433 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-451dda846a0so56144475e9.2 for ; Wed, 18 Jun 2025 10:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268433; x=1750873233; 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=piFGbpStSQJy+mcXr4hbLewWyhEioJRgfJ7dmrDuxBM=; b=uWvaDKXAsTCiXZqqENGtd6CCgDPnOOQPnxDxIx29eGzfw3kuwtIJKahTeDTOT944Bg H4SddvFtMxLm8xxqPeMNMniQyF3RQPcw5QukfQJpHsAZ9tAEpYNf0Kezwp3DHQQ5OeV4 9ASdyHm1BqG/o4IJGLkrt6gkzeHXBiYW0DquAqFtho+AdMcRREY1919lQnYxSXrJ6mYj xWqZugWO4g/5yS8R63bcwAFJ29QGdM4oFMhmzqJfSCknIGdWPc1yD5Larc5ZZM9GFxoC hIjtc1v5dvgD8HpPZClyg4a7O3uma0Ps+Ryx2tEESX+IxIqd8GRY3h1mu7IhMoZ7rwYb YIag== X-Gm-Message-State: AOJu0Yy2/iX8+3N6TbYq7agFuXzBtYLUkikKTn0Uvrtq2J+2f016i+Ma PdBMDdRyM+Uk922ht/o6GCE8gcDUWXggPRyXU5FsCF8znqn5zA89eo/uE4xlDoiMTwVpGx2oVGZ PGYN94TTpcf1xzV1kn2QhGzhCDCJQVvVXhj3dVHVuXz+CHnnzfmOXxdoH2hcftMjTx2WBwOyxkf unEseeRm1FvhpL5ZVEpVA3+tARNQjDfHsGz8tjFEdZOZbYWv+0 X-Gm-Gg: ASbGncvhyUVSLs75ZCLu7FTZCub5Inn6q2+gGmZqOOVIglJ9SJl1lDWIfzo5RNGNjxv CTawfuCnAJT4EeMHfMqpWWM29dGgk93V6K5STedjwlWKxSBYUPrvySTLR7N1Xm5CGynJeAWTkMS fKu/Ai78KpLzvwRvD33LC4+vLSGhHjfCbh10HHlWVDk9yZzq9Vutj2R++AB5J11l8PQC/LaUdgr GH5nrxsx/r/WAj2dERqDM8T0tK+F+XTdGSyqqag087wnnf58mK13QSXue2JC8Ro8EX6wvaePV3F i+iYumuoWJ8utdh3SzHp9+iTg32mHTqP8c0J+Z1GcCD/hpfugq34VgEo9cPJCGayYRly401sbO0 TyeK7gw== X-Received: by 2002:a05:600c:8b26:b0:43d:878c:7c40 with SMTP id 5b1f17b1804b1-4533ca6635amr196393105e9.10.1750268433092; Wed, 18 Jun 2025 10:40:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPWAw9+UfLP1Ct5dqz9wzZx48CMnDwfNIf0E7YgKYn6BQsIliiNikQN1x74QYxh04+83mIbA== X-Received: by 2002:a05:600c:8b26:b0:43d:878c:7c40 with SMTP id 5b1f17b1804b1-4533ca6635amr196392375e9.10.1750268432585; Wed, 18 Jun 2025 10:40:32 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e99d5bbsm3600465e9.36.2025.06.18.10.40.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40: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 RFC 06/29] mm/zsmalloc: make PageZsmalloc() sticky Date: Wed, 18 Jun 2025 19:39:49 +0200 Message-ID: <20250618174014.1168640-7-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 buddy handle clearing the type. Signed-off-by: David Hildenbrand Acked-by: Harry Yoo Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky --- 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 Thu Oct 9 09:03:18 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 B31382F49F9 for ; Wed, 18 Jun 2025 17:40:39 +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=1750268446; cv=none; b=jIl6ZOggmi2LzgIEJlowbbldhivLobHIc0AzeyFOmV7Je1mCirj+4XkjQC30HQ8FRAf65orf16jjqTPOrB1cH1M4jl1YZY/eC2LcRLcthYpG8kJUqTCU+EI3jidXsz6jc0nvLg9T8OE7+cedWxsZQ41MT0y87uu4gnRZt2jgQfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268446; c=relaxed/simple; bh=D5IKjl7h4uxnWuYRcVu+bMy926nngQzlNWfjJA6AuzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CCtKmKr1Uk+f06KnRJuOLYHt8xKVlRFK6ahgmJhYzT/8KFxemPzP5PolJNmV4VIpe/YUYriVHSQ7Jl3LYLEToIYniJ6ZXoIBtiVhdd/fdcr+L0UswTA3U6KSZQvm1XOuldg2+SZZ+v3OUGGl7MRQYEWjYxsoYBfHNdl0Y1KcZ4I= 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=FM/vYTgT; 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="FM/vYTgT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268438; 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=cYycAi7wypL2i/sUXw4R4ObGitZAt3xcPvEHBQISmjY=; b=FM/vYTgTFOyKAaBZkJ8bNwtpOeGL20X5Ny1IBpS2f/KwJ09qyj5rO8q0XyEMmZL0BNxaPy wXP822zE9MvEGfM3Wp1dxUp/ks5R6HF9ITkkVNa5xic4GvWHPNdNoMudLbxoyIcFJa2jjw ZkiotPR1K6IA2OmiKpufYBkSY0cNkec= 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-452--n1mG375Mjqz2ixM6yiLCg-1; Wed, 18 Jun 2025 13:40:37 -0400 X-MC-Unique: -n1mG375Mjqz2ixM6yiLCg-1 X-Mimecast-MFC-AGG-ID: -n1mG375Mjqz2ixM6yiLCg_1750268436 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-450df53d461so60267785e9.1 for ; Wed, 18 Jun 2025 10:40:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268436; x=1750873236; 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=cYycAi7wypL2i/sUXw4R4ObGitZAt3xcPvEHBQISmjY=; b=h4dWy11LLtqsvwBjWeAqJx13JokiKSSnJ4G51WQZsSepZcsPybwqvm8eH3h6Xw5elq Q/Qj1E4CoUfeQidA65Lu1+3dVNdeeuuThrmIOOvHgjkuHvwCZRQWLk0LQCpxXloXTcl/ xqhO7lUVgOlxPRW6Zkx1kMi+B8q9vmNGHnrTvA/cb2KlO3jXds5TvEvROFDHcph/sZlz dKuNEEpE60czQ9M1BVeWR6ziLzMm8RiqGJGRoQ99KWWiwn/Mm/jwXxtAl24XFGaaDzHo Mavvl1jMRHYiu/skHce1xV0tcrXyXsHXLfGnE1IIO13xD1BKInA9sZ3zySz/hQ8IhL6O olLg== X-Gm-Message-State: AOJu0YxRXZHeHeV3b7i6xuFobp3XYs6/xNMMdH1GgUSvt6k8urw8f1nI 3+NEGVOLwtAwiLIxbq5MMM1CWEL01Gk39tL7PJZJ+IPPXPVeFUVBl0Qvege6pyuhbn8yKkHdE2m qgzLL25s0JvimpFcGSuinJ5ZXi0LbbhDSWAsmJdGVwGJvu47vydGRZ47KO5IonC4neIfBsDqn8G cnG2OuMpQJk91by3Wvp3SshkfL/l2sZEkwkAuKmHEQf/BxjZB7 X-Gm-Gg: ASbGnctjTy7pb7+KYuR+ts0+kSV/bK8XgLlTdFMuanwOKEOh85MCy2qMH6OBg96P4GZ PIVgge9hboX4AntDVG/nI8vETQqDXb/WBpBx7+S1XRkRMm6FCbrQwrV709MjA+tTp2BUawsRpjr 9fV1j5sFmcBm/cJImbnMht/bVS1JuFg/5ojf5viz8Vsgd8THltUCH+UqrHF/fFeUYC1NXUkvuhC yTSN9dCikZF7qfKtKOHxaLR+Z81ZdRakcl0jMzdZchaA4dq8Yl1MeRGV2tVH2NBf5wDwg938Ylc VsSPJgnszUXNORf8h3kesR1D8jC7XDGgCuUVdZadmhpgLpVDvXJHYdMvYcilQMZ+CMssySNsPpV KHMhNBQ== X-Received: by 2002:a05:600c:1c8d:b0:453:dbe:7574 with SMTP id 5b1f17b1804b1-4535018683amr106187835e9.12.1750268436057; Wed, 18 Jun 2025 10:40:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUDiWgwWbQgJVHFyRRixono5bEyE4cqQlAJV7lYOWhJt5afQ5kfI4WOQTfix7X+TWBj4ApqA== X-Received: by 2002:a05:600c:1c8d:b0:453:dbe:7574 with SMTP id 5b1f17b1804b1-4535018683amr106187035e9.12.1750268435264; Wed, 18 Jun 2025 10:40:35 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e98b4bbsm3633515e9.15.2025.06.18.10.40.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:34 -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 RFC 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page() Date: Wed, 18 Jun 2025 19:39:50 +0200 Message-ID: <20250618174014.1168640-8-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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(). Signed-off-by: David Hildenbrand Reviewed-by: Harry Yoo --- 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 ea8c74d996592..6bbb455f8b593 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 Thu Oct 9 09:03:18 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 C06BE2FE384 for ; Wed, 18 Jun 2025 17:40:42 +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=1750268448; cv=none; b=vDq0Z6Z1T+L8kSo48/G4qG2NgLnYpuSp0ISB4mde2YMTnmZ6KTMhzqSYp4y5oDWxtTFD6pQMEpxbfbLTUzw9WjCB+g5IatvOCx01rcSzyeN1kYuv7EYDnB3fyZTta/r6IgXBuT/+dUZC5/OmcxzsEA7z3r/ymvS5R23iemSxhMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268448; c=relaxed/simple; bh=zbcjdtHnZ1BcawVRomdGBMsau7cooieEoCmjNLCJMWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gUqd60PzWHBdXNzqvvCIG30YlMcVTGbg9Ssc1jsu2b+exUpZreg1cTCZ6F+VBBMe5C5KbFz+x5iBEhgcOSO5NTq0CpX9iX0INa5Wz6xIx1boJOZ7Kkxn4vUQvPs01gRRaNXmoV242wYHl0ywehncRbSp5+XcRkhmoM5BHu3myAw= 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=b6w9Cslo; 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="b6w9Cslo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268441; 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=5rGfc3zUjh7F4hWUWCipVozVPKyNvGr3sO3WbBx9inE=; b=b6w9CsloZEvd0XCjtYKTnr/TvaAbd5PCSq3cG5U/KxPAiH+R70+kH0vQJteUh0RyHVchR1 HHMk2Zqr+XBwwMpiQZKn3tsKo6RMAHOr4SRnTwe3DSv0ddsFMx9ZzkPVuTy1zraflPT13Q jlXAVuGc5kTxujEbywbzMMcXglNPRH8= 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-60-8edhxGwxMTO2Q1ar0dSaHQ-1; Wed, 18 Jun 2025 13:40:40 -0400 X-MC-Unique: 8edhxGwxMTO2Q1ar0dSaHQ-1 X-Mimecast-MFC-AGG-ID: 8edhxGwxMTO2Q1ar0dSaHQ_1750268439 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a4f7ebfd00so3267793f8f.2 for ; Wed, 18 Jun 2025 10:40:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268439; x=1750873239; 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=5rGfc3zUjh7F4hWUWCipVozVPKyNvGr3sO3WbBx9inE=; b=HUrdNFVULULsm3jGTwWnEGFvt1LnpPKMsyUSlFnl4z0B+j+GpIq5zYjSbdnjbCz2Wd //HvVJyYHuxfbz4ImsUX4PhvGhCEeBpBkTtD32Fy+1b6SzUOR8XPS3Iw0MoUZdKawNss VJy7Wj1eMTzKy6UTgSp+JNvKnvb6jPg4G4dOTMW0aLVT4mXo0eKl3/6MQOHuM1J8T2pt QN/34g3VzjtbAhnYJlUxHs23o8lSJVGarNpOgHnSlP2hQ+rlJPMoTORWmR6Z5ncQkrPL OhLzDyv0pJmou/tzSJkfi4WGPdXC+m17x7gogQJNwOpo6zyWtbiS6B9/pJnWMFnKhJ/b jttw== X-Gm-Message-State: AOJu0YzX5DROf7nQLdJDxyq2jdS/VRj7oNoe6Q2QaeDyxnHEmwp6Hc99 yvveOo7ZwGHpkeFQfZ+WKMwc6V8r2mUgvXuY4fv2WtKQ6oBO5E550Ya4lwwJy5+za7oIQQ7A/Sw h3WwpOZ7QGFc7+J5eo2RgP3WOhMspRLmUZPkiIxuXQ3iQoF78wTuORpKQj9b5yaU7c9OExLZYFO FC0p15xZ3uasjGtIWi2PXGE8wt6BFCVwgkGL6s7wkXUK1I/WUI X-Gm-Gg: ASbGncvDqWIMKFcNTuBtzdFb/rU0vtPsFXR3xLNYXj9H90UWjBvrs/3wuMWMY2ReFqQ uPjiOekne9qrLtIJYbSc9/T01GZ+DAspMFF5IuyPPjzpFMj3ngNoH+l1SR32ql/FB8JrdaEZ2/s 9DnHxTF9dqJyGNLzxZTaHDPHOm0sL/EMDcNa3a6p7jp1ID3QzMvEDTMZ89G2lAFswPQ5jHXz8bU i9Q7xZFdeXGXsYdwcbYXzsWKYaYwnfKbr2LT9BCwWRT73gFs4NKIwvCElaOb5EsO2DfCYFiH8oZ U5Wy/1DhCmQox791+fO/GLzuvdzt5EJkHHJq+zCWCRV4x48kZb79qJ9LoEVZkdaKq2ZcjLe+DnD JLBWUxA== X-Received: by 2002:a05:6000:144f:b0:3a3:7ba5:93a5 with SMTP id ffacd0b85a97d-3a57237c9a7mr17230312f8f.26.1750268438674; Wed, 18 Jun 2025 10:40:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk4wH3M6h2T58ReQA5DPEIh/WOsy58XEgAZ0LBQTHsCj9tNbupSQVC4fwDx3ff0ep2cpGgew== X-Received: by 2002:a05:6000:144f:b0:3a3:7ba5:93a5 with SMTP id ffacd0b85a97d-3a57237c9a7mr17230239f8f.26.1750268438093; Wed, 18 Jun 2025 10:40:38 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568a800d9sm17307416f8f.45.2025.06.18.10.40.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40: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 RFC 08/29] mm/migrate: rename putback_movable_folio() to putback_movable_ops_page() Date: Wed, 18 Jun 2025 19:39:51 +0200 Message-ID: <20250618174014.1168640-9-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 Acked-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 6bbb455f8b593..32e77898f7d6c 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 Thu Oct 9 09:03:18 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 C99FB2FE386 for ; Wed, 18 Jun 2025 17:40:44 +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=1750268449; cv=none; b=PojUAbzVQndm6ljRVymu5DFezGhDxHeuIaI4cmbEjt62TwtV7sg61dC9Hz+pGnLSWYOacaq8PnSkB0kuPq9ZvqWBV4+RYIJzS+pv7pHxCl0MaY5vR4/xA/DtYeepMuHMFxHk1G3xF/KUQHlwYaLpBtYSwuoxTn/cyeWtkmJDzQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268449; c=relaxed/simple; bh=aEP6DnjEOauJOFrkxr2zR+ZZpgBJ0tgUTK1LoPRl2/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CKe9fkUi19O5SSDjUGdCkIGtbI0OkbtZ83I5dUMsXGbNFzAu80sdU6XaTPq1qtUYMbFsvferaE+go+43lGc11AkpaetgMl7yHsOfNhsr9kltrqrdr5puJXm8WApWoX4Lkjrs3qMbcNEkR0BXjVEHJ59TTRf4BMZ3/Y7kfngnj4w= 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=Q0G6m8Tb; 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="Q0G6m8Tb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268443; 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=j8LuODrccx/EBs9A7vTNySqHbhe9k9tI08r8Ga0Xgcs=; b=Q0G6m8TbA1ZjvVryxveyfa/ejwdn2GMI9b4s1y7S7QULoikCIUQNnHSG+jB0J8+/YlUaYV 6W+EhJBugQg9/U54KEM3ne6ADpswq4cqMlr0cBxDFz8UpwPwzqdi5XRGlOWV14F2y19KXU 3MuqHnjtlDumdmSosroZ9N/jNIJrqhg= 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-240-35Zafi9zP_63VwN2v6CovA-1; Wed, 18 Jun 2025 13:40:42 -0400 X-MC-Unique: 35Zafi9zP_63VwN2v6CovA-1 X-Mimecast-MFC-AGG-ID: 35Zafi9zP_63VwN2v6CovA_1750268441 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45311704d1fso40530495e9.1 for ; Wed, 18 Jun 2025 10:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268441; x=1750873241; 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=j8LuODrccx/EBs9A7vTNySqHbhe9k9tI08r8Ga0Xgcs=; b=m2nKzbEBDWqmFxi+34lxq7hUp4FTc7iStPEbeyTbmO0DDZYbQXYZa3yaH4fnauny6P braHgwpQvvXEYX2ffskvjZFsQlhAUTQvCiJVR0MqLY6f8k0TImfDsvVk51e7qA8ifBll JgUIgfLrxl/SOAmD48Atvdn7z32RAvVF4v/eavcOWGFwyg7GhSx2b+h2xlguAc2/aGNL JJKNMO8AK2SGBjxQe2ubFlqd2mkDZfWtWcEi+kv0xLwcC++L5xVozUMJFVkvMJQhC1lU mCXCYwuBe9tJCatdeJK9NI7lkptVAxjFyHE9q8QuibP0Zx5YJb9jbYha8/wIw3lv3xkx a4JA== X-Gm-Message-State: AOJu0YzdswJF1Q+J4/ZpDbzK1LfQs2QiO/yRcPf0ZAgFNnNfZQWpthxq b4oWRDA+Py5Uo5zeOkTkoRs4yKFc+i1YC4rF6uEji1KNaLymlyxF+1tasdOAsKyisLXwSPQpyql kzpcK9U+IxQ1AAoEPlu1+0qvGh4QVK0CkBEvlVmnJ4EMjgzjbmNnhznl1awWlMgX8a/Vuzy227p S/dLRnANmJ49MxnijmkAN0G7rdqxishTPJnsyty+ufm974YI4d X-Gm-Gg: ASbGncu2xcPNf6AZAH52vOaF+WxiB5VDyDi354cSpviuvAXOc3Vra+LRfJAwrwOJK5R Lf7j74J3F+sS3KsNrWr/YBrPfxnTl72gOfMb9JyZ7r9PcXMWdFZZJfsfRjOwRTVCrxuqO4V93sp HfXqKK80fMi11WRBxUJ9iPI7g6vPi4p6SlsAePoa5GVEJGaktyIGD/Q48t53bJXt6zuFYyjepCQ rmQvtcG6DWTRTLPGMGrBsyr9Anzy0d4adCNTr+roXawwxCZna7+maKWycXDVEmHnlawd3EZA1pd umyNGua4nlZ0LVPSRjc5EuJTpUlWPBrgLKrtxSdfcoeyP84ettGBMvn+NcogbtFHYhG7G79sBy+ VJ2OcOw== X-Received: by 2002:a05:600c:1ca1:b0:440:54ef:dfdc with SMTP id 5b1f17b1804b1-4533cae6605mr166407945e9.8.1750268441330; Wed, 18 Jun 2025 10:40:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHc4TaNXORzdooVLODlvwGNYZ3WZPNGmS5C2sKfTSdPVLBbA2Ps3b4UKdLfdRWvy1N8seVTmg== X-Received: by 2002:a05:600c:1ca1:b0:440:54ef:dfdc with SMTP id 5b1f17b1804b1-4533cae6605mr166407185e9.8.1750268440690; Wed, 18 Jun 2025 10:40:40 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e97ab95sm3814165e9.7.2025.06.18.10.40.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40: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 RFC 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page() Date: Wed, 18 Jun 2025 19:39:52 +0200 Message-ID: <20250618174014.1168640-10-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand --- mm/migrate.c | 82 ++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 32e77898f7d6c..456e41dad83a2 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 Thu Oct 9 09:03:18 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 70A5F2FCFC4 for ; Wed, 18 Jun 2025 17:40: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=1750268452; cv=none; b=nkI2RYNoPyh7yOiSBEmPoRgD7rgW/UQRk5rckF/atHCZaBMN8h1WwHTnLzJNDGl9BYMglr2TXwaZBcQA+gmgSTIwAsfoden2UdFWvVKUJPmgLEtZJwiVpc/AR1IEgR2zbgTTtWMQlCyC/acqK775cZRYHkPs9HzkJpS36/U7mpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268452; c=relaxed/simple; bh=4i7IUlR1GYEmR6zjKB+4nkWLQlvD9f6ku5JrjlUDoK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=emcXjgzchj8O90vwI7WDs0OwJLTEUgaAQirQVwSnXug/u8S6MUASYRbLDr9D26opkBPFV54Qb+0yqdugAw9Cy0Rs0zWZNut/YmgkKybFHd/RNdfCzEK3XuvSYQSw4wLQjdNEMmOT2HdgAT/PR5nZqx78kf2JISpTB2xzdtyrcL0= 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=Uy3s8c1Z; 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="Uy3s8c1Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268446; 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=fwm1uiBUBcXGnja63XmY2QjIjVtNliVfN8dAKrOXwFc=; b=Uy3s8c1Z/tWilGEAO8tn6yYtWs0GcI3hmmpo+rzXd1AQSzsiOhfgHQlS3J7WMx81NTZcXP RccxWUb8qpBRuijt9E5uI+BbmQYA7igpVVPWt98yFJHv+4aLu9Y46sWPu3P9iStY5BshkN MFK5YsKW4zXD0AH5FLgSsIlMBbJEs/8= 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-223-p3ZcXvAtNj2Klv2wl0Ro9g-1; Wed, 18 Jun 2025 13:40:45 -0400 X-MC-Unique: p3ZcXvAtNj2Klv2wl0Ro9g-1 X-Mimecast-MFC-AGG-ID: p3ZcXvAtNj2Klv2wl0Ro9g_1750268444 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f7f1b932so4391033f8f.2 for ; Wed, 18 Jun 2025 10:40:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268444; x=1750873244; 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=fwm1uiBUBcXGnja63XmY2QjIjVtNliVfN8dAKrOXwFc=; b=UAZFXW8JA39pMU9h4Z98nDsFpvGJqJ+/CAMhRnJLdN+oi3LQRys0kys9jcj85urw/9 FUbaymB4T7iY5rExlpjXpGoD+oNPbDrBQ+S/AGq5KlAO0Gy4T3Hql3bM2E3dX5TGGJAC X//mJeX+H++S9l2n1QRxuhKFl3hD8CktHH9NeDHHlI5Wqa10naoDMYhubPqvIKaa6UFN U022H09/bYQauT0ZWxWTWuT9PGcvTNxpEJRZgEPkAqy4uWHpUq5G9PHzYDzS4u4TXUK+ 5j/Dp085xAHxe+NvpTFtD5LrTr/ycg4SYLGgFsKhybbf9CQNLqs+o6xi/zbBnf6g2MKx aHgg== X-Gm-Message-State: AOJu0Yy1uUs7/+zN6+XhnNHqKTUYwDmF/AWHEALdnDsGkyCKA7J5m0/w I9V+AwOFHK5FIVSdFGUBE6dcCMDHJYeKSduogXiycn90IvnxDZWqRKug2Eqiimg0c2xhv0c2SUc pC96dPJ7bkg3FCDImgix/AVepuWGjaYu/QExMwbz2dBgIIv5jWrdo98v7w5aO7Mzh65nZYB7RIF gsp05h9HZNAkQf7bgjF7fDxx3J1ulIDcyp9G2kck6eGEr9uuN8 X-Gm-Gg: ASbGnct7/5Fcwzeb7D+A7ex+xTIMFHhmalsjEj7m6g/+rjLfsuFCh+e3/UXMzgOGygg Cd2XtiblsZKAg7NmWtqqB2E7P3xtUvsjIA3mCjhaHsqv0vNbib0U0y+Yyy941kFSPORRmjb2cBQ 3HNJp0vb9MgOEcoehjYNMbArbXzO7A7l13mXS4JkjqxTfYEjWaKk0/eZolTZa43qq2szh2L/ccy u7q2a4LU3iEtlUdPH72YbVx/ynG7W5hSaWtei3MA8unG6o243JfvNugPoqPD9KjeP6KK4oLy0aq exYyRLlaO0pT+b6abD0evOKdIoveA/epiTCGNO1HoMgL99jspGmh3R6OZXuoWJ8fQneFif7FSYG DOtdrzg== X-Received: by 2002:a05:6000:71c:b0:3a4:cfbf:51ae with SMTP id ffacd0b85a97d-3a572367afbmr15684703f8f.4.1750268443823; Wed, 18 Jun 2025 10:40:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEywSnKMkZlpTz2OAMYD8vOZkvPdDtLDDWrsPSDJX8ViTkX0laZRXIHvaFqn8ElXQBewjN+xg== X-Received: by 2002:a05:6000:71c:b0:3a4:cfbf:51ae with SMTP id ffacd0b85a97d-3a572367afbmr15684628f8f.4.1750268443292; Wed, 18 Jun 2025 10:40:43 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568a54b7asm17688084f8f.16.2025.06.18.10.40.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:42 -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 RFC 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops() Date: Wed, 18 Jun 2025 19:39:53 +0200 Message-ID: <20250618174014.1168640-11-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 E09692FCFC5 for ; Wed, 18 Jun 2025 17:40:50 +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=1750268455; cv=none; b=c4Qsu+11JWV70a9d5McwGVLOvoc+6uygHJRS1uPWkkTa73WB1puOcXWtaHcQPAWG4oO/rkn1CNzNuzK6jhDonu1EA2el6uVcfpa3QpzJoamlW08GHau24nizuTWTvBW86c17KxvmBMCJD+qw52GcPPDLuGcoYPt93ug9Mgg20TI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268455; c=relaxed/simple; bh=kK+1H5O+WM/ACnNcL3KxA88ivXOG9CXAUU38rvMnDO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c+eKwaloCauzt6cYSWTg/Wi+eamB2RmiXj03/tlq2rJnOa2y4viVzVydmaRb+9QlgnYi8xQorhb0DQWRhk2Vb1koKP+hNJLWCWfKWS1OuOnZMOhtStLrpmvE/LyZPji9JLay6DMDep1+6Ht5mgACBb00b9Pb6rqZk293jHY6a1M= 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=aJk6bjMP; 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="aJk6bjMP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268450; 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=fdGmEg3KxJkHEQxrZBJZz4koG+H5rtVXjjGZN1RlWcM=; b=aJk6bjMPWbz4fo9tanBF/Bn1ScFgtQCU8aABBU+OXvHWGl/p9U0IyOfT+Rf3hWWsryJZna MttHCiRmfO03kAVsZKY0plHGlrtW+zqLnDHw5y4VkLsuYXqhTVJ8PT6KaLFmMV+En1/jL/ i8lHCQ3oSmt7j6MxqmziS2CoGv+6Z/M= 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-533-PzV2P5n3N-WodLoLrLj9RQ-1; Wed, 18 Jun 2025 13:40:48 -0400 X-MC-Unique: PzV2P5n3N-WodLoLrLj9RQ-1 X-Mimecast-MFC-AGG-ID: PzV2P5n3N-WodLoLrLj9RQ_1750268447 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-450cb8f8b1bso15227185e9.3 for ; Wed, 18 Jun 2025 10:40:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268447; x=1750873247; 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=fdGmEg3KxJkHEQxrZBJZz4koG+H5rtVXjjGZN1RlWcM=; b=boY4hiPiOKmMweA+/zQSL/xOp+/1UqNEYEViv9xypVvi5rKP0adgcz7J4XZRxc7qv8 yRnfJlmGMokxvrxf2+cyTjc0E6dfA4CLe0T9ayjd+DFQyBgpKW/1pVVldRxUcOLjVcPZ Qm8XuDOa4axIgm/0p7rXxdRWOHJXzzKAosuyYO7vXp/S91RFAmPv5Wgu0SodHLX4NLGA KrJXKR1PYXzmNFX92CFSxbFnc6m8hPL/ftP+K8CmtR5zgNpHMB04Tscpuz4ftNI2YegW 7NK2n644QPan5We2MNo7BBG/oeu+i6SO4A0JcujYqo+nXu4JJjHUPLJOe2/FZjVxVBtP 8AZg== X-Gm-Message-State: AOJu0YxkhWIK/BR1OhOm0FLpmJ6/7sn7A4O0t3KcDnOh1es5VoUtXP9x R2IEyPFgso/XwbaUEg15iIeOXJUwci459DrrgGmXbf0gClZMeXvJxI3bvRthUiOZv7htDCKIzLq yWAB7pV75B75Sj81YjC05zKh81ckEHe2zFomWTpDR6gVTVW1zbDfsZ5CmO7o+WGxXQuBroWOpb/ BfI7P/+L+KnYwZmvUiPtx6MgLOoktdqMIC6xUHYJIs8Ampxi3H X-Gm-Gg: ASbGncsEHG6NSfzqIOzgtlUSHIA3I9al+Mb6Kc5LQ+XkMSsLabQGqgOU5Kf+d6xp+bP OM1oTryhP2G4wYaV09aqmxR4Kpmh8CcpKjkNKcASG89k66bNE29RXS4XiSvxhw7dhUTrr5yjap0 K0J66bEcnZ11yWLcvYQz52tRO9bpi7jVC3m4Rt5fbTzH7rYbGt/wOZ9n44Caa9yhXFUK/SvgEg3 so7ZdKV16d6U31hv66n34jGxmB49JOetGVe+DB5pyx2Xj+jpszXMgUbqmJGx8EqnT6gqXHOaxRQ XH9kS/icdVcH+cwSN2iTp+W8Q49/2jsWVtMnHhjdnaEdJiUH69bYkOAG78VwWFBcoTjSMZd+53z tVHPw+g== X-Received: by 2002:a05:600c:5253:b0:453:66f:b96e with SMTP id 5b1f17b1804b1-4534219a64fmr154403525e9.11.1750268446668; Wed, 18 Jun 2025 10:40:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXftk3ZXBXIBGlT1RpZSgQfC+IysEY/Lblmm+ealanQwQ/CfiKMmfIF1BFjPpj67LfRQmzUw== X-Received: by 2002:a05:600c:5253:b0:453:66f:b96e with SMTP id 5b1f17b1804b1-4534219a64fmr154402755e9.11.1750268446175; Wed, 18 Jun 2025 10:40:46 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e97aa15sm3975415e9.2.2025.06.18.10.40.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:45 -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 RFC 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio() Date: Wed, 18 Jun 2025 19:39:54 +0200 Message-ID: <20250618174014.1168640-12-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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) Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- mm/migrate.c | 61 ++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 456e41dad83a2..db807f9bbf975 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,21 @@ 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); + 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 Thu Oct 9 09:03:18 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 2EDAC2FD89E for ; Wed, 18 Jun 2025 17:40:53 +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=1750268457; cv=none; b=ZXkgYq4WjsK3xtYhpHRhZzgaApSiI+IwhkjwVBJhX1sSzLgrtlj1jgUEuMygktWy4s80l8DOqiBN8gFaI6Nw5O46wWd8afQbZGc32D8N/hpVKghhZlwAkub0g+Ls8fKCjFTDcuNqFnOnacPw+QHf2UZUqtWeul/LLyAC+LOgUzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268457; c=relaxed/simple; bh=B4KdnntE/37K79ZPh7jyK3I0hRR/1p6A2DVmbrYflX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jdgnhWOvmoWJBZ5Q1GlDrD3VyIjicbx6fwP8JvcguaH5REPBDxn43UfgccX2ocfPnVB6QgpiLY6lLW45Ibph0zgovQvzwj12P0EPfb1z1hz6EQsH10kyIU1vb7I5n1bAfADnkWMJ3OdefpjM7VJEAj3CsLgQlRaiwNPf7sSvT48= 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=gFnIXG88; 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="gFnIXG88" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268452; 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=gFnIXG88LC01Jo6lPbJ1TaKGfsw/qSVYvpFDxSw4ZKev2lxQty9BMknSdtiUEom0ppsCKO vNZ2aEVHgUWzAnvdG/5xFqBYJXWOtkvF5cQzy8EaJ2jYy8wKSGTxvrbxMUDQPEHldUitdW /i38MkVo1TKnmZU9Fi9azoruFqhPFmE= 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-564-retcN2DXM7uIyQEpyopIrQ-1; Wed, 18 Jun 2025 13:40:51 -0400 X-MC-Unique: retcN2DXM7uIyQEpyopIrQ-1 X-Mimecast-MFC-AGG-ID: retcN2DXM7uIyQEpyopIrQ_1750268450 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45311704cdbso37818195e9.1 for ; Wed, 18 Jun 2025 10:40:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268450; x=1750873250; 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=j2ZYytr3d11Uf9h6X4RQQVJpoNTmV3hMURsJDfHQY+cHdQbI453T0ZAHqOhNsndOBj q0SO0AesgtsmwgxVNOhRYrroe9/0roboOi+RxkusAkLAli2lpQyHuDVnG9mM99tgT5vK N2CjVFf/oIn9EiUAJ63ZG4lBBbNwnBY+y2buYqYWuYs+xZFl1zjUX+XbtDFrrozi1Lms jKYPrAMg+Fs90OYUSnsCk1AAGdTb9PueVqlT0sUs0ZODhW04VcWDmpAlt8jjlmclpXeY KOawqhqieHiSnkX3IZhavZcqQRf7Kq6NBrEOeEq5K8E1uNH4kVPIUH+//DqJAQTXn4e3 Z2JQ== X-Gm-Message-State: AOJu0Yxr01/PvRCpk1sUGRa3fZbJSuxwX3PLnHqldsnKomqekj7waw0s gQZfg4+dnfnYKJtc1sGfpaHjbUitoBpL/0qfMvQOs84S1f+oOnNSOSWNfS43jpw0s0E7d38U/0U CBH0ZsHnxOLc9QS+X1+YMKdz9Xy0LVwDNyvXSgzT4EPFvUZQAI9CtLAKp0XG8h7bd47eu0GV/5i fY59n542zaQSX2H7a34kOs0Do293Er4/dwgjRDwannthvonJEE X-Gm-Gg: ASbGncv05JFdbQh8OE16lPuW7XV6V+lsJthXQaJ+SZytd8uyonHwD7wkl29mRA59nAW NtVMEymiByuMmlZlzgPkI8m6+cEu5vo4+Hgc7xQUNXKdNRaGwc5dFcq/EiB33uwOHdrb5g0Uzb5 hlu17rcmkHT8usNvFg391LY0dk0dF30DgfD/X8ut65u9JaIgqZ76BWGa8IOKijG/6WrzVMSjTQs JGF6ifDxGUVaYYxhAsRDYcXBlRbVW5Sx4+pvqCtBBwJJiD88I9v7q79ANx9DBbMZs4fPvCAAh6N VyAK3bw/I4w45jB+WEbZvSDoy2J2VlgNnnsHwbakOlSg34zS+iq5AApjrseGehTM41raKDwFLLd PwbDHeA== X-Received: by 2002:a05:600c:1d8c:b0:43c:e70d:44f0 with SMTP id 5b1f17b1804b1-4533caad0aemr171065095e9.19.1750268449818; Wed, 18 Jun 2025 10:40:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGznKIGl3nAorQ6sfOY/mgzfowzauuqoYlpxs90ugUrSAZIVXpSWN8Es+fpzvWy+uQJD/IOZw== X-Received: by 2002:a05:600c:1d8c:b0:43c:e70d:44f0 with SMTP id 5b1f17b1804b1-4533caad0aemr171064285e9.19.1750268449019; Wed, 18 Jun 2025 10:40:49 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e983c76sm3664265e9.10.2025.06.18.10.40.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:48 -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 RFC 12/29] mm/zsmalloc: stop using __ClearPageMovable() Date: Wed, 18 Jun 2025 19:39:55 +0200 Message-ID: <20250618174014.1168640-13-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 --- 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 Thu Oct 9 09:03:18 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 94CFD2FCFC2 for ; Wed, 18 Jun 2025 17:40:56 +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=1750268461; cv=none; b=e9XS4rhoPG6nd8UdMcpdQxl4vKPWL2SdqY19yfiIqvDAp7DwT1BGWkaICFjPURG4O7AAxesMRq6Wcsy6nevgHWF/6kMlz5yWHF0Xj0j3nRCUqUrX4qLJWGSOA6Zbljr1AvRgsQLMWLr8XCXwT9M8fSnyFIDcuJO/bp90sCSPgzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268461; c=relaxed/simple; bh=qF9Vy6Hq3fkswUG+ny4V9wMgoAlWF7MBQAZDgFpHwys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oASu798MtbvUw8beNxFIb1gc7RVUPvdbaP/2GGP1J1CMVRSOBaqRVAdagjfM9pRwgBqZXsmOT5CqfRER6IKy21EmTWkehbl/czkMb/fv0DHLxJjz3KXT9t2tB7qzuPJM3icbK4A37FMomfDOlK+5s/SyRYNr3a+VJo4RqBM8Ikg= 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=Z9UcrD4A; 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="Z9UcrD4A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268455; 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=l6C8lbjEXu6LV6W+fOxtWyWYf418kuz/nIG8TPoHlVI=; b=Z9UcrD4AgrVAV3A7pbeUic2BO95FSqSYhkik9xBsOOPqQYUMmUht+y5NmLJjid1FJ5OFsu Ey9j0e5jBxop29SoyFUzuitF1elFGEHQfsvQdNN37HrK8/7Xm7BM4DvhFTZU8I6F8GVbuD R9fn7PrlL6p9rxRWOq7x0Um7MV1mvdk= 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-557-UuCAPPjoPBiA9uWP49FJzQ-1; Wed, 18 Jun 2025 13:40:53 -0400 X-MC-Unique: UuCAPPjoPBiA9uWP49FJzQ-1 X-Mimecast-MFC-AGG-ID: UuCAPPjoPBiA9uWP49FJzQ_1750268453 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f3796779so4865773f8f.1 for ; Wed, 18 Jun 2025 10:40:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268452; x=1750873252; 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=l6C8lbjEXu6LV6W+fOxtWyWYf418kuz/nIG8TPoHlVI=; b=k7RUvPbvUfQukvC/KGXXlQf5gyed8wFva0Exp9X1ixQ6jHdalSfkOEGupF4zEUI0IW nKUOhDuj6n9gVgGIUCgYb//3nVwXMYN8x/HyFOk/WqImQyQ8ldQOKM7HwZtE9bKjzTf6 HhqFhOFII5hYKz9jDfMttPsaHIwe65vYGcBzyJnUD4DEW6oa09AWlFFx6uwufcz4/wIn vS2irxA6BWbPtMM8nd7RKUJy0KYRO1uorT7wvF0e8MXuseQGckSeaV4Y/89rgFEfDzZN THnkSjx5tpPjIryx2OJ92fNGCissR7N427dEamwAy8UueHJKa0io5LOwgI2qZIqpnffe Jg3Q== X-Gm-Message-State: AOJu0YxK84vtysdiuWxsyyJHWbFk/6uv0LFBLTe2y5MsiLHqLoDR6jea Wt9IYfen83uYlocZ5lMOZvv8jas7iWEvpvxDdF5pHV/O7FyOKSvfOEhpPfwoyqpdmXLalEdEaZX cTNDXTLkLV4J6Agc9AL+6B8TGfevi2PIEjDD0x3HC+rMcfi9dKOq9RNPGM+iUnObYRhTDFhhGlM VELDACzYkV472zvxDqCXVuzIQD9gnEq+49UB0kCC85M4jiTwfo X-Gm-Gg: ASbGncvmgv5mbdXh2Lg+Q6HdN2xwO7DZLck2LoZWnScipvxqQszCQLxAjswiv1MQGXV 5Vkn8ejb4CDHauONrZiRlBUVDXwHvFLdNzUDF45BaELuyeYrSpaMk8jJf+b8txMGiMYFltkyQsp WtQ9TBnBXgdEWpRVFbOUs4aLZ6SGIlc1/V5osx27QAvvhDO3HFyD4BY0wtw71N35a3isNDahqLI 81HbtKwVJNuljcUPKAlwDY4qrI3pNqiJnQrB8aYXz3nmHNxtzSs/IqOd9G3eS2sM40RefkaNS0a NXb/bSLWytBjvuizuNNDcZo+N41BsPYLU01NTdu9xCKM5znHdPpp0fr9Dh958kdkdeBKjlAzX9U iAOLY8A== X-Received: by 2002:a5d:64ce:0:b0:3a4:f513:7f03 with SMTP id ffacd0b85a97d-3a572e8bfb1mr13954348f8f.44.1750268452518; Wed, 18 Jun 2025 10:40:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4X4ziwIkhys2144e75SHEIZN/Ibpbo9aRHgWcvkByvBS3juQ4aklJtEd9sXicogG+MbEwPQ== X-Received: by 2002:a5d:64ce:0:b0:3a4:f513:7f03 with SMTP id ffacd0b85a97d-3a572e8bfb1mr13954276f8f.44.1750268451787; Wed, 18 Jun 2025 10:40:51 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b089c2sm17710418f8f.59.2025.06.18.10.40.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:51 -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 RFC 13/29] mm/balloon_compaction: stop using __ClearPageMovable() Date: Wed, 18 Jun 2025 19:39:56 +0200 Message-ID: <20250618174014.1168640-14-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 of 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 --- 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 Thu Oct 9 09:03:18 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 858C72FFDEC for ; Wed, 18 Jun 2025 17:40: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=1750268463; cv=none; b=Gsq0yw4fUWAbnbd8gwmYoqBWmjyoIveaxz/k0JKsguir6BeGqy5i0FArRyACDio25JRfQVw+pcPCe7KNYjYF0jgS6lE+cv3mZx+3XrRKmUKh+M/VL1d2fPQqxqu/3Gi4lYqPEaGPLu23JTMzPOn21xY4U3PzCNWVEHPwO0T3doc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268463; c=relaxed/simple; bh=ltmtOsj6PvpW+vjN7IqM0EXe8b45WiKSrK0SISC1AKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SPTsjXBFZS1X17tItlW5Tnhn8wma8AMemUYBMr+QF1p3SCd1X34s5MPdNxbO7C40n36x5mFc7N7eeF4wi8jB/yEKRXt2OX1mr91KJnA5BrtrcLlMo9BYpV87pbvHpTwwaQP3lE8TLGmekcNPcop1nx+SRW0XFZPbxMZokCOFILQ= 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=N4qXCSVT; 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="N4qXCSVT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268457; 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=R518sUXauciWuWBIWO47EfDSUo24r+YyG2S8Z5J8Wko=; b=N4qXCSVTOqS0jmWYH8loTM3Uk4emj/K3JX/PUFypyYUko4RxqE1/MjxjURE8tTI06Wp2n3 WM7zz4AabxtD0FBbHI20CDp0/mMIme7TAoHX2+KYut2eFrtF1NQk4F4i/ZsUGWoqm4X0+F TLtKWC8xikiMpOI2Aro095CFCxrqHlc= 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-436-qSCLbJXdPeCxuJKeUGUg_A-1; Wed, 18 Jun 2025 13:40:56 -0400 X-MC-Unique: qSCLbJXdPeCxuJKeUGUg_A-1 X-Mimecast-MFC-AGG-ID: qSCLbJXdPeCxuJKeUGUg_A_1750268455 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-451d2037f1eso43919725e9.0 for ; Wed, 18 Jun 2025 10:40:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268455; x=1750873255; 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=R518sUXauciWuWBIWO47EfDSUo24r+YyG2S8Z5J8Wko=; b=dnfzJmY9n+ECxcqiuFe5Q6NBVhHpVSuDJxxHbjfAMaSVX3dbKDiF3IBlkUJl/oYfF0 HP4srM5ZehZdYapM+zdFa8eJTStPRxaNrqqGg71JlJCz+FgyR1WbhwdF+ne0s8uv4/fq lI17hUrC3gBN641uXHPIi4gUts+qTE5PtOOLyEnsAMrWeZxcNBn9pringfWUeFVy5HKF jB4OwDH9qMlcxYkcNboi8MAP9qFYPB3bFbXmvQCmx+kKBhjAfpMBwgGHxDiVgwUtfNTl gRHJXctGvUzy+VHz43EDd+qy0TOxV4junOS6pt+8jMDE4FgPFd3N0k6vRTmSSs7MkjKJ nFKA== X-Gm-Message-State: AOJu0Yy3rE6DywC/fiaNdKmD/siNh6GKn7LaRuaeRT2J67Fcd64WkIN4 KXc/dsDvW3P4Ntl8/SMHpyYiGVCJrA82zX4V2meCNJLCvi1O4ic5lYsq3h4cDkng0PBPI01D2de JtW7TyV1wEURz8JOGdAUgP33HLj8AWWTZEuYdkG+Y98BL//dNRMticbCZtATtQWfiDFFP7QJJo2 lCB5PCRdzgPQNbKRzK3gK82sQ2mAJ4rSadOwyp/KI1vUBsp/n8 X-Gm-Gg: ASbGnctrg+pZCSDMp1hGRWKc0YcbU1jXn2hRlkANkIygxP2bKghCKxhynN1kak5cMtS CIBO6z68B+sjs4DSeBEt+IaIUvuGB4LfuBqQ4p9+mc51j1IinZND9DTPyI4OFpxNShp9Flesl+5 uhB3AuwV93DleyaIy8VItYmpms9ne5uKkGMPBkoOcmY/Zq4auaDfw96wG+MG3Tp4ueGVamEZ+By ugEktdOoFmj7l8MBzN2ZEUF2fGRR2SuNReunwLsLAt5spJfB1LyCujrO/qbvhXRToXFITiA2zDP e3gYYYBA7aTMfA+4VlFkoApm9CgGGDCbJYeTz+93xXyt3aUSKiWmDqynoD0Xys2edTWugdNO7tM sC5sN+Q== X-Received: by 2002:a05:600c:8509:b0:450:cf46:5510 with SMTP id 5b1f17b1804b1-4533cb53b27mr169413085e9.29.1750268454970; Wed, 18 Jun 2025 10:40:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECPQIWD9z7ds8IhVmKE9L3mk+qhph5JCu6Oi2OcOPUlhg6wunpBLWb7MobaQ8CxMoDDmzTIg== X-Received: by 2002:a05:600c:8509:b0:450:cf46:5510 with SMTP id 5b1f17b1804b1-4533cb53b27mr169412335e9.29.1750268454440; Wed, 18 Jun 2025 10:40:54 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e983b14sm3703725e9.13.2025.06.18.10.40.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:53 -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 RFC 14/29] mm/migrate: remove __ClearPageMovable() Date: Wed, 18 Jun 2025 19:39:57 +0200 Message-ID: <20250618174014.1168640-15-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 4 ---- mm/compaction.c | 11 ----------- 2 files changed, 15 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c99a00d4ca27d..fb6e9612e9f0b 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -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 Thu Oct 9 09:03:18 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 3AF3C2F5466 for ; Wed, 18 Jun 2025 17:41:01 +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=1750268467; cv=none; b=UnhZDV+sR12S7Sm8/9A9zdc6nSEod1PdIOi5MhK2P7FDJtd+CWvOyGZENuM90aYWgY05rfkf9Te08eh2O2TwINWuIjpSOOtJAjHzydU5MPz+FdUdU9YUrMvphEH/dpMTmydeG9z1c2eGO3/Q8uKtoTF+OtZXUJGjVxZxWGmg+ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268467; c=relaxed/simple; bh=medYXpX+TMULRTtTMKcGdqcFj+q0FGabFVW2TyLbuho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PBVnYXheYTWkefIFE+BEB11TOwC4amGXRS5EHd+maKatuWlrqUSS6jgupKBEYcgHL+VtH3ljEnYz9YHsxEpqQeeXiFhQ5Yl1Xy3uz3nTXBbU8qonkSBk9o/1yBWu3ekzfo67PXWwySwR7mHTe49LR7aq+XBrbjFJp84HqTljJjs= 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=X/xKM/TK; 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="X/xKM/TK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268460; 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=3ASXfJp4RHbfj4rINsJONSvcqE1rahDwcrPqymsVLDE=; b=X/xKM/TKMdlRRQYSkEjK0I7k7TmCb9j/kVUvzvTFOwOP1oBjXJlN/Hi5VYiAhjVSNkCJCm iahg3FQ3TrKyDbL2nkpIawgnWhuDKLjXebwWeJ7WovOC9dTGwbObzLE7PitPIEo4QvHJbJ kan6KbK5rggHckK7rqW4K2kSKK/htqA= 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-390-9-FQ57CPN3S1eSD8oT6OJA-1; Wed, 18 Jun 2025 13:40:59 -0400 X-MC-Unique: 9-FQ57CPN3S1eSD8oT6OJA-1 X-Mimecast-MFC-AGG-ID: 9-FQ57CPN3S1eSD8oT6OJA_1750268458 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450d6768d4dso47060745e9.2 for ; Wed, 18 Jun 2025 10:40:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268458; x=1750873258; 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=3ASXfJp4RHbfj4rINsJONSvcqE1rahDwcrPqymsVLDE=; b=UYGp/dWiw4smd4YoZLHCRRcyH++DQyLtjUpQiw9Rw8Ix1cJXUy82GZLor+3SEyydza Odhbdoe4Garwvb3lCai+faGSrG0JninSg7cAzpA8XFDkQQXO53GaDT8CS9PO+c3SmGA2 LGl9BOvED9lFMFnELc/YDDmjy04AZr4NIBRNgkH4sYEh9O9ccJEK93YQlfrE9UhNcVwi IzQJeLfBD5xah2Mn0iDNTgirrVSZBax1qTRhrTFtogP7OrPHeHcffg3PDhhuMCa4OFXU bpzD5BmJgWutEw+lW6YriC4D9eBt7ZS72aukWG9re7wreqW/hM3p0/justBhbmdS0U+0 ZInA== X-Gm-Message-State: AOJu0Yxk7ww93v5L2xJZsri9hpnq5dtnQ9BMW6BSt9C+6+mWRFVYEOHc G4Ba7BupHcHXwwME3qCuGJeNJtD2/KnXs4BOLbMuAAXZ1VgL4DdcsFmltDze38L+nWw3+5VCvT5 4+q81oX8gKVe4tPspQfoiigQ/HR7BTxnDxA1j22VACZlvgDGy7ApYF58ulb6xl4IIIEHjVQYxMg cowlqy6adUgYX1SzyZqQx7L7B1tr6WHWuQbZxP3DLtcMUDS57/ X-Gm-Gg: ASbGncvu4tWekZFbhJoCPqQqdOV2LeqTY6NAnKcYeao/pMK8V+GXq93qRQUKyYhyTZs DBUUbzIWrUj5ZCmWbV50W109h6qEmJLYxvCksNAW0C0/k8Wb2aj50QXrLxTFvFYCCxYq1jJJ77o OiDd+jZbmvKYJ94WtBvXNbDr4xoO/VsySM8+D8jxlucY3PwVjwN7GtuHcpj54hYRVqwj4yhxZSv a+HOTohkpOtwU4D1wHqgL/dJkuzvMDeT4oOw2Xpso1a5HKSOZUQGNgLie9kQhwGiZSegojRJx7z /pwaU4OHVUlUade0iesqmIH1Hjfgqfvn+ih3niQ5jATwamlcrqTLPZZKkBbBqu1eb2dlJZHSihV ZdMMJfA== X-Received: by 2002:a05:6000:402a:b0:3a5:2208:41e3 with SMTP id ffacd0b85a97d-3a572398dcfmr14347297f8f.4.1750268457865; Wed, 18 Jun 2025 10:40:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxU0kwdlscA0a/TfkuoDPVpV0SY0h1I0z821bVOupD96O2QJDPBeoneLN1ts9zfh0zY6p91g== X-Received: by 2002:a05:6000:402a:b0:3a5:2208:41e3 with SMTP id ffacd0b85a97d-3a572398dcfmr14347224f8f.4.1750268457179; Wed, 18 Jun 2025 10:40:57 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b74313sm17643014f8f.96.2025.06.18.10.40.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40:56 -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 RFC 15/29] mm/migration: remove PageMovable() Date: Wed, 18 Jun 2025 19:39:58 +0200 Message-ID: <20250618174014.1168640-16-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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(). Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 fb6e9612e9f0b..204e89eac998f 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 db807f9bbf975..cf92075108f0c 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 Thu Oct 9 09:03:18 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 229F23009B0 for ; Wed, 18 Jun 2025 17:41:04 +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=1750268469; cv=none; b=USNO6rUw4RzsWLqOqmDVm5Wefo88OjT381XjR+ft1JUI8u9MLphKfov1PAYqIs8U8CB6BebGdvs0yVH25tXt/ePX0VmIdkMdAS7F4LRs3xZR7bRQGOR+cxsmi8/oDAxD8ZwnlmsZauceOBCVybcjXxV2cl6ljXPiL6Wkz66er7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268469; c=relaxed/simple; bh=9tpdq1o7FbMiiO9x/kYE4cJFXkkL5WNyoS5e4zISHZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sycqb0MVDS9s7oLk7SzpkD+oEVsRtyYTMy99yFA5i8kdXKjuVskeatJJGA9e7XiwA9iBwHFucNfNbn9aqMbbdxxOUpAPH/ky9rRECtuhhKNH5dWrX2dq4Pig6nTuhFlPF7x73c6zW+/whL8Cf9pq+qZNL1kBhAqsH9XMbeNucVI= 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=C3DmlBt/; 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="C3DmlBt/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268463; 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=pn7yGSPhSFiXpI5R4Bp6dvC2hmWGRnPce0Bw+h6ULBk=; b=C3DmlBt/+ZdxD93QvwO5OBBiYdmz88x3Aj5+7SjTLOI7ECSH3NEi+chkvEEEz5gm7bFza2 1jr/AMrycfA4XKJTHQbp04AfZEiTdVp1UxLe1SPJ6srw3OIcZizk7CWnZ+WbkKdYdzF9sz NC5J6pg+18WRWykAfwC1Whv9SDrvveA= 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-689-gDM506tnMbW73qU_L_RYVw-1; Wed, 18 Jun 2025 13:41:02 -0400 X-MC-Unique: gDM506tnMbW73qU_L_RYVw-1 X-Mimecast-MFC-AGG-ID: gDM506tnMbW73qU_L_RYVw_1750268461 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-451ac1b43c4so41421885e9.0 for ; Wed, 18 Jun 2025 10:41:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268461; x=1750873261; 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=pn7yGSPhSFiXpI5R4Bp6dvC2hmWGRnPce0Bw+h6ULBk=; b=DJcgAr99FmN9E4NlP10qdumv52vE1+FM0dtCTDXRxLJOWIvAn/x77AsXuS8Xfiu31G QbWo97aqyxv9JS6B70MBxjNNBJEFfxyM83jhvIXYQALmfAiyAJTV7fi9Tu2zoSybh3Ty skP3bRF9uL8UBYcj6TPmu4/6PPUTuSMKJzH3FSQkZY4swMUTkMuAMkjJcw8Rt3XE7I1Z URiohUei8Lpfh+/OOw7xF2kwoZ1/F5+Tqyim46G+ncwhu0M3CZO9GRVjBjUEnccQEJT+ xm7F73RzV1VsrbHn5f8PghB6QEA5qJxnqorkKlP3cxCw1jBEp+5T1GamUGIKl+iQJ9TK eJyA== X-Gm-Message-State: AOJu0Yw9ohiqj9+41wvwmSmz7gFKEWMH8ftxEZoFefvRcQj2pnqoELfp vzcfNTIxUysH3jozRHxFNdHaQIZrC1BYHNhc5zltqJt8penbr6ecVXxW+bd9andoVGhd45dek+q W3btDv2h3a1TQQbrmrVhtAzvhS6Q6p0FlDsRnxH9/DrLRB7n3PQ86MqqkJ3GsHLY8GMVeQamT2g 6/fx09DaC+WLaOVIzyEluhfIBuske9tegeS8nKEht6faNRl4ZR X-Gm-Gg: ASbGncsuiSJdoqTDgbi2BXbHOCLSMc4k2Uq2Ytp3va5PZcPBQ5XQe4q9rzC+qmKcVGB vxXx+0kD7OQeP7C0UEqFkdvHcSKlS1jE15jsPvP91sLHAIZ/irA1KqTbX6cSliRPp3+C0dFug1q EepNnn+u83vxYxuJEabrkvilvFFaHtEMbbhc72+/yZNh5xHbq3uJFhLwaLPw82vz6BUD97SV56O O6NFMxThuHiUe+/U3idHFTCbJWs4MPQTpQY6J1hSXW7OIVve3X2ikSLgizMXvTvneb+axSl1wfs QpXdmiTVnkzSGKfxaOIy3u25fdyblCpvcDKOK01huVmER4MUcrseDTVy/e59lYFiHiAGURU3lcO H0KTOZA== X-Received: by 2002:a05:600c:4e13:b0:43c:fe15:41dd with SMTP id 5b1f17b1804b1-4533ca7a5b4mr172427105e9.6.1750268460715; Wed, 18 Jun 2025 10:41:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPI4qnomtJiihDYZHrEYfWz3Hi6xPZWIy9RNeAMNhrydAHd5Ktr+DvLvfsdyiYBEhOo2Z7gg== X-Received: by 2002:a05:600c:4e13:b0:43c:fe15:41dd with SMTP id 5b1f17b1804b1-4533ca7a5b4mr172426335e9.6.1750268460017; Wed, 18 Jun 2025 10:41:00 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e98b50csm3675535e9.22.2025.06.18.10.40.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:40: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 RFC 16/29] mm: rename __PageMovable() to page_has_movable_ops() Date: Wed, 18 Jun 2025 19:39:59 +0200 Message-ID: <20250618174014.1168640-17-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 204e89eac998f..c575778456f97 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_BUG_ON(!page_has_movable_ops(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..f8b7c09e2e48c 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 will grab the page lock. */ + 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 4d864b4fb8916..1d4d0f093af29 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 cf92075108f0c..5f97369eac2f9 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 Thu Oct 9 09:03:18 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 88C2B3009B5 for ; Wed, 18 Jun 2025 17:41:06 +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=1750268471; cv=none; b=ZJ5V0Y9VU8goqTobd5WebeE9RWmbmNGLME/lhSR/MzirkIR6dNy/0R+2rHhLEspoqvCJHqM9z3pu7IDGd639bMOkqJsPqxefk9UPWS1RxvAh2oHVa5uigWb6BI5cEJDU8Abj9J5AhEcPNwNo9hnDhsc/2grCsPzr95bVGMe9z/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268471; c=relaxed/simple; bh=0evh8/P+NmJQ1hFz8tzRv5gkRTQcHLHrxi5Nv+XvqCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GmlWQF26ptq/Y5RcZYaz0XBTjanZwImZANYmpYWuDsp4wwQNWgFWvqxV9OXsX1e8Ar/xHeEeKPssAsyxdZHBx0g6ii/cZlEzeDjPbArjjXpVqAUzZ4vxOgnRbekg8rMaESROgB7Bjuz4Ak3WnjkTOIzxHLDYY9wg6lH37SUsv2s= 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=Lf/v1WoG; 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="Lf/v1WoG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268465; 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=iZh2vT8OhFDnKR2hfytPb7VOtq98Q1N4tcWXpFSfOT0=; b=Lf/v1WoGNfdJWpjvHWaEdIqCe1OX99Rlgk9Ij/xdBDOWkSlGuvURUSWKPROkcC9tpL4Rhq KNjaPHF5jKiMgWprJJjjLLYM3UAgMQOsj8lICZSv7ioUNlpu03DOzNYo415GkQrwlW/cZU Xb8u3zIZg7mCVN8jlTnSeX9a3cdZ+W8= 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-121-_Fq86aqxMCiCZKp_4FyRnA-1; Wed, 18 Jun 2025 13:41:04 -0400 X-MC-Unique: _Fq86aqxMCiCZKp_4FyRnA-1 X-Mimecast-MFC-AGG-ID: _Fq86aqxMCiCZKp_4FyRnA_1750268463 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a5780e8137so531024f8f.1 for ; Wed, 18 Jun 2025 10:41:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268463; x=1750873263; 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=iZh2vT8OhFDnKR2hfytPb7VOtq98Q1N4tcWXpFSfOT0=; b=qczFDp4hNKwpvBwMZ7DHkuqbmNHuZyDSHd43obCowh7tkz555v9T6GnlOQ1wuJ5oTG CvGllX8jlPDo1GipUja4YLVCuSjJFDibjd2JmTGaHZmO2HX6+aqEcC8plTCCpJePsNLG GCzcA5z3z6gnOE8hsDYwzsfS9VeM47Cs4taLh+uoWIUgpH1r6eTetAXR04pM6kg8Uzga mRQL/It7XrGsYdz+IiebpwbaN3QtiNEg0u4QXPgsJtgMWmqVDU4LuBI2pSMXSJpy8ZeB cw49EMZIvOPZp2BtxEPfQhvvYEJPwCnO5IELJE0ZPrGv3eqS3/Cjn9o3pKiAvqb+uIBM vagQ== X-Gm-Message-State: AOJu0YzyVqn+gZdQhAcsmj7+Fm2jCUZzGjnd9NhcUR/fCKSP8bA6x0Gf pgfJU6dqY2ivFfSF9TAJtd5ObFFdhEB4N2s7GcG9/vNcRhSv4ZiP0tRbhEqKGizVifVhz3d87B+ bbvLpSWoclBgxrLuVDwSVUtq0RaRA/c8bl+BIT8cA59pe8VQa0zLIDN50FpJbAEpmJlNLIQgi/3 D2Y9kWCTf7aqSFNl8XFU3holNeO90iyNWgTMG8pmT6sU8F9VpZ X-Gm-Gg: ASbGncszO+KeDwbGxzuA73hQJqYjyEEWXBa12UBq+IWo7iDP6WR8MflBSKFJ/9jMT3E Wx1Vdt3EfCrwdvb3oPHrnuwdgELR+3+liLr5CHakGtlNf3GxXtu6On9X3f4BnmKMS7Uj5z0K8UB 9Nte7LmP+h3P4mYXXk1T3tFzwvikyCc7B5zCaabiXcPe2TNo830JsgxvNGvV85OEIu5JrmFt1Y+ Vwvlieyvxc+GMi4Ka74xTzNtREwtnCyeF0Cj6EyFqzkE6NN0HeZKjZOulnHtZw6sNuu+EYTQkyc hsKjkH5wUQ0FtpuSJUGisWrjXZcb0XwOXuadiepnDlrVpd0owBDtG7vNa8SGDGkhBJcq3Xc5KtW B3EC0gw== X-Received: by 2002:a05:6000:2a04:b0:3a4:e1f5:41f4 with SMTP id ffacd0b85a97d-3a6c971ce8dmr252847f8f.17.1750268463078; Wed, 18 Jun 2025 10:41:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIfeWEl0T3CJLW2Q374pwGp0+w6+6OG/MMLaU0GvL+YMoweLR1hXiYpIsPjINzwYBpzh5jeg== X-Received: by 2002:a05:6000:2a04:b0:3a4:e1f5:41f4 with SMTP id ffacd0b85a97d-3a6c971ce8dmr252776f8f.17.1750268462550; Wed, 18 Jun 2025 10:41:02 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-453596df276sm20306265e9.0.2025.06.18.10.41.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios Date: Wed, 18 Jun 2025 19:40:00 +0200 Message-ID: <20250618174014.1168640-18-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 non-folio pages, so we can not run into that. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 E87C2302040 for ; Wed, 18 Jun 2025 17:41:11 +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=1750268473; cv=none; b=h6zYnmrkSDZcjHBxhhA+XrdLyHmlpifbuvLgx514fH9mLv7LR0cAKCILUOn5O3g5Zh0KTF09tET3G25JadXicdYL1LehXZFWmgI6LNoltuN/AdZ10gXGnG2t3s43k2xJFnxZczZ4R/AmFdCxmUvsTEX/IUXI1Pw9S48AOqeS7IE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268473; c=relaxed/simple; bh=N7jwckJ4mxd6ChT2/w7Hj4rKkzFB4g5Ru3Zj9zwCqwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nlXIFhkJE811iEJuawW6E7drLEaxMZj3/HqetaFfnOotiK4z0+596zPKRbO45fyK90udyS7D7y8wB+4SDljhDv8YULZBIPgJENkVNasIXgN/pK3Xu9gW89A38eaY9kmkcznx+tsoqQcPKfInfSKtAAJARYoNLuBcMq8o4djd4qg= 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=bgPQMF+h; 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="bgPQMF+h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268469; 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=XNETPXN7225Q+hZzTHNEAHzgtHhIrhZYYBe8I562/sc=; b=bgPQMF+hKW+9QsjaTh+4Q+YpTOZLznqgJJSXBgSV/Eyzqs5xwSOAa+m/8rdxWeE5MJlqbn nxTQzAcjIeC8PAegEYTAeGvu0WfrK5jy7jg+WzEortE51AqO/DaQsdcDoPTBpHYVDV4sJS P6uuP+3BVn084fXzrMjyyIRscBS40HM= 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-244-qLnlsytiM0-ZZ844KlJ5WA-1; Wed, 18 Jun 2025 13:41:07 -0400 X-MC-Unique: qLnlsytiM0-ZZ844KlJ5WA-1 X-Mimecast-MFC-AGG-ID: qLnlsytiM0-ZZ844KlJ5WA_1750268466 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a4f8fd1856so3532426f8f.2 for ; Wed, 18 Jun 2025 10:41:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268466; x=1750873266; 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=XNETPXN7225Q+hZzTHNEAHzgtHhIrhZYYBe8I562/sc=; b=TVr4qnxUgyAbeWwy104xARRXU2EYNYjdjBoSRPzhvaPp186jD3YrxWzrWlUm9ui15j 8cghLg6mgkhrMckFuqVskAkbIwuVFFpBxc08v6TXMhBH3gSR24zMuLlktMrdrb5r3Jp1 C+7kkMpnNBTgPqz7soJ2cTF2kH5s6348numM1EPaKj9V3iEKDiYrsygp3231BZqnI5zy sch3vDNGVMbGzRE5NeKmEiomNIq51Mf/Oc7CQmjJAk9z+B/ddaPYkTkOSoo+bp3aV2RF gBBSgMaiRdZli7KhXbROb3j73/ZSnHuCUi4EQlO+up/taWm4g4EV8zgjXtiBpCCbeWLe yj5A== X-Gm-Message-State: AOJu0YzkmEcWpwMuZAS7D94qG/InJ9DzD5fNdc/VbyW8RhZ0rzhWCDo1 M8ACotxXP6yTdnYHNSbd8GlV8Wl2Fh0DEUfjIkd+Df6IGhM8o2rD1MVPJElWh0Fp01IgUJkodPs RTx5hjDhcM/vbvJc6emivZ9php9drjn4UAlFdkHuUF/Tp/ATFVxknqQrFtDHLzhRxM1LjKvGB7y wCbVPaECqFeGESbMLlrxDPX0rPjT2Rc5mEqYbtMqLwKnFPcFwe X-Gm-Gg: ASbGnctUuFiw91SUon6PluICRmH9tkm3OuCkaen2k6I7n1PSv1gyL4gota59lqqngTI rIjBQb7xq/9znFZBAHjyrAqwsEcN3kTOs30JD+nNuC0d4SQkwUF1xQrfWFjwToji+ot/rhaxYTS QUA9s3ZcooF+Adj/TOgCfcibbQZ6KfvbMLZ84BoQd9Z1QfzH+UePmdqiixr/QdMLZvay3WtrVl7 ZQ33XynGDSVPjvi+/7fhRPrg4beSAAtnqDmdYmt23dr9zNrU7+ItqOkAvA1YYcfqv2RTTYTe2pF DBiqoQYZKSN2cygtIqg/RCo2IxNVJ+2dwWmdzbZYFtKiP3WKz8KQlItU6W/li99C1oDNnczxoeB LJXS/Kw== X-Received: by 2002:a05:6000:2a84:b0:3a5:8934:b10d with SMTP id ffacd0b85a97d-3a58934b44emr4899285f8f.10.1750268465764; Wed, 18 Jun 2025 10:41:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGweIJH7UFdL4iF+vDHHDFBTBiRTPsGiwY+Mamaq8n4uKw+sdUC4NhASQWA8g0N93X4/5Zu1g== X-Received: by 2002:a05:6000:2a84:b0:3a5:8934:b10d with SMTP id ffacd0b85a97d-3a58934b44emr4899213f8f.10.1750268465236; Wed, 18 Jun 2025 10:41:05 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b18f96sm17611143f8f.66.2025.06.18.10.41.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:04 -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 RFC 18/29] mm: remove __folio_test_movable() Date: Wed, 18 Jun 2025 19:40:01 +0200 Message-ID: <20250618174014.1168640-19-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 5f97369eac2f9..37e722fbfee70 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(&dst->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); goto out_unlock_both; } diff --git a/mm/vmscan.c b/mm/vmscan.c index efc818a0bbecb..e5d04c98af976 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1651,9 +1651,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 Thu Oct 9 09:03:18 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 EEC29302041 for ; Wed, 18 Jun 2025 17:41:11 +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=1750268474; cv=none; b=s8lDHGUU89uTVhAn32YnkQ+DX5ThBwqPKoivKLoZUZgLN6zOGOK5DFzO377qvIKivn6S/4KeuD3K/al3nxTpDzBUi/tbDdJRIrXY8197Y+fVIdcxpq8PoQlGjVb3oQ0r820gPxNZ5TtXVeliHreLbWMuqma7EknGLCwpOVbhdO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268474; c=relaxed/simple; bh=mz892AAXYlO5CKl8RE5EQFbQoV+Cb7/Iv0Y/vIRyypU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ojemkuoPxY0naL2HgHjGtDqNcabdDnomQBJWhKMQ0GNa/+dwi+ue23e3mMLONLFIpv82+gjnbltpCqT4mXWCtK6F+GVoIooZefCBZmvwkdctrP5Deqd7Cke27FYkSJOR6WxnmMD4B+wR5QlFjqSA1yzrRbsKrexcSD7vZaS5dhA= 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=AmoGZVnL; 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="AmoGZVnL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268471; 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=DzfM28AXUPw/AfYpLS1hZTUERIY8AF/rsj6KIsT8/ZY=; b=AmoGZVnL6v4M72qSPN44LQzynhDz/mou/ExK5VWV0Ebc5zALO7Qztz3+2FtUs93bywiBV0 MDey6BXE4/b/lS5FIwZ8kxAy7RdQRs7G67Nq1MWIraaDncj+C3tts2wlvQiBp5GRaLTzt7 ZywxVRvmSgQfjYAZgdO+hp/GViDfdS0= 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-333-SyDUgDDoOg6FUurf_tqF4g-1; Wed, 18 Jun 2025 13:41:09 -0400 X-MC-Unique: SyDUgDDoOg6FUurf_tqF4g-1 X-Mimecast-MFC-AGG-ID: SyDUgDDoOg6FUurf_tqF4g_1750268468 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-452ff9e054eso37583675e9.2 for ; Wed, 18 Jun 2025 10:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268468; x=1750873268; 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=DzfM28AXUPw/AfYpLS1hZTUERIY8AF/rsj6KIsT8/ZY=; b=WFf6+KPHbW4SnpGhv/d5ygdbodhDyzs2JJlof0N6H87RAIYemtBC5ExI8JK5zhQkBL jOW10yuVKHdgri1+4ALyvm+9fZk0XF8moY4DTaGrfEZo/jXO7qscW7A4QP/NRxtY7sh3 1a59ybrZDBTXaIsFz7Hqr2k548+PS06vcbfh9OrVhkchTz+LZ2yFQYP+WNL3Pi1jor9t tRlgf8c48FYxCXAKIJEMIL+MYb6Wxdkh7m3UW3Qy9uzNq4aX+pPMCkzB9U89kdToB5eB bWpicJIGzUtpbU8XbclZiKgS5/614K4W+ehYp7AI22xE/viIn2N2FMX+4ZbG1QZ0O1Js Uzmw== X-Gm-Message-State: AOJu0YxpMjDZ19YnKxbe+DRdEFnTGlj6LykWCrzaZhfnIVRPTjOYDMr3 UzrGi4gpUiQB/y9SXOxqfEYuRjxfPkz3v8sjJwVuAwkQ8ZQj1cotsuByMaBWPQLbrEWa1SowxBy cF+oeBD0uAaGzDKnkjrPyOcOnWsfTi9HvZdHXremCvoTPkvd7t1+X30ny5NoHoE5uyVG77h/MtY uj6213dmaTqzt8W4hT3zrRyhEs78+/pxsfI73gKxf7u2TKSw/1 X-Gm-Gg: ASbGncuMcB4CJdLq7ES0kodx1KYCw0JeYSdNut/p9+bCKbB936bsMF76YWBiSViF0JL fYq+e33UhJdQVvPflD9rgGwKgCpKT2XyI0fUMo/O/1NQ9sNqKwznUi43PyYzxKBfHjdFTAq2PIt zN+8ctskV2MiPJm5aaKEwOUtGDLSQKpTGvqsUNhA2tStsKKrJULlD9CxabyqVMjfe1xjGVLAycN HK/ResU5fYI8jnnCjtxlIvyYDRWfiI87l579zPx5i3JfbqZoie2/mXgXPZcht4pCTqVJNjAMB8o RdTBar8z53WXXJK1DiUg1Wid5hd/OLSTh12wHFPxtN32AyA3V2Qe7BKFBG/ES7CfyFtCFNluiOA z7p5maw== X-Received: by 2002:a05:600c:820c:b0:43c:fa24:8721 with SMTP id 5b1f17b1804b1-4533caa2186mr184243255e9.17.1750268468446; Wed, 18 Jun 2025 10:41:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKEjDqAoZjEM/lQyE0UXotydmkpa81gpxxIPt+zLIqzN6Ot9NSYzqnSxIiiN03uF8vCn5Ghw== X-Received: by 2002:a05:600c:820c:b0:43c:fa24:8721 with SMTP id 5b1f17b1804b1-4533caa2186mr184242395e9.17.1750268467893; Wed, 18 Jun 2025 10:41:07 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b087b4sm17884528f8f.51.2025.06.18.10.41.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 19/29] mm: stop storing migration_ops in page->mapping Date: Wed, 18 Jun 2025 19:40:02 +0200 Message-ID: <20250618174014.1168640-20-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 c575778456f97..64639dab92b91 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_BUG_ON(!page_has_movable_ops(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 f8b7c09e2e48c..a10f23df9396e 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 37e722fbfee70..a36030de94f30 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 */ +#ifdef CONFIG_ZSMALLOC + if (PageZsmalloc(page)) + return &zsmalloc_mops; +#endif /* CONFIG_ZSMALLOC */ + 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 Thu Oct 9 09:03:18 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 DB2D6302CCC for ; Wed, 18 Jun 2025 17:41:18 +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=1750268480; cv=none; b=PZpwbvaPAmDWrRnmV5YrDPRTnod/r5l0ePb8xcHPwb4pavKjE/86RbO7TRzdLxKDgy2IpYQtUAXxUePW12cbrnyFYjWTMESZLZye+n/6pfguVf1NpyFSruMpSl4OAd2fmD5DnfyG127p0I0dHQlgoCqjjIkp8aJIf/sMl1lzF50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268480; c=relaxed/simple; bh=xdS5HD4MUJ1SAp8T3v4mmHtDVA5N2mYHTeOtyErEsCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PTy9nn7P1zBL4hJ6vihkx7a80WuVxNR1NImtc3atFqZmDNFCgsGGNPJ5X3U12MAZNqE5beRkE9WkTO1LXdZHEu5J4Hw+kpynLnkzilsF+08jsLyhzj8fQrZsGAL45jURQaYsWsMSebKswWQmiCLzRR5k8rPViFygyz9zTJ17wnw= 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=IWPEK1NR; 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="IWPEK1NR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268478; 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=sAf4Dh14UAIqeNeWRGXlrmZ3XJWuUden7rJ9s11c67A=; b=IWPEK1NRTsjKdpRVANd524nHEQfIwrDntQ0rdikrbVqYnFbeJ7zTGqFoAh368Vr5oMvgjJ 4pbXPpVnrJbirb72YHXOzdDkNmdK2CGqzS0wRe607c+6hdoZT9K0C0ZG7lBN6k2/KgL2rR 7h39zhoC4CWJ5HU8RuBvgf0Kxa8FMck= 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-608-cJ7EfKXeNWGkzrkEfQAsuA-1; Wed, 18 Jun 2025 13:41:14 -0400 X-MC-Unique: cJ7EfKXeNWGkzrkEfQAsuA-1 X-Mimecast-MFC-AGG-ID: cJ7EfKXeNWGkzrkEfQAsuA_1750268471 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a4eec544c6so2847116f8f.0 for ; Wed, 18 Jun 2025 10:41:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268471; x=1750873271; 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=sAf4Dh14UAIqeNeWRGXlrmZ3XJWuUden7rJ9s11c67A=; b=JYRqZKB3+RwMsO08diwrMDhDCE93lHmnVdt+Mco2wzSt4GZ1gRQXED6nQRttyjAgF4 hL5wATJy13b8Qh/4Ht6PH/i+/HAlVkSTYOq9FqxWwmIVuYq2dXDpunMr+GiClg2NrQNi HDvZ3ISRY5YErFg2cS+bJ8Gj6PzVUTkqOUkYcOPLDTLnkXIoiGI1aasfUIrW4q0FmAxN Tmh5m9FyRA8EzRpEyJlvvFiR5rZ35evuWvTklwWW3DSWKNJuLfXLgJs573WjanBFt9pD qvgDDsZnVVU5VoW8g72s5jiUtJBxgVpetwaAyD3FIRI09p23I2yIsyU1YndM7TVQO6lp Mp6g== X-Gm-Message-State: AOJu0Yx0fRCw8aDc9YQSYmhc8xXOKNdrsaRQcD4xqhz++MeW18rSzjVH cJ2ByTW1rUVRdKfIUTH/ehh/eRGSW334LQxswyP7Kx24qdw7JMGKEQuAjzQN36Qkd4NV6ZTXDtg sB4JS2h3ouzgfUsSTHxbx8DrXc+V3h5G1KHdS2GDHkEHa0XLHL6fWM9WRcYDrUaq6k3regq2hwH fJWnvfjCaH5wpImPXYNNyOqJ1EVazbTL79iqoUoezC2C6r34+N X-Gm-Gg: ASbGncvtOCJ8BoTl/zs1TmO6U2oNugSn3TKr4PSb3vkJIPm8CuIzgr+eFXOmUQ5Nm9d hKtgOv92sJEWRMyulBidcN2ylLqZwCD1TdLq7sQr3aYK3V0zzBwdTXxKZtbUakHE1lE+Qtg1c6C zcF0DlOwUSOu8Sl8F6Ss5O/oi1vTo5InJSTduji8yjxVORXtlWCEaKud7lL89sbPNkV6m2hij5F kEedV609ekV/UCPtB6d94E11Gtl8zPcG4dQQAgoDVr9pF62YaAX5Ke0MM53XwthBInTph/fpw87 /x41MnZ0J6QFeL1osIU3V4zi8+zTY9IyFKHvw/lp2sMuxaf167rTa+nkomvBVd1hWupRGWKyggk V1xkZ8A== X-Received: by 2002:a05:6000:643:b0:3a5:858f:f6c4 with SMTP id ffacd0b85a97d-3a5858ff721mr7648588f8f.24.1750268471194; Wed, 18 Jun 2025 10:41:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+8+c12bV3QXFpelqf7ZUsWU+nueVuiLXazDhi/qX6uph+PN90J8FEbsBo/IgcCAbkgHz7uw== X-Received: by 2002:a05:6000:643:b0:3a5:858f:f6c4 with SMTP id ffacd0b85a97d-3a5858ff721mr7648508f8f.24.1750268470566; Wed, 18 Jun 2025 10:41:10 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568a7ddefsm17533369f8f.39.2025.06.18.10.41.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:10 -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 RFC 20/29] mm: convert "movable" flag in page->mapping to a page flag Date: Wed, 18 Jun 2025 19:40:03 +0200 Message-ID: <20250618174014.1168640-21-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand --- 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 64639dab92b91..314cbeba1bb91 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 a10f23df9396e..86d671a520e91 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 Thu Oct 9 09:03:18 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 E6B42302CA6 for ; Wed, 18 Jun 2025 17:41:17 +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=1750268479; cv=none; b=Sx3aXt/6WvwyaEdHHhSOS1H/z6J0r/mfwM8v7urzL1CZqEi8aLZ7w024wozKXq/Hkw7CrQn2wijmGWaeru02AgyzP+NKS9z5gryTkoI9uKx2wsSO+0gIpp6ljw2XyElvn9P6VM8N2mxt0RpBPSArqbxJNjM6++ceoiaamTQBkBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268479; c=relaxed/simple; bh=/I2SWzcXvlUkl4dzsdwEhOqXgULSh4KVorXOxq8r2O4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qCmklSgfRHCJ4NqzzzoOwdDif5GDOTwPfqbhBV6rqlSPQzKmfhku8bYrGJAeKaItnLVRqWKHPTQP+x1IQdGXi0xPIpkSaHOJJ6MVGak0a68WcPNLGLBypGpNIaYE6/8AK0TpS6qh5wN+pN2Ng54GNJBLKomJixhYs6Fy7Ee0XHk= 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=ZvQwj4Oj; 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="ZvQwj4Oj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268477; 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=VgDxyojJlL5XcnaJgd1JoaTm/pUk71nf1V9W9yKY0aE=; b=ZvQwj4OjPCnBsHzO2XNsfXhjr8t6N73pOSSwJJVFdzSmD2CU2uOsj9XIGtIUEV5ChzLTb2 jJ46/gSt+oWoA+WVD+IKX0jP16o2h6gKT7Tp3ouKJB4duOCV/PGYVZwbVfiGgCjuVTh/Nl UFVAFNjPVvJ2c+qyLVtkfcTWCIMAZvk= 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-680-JXjSxa3DO4yi4bvuKhNwsw-1; Wed, 18 Jun 2025 13:41:15 -0400 X-MC-Unique: JXjSxa3DO4yi4bvuKhNwsw-1 X-Mimecast-MFC-AGG-ID: JXjSxa3DO4yi4bvuKhNwsw_1750268475 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-453018b4ddeso42422945e9.3 for ; Wed, 18 Jun 2025 10:41:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268474; x=1750873274; 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=VgDxyojJlL5XcnaJgd1JoaTm/pUk71nf1V9W9yKY0aE=; b=hAwJfMlpbuiPuDONXL8XU6MpBDR0DVjsLxyAKY2zd8Nf4dX33f5L9GUYB9qPG4inc0 hKmaugsXwerfqqPDUBZpeP2zZuNACr6VTODKh7DHlaCRmwHxnt7LC6MjDULlkfk0Nmt7 i5krFgXXdZXZFxl0FLH2YaPbHmt3zqiReSrca6hpsq2cG9wHT6xk19xU7tixwceoaGon EWde8sXeJv1ltDkJpHI5O3xILEno2WB6Q7wHk+/cqGn1zGNbFgQejBDgazK4FpLfZVR3 KhdZowt3Yur8nubn1QgXntZV5tT/Mi2HUG3KGlJz6EH8up/I2zZ5gJj0N9mnW4Zr0yfq iTsw== X-Gm-Message-State: AOJu0Yy4I0Wlm/m/LeUvZUCrv2rkeKSqyWP9gi1ghF5N7IwSiSNtl5ET ahn0UI+Bb3Al/Jr6XWexOIu/nlQxiK1KuZLHPB/5LkqEp1ly0fjIwHUyVwC1G3d7ExF+vrZjHd4 V9j2xfh93aG4GaM2+VWoFB5KKWs8k9awg4AIU42mcjSGVJ9Nwu7uBR65tuOU0MRRl1GkUG5gxsL 8mF4VTeTvkKfhkHo3ESUN5gSBi7/JgvXRd8pGN5/tVy1hxapme X-Gm-Gg: ASbGncstP7ASOdDqsweus7TC2PfNTgx3BBHo5AkGLqQ3VeOdswwfap7wk4VuyKPzgdn 0v+FzMVlIgp8QFV7iAXpoKfxiub020lE8iIQ7p2KEHwyqoqfuzapUyKvyhnB0jVceWDHC8TNyKP dUmy1hHTjUAtWRSkiFRnUMGQW/k0adh2F4pMMi+BFDHHqpprdxiG1PTcdDf3IAtLudhqo4NVivV LpPt9fxrkC8cUnYdaVtYxU7zylcsr7jsTNH7HWVbZfYJz8IQLLJJ2QGSbhnRSHtrG3E4GHiHZB1 UyTvvbKK0z5/uXsyEnOGUNcTDfNZYtvbt3NDjZUY9adbcjtBddadQ32M2xhurwGfOi5GPuwG3lG LYxWkFg== X-Received: by 2002:a05:600c:3e19:b0:43d:2313:7b49 with SMTP id 5b1f17b1804b1-4533ca66cd0mr176797975e9.12.1750268474605; Wed, 18 Jun 2025 10:41:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIk5j0XUOc2qfzy9nY3G7Nge7jrVSGi6o08YDSv4Mte+xl8dtPQDJlCzuSsfiSc9/ShViabA== X-Received: by 2002:a05:600c:3e19:b0:43d:2313:7b49 with SMTP id 5b1f17b1804b1-4533ca66cd0mr176797145e9.12.1750268473925; Wed, 18 Jun 2025 10:41:13 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535e993c95sm3729315e9.26.2025.06.18.10.41.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:13 -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 RFC 21/29] mm: rename PG_isolated to PG_movable_ops_isolated Date: Wed, 18 Jun 2025 19:40:04 +0200 Message-ID: <20250618174014.1168640-22-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 86d671a520e91..809e4395cadfc 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 will grab the page lock. */ 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 a36030de94f30..f87a998b696e2 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 Thu Oct 9 09:03:18 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 57A41302CD7 for ; Wed, 18 Jun 2025 17:41:20 +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=1750268482; cv=none; b=AbF3CyVHKpzCkKtksB39ecaUP+LsC97PkjY9JLyUT6wOPWHnBW0UZaavwwdF4LSsw0885D+olyFaj23Mxk+5xRNVEMdxo6fJZ8EJUpfAXLSwmSd24JRYBC8PERNgmTduoEDo1UzLicwAQl2i23Ax6z/DcTuJ7eOhTlf5zDCPSeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268482; c=relaxed/simple; bh=7MqWYtvNLDCeRHTl94GzHGrw7bPzHhaA6ax/7SHlO8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OWbZEdkPvwwCI71J+wqiAfw4FFUTBKW6BJiPqPfEHOctuZo/NujPjNZTmHp8TdO5v64JlKhAsSA09Nga0OegXeXzbgK3E2KwM2v9pwkNVFBJs++Z87+HjjfCQ1R4pfGEtkUFgJq7WKSG+LzRCbWfskkciv9L6t7JZFdjOyNnqjA= 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=ZKS1Xflf; 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="ZKS1Xflf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268479; 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=HKAYn5W/PSf7oEyDpSl452LRf2zvea6hrq0MdbpucUo=; b=ZKS1XflfMbufrjNTh/XCijg4PCf8FU2scUO1BgMqz/LHpVd3LrU4GKeGUIFxFARUzLgFTK rYLoQp4Ktw5D4VaMMoVNm/4KP94itZxx/hD9g1c1zwNC4RIeJ0kPx015c+Zq7U0uh8T44Y 0Cbdc3zpRDesQBsDtTgxWx97aiuZ7ik= 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-433-oVDzh4pSNyeUQlcQcukzTA-1; Wed, 18 Jun 2025 13:41:18 -0400 X-MC-Unique: oVDzh4pSNyeUQlcQcukzTA-1 X-Mimecast-MFC-AGG-ID: oVDzh4pSNyeUQlcQcukzTA_1750268477 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-450d64026baso49047205e9.1 for ; Wed, 18 Jun 2025 10:41:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268477; x=1750873277; 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=HKAYn5W/PSf7oEyDpSl452LRf2zvea6hrq0MdbpucUo=; b=II5hy7fUgvHsx36a0xKuDtC9FvuBQMVEklJ7Uy9zngh+Si7jHHhg7AVKu5LKNeklz/ eXxdcYT1oEXxzitUWtRWON6xrZiObxdq2V8ZJyLbmYSGQIZtN4/moKqrHC8K4niJJ11P py13i+0A7X31BBs0GIcFTf7mq1F+RUnUIZigm3Ikh7804bwtIdnE1CRrIiyNDGwDFx+I PxiQz/ruVSAV1PabQUUNXv6aOzxFkS51QDaioQwyX8AMamQW+0ANdMU4s8VSwWN9omdj yYqs/m1XqpBpi8TPt+vkHK5sNoVlNNwrDZxwY+dbxp7eXH9/dyVtK1NoLxxE36y81b1O K7Bg== X-Gm-Message-State: AOJu0YwGA9mu3Ed48IlMyRfvfVW+cksRrILdntx4XGS7pBTy8IeUT7W3 BI106xAH+HHGYp4jpQlv0xEsNwt9T9F+qMY9qTqRGU1tWpPY5A+64JQ+YQzVgQKA7aC+bAJPAxA IQTzNbbavQTWI5vejHJFByQHq23w60T1Oep7ktNj1pKkkiYMTq94q7/saRpJ7FWdVRHJp0Sa/wP FACfOEzRiGD65CmhZ1CaxNvJO6bn/fH9iCNLcjhDV2MKIy2LIr X-Gm-Gg: ASbGncsQ6BJDFfFXzoNogDRkPQUNQPmwyHkOqXpPZjuEKSvadVeNAF2tpgvfFbd2V8q 6CpzMhvMVq9S+KEvLOWpmfoI6SUHxCUVVwsQIxNJF/lm40977SRWxVKyTzDtlOifK+Hi9mlzSGG QjQNRVZFw9GRIxOaExocltcSFXy11Lag2/HdqCHG2iYW52er7v+ZglvzrGiJng3edGOb1RcuwA6 hU0zMzx0asBt2MP3O/2lg1kVZ3Vfqhr7lCuPS7XDDKAxQU3iD4HmI8YySIZ0Bfh5q/lDs2YzYe2 CVoIl+2mt3Jn+vGJ+WBPhp+iBpB+HiMx5/6e6QnoW65VnpyQs4zgkZSLKTXssJO0JzA9xRa2NVm A/xYOHQ== X-Received: by 2002:a05:600c:1c14:b0:43c:fceb:91a with SMTP id 5b1f17b1804b1-453430ececamr157094715e9.11.1750268477219; Wed, 18 Jun 2025 10:41:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENrfq9JZf2w4nH2VRe3EOokVKel4Rw1khN0dggc1dWhdYjdSzsol44AwGmQNvJE5b04zR6vw== X-Received: by 2002:a05:600c:1c14:b0:43c:fceb:91a with SMTP id 5b1f17b1804b1-453430ececamr157093925e9.11.1750268476711; Wed, 18 Jun 2025 10:41:16 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b087a9sm17793395f8f.55.2025.06.18.10.41.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM Date: Wed, 18 Jun 2025 19:40:05 +0200 Message-ID: <20250618174014.1168640-23-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 BF5DD303817 for ; Wed, 18 Jun 2025 17:41:23 +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=1750268485; cv=none; b=YuQ/neqk09f1fqJG00w9qQrsjsiRIfcjXRb4/pDgXpPyKkj+zz4hM9QNooVZhcnAzvi/xE/D98hkjsA79+mJ1jGEwJYudb+WeU9/jpfjRZOzdDPdINjJAU3ArKGyUFEQG9/SdcMcBhHG4S6/ELgw0Wfkifs2r1uyCrf3fwKrJYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268485; c=relaxed/simple; bh=mR4wKIFzNAz9lCxg/2MhGizqJd2oyhLD6gTXEVIJK5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j3/mKaL9PaCoer8Tdg8PZbCxcByQFKXP9apV6fJswh25nU+fN6P7SzierXPKdoX1jBq+EiDtIgvzJP/1uCeBplJ0kGr5I8arcnW4XFSv9nVEqnp5wpW4rG3RneBVcOz+yLIN3vXC0396oO3bhYhXEXPZBSGVRG/0l0jN54wxlDc= 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=cnYjW/0v; 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="cnYjW/0v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268482; 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=OFGM8ws286HsZ+G2nyb5/sPhilYYDV0QN54X+S74Jfc=; b=cnYjW/0vveQnlf7N5lEvxILby+8nkU6rXMGZlLgddd2ngAta4V9M7fGltXuKUvhFZ0qYlI nMLz0+RxQShOJgLfooSdZmfnQgNjZyHWnml17wEzbFHOqmnrfNpD/i01iBeAmbOyMksW2v B0oTP2mqaewUus7wXN0HUlqCHV7rpPI= 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-563-wfoRhxuVMFOGe6Mln5M5Lg-1; Wed, 18 Jun 2025 13:41:21 -0400 X-MC-Unique: wfoRhxuVMFOGe6Mln5M5Lg-1 X-Mimecast-MFC-AGG-ID: wfoRhxuVMFOGe6Mln5M5Lg_1750268480 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a37a0d1005so4365920f8f.3 for ; Wed, 18 Jun 2025 10:41:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268480; x=1750873280; 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=OFGM8ws286HsZ+G2nyb5/sPhilYYDV0QN54X+S74Jfc=; b=Xxfn7UjC6zoHD4+4XnV25oE7eqXlptfHB3eouImArbvBs2rdR++oKZmjyhmnSOT/81 bJpt46xUNUpeNYFCsaCECCJWivUzxcKRbGPEKqTweupVlo24RlllOvI307b5HD+CPYkS 8G30qg/WcTEDG0dE4YFYOhM3B1UAX4pYS5SY9Pde3qzNjyNq38H3fnCq4ywwpKRmM+Id tgTCvI3ZiRRgpGdw45Htz6RfxnwMyDiw1KWmii1Am9ZU6nhYfChqfzU8GUEm5G1h2k90 OFPUFHEJS4t6QO/McCHzLpE6m89V4mS+4YuNgOJAdPtwQoIp+1txMCPKvYlHsfs3Z70Y SX7g== X-Gm-Message-State: AOJu0YyCnJ9Tnd9hlrwLlM1cmAQ2u4Zh8W/mP0JQuXdVY+1xa8wGO/lZ mrah2sMqMGiKrY5zPRbmLGoyIZeF/GPTSkFv0t5LGNA5SWiXNtr3Kwqa5TiEr+zL5cMWPQtbEqW gNCpxmG4yUKqXWkwrsv16qXxqy1mOBreBvRz4XNXFvD7NvPIfYVNlxk2SIgIGU+h/jwGY6RdCAc Gw/DiHLPg2GOiQDcyiBP98E4a/kjNZwSDNEpZWf1IzJa3t/ieS X-Gm-Gg: ASbGncus3Hb1H92LVsGwYErZ3d0/bc9ybJm7TXJpgO+UST/Dj3XBwH2NdcaXyoziuno /JKL3tsAuy7FPRnDhQVtT2XQ9GG26OGcueXuZzElZabdI3WsMuYq+D/B8WbJy+M2ypC57mmLkq3 B3URp9II77n1mG/xhTqym9INLgXymrfv4Zv8iouyoCdFd5pEVBV3lkLj9oFSOqnIdmL63S11cYo AzRhRgLqlrP4u0XveAb23t7MAeL1tNeliPVLbllJmR5CYXKthLTE/SaUKTVluBFiRKvU/EBUyFG V5HdAHThCUpeOsiYimCqxgLL9aq0pMRVUEXTIy9FYS7NmRcO7lXp5mIykvkRGekWFM1cabu3XgM uJKSzEw== X-Received: by 2002:a05:6000:2f88:b0:3a4:f8e9:cef2 with SMTP id ffacd0b85a97d-3a572e6be35mr15379352f8f.36.1750268479954; Wed, 18 Jun 2025 10:41:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGgOLn/JzQiVrSw8561br8iJzDS6W98mGXalaJQyvnuLaRLghELBqFwLLjepyMMgs/X1CCpA== X-Received: by 2002:a05:6000:2f88:b0:3a4:f8e9:cef2 with SMTP id ffacd0b85a97d-3a572e6be35mr15379264f8f.36.1750268479340; Wed, 18 Jun 2025 10:41:19 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b62ba7sm17866251f8f.91.2025.06.18.10.41.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:18 -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 RFC 23/29] mm/page-alloc: remove PageMappingFlags() Date: Wed, 18 Jun 2025 19:40:06 +0200 Message-ID: <20250618174014.1168640-24-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 00138304310 for ; Wed, 18 Jun 2025 17:41:25 +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=1750268487; cv=none; b=LKytjAzDoK7kmI3zuB1v4XKN8zaA2m2Oz3L7xTRemaiXEkQz6FlvJHFUkvlzawIUkg6GlDW6kOXxAjl8ru60K+dt9YwsGn7ktNtPI1XzhZ0g1OHnfl5N2UX6/dh3zqusyDKFLkqHgPdOWrlWIQaPCuul8x++yBfQIIEYV2kfLAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268487; c=relaxed/simple; bh=/g8pHF1/RVrgJ0Pc+SNNZki6HQmNZWyjtOO510JBXkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sZFefF7Bx8Ound9zJ2xsdr5ydWCfSNr73PIHBQKKrfOiP0tZqlU5NShsQSdwVPcMUxslEyT+Gs3DB/YxFjoFY2lYqJrYfuzJwDdhIn/pWslepIbmYVsxARP2v+LzEvXsXmcP/yDV5Z70WcQVSSczjvmr1D6B78wgtH28qVhT9xg= 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=dbFqTpNV; 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="dbFqTpNV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268485; 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=CdeAYiIbvuQl6YyCSbJM0KZ+PwGvgoJ4GiSuuebq9Wc=; b=dbFqTpNVHhNZMpsUo+zFiZioHGOyFqWZeJ8+k4rQt7Y0mLV7gAx0amZoYSYoa0SMzMHoOY SOGzcTaQWI0IxykAYRqwp+39+hkKVxbYlUSVE1wbq2wmqa9GM6+YRugizfxlPwgHM6ZsHp J6kh/N0rers3xEFZvGG0CsiU1MKfDt0= 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-381-H6deV7rBPimKwF6SZDF2Bw-1; Wed, 18 Jun 2025 13:41:23 -0400 X-MC-Unique: H6deV7rBPimKwF6SZDF2Bw-1 X-Mimecast-MFC-AGG-ID: H6deV7rBPimKwF6SZDF2Bw_1750268483 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45311704d1fso40533165e9.1 for ; Wed, 18 Jun 2025 10:41:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268482; x=1750873282; 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=CdeAYiIbvuQl6YyCSbJM0KZ+PwGvgoJ4GiSuuebq9Wc=; b=nFKDv9TnwbmjksIOdHly+4MdepOnGabo7zgaNaKkquM+1XBF1/6FuP2f6eY0NYm+NE i7685MyqcJQOAV6bnSvywEzEnAnRHbQguwmWd2NY1KrP2/SljQQ5zLdf5mNzNd1kiMDv GaK/ftEWYqaDdIRQO2gQgnX1+GOpBuDUasifuaxCrhcsmqhNc1/qf7GfOf8AUuxzzYD1 2k8DPhZAOXZ1iSlvM3SfJxMK/tdFKx2EtElrYxRIbZ6g6Bc726GOxUDZoGhjMgQGv1V/ mD2wZ5Z6mCiy4y+kNW8o20J0CtX0tVm26XIUI5mmFBUbzOSg7X8rnlRY2gq3iD2kbqap 90IQ== X-Gm-Message-State: AOJu0Yx4WGfXhK/csMpiq5pGDRfD8Bn2LoOvXHN2aAkhLQIaPRpVXM2J oetdtkRQNRe4zVYwFS7pmhF6Y7JBzHWh7WmpQWwdp96wuPE5gmxZcOO66JXlnnvKLSo69jevuvS vbnX73dgWdzuxKZs01u16gxGxEEo90yT0s5GzHppPky6FQZuoDvxk5m6tmcuo+gHR1pnjwYMwEu qbGXh1mclTfqZ/Hb6UHK47icqdLtUNkNovBoMWMOtMIvw+2I1l X-Gm-Gg: ASbGnctPfxHELLTnL9kNPgjf5KErhcS0cx9M4I3LiWAZKULHfr1ITAtIRe/TuT6z/f6 9ofV0XK2PgrvEw8gnEvBEIvdLSJC2F2ghei6v5cTyP6p+++dFJoDUHnNJ1z5LLu3nDWvQBMIszC nYJS+CO725AuMimVIrvY60TWzfNTdQ3/Apfu/FnbhmzvqKJwbiFHKLiU95zq1GtfWhVLelFaJ23 nYUzoGmu5oTn1fbY86R/sWEFMXhZ9AkKckox2h68ok78d9ajIrfscSFpMxztxNM/HYCzD991J/Z Fzbn1eRH1SvfmByCsIFr5d2A/IZI55cIKpom6r5NVYrUQNaUEz4tF0MoHLBVcezRPg5FSnc2ldG nig9Ubw== X-Received: by 2002:a05:600c:3489:b0:453:78f:faa8 with SMTP id 5b1f17b1804b1-4533cacf0b2mr167448235e9.6.1750268482567; Wed, 18 Jun 2025 10:41:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrKZ8zfCrGufAh/HvE/XIf55Hjs+1HFJqQV1cfkKzvu6o7QRQJ1IpAcZ7M33DksKCqTfpzKA== X-Received: by 2002:a05:600c:3489:b0:453:78f:faa8 with SMTP id 5b1f17b1804b1-4533cacf0b2mr167447475e9.6.1750268482090; Wed, 18 Jun 2025 10:41:22 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535ebcee09sm3315485e9.38.2025.06.18.10.41.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:21 -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 RFC 24/29] mm/page-flags: remove folio_mapping_flags() Date: Wed, 18 Jun 2025 19:40:07 +0200 Message-ID: <20250618174014.1168640-25-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 Thu Oct 9 09:03:18 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 AF0652FBFE8 for ; Wed, 18 Jun 2025 17:41: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=1750268491; cv=none; b=Iw5SOnNOgeCKZiAwLpfPczApGCoJSE2lEt0M0orGR8eh/o2PqmgkBU+rtBCpz52hvpUGbC61RxkENqTjmWTzx/0HSsmVpFJvDfDG4V8RaEEbWGEP0wbcHlJoPn/EEO9wtBSV1+PGmtARY0BTj1be59EXMbLkrV9OiXekDnpKPY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268491; c=relaxed/simple; bh=klS5wctUdaGGEO0GDFp0U+oLqOtRx0jqeVG9P2Se0qU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DH7kS1uxrbS0aor1cmQNGAXNCLHcwUoGNzEPZ0VXvq2Lo80mu0uXCq4bEjv+WsxRgIyHXLMBhLeQAJDK84OzdB6pWrjoZiONF42IDoC4+4gZB2F81d+wAL87Iags7urgr85a1z5YiI7PDKdmPsUG2Pstz8qE3etbcZIcKlm0c64= 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=EjNJwPwC; 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="EjNJwPwC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268489; 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=UnwUSh7o+5ZmaRZCKb6UInkhBSWZlCwshIxY9Qz5Cgk=; b=EjNJwPwCoZ6wmrrUKTjRbGbAOnTZg93QQzrb7Iocs/VQdILH334rfW3xVnLFiV+2CT+6pj x9NuE3rgfx8HgSnl6l41CIJFBFrbv7bkyCDISz7u8Xuz41Tlih6xdFyPIeYY+VKYuYdCLU zoZMwVFven7rk28v9Wu+dSuWD7s7GPo= 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-673-xQCCJaNAM4-6Wc3slZ5C8Q-1; Wed, 18 Jun 2025 13:41:26 -0400 X-MC-Unique: xQCCJaNAM4-6Wc3slZ5C8Q-1 X-Mimecast-MFC-AGG-ID: xQCCJaNAM4-6Wc3slZ5C8Q_1750268485 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450d6768d4dso47063355e9.2 for ; Wed, 18 Jun 2025 10:41:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268485; x=1750873285; 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=UnwUSh7o+5ZmaRZCKb6UInkhBSWZlCwshIxY9Qz5Cgk=; b=Ps6mxSIYdqcUlWY6scraLTE6DIu6Ega03oHcVabBZpRS6qWjtFvGtcN6+sMwhRSXlo DsHSh2vNwVe6EccePrXf2+TfoSUrmCQRqsOqFE1ieDWWif+cs2ZlKzXHw0xifGKigdKO 8Gn6BaKlWFFCsWX4LXptzPI5pqd1JRpk2WMCQugs/LZu7MAfRLet1VkyeedaQrWZRLbe XG+HCPPo35LDASrOtzt06KAC2seF+CtenkKUjRXp+i8/LV6nFJ/mDnZhynEBMECoSC+n hnYlyqfpJuS93ITk74ln3BhesjRNYyHtvh+Quvdp9KdFlEFtcStDCO1cqmOfinq6SQAL sgDg== X-Gm-Message-State: AOJu0YxHUQUXSVM6HA3CBh/TojF7nAHIkWMhxr5vFOOP0yinXHRZMHkL u/gU4KOatPJUzvH7dPAEvdXrItBK/a3IiHo/WyHGhZfgenybsUMfqehqjANTcSQjmoGEPzKZGP+ XpoUnv3/2QYmaRMryfeLTw7FMEfIpaSqw1587nVJyh1acDHGDv+Ifs3i7JnqkVbt5UabYwXWv18 KSa0GWZsl3uXUltFui6MF0jJaoau9uDX6Kv2FRIir/VyTjezzg X-Gm-Gg: ASbGncsJpdvXfFpzvUNMEPZRVWAi1C9uWMB3x8YmKD5poYQ9neba4n7o3+jVHt3LvfF thio7/RWyeMZxWSirwa6UiJ2EUxMKL80x4xAX6p+aStE63g42g0VYOUUL4KIXB3MY3huQLUPqps 6eLS8jQnKXwGv3lo+7JxBdG/H8MX/j+rEHQFLb7hOA6rn004j9M1yzzi/jGf8vYF9KRZOgTpajq e2IrEIek5oHX4GrAzL7qjkvkqhNXn4k2/oftClWoY0RRCM6/MGsl4ffLm3eYT1WJErpwukLYSWY vuCM0GKMtz8EGPgkxVusbJ5JEk/3JiSDWN81vXd9i4dDudeClC3CtbqW1ircdN/WOcnfiHmk62W R9oFtCQ== X-Received: by 2002:a05:600d:1:b0:453:5a04:b60e with SMTP id 5b1f17b1804b1-4535a04bc8amr21843395e9.26.1750268485456; Wed, 18 Jun 2025 10:41:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv5K+zuY4+JCApu2tViRQi8tnrUP4BMaDADA459jpWP1i37cwdJ2pp4j+WJZa019DgSPcT4A== X-Received: by 2002:a05:600d:1:b0:453:5a04:b60e with SMTP id 5b1f17b1804b1-4535a04bc8amr21842675e9.26.1750268484986; Wed, 18 Jun 2025 10:41:24 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535ebced8asm3463925e9.40.2025.06.18.10.41.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 25/29] mm: simplify folio_expected_ref_count() Date: Wed, 18 Jun 2025 19:40:08 +0200 Message-ID: <20250618174014.1168640-26-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 98a606908307b..61da588dda892 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2167,13 +2167,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 Thu Oct 9 09:03:18 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 2E7B12FC005 for ; Wed, 18 Jun 2025 17:41:34 +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=1750268496; cv=none; b=rP4vXJZjaIOFpPULkyBmdj7VzHAeY84wVi9t609BvIajdgKiHaR2s1I9WivdL/BmBwgLsWSabJ5lkc40H2W/wmTe/VKEYES8lbKhO0+I0RvnxipF9KRQ+I5jQj373MDI1LHnSzsq6l14VcFf20Xa+jmNGDs3V66AIX1coB4/Vk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268496; c=relaxed/simple; bh=4TlSSp/B7+/N/ILiDxGnb+tpfbPIQ9nea0SrUYxJmrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KVSnpGN0Rc8gnkG4+7W+nEf/LWeHBqxrPUPIPaIqdgLM+dnxiNBzs+sQU3u6T09/J0+FHBQcMuqbcicqjz6ottIsqiQ94Vq1csWKqPZQVhhhSkubONVCT2XbE1icT2P+E74Dx8YWDVnZE7AsLA6ck/DpwiIC2EpXf11fSpCGUsY= 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=h+b4heuY; 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="h+b4heuY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268493; 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=iWRDBtzd4nIP01/duk3xBYsYZViv9Z7E8J4LCipKpgg=; b=h+b4heuYtV06mdgrSjBxbzDl0SOHwBkh0Vyo1qMq4gLdILvFyriOzAzyZyGC8p4WC4Br3P fZ0X8VWBArLdBpMRM0cF5yyx8rfWMynXLq9JLHzm7UYdfO9czjnchych6zzzttqmsT42mk NojSlsRZcVa7VNbHiCe5AUoojE8ViMk= 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-18-s560JbI1MDKeo78snzmHXw-1; Wed, 18 Jun 2025 13:41:30 -0400 X-MC-Unique: s560JbI1MDKeo78snzmHXw-1 X-Mimecast-MFC-AGG-ID: s560JbI1MDKeo78snzmHXw_1750268488 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a5281ba3a4so2495888f8f.0 for ; Wed, 18 Jun 2025 10:41:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268488; x=1750873288; 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=iWRDBtzd4nIP01/duk3xBYsYZViv9Z7E8J4LCipKpgg=; b=h1yCQ1K8ES7RDp7QdwPv44QHku/Vp5/1u84+AHhWiUE83X6QFcE8pIz8yfdy1nbT6z MhsdNLNqlUZsWVgX+cQuWOp2vFE9BSw4EQait/jR1q5wxnRCM0lCUoq1hfOrb03qyZht fCk/khO7luJvwK/LBHhdNvHy7wMWWl63F/5gW1QmBLIoRyhBjrQ+OOmhXKy8TNzQ9lXv Qtir3f/DSGfAUDqUrUEQMU6k338Ncgq/ZP3l5Po2SXM+FoL5JlBS+yMU1O2MTxbxlxrI wVOkFAjnVid5zSnTTEjVMolqC4P14DDXP1DEDD0anuRStFOc1r1LSEtz4ZDQGc5GGBjF +Ezw== X-Gm-Message-State: AOJu0YyU/56mdVVuABHZJKfB4y8e8pKh7Fa2YqUw82gcdRQrvczZ4Arl L3mOOb26Xv456V0jT57l36iWjzzGwv+fzPLsx4Bdn+NWeiNsRk+KpXZIol4y2gD/LIdujyigLTD RA8/3+haD1m+pHdgcjUs4aqXzlxJlK0utWQ79UCpGWoZkBnRyLTiXtYdvvS8oUl2Uc2JTRAZi/l wEjb3zPwwJD5vrzi7TsgaDOgFIBMr94dQ3cagAe+YAx6ROMJ0J X-Gm-Gg: ASbGncs0tJ6ZOah1jEShgQyPAG07WDrZKjcMg7as1zTvhKlrOjHZpn7L6hhiQTTKXWE aG32lOvILCzG1vhstvBv+zhMIpaIih3tcu65dkHDrEH5Wbykxe5ZeRdgTL6G8SICco485zXqa4b +UGH05kMo6RMX2TRPLSuEArqPohS8JbZTGwF3ZUOfAiPT2V2mmFrqm9fcfNRyVRZyZNhxBdqCNM W54azsw0HZxMOS2PRzAOGF4eMjswRJz0HKy9He6SsbTNd1B756Tmb34R8UesBkPgIZHepXXY3mb CKx4uWNDowhBu0SBorPlqeJpkEy7ilF5t4L4ninUxcl+ywzWTv3Hw/0MiVzyNtpWe4l/p/lbXcV gH3lrOQ== X-Received: by 2002:a5d:5f4b:0:b0:3a4:e5ea:1ac0 with SMTP id ffacd0b85a97d-3a57239782fmr14644120f8f.5.1750268488291; Wed, 18 Jun 2025 10:41:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe8UrsZSiMxiNmESOiojos47BRrZtzx99uy76zavyI6JTu09cx8RaDL9RnhQyywn3/qc/sHg== X-Received: by 2002:a5d:5f4b:0:b0:3a4:e5ea:1ac0 with SMTP id ffacd0b85a97d-3a57239782fmr14644032f8f.5.1750268487539; Wed, 18 Jun 2025 10:41:27 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b48564sm17230726f8f.82.2025.06.18.10.41.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 26/29] mm: rename PAGE_MAPPING_* to FOLIO_MAPPING_* Date: Wed, 18 Jun 2025 19:40:09 +0200 Message-ID: <20250618174014.1168640-27-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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 93ee0d2d6f1ad..f00a073c35c45 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -524,7 +524,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 d6b91e8a66d6d..f139f47696f63 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 6888e871a74a9..76ef1839a126a 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 feda91c9b3f4e..ef11d341e3915 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -150,7 +150,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 18b3690bb69ad..660a94964438f 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 fd160ddaa9807..c8610ea772683 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 Thu Oct 9 09:03:18 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 421A12FC002 for ; Wed, 18 Jun 2025 17:41:34 +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=1750268497; cv=none; b=GQVFuZLrVfZ6oPunAbaiRNOEdOOHPJiEJ5asI9YFItKeG36g6fkkN6hbevmjbr6KH3tDp/mDAEep0310Xx7AOU7O1tIrfVZWhDsDjMQ5MULJjuLIieh2wUoUA6PYkJxWxaOrQOrsC+yT3B3pWnfaKOy6bubZRtArYAOh7mkWQfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268497; c=relaxed/simple; bh=qANw5s/Bw3QCvq7BlzvxZffSRQGWJpFueQvB/Dfqsvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=msb4ZQoac4ldfcbrMTpt4Xbq49aDw4RAyJ70y33xWEyRcEGemMyMzqnM20xMloKk2ZHv9tPH3pwhGoKltz+UNOVMtVOhFIpIypu6VsPalI19+QV1b7kgo7dWWbDv5iTcwnPhOYzZyAAInR5C4HyctAKo7anCspueWLyTe0u6w8E= 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=Bv5ZI2eQ; 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="Bv5ZI2eQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268493; 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=OmfdwaP0f5XUY3WcVBI8N3swmSiQtYBlwUFmuX0ZYxw=; b=Bv5ZI2eQ/dGldGwaua9XQhxpnfr9C51HJjG77T68zXscE04eMToqCfntF30JA1g3NGGodO 8GFji0uuOp+cMLD0k2g9Rz+Rw0VeTCkjpTK2+/EGsXornRnKd2UloKg6qDCedeGLUa8qkZ ekTJ2z4TxZptLhl0LpNjTlmcUDlhem8= 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-462-KEXdgAFsNIulMDxGQCDfVQ-1; Wed, 18 Jun 2025 13:41:32 -0400 X-MC-Unique: KEXdgAFsNIulMDxGQCDfVQ-1 X-Mimecast-MFC-AGG-ID: KEXdgAFsNIulMDxGQCDfVQ_1750268491 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a4f8192e2cso3545473f8f.3 for ; Wed, 18 Jun 2025 10:41:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268491; x=1750873291; 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=OmfdwaP0f5XUY3WcVBI8N3swmSiQtYBlwUFmuX0ZYxw=; b=rj7SAf96c4XqPhm0UDjruTz1Kf6ZIdBeV1NcNqq2QP2q3h5ySAyKdqTFN3uhQsOWAk IdZdfgI92t21oDf25cXHjLACI1LluseZWewpvIngaHpC+T1zkrRcubiWlfrPxaZpztG1 +Tx7wg8e2g8M8fQOaqW9HhmDmu1hbOS6+OK+I6XPE23kCEml/tTbQDNTnFlgGHtHy/3C 0tOtActEAtJx/BhsMpZ6NxVvydn2op+Xod5+bINfg3Qb3G4FP6Lk+8LduElHMmRsNY1y Z+f0s+jwxDmJpcLr0nIoL1gYNhRxDmSDlVLNrMS+z1tzBiu9AqTvsHEFjc3Fj2c2+MyW thOg== X-Gm-Message-State: AOJu0YyIcaXtvjGzklo6mefMS8TzutljNh082WoOlDQytTTHWKSkBS+B LtNDG8cCTXj0oSUnfKQYxcoTJYLu0LENWToiXN5WCyFYwHJskZrPajtJUKJ13PI5amKOREtLfjP 2nbUBg2SpxepSqAtFsMCc0Vw32ic9Bk3QV7TJGQ3WAyB0tA8GAjrk1mgkvrStbMP8UUqn3VwMJW Lj3L1OtyvsdCFxmlk6Di4Mlf+ZxLuB0J+4APbbY05Qj81Qqo+K X-Gm-Gg: ASbGncvNqwr1pA92zI7V3s1XoXaTwL7aFo9f0+iqWPolwLQF1wfgRr5TB6bmCfBcPIr FHvr7EJ9XbtOPyx3vZ+8dP9optzZ2n/VU+Q7GCCrql6JVT0dLtaJguj+xATWHtcNQlEa87+XeXk wmLFrH4XS/cUh61rU5kvnH7Z1+UXS0jPqbdl1uxckzb2De4eFHlO+9w7fM7w4MRmD9dKMMuFM/9 JyEWfKNxu6L8HLfalNaM8xqA8nmTeaqQBZnk+VMz6/wvsOYEcXPGE5PV9RMMSRPRMAcDJ83mwBO biSmuAaHtWTVTg7xyNegE6xuYutmS73wgg4GVer2rTOEuesACdzhmtwwXiS3B4AtIOFQ0+Aaf9C yZ0gxmg== X-Received: by 2002:a05:6000:178b:b0:3a5:21c8:af31 with SMTP id ffacd0b85a97d-3a5723721bdmr15240252f8f.16.1750268490904; Wed, 18 Jun 2025 10:41:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAZhpZh4slqbXf6Y+7KOO1SPenqI87LsZpqVnArN4AUioCPUgU259IOTbkkNjhv6BPhqHLFQ== X-Received: by 2002:a05:6000:178b:b0:3a5:21c8:af31 with SMTP id ffacd0b85a97d-3a5723721bdmr15240182f8f.16.1750268490320; Wed, 18 Jun 2025 10:41:30 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b2f80asm17518051f8f.78.2025.06.18.10.41.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:29 -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 RFC 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration" Date: Wed, 18 Jun 2025 19:40:10 +0200 Message-ID: <20250618174014.1168640-28-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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. Signed-off-by: David Hildenbrand Reviewed-by: Zi Yan --- 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..a448e95e0a98e 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 framework 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 Thu Oct 9 09:03:18 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 C61C9305525 for ; Wed, 18 Jun 2025 17:41:36 +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=1750268499; cv=none; b=unlTZLSP5xADO6rBSEY6p0MGNEkAcraQm3izvZYwyfRhe1UAwP9wXdkJvRH0OHasRHJ9R9aKJITlGMeJGlFo76xBvtwu5tqfvEnMK4QizDYqAF9NhoeCHG+Xy3JUN/sAG3mjPVXwnwlFRktQ4haRA89ZxV4p4Lxf1zMVqDcb7E8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268499; c=relaxed/simple; bh=xmAX6FaG7PwzByxdVNWIboeTPGW5tjq2c62uEFet5m4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BsMxS8t5zpU7Xg3Ey6e7wk/qbZMzPeMM1QlqRR+OAmbQ773CMdKoVdEETF2gGdKVwu5+vDRS0tygD/SWPuQwNNi3DdyIH9awrXHz5nen+Pl4xKOKOesX72UhJsniIkRXIjGlLH48q/D2/cPrIfTqk+sKfdLuVzJVSnsYV575F0U= 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=UWuZz79D; 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="UWuZz79D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268496; 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=UWuZz79DKCer1K2zP2dkFjhVTfQXYPyAgt89CuDopdCEaMw1IDDvBx3JEOBWHYx2qQeq37 TAP9nmUKxdLhlQEIuVnkQodczviJNzTb/36cCbiD6PByVZOxzwxK3Qqh4pV75+SrAtlE8I DBQq3dkaFeXemaYovnYly9FVCPOi5zY= 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-503-fPVFkNCiPASVRLkZpJxzzg-1; Wed, 18 Jun 2025 13:41:34 -0400 X-MC-Unique: fPVFkNCiPASVRLkZpJxzzg-1 X-Mimecast-MFC-AGG-ID: fPVFkNCiPASVRLkZpJxzzg_1750268494 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a4f7ebfd00so3268672f8f.2 for ; Wed, 18 Jun 2025 10:41:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268493; x=1750873293; 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=GL1smevLdPhdnuG2pvv/mf82zR0QyFyfQDMrhQRH8CqMHtrbJ3bOoDTcv80pfQx/YF A3sSr2p0SRRrDaBuyRJtccA1pxSd2xxvx1CB8E7X3n0QloUC6Vib3jQIyLpAREvlUt0+ TBAYTiBxGnp4F7ZnKaq4cOenxVM4pdbSTYpZg4pzqZkPGyQ5HqZve1QqIjP1lRBOzAq8 US6gQlSu1evJKs+vZk7py3BVLsjwEpfsX9j3LiiQ50RMFwP/O5xRZUKo/q04CE4By7rh 2AMhoAnTQvVHbqirNrzVL0Roiuy704Lq34BKtN6ixoNpijonnCuel5xec3x11pFC8NKI eLhA== X-Gm-Message-State: AOJu0YwB6OzjMvhlSN4fWAkXtQLHhvPNOHWKrx8+bQym0hTBSUJRj3OD sH7GiBpDZ2NAJvuvhLe1GO5n0vcf8iinhxrpKoWVUmYqQ5Y7Ao0fn2Gx/gCQGAlbkd61SXRjdn9 1QuYWvBWsJyx/H4xDxufycZ6vx2cP38egwsrsxzVERpJlzRIza1blKZa3ZaGNrjEVoyI8FpW/GN JqZWd8WYqV3dvlbyq83fwIm64qZfAL0cyt+ksQMfZYo2l3UAg1 X-Gm-Gg: ASbGncvsdYAAtNTMaHAEqLEo58uUD0pN+SK7Zg/Yfb9ni7eMka3ECh1apS+PG4N+bgs LeYy1wwhCDsoDwtIGOLYV8bmXkBtgbYnLpy6z19FAFDsgETZbRHtgxBbOgW7XCRvbf/LP2Y5EXY 3pmanTrK4idO5Dtjr4Kfrrh4t/YSSt4KMnjsp/G7A6W/CJ9yxKB38N826FO7QHrJxmKv0pA0bQc s/U9y3ssJIjjqloBz2zOYPrDjJ1AQmE8+S+54WVROgFKPAmPWnHBqNVNDdN/H2/a1CYMl+0BVRq Q+QUJDodHKftl3b8mcixLhtEWq845naNJPwHq91nhejbVqT/q58qypyX/oE7HLVfZ34ip7M0jTJ qfjOTrQ== X-Received: by 2002:a05:6000:708:b0:3a5:5278:e635 with SMTP id ffacd0b85a97d-3a572367577mr14018505f8f.3.1750268493547; Wed, 18 Jun 2025 10:41:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIdYJ4byKGNqSckw7stdQWmP9a+mk+8zzlUOQQiezgX3FefY2T8iN/DegCcyfhV4fwKQhI6A== X-Received: by 2002:a05:6000:708:b0:3a5:5278:e635 with SMTP id ffacd0b85a97d-3a572367577mr14018429f8f.3.1750268493058; Wed, 18 Jun 2025 10:41:33 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b5bfefsm17100889f8f.88.2025.06.18.10.41.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 28/29] mm/balloon_compaction: "movable_ops" doc updates Date: Wed, 18 Jun 2025 19:40:11 +0200 Message-ID: <20250618174014.1168640-29-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 --- 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 Thu Oct 9 09:03:18 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 7611F30554F for ; Wed, 18 Jun 2025 17:41:39 +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=1750268501; cv=none; b=GFXe/Ec3BgmGu1iJm2Ht2nZHyQBAdHRXDK5nQCzzCeXydAACQn7ryNuguReamXVWobDqjjMqKkYBd6RpiLSH/yzZWENqTx2UZafqTlL7UsJd0bhVZbAam90rzfLm2u0SwAu/rSQEH/uhyfnO5bYxeZM9gvOMOyzGGjOBovuz+7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750268501; c=relaxed/simple; bh=VLtr/75+OgLg5UKJqAhr4SPpTHq3QNsAl+8ocPk3Nhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l1SUl1bK/0vJj7x/Dw5sGZ3+ph/avqXrD/3iQt/7knLv+D6L5VHjenUcAnCMOmvBYfFtxDu3MM23MNTM5bfSj2mRSXCcoMyCQKVk+1fhKLYUtmss/IjN/YO/t0yC9hTTOgocJmbPgc6eDDZ177fcmfZVDEyw2AWgL/oFB/KtAjM= 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=RbbKPKIa; 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="RbbKPKIa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268498; 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=RbbKPKIamvam59q7i2JUbHN+/91evqGYAK47FwhUsB6vkEErp9wsMZQhpXi4UCgdqsUIPE PLnZHZ1sBJaBs4fnlGEYHJrLCcA+k4n2G7PefHZFLrNOOUg0oRHdxZn0GoteFEfSYALVk0 AzZ1CV80CSuj1V2NS06dpd8O5lD1Zm8= 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-693-zrQn6tsJNQC5Mc48ctmRYQ-1; Wed, 18 Jun 2025 13:41:37 -0400 X-MC-Unique: zrQn6tsJNQC5Mc48ctmRYQ-1 X-Mimecast-MFC-AGG-ID: zrQn6tsJNQC5Mc48ctmRYQ_1750268496 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45311704d22so46556025e9.2 for ; Wed, 18 Jun 2025 10:41:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268496; x=1750873296; 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=MkqkaWhwo50ufxpbKq1xIjKm/eYEmT6EbVfjVy4WOpKfBBOocaGme2yFdDQALegqpl omvuCjORkhGQ1r9kqadTSTmmMkAP4Xw8eEaHacweYArJri3rzk3oeJ9J/f0z7U1Wrm7Y p0On38kDNOwrJw3PRyLJOkgbqEPUY7btIFqZJ/2YiyBqfdgyfKgDZIl4S2bM3lqvkeGD V7w+8gQmmcFRg/Ep+0deFfIx+iOrKwizJJd69xc//UK5hc/ry2phHMrYtGv1jZGpqpg2 vSRF4Bge4QQyYI1Xotk9731oSz/MG9sdQwTx5Oi9yKzcpOtTeTxPcycUHgmCi7kwbqwC 2n0Q== X-Gm-Message-State: AOJu0Ywxq4Zs4kjqR86UL+2LWgB4tPK8Y3bA6uoOEhkIlWSsDiOufqvS WHKtDWvHlQQnvwLvnm5XOCGux3mpIRX0GlsMSMA/UWt29+fltBaY48eN4eIiTEvN7FrK4sYR2Y2 LQwJ/y55z3ObyFq/H3YHdPQickgdx3RKQVyeHw64LEDTvwbuHf9T9unjeSwowuX7ZwTmUkvVOI0 Wvbh+tmgLgp51yQ2gg10+Nbz8cOvN+srJ5tG2LeQx6nUCXoH4C X-Gm-Gg: ASbGncs4tqua98rPfdw2LGfqbh6joG32bg5hyQu77fypbbHumPbgTciFEo2Dd7dC3cc 8vkSOMcPampdUQzbGIRc7MG/urF8z/Ei6pPISBOZzz0IpBjBdofjEB4e0CwDmZ2opjCTxTjpi3y 8h7cQdsA1/k/3ERoTY6KuqT/xOl3InoUsLm72OQ87gPEBwoXVwB5ozy4zNc8B0mYs1iq31y3TmR ARz/dynAUcN6nTfIFzJdHtEJYAx51KHfy6EatMWuJQiKGP7oVXxpD0TIap7e/MYrcxpKhVFaP8O v9SBYb2PRimMxqgCMrjjDHEaVlxze+gKtf9ABww/wO5KVt+iBeiEKmrqG/uR1wW7/hShRzEPKlP hLs5CSA== X-Received: by 2002:a05:600c:5253:b0:453:66f:b96e with SMTP id 5b1f17b1804b1-4534219a64fmr154424705e9.11.1750268496242; Wed, 18 Jun 2025 10:41:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQJSoFqz4Qx4eaIpu3abT7lqqTMcn+cWB1r/wxQDnmsMcckQg5l2MzM3eBNzoSDxLAyECFAg== X-Received: by 2002:a05:600c:5253:b0:453:66f:b96e with SMTP id 5b1f17b1804b1-4534219a64fmr154423805e9.11.1750268495716; Wed, 18 Jun 2025 10:41:35 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4535eac8edbsm3459385e9.24.2025.06.18.10.41.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41: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 RFC 29/29] mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask() Date: Wed, 18 Jun 2025 19:40:12 +0200 Message-ID: <20250618174014.1168640-30-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-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 --- 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