From nobody Tue Oct 7 22:50:53 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 E29F72F234F for ; Fri, 4 Jul 2025 10:25: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=1751624736; cv=none; b=aJKtj6M6jdw7cU/T3uHnjnQSuGS/3BJngpD4r4EZ1otSTrfesRByspwla6K0NRzLay20QIGBM1cMombtsoW2OnmG62A3p9mHtzb3HqJUlszPggvTgD9sKtYYYOoAonFp1VjvOlU3VAr7Nm00LQCSPEhrQXEddtQo/4YZujayADk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624736; c=relaxed/simple; bh=N0i0mDmhVdZqrTyFYSoYTge/lbt5vfjL3ApU/H749m0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DfDVLGVqdjFmadBVmo/nSIOgHXURXpa3CdjV7NT1IkPNY2TK9CtGo/inFItc4gYbz+a/E5tP1rdsRcnOk9FSv6okWfpC2aIyS2fcnvcAmSrOx/f3OQiqjN4HrdyoI1N9OQfYI4djjjrcU7WEceKrqW5V7ONJbRgRyA0s+VOopvQ= 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=Dv4e5rzU; 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="Dv4e5rzU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624733; 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=cQQqBmPuJGjYXvvpwjiHFMj2XowEg2vBjzCyliDZdkg=; b=Dv4e5rzUQuJCJ7ENSuydkFd18om1f8WJUMM3YG8INvtYAmiObPBojwsb943cyS9gzH0Un3 NRufT3WHp88ntXe/muVCv3syPsZ1/IoDnnEQYnZGE1rEfILbM6eCHVu4VQ6jeiY1JN+y4w OuqG7S9UlZWH2cRKBaZ8BAvOblK/4Tc= 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-660-dyCMqBWqOxqxbTPoQi9prg-1; Fri, 04 Jul 2025 06:25:32 -0400 X-MC-Unique: dyCMqBWqOxqxbTPoQi9prg-1 X-Mimecast-MFC-AGG-ID: dyCMqBWqOxqxbTPoQi9prg_1751624731 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4536962204aso3196945e9.3 for ; Fri, 04 Jul 2025 03:25:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624731; x=1752229531; 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=cQQqBmPuJGjYXvvpwjiHFMj2XowEg2vBjzCyliDZdkg=; b=L5FVUdFf6EW1OnqMFy7xYt/VoakH/2kNOB3OazDco+P2EqWxBLjnMztCTfiok1moXn JatAf7Kq1rnCaVH19KwY+iXcQNu8FfjxdFEsu2/wTFvFzj5gINy/YP4gNqvlUlSs+lL4 Mh3AW08HRIrPXH2NgbjKBeKfTJqKM26kIJ9aoFfSDmYON8h1fXL6bKRz7O7HHu6XmV/O fyNUdin+01oTy/EdEPrsgeSX2Osx3Nux1YPuQa4kTS6PfKr7PFL9Wv4zVucoNQMbfP0y 8D/AvSg1ftl7JctmGKXUnuKmdqc9rheZaPCMpudzlGPBVhHpxkdw13evCkS7IvmIl0d8 HumA== X-Gm-Message-State: AOJu0YzwHxMkolkERg1wVVwxfLzlwaTiHrg+PNRYFkA5p2guav6qqanS 2EMrDlUthwT49HCbrfcGHyve0iRh2Dqi9zq4/FpTVjlxZ4V/RYkjNAdHMHouh1NKhe5iFKIOxZg HF9PIXgKIIjKGaMUmbi8xRXSLWYjPFPhytV29JD3i2l+2dLuem+yOvggCIk5EODtSfFOWpXbPUF 4oXaCZ/nzU8erzqiIom1BL+7BhKRKrDjd946rPAvHvLRlDgA== X-Gm-Gg: ASbGncv8lC86PjqR5Qnx0SabRf7dKDwluYn9xn6sdH3ebp28nCpEF8DZmNyt1sGFXNt +EXBhz9vcL29PndURncUqKqEAs8zpbz92hy4THvsDOmCFE2Qu8fjh7Vx/gl3dJISHZ2xqgFP7qW pXIvXci8s7hh10IPWmIcv0dpZysnIj8fQZ39ZGBOvQhJ3dQXrygPv3GNGMvCoTaHTZLvWD6WUvr fTpO1Rt0nfwFy43lGd8wlLu0kFpyS+O5F/RghIkAILbuS0sCv7eEZshw5rewt4Lt7zpNvhCvmvb uAXpB8gqFkLK7W+C01moDWOus8wVNvdofsSGAm0zYCFkvWXnNU+uQMKHqdimWwDrhC4ShZsRdo/ Klc86Lg== X-Received: by 2002:a05:600c:1c19:b0:43c:f8fc:f697 with SMTP id 5b1f17b1804b1-454b4e74ba9mr16508115e9.9.1751624731043; Fri, 04 Jul 2025 03:25:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2JCKcFSESlucn/AkzEEQU5f9yWEwz5OrnoWVnvSvIPUgrXnOXbfSZDcsxaTgozbAMtqKAdQ== X-Received: by 2002:a05:600c:1c19:b0:43c:f8fc:f697 with SMTP id 5b1f17b1804b1-454b4e74ba9mr16507075e9.9.1751624730349; Fri, 04 Jul 2025 03:25:30 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a9989fcesm51185055e9.16.2025.07.04.03.25.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 01/29] mm/balloon_compaction: we cannot have isolated pages in the balloon list Date: Fri, 4 Jul 2025 12:24:55 +0200 Message-ID: <20250704102524.326966-2-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The core will set PG_isolated only after mops->isolate_page() was called. In case of the balloon, that is where we will remove it from the balloon list. So we cannot have isolated pages in the balloon list. Let's drop this unnecessary check. Acked-by: Zi Yan Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- 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 Tue Oct 7 22:50:53 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 2623F2F2730 for ; Fri, 4 Jul 2025 10:25:37 +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=1751624738; cv=none; b=oUEX1qKEsxzVzZutjAJaBXy3r7ceR5AdzXHHAYfuRPrXFxoYaytyYzzcMQdeH6dtqAc8n1fRNtsyoaoaHNsc0IlwXx+3mdJN+IQUVL3QzkKI9ywebood0LrN+7mH/1e69h/uLEo8hLHnDOjGs6Qt/fVQgg3FcFfokOJfdIT4Usg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624738; c=relaxed/simple; bh=I63+tICEwC4FRjr5OpxcwU6Xz35bpjNotIszeWd/mZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J0FEtUwWbpJb82QzFBNg1JN8pN9xbaJ9wt5rgZ2lKO3P5faI0Y6N2jwSppUWVld7Lu3qEeQC619mlTkkCC2qs3XOt0p3avaY+3jTwURqASJ/B9II9VOdZsrWIBPhQwbfoH8eotWG6aJ4E6/hDPwxcm10NN2zXAHADlWaQN1T9Tk= 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=Ao+/f5wH; 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="Ao+/f5wH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624736; 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=rzG8kZhPdoUa83Bv+EhsniO+15GPe15At7nc5LLJ+tY=; b=Ao+/f5wHEVXwRg2dXPDPFP+nZwJAvj0NdFmPWsu/S8t4tY7z9VjMXnx6reitOd2MHWdLC9 R0FnE+7d6MikBRXTWQWF1meiIX2cBAzLAyKm+8wuYr7VkQuo80Tv3Ow01j2VeLfSqExDop ZsR6fqQ/RqngFr8McAmneY17y3zLau8= 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-182-n_5L5L8-PNCPH5u3LFbGfg-1; Fri, 04 Jul 2025 06:25:35 -0400 X-MC-Unique: n_5L5L8-PNCPH5u3LFbGfg-1 X-Mimecast-MFC-AGG-ID: n_5L5L8-PNCPH5u3LFbGfg_1751624734 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a3696a0d3aso354516f8f.2 for ; Fri, 04 Jul 2025 03:25:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624734; x=1752229534; 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=rzG8kZhPdoUa83Bv+EhsniO+15GPe15At7nc5LLJ+tY=; b=Mn1etEKlF87WB8vBemw0xYPX8IjaAb/7DB4vY9E6vrgHaZEB7M0oRMjF1YiEkWDLOO OLlvR9ksHFkKk54gTduuHpztSW9HuecbTeeciVHCoLepcQQmlu8+e8sCAb1OsrnrdFP7 M2gZS4Mn+SBtljje1/X7LByc66EdNqh72TojXcadrAzVb1sJSUvIGgeoxlZHGDr5JWmT JIkBOEyqgCtLyA2WIvYowV/o76D4DK0TdO7RHtZM9BvPa9ucVHJwLKyrHYtPz2Bo+s5d 1d22BqCwJoNoajEggb1NHDkun4fgIT5KBYJhvEagQe0vn8XZ0diFFtDZlBVTEV5i0/iY GgBw== X-Gm-Message-State: AOJu0YwbtMXGHKv1LPuRZab3Mn1qlBp3UvTtRgXuj/Vt+39oa50glxVD FodQytXAfnEEn5H8zdRyJN0pd0stmCA6LgTAoGEfd9os8bAUIbji7DMf+v92ZJwkASIuuIQLUBQ Tn3tXoA44u996FjXuV4b9iRs1lYzVct44OeuSl6wkvvZfM9xDN2OB93OKi+KxVEXstWVn3PjOWx 2KVfVdARTKrGiTEig+NTtGkcJi+lAN89rr/2ZWL+/XLnXdBQ== X-Gm-Gg: ASbGnct/jx6T4RoV0pWRoy1czFTIskrXdKuYEwNmLcSvkO+1RsHso5Oh55y2D2hIjiP Dox4kZOHzh6aAOkoZ7Z86khvWPtEt0DgEOO0bomqRife8d4OSvsEBQMHf3+/ADGiMf4oQXlDONh 8lOFsi8ydaXuFTf8tmzXbTU2XZPKSoR8i6GaS9egw5LWjCCa8DsMj9//d0ffH9ZLULje9/A22ol ACzGJCTTiFR9JuuNBPItHro8L+9xODoW9EyPJ/lnSvk/bUYEZ3T2sNA8GZhSZlKhNAOnXROUYL0 Ht69DaVJHk1Td9mP+rEFdWcB/bQY07T6UWQjMT+P98mDz9qQzsvk8nI1OczhwnJRLpgIKzhFSZ+ Hi+mvuQ== X-Received: by 2002:a05:6000:2f86:b0:3a4:fbaf:749e with SMTP id ffacd0b85a97d-3b4964ea59fmr1485344f8f.49.1751624733894; Fri, 04 Jul 2025 03:25:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzOdZy9kGaBK2IhW4pGMieYfGDGuCayvREmmwE/RZquZQddy2FKZttIuDRBnk85RTka/4UcQ== X-Received: by 2002:a05:6000:2f86:b0:3a4:fbaf:749e with SMTP id ffacd0b85a97d-3b4964ea59fmr1485265f8f.49.1751624733234; Fri, 04 Jul 2025 03:25:33 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a9bea4a9sm50548875e9.37.2025.07.04.03.25.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 02/29] mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize() Date: Fri, 4 Jul 2025 12:24:56 +0200 Message-ID: <20250704102524.326966-3-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Note that for now, balloon_page_delete() was used on two paths: (1) Removing a page from the balloon for deflation through balloon_page_list_dequeue() (2) Removing an isolated page from the balloon for migration in the per-driver migration handlers. Isolated pages were already removed from the balloon list during isolation. So instead of relying on the flag, we can just distinguish both cases directly and handle it accordingly in the caller. 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. Reviewed-by: Lorenzo Stoakes 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 Tue Oct 7 22:50:53 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 C78E92F3645 for ; Fri, 4 Jul 2025 10:25: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=1751624741; cv=none; b=lRu1A3oplsE6KW2UjOtBxs4wfUJrnSLFbuWmObNHZUXG+BvhFnWYvzW7R92vfQjvn5FLx0WDYibArWV58QEUI2jdf5vpRZo7vBWtu7pg6QqE8sB3B1IYMjAwxfPn43C0zH1QsL/KszrI7NWx2QRZ5mVYc3m0fZ4wCip4R+XGgJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624741; c=relaxed/simple; bh=yirVZfO+dHe5+EJCXh68ilzI6s3sApzRdgd2Lx9ZJLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VYhO73MFBG0SNkXObI8fAfNbzcDJ3U0p/J28eAEWbwJvuzOj14f5OKrxuoV05PuwbCfnOi3yzkOpfxUuUH4c3Utbt0qMpih5tLTSsEfYZEENEHJCZNLesYlpDNQCyb4hWA7+JmxzD+tjJLi/7ewv2MlLqf27lzKt40+mEuydYVY= 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=fG28geii; 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="fG28geii" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624739; 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=Km36h+57LoMclmINdAl2JdQwpEFbx1KUS9NaV7ZwoS0=; b=fG28geiiYuy3XjDZbjgxSMioRpovW8W2VMuuDZoIgn/RA3ki3F/iYTuTkI0LV/vIGLvIo+ wZ9W6Ajtd8BvRnD5FAaI1g0qwfzO++ajeGp1ccnhvDnXEdsR98w+Sp/y8auyz47Q5f4hRk ONAxtf7W7rt8wBypoAw/d9ZzYfpOsY0= 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-48-uMYI-WDLNEirbkZbsMM32Q-1; Fri, 04 Jul 2025 06:25:38 -0400 X-MC-Unique: uMYI-WDLNEirbkZbsMM32Q-1 X-Mimecast-MFC-AGG-ID: uMYI-WDLNEirbkZbsMM32Q_1751624737 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4538f375e86so5909185e9.3 for ; Fri, 04 Jul 2025 03:25:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624736; x=1752229536; 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=Km36h+57LoMclmINdAl2JdQwpEFbx1KUS9NaV7ZwoS0=; b=Pk2VEwXx54gKVYMmBxvZ/mO4/44ZWguZNSMfh0CvqUudegsGBdaJYHhewal3UvF3PE Dl1tCHMxZc+vfdHf1dBI9QgaZdGny+NCW1jWne/rwPM9BxfaSROK1E5BfqNemCkPrTTt URzoMeaIIlNaKzUrlJSEjJye5rzWnQtbNgIRoVbz9cuKJUMU8jxMHiq0UNVCpiuqwL/5 +9n0caJG0B6A98KhZZxXIn9N+1ebuGS1EeUXQuyjjXdtXXdQYlSNmq4sWQqxcMt/Aw24 MREnGkIbl1epZdMPM+eHoGuctngrOOh5ue2dfCGfn8Pl5pzLKGgyEpsZ9kDP0Nk8dqpk nOQg== X-Gm-Message-State: AOJu0YxUGfl8IlFCybvHlor2Qqxbp4uHuzmMspWgkeBx18XhxqD3zaZO +qZDHkTmuLdthw6uTMVSMvijmvSiyHAFciIwvgKSl1xNPkDim8uvoqg6vRxgDdhFuJpraVfpdOa impRix09Uyedf0qLC1AAPZBBR7X47DN0+/vi/OIPSozE+qcbHY7e8ajroGKSIElHtKddxFempgj 5jad9nDhnGGn8C4JtSFrW2xNE5DNw2YtdajsvuZSQ3J4MSxw== X-Gm-Gg: ASbGncu/+ECOKAkS/lneaV4uEZEMGHFCHbQjy9Uv8oow8ZNkBMMqovH0Vbs/aTWeCBs t/8pPmo3XnW7PkHcrhO/xpDQjk6sa9/51r5onXpW1c1jFw3wYN57L5z7kHtTvqisYZ/2OuUOsBK 8VTeasGB7+7xyeTUT3evSANWL9P743w51h6L4Tz9zjuE0WX7RwZFWCuaTK4Zyqw0F5Eurt3EGg6 GiZq9nnSCHq3nGnphnUxIxeWm/99Br7mwaczRlst0ryCcDEGENUoTxOLVfXlSgd89XZ+x5uqpbK uQXYImqG6RMW8MijVxw5wiI3ojGJryvefIJx/UkGmwh0/851hN+1WU9KThOnvpH3koToVL41U7e vt6Zh3g== X-Received: by 2002:a05:600c:348d:b0:453:608:a18b with SMTP id 5b1f17b1804b1-454b3096211mr21111395e9.9.1751624736545; Fri, 04 Jul 2025 03:25:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYWTkwuG63kWN2pUNG4mMJ/rp0CK4ANHmE+tpQrKYs+JLvfC5kMT/JJWZ4Z30efeBW784Wqg== X-Received: by 2002:a05:600c:348d:b0:453:608:a18b with SMTP id 5b1f17b1804b1-454b3096211mr21110415e9.9.1751624735911; Fri, 04 Jul 2025 03:25:35 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b4708d080csm2111024f8f.23.2025.07.04.03.25.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 03/29] mm/zsmalloc: drop PageIsolated() related VM_BUG_ONs Date: Fri, 4 Jul 2025 12:24:57 +0200 Message-ID: <20250704102524.326966-4-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's drop these checks; these are conditions the core migration code must make sure will hold either way, no need to double check. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- 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 Tue Oct 7 22:50:53 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 CCA182F3C0D for ; Fri, 4 Jul 2025 10:25: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=1751624744; cv=none; b=fqnNoKdXA3OHJLAmcY9S2P1sYThlzFcYrUd9omD8wTyyxM0UZM3U33vGdFgem9eZYPEhDT7zRgkFG8rTwfuVnNK9/qSdXusC3rYTKgFmKVsS3OAMreZGgyp3Alq73LXMqZgD9k0ZTAmihjP/sMb5HimgTr6nm428l7aUcsM0cZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624744; c=relaxed/simple; bh=AM3xYskqV1GdLk2CfAavrgvRU1Z8ivBgX0T2p7YhDTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HjEcuq0uHsSIY2SatOOBgwjck+icVZ9AZC+nVu4NVMajRYoZhIh7bsr33z7l697Rh41onndXvrhaZPkMJvd+jBH/WRQrjJ27H1Uis+nMZ2yAFe5IqZa2++2vElZkuoWtvTq6VBDT/XHDUcWJgOVyJ9bqcI1+ZFyKb7aI4PVcTjw= 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=dn+Gth0w; 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="dn+Gth0w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624742; 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=CYTSovr6D54lprWegV/WfQaWtrhfAm9Hhj9zhgiC0NY=; b=dn+Gth0wa1D+SSUkSqzR8RHdADz23WiU3biqXTvhh1vJPdsj5uiDGGktI5jrNZmQrpPjbz Nugl9ow9Od5Cu7YriQTtCvh8SowioJxlVajM9kZ1ho8wxElPrOFEktR3s1frLPFLgkPTil BeMdUkx4D73XmKhkwtpLqHamZlj/Y6g= 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-332-m-JpfE6oNFya3LIgzVb8Zw-1; Fri, 04 Jul 2025 06:25:40 -0400 X-MC-Unique: m-JpfE6oNFya3LIgzVb8Zw-1 X-Mimecast-MFC-AGG-ID: m-JpfE6oNFya3LIgzVb8Zw_1751624740 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450eaae2934so6575475e9.2 for ; Fri, 04 Jul 2025 03:25:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624739; x=1752229539; 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=CYTSovr6D54lprWegV/WfQaWtrhfAm9Hhj9zhgiC0NY=; b=QweMKfb1/V6/lWLC1fdiQF/LVWo2Lt/eM5EZ1ewKEU3FqKUEBhJGuxQlO4UmbVx2GP V4p1jxJ0UIgevYazVeVlNpTS+kti33+HZPPne3Wm+kSLZ7hU96IGnw6EGeh+62uD3rK+ teHJ8yPTSvi+L/oQQzc5yOoMVzPJADXN5t3sFfkklV9euRDEjPHNT6DYxP9FaU8fCpLK Qb1Qk7LNy/CqXskd6tA4nZ9+k1QTxgAi9d1TDSRA5GO/JYYbIJUngspl34fyl9KZ9qyR Nv3Fr++92o3s7tZ1yzH8MhBoD7Gygp4+ytia27PDBBSsn2kdCMCdH3/arxOTfCDQn2z6 VKHg== X-Gm-Message-State: AOJu0YyP1l/ig7PeonNqR+wSUcSWcB/S+Ve6lUo78WP8ld//uzc2rpsU rXQHriCJ/dW6JxXXFezHa3x3CswaciIHSW68WRRbPbIYXylYlUHgjqMoKwZ1xEqQDoDVn2JjRzW J0ReHQj2EoGPMUVMJtDlw05prKbQT0WwUEpYMEfgbEgtEfuI9S5NNCB+6yUSdPIpYp4ZMJWzWQ7 htOc1VhQlsvpeeCIQaZRj3ImE4rAyShwq1Cd2/ki68mY5YCQ== X-Gm-Gg: ASbGncs/QhqERy6fJRUT4DS90PWJijFv+xtguT34YuOx53aZSKOIe9+V+RY9syIJ3q5 xpY8BhVFyrTLhvzLVMvOFA5+RVMpMX8HxemEaeiLAj5F4Y4Z29xzdm56dZt5uRLr9kRjHZHc7kc utvjy2qirQddrTcfLRjOn837QM3RoOtCDsId6/UZ2dHPkpF7fjReoW34ymq5v9qdJeeXR6te0iD enkQHoYC1olu53ndMiv1Pc+KNDJZKzO+KUPTdIgxaXTVQJf70xXZfYMdUXyhkRVzc5fgAE3Up8+ qDgKY4hQPWUEaa7Z/RM8SsHdG4oZIzr5W+msDloRTZKG4Xnv+KuwH3yuykVixmDcOhgZlqHaaqh HdMJ1ww== X-Received: by 2002:a05:600c:3e1a:b0:450:d01f:de6f with SMTP id 5b1f17b1804b1-454b30aff3dmr25066705e9.15.1751624739363; Fri, 04 Jul 2025 03:25:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEabPcFPa9J30O6qNf8/Kx6cfnBeZR0NWqXc94Uy+RT4akZprmrg4imDnBXRg/gEanMTx6ZJQ== X-Received: by 2002:a05:600c:3e1a:b0:450:d01f:de6f with SMTP id 5b1f17b1804b1-454b30aff3dmr25065735e9.15.1751624738758; Fri, 04 Jul 2025 03:25:38 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47285d3c6sm2121167f8f.95.2025.07.04.03.25.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25:38 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 04/29] mm/page_alloc: let page freeing clear any set page type Date: Fri, 4 Jul 2025 12:24:58 +0200 Message-ID: <20250704102524.326966-5-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, any user of page types must clear that type before freeing a page back to the buddy, otherwise we'll run into mapcount related sanity checks (because the page type currently overlays the page mapcount). Let's allow for not clearing the page type by page type users by letting the buddy handle it instead. We'll focus on having a page type set on the first page of a larger allocation only. With this change, we can reliably identify typed folios even though they might be in the process of getting freed, which will come in handy in migration code (at least in the transition phase). In the future we might want to warn on some page types. Instead of having an "allow list", let's rather wait until we know about once that should go on such a "disallow list". Reviewed-by: Zi Yan Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/page_alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 858bc17653af9..b825f224af01f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1380,6 +1380,10 @@ __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))) + /* Reset the page_type (which overlays _mapcount) */ + page->page_type =3D UINT_MAX; + if (is_check_pages_enabled()) { if (free_page_is_bad(page)) bad++; --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 DB2432F4317 for ; Fri, 4 Jul 2025 10:25:46 +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=1751624748; cv=none; b=pI+kIYZ7uZyFWbrwAec8wSiUZgG7owxrBhupbbVBMOr8dCfBTEAvUdVM8vSrAuZTxfVOqJb4rIS2i1gUfEgUkczYWp907CSZ4/OAUqQ7BhAaRBNhhursS1OpgYSoJJHUV9QzH1YY2IaCtBHNYk552w2HOXvM6kE3xLlHcKqTehM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624748; c=relaxed/simple; bh=ALxPszCmVcU8TjBy7B2t3BqkreYKMgNug+n8yrbc+Ng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gSMabOQgZAoU0ifV0z7gDsIh9C673zmK5940MMHE/aAg+3/QSkY7kX6ODmQWIA5oWjqDSrivAVc5wit0S0PF4VkULfaqnDwf2oi1BNz+MVp1G+z5VZODqYPgXxmpibb/zyiExcudhxcbxoUHxHzE4NtJJhlPWhCC1tKXXVwJ8Ac= 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=AkkQMC71; 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="AkkQMC71" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624746; 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=+4vricv2e71NWYYMzs8BIQr/CRgQSzBMTqlFovEI9fk=; b=AkkQMC715yGmSovBRIW3z6FKfftarha9NjRCKC96i1kcYfAzI/dwgiVPY4uuYoy4mKIdp0 uokh3MYkcSTj7o7q9s+Yv1EsrE/Iv4BVdSxXzddURdgpDiVspuRVN1kaG4K0ejz3zVAuIk IsdIHfNcK7UBcydtu+6h25UYOngKtVY= 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-12-hUTdnfJLOhWg_oCfGSiTng-1; Fri, 04 Jul 2025 06:25:45 -0400 X-MC-Unique: hUTdnfJLOhWg_oCfGSiTng-1 X-Mimecast-MFC-AGG-ID: hUTdnfJLOhWg_oCfGSiTng_1751624744 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a579058758so295568f8f.1 for ; Fri, 04 Jul 2025 03:25:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624744; x=1752229544; 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=+4vricv2e71NWYYMzs8BIQr/CRgQSzBMTqlFovEI9fk=; b=saACZ5EfHPub3jUimpZHbJC4tVL4j+oKgNtXVlqtZSQ0dGP0F5taal9eBJWY+lvlj+ z7WEhvuvzpNYFxQhQmho2n1yL4QC9prUORroq6JcK42CeGKZCGVeFO8ac0/4v6YP1MJ6 8gR5bX/IxLt76x8aceUldLDs2i5uBLZG7M+szSJLpRs+1XstV0h/PA6txV0YrCb+7xF6 aiz29OfbrAqkiQXb9ruzhtvoJceRDWqKKwFqjbyPB/VaPsONswgpK1/+VwmntrfecQWQ jw3FshC1t3ESw0nBwYz2DTzVu0cvmCEcW2wTqdfwH/QNT64VLscS+ocAsujTkUa6hGQ1 72lg== X-Gm-Message-State: AOJu0Yx+sJRKcVlN2lriPp+Wli40u6s8FneBuEm8ZEhtE2nxI0n8WcvB XhIEOuQh5FwPD4NyzNxZQWfN3sKWPEoi5u3F/RFbCFrXSh3GlRQcTmORT5BDXaHKhv6yzn1G0Cd UEKB+nf3tH19S6dSJ3q0mtp4VTH/Jp5yes3EDCk8ZXJlpoK5pOK1pwZ7LVlZmNpM2GTREprg0mj CfyDbYVKtKH6HIwNChXUJ0PkeNkqjvor39ieu/eY/fPrE2OQ== X-Gm-Gg: ASbGncumamXEkDYOeIyQI29+Lw8FVJz3Qb2ImDZAiOK/MSHFvEpJFpGVviXuxkEwdpa B0qyk0GB4v8qM1lnt1gSRSFlntEAlza3WeaIgV9eQsnzfaRjlyHMUrVEvSCk7bp2/cNmjKEQlN9 EPY75o4nwyjOtDXVIWg8nqYpzMnqXfNcNvb2AZfXVAhxyud8OxoxeFrgdzCoI1jLEQflc4M2Phr OYdNMRZU/CZiu2cJfpEMd0t+HLcsnt/83of1LBGUsGPKJF6TLCHiZaSNFhAH+YD3ZJhU1OpZWdk hlxwMFazNoS4y6NkT90hddkpwBDplHgU5iWGFf36klRX2o9vR1i6ss+oDu/XNXXVkReFvK5LYm2 LHTcyZA== X-Received: by 2002:a05:6000:25e7:b0:3a5:2d42:aa17 with SMTP id ffacd0b85a97d-3b4964ded13mr1424180f8f.31.1751624743622; Fri, 04 Jul 2025 03:25:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFw2GicaPInsB28PjQGll7qbBWs9+u0wQOGd0rdAKVxiB08VA9zODFfDmMz6Eob0+nsp252Q== X-Received: by 2002:a05:6000:25e7:b0:3a5:2d42:aa17 with SMTP id ffacd0b85a97d-3b4964ded13mr1424048f8f.31.1751624741867; Fri, 04 Jul 2025 03:25:41 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47225a2dcsm2114225f8f.71.2025.07.04.03.25.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 05/29] mm/balloon_compaction: make PageOffline sticky until the page is freed Date: Fri, 4 Jul 2025 12:24:59 +0200 Message-ID: <20250704102524.326966-6-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let the page freeing code handle clearing the page type. Being able to identify balloon pages until actually freed is a requirement for upcoming movable_ops migration changes. Acked-by: Zi Yan Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- 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 Tue Oct 7 22:50:53 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 CE05F2F4326 for ; Fri, 4 Jul 2025 10:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624750; cv=none; b=MpBc877lKSX5p0LvERgwyjlKaBI+ZXoi2WpWgKM7JQecfREYpG3Er0JGZQZB185nQirs5t+jukiJTajzn8FUFW93L0sN9VEm9jgok6n3k4xSAMVgK2gdb9eedHIpbAIYFxAjqtKr9lXlyhqHvMXNGfwwE8C2PvHnfEBQwECe+RU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624750; c=relaxed/simple; bh=Whhu182ZcZuvW8AFFhlkxBAnfsoxAKiodOBFvbw9Jf8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sqI5+pwhqftart53Sg9WjdQ6la05GYL9qE/MKUosn/q10cutkzSS4T4H6HVrYoA601bimQaj5i+EnvOyEHhfd8FonY6aOyYFq1y6eLg5twF6uwUfLfKTyey5SUDmiqpEdHsaEfnDFDZ6fpAvp/ESDTDfFTbOIcEDZjZBsQMuTFE= 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=UBwG5z79; 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="UBwG5z79" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624748; 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=ONGts7/hBJv/SI9LHH6S4PEHXTtUzsYSWsi4Xmz5Gpg=; b=UBwG5z79jDw9RHqJLbjcjKibjzWfLWZkErel6XOeyC29N/kZqVDY9Z4IukfFUfoc0rUnOU KuEwqGItF8EKrl5d7ZCYYBMj1GSgcYknKw7Esm52xH290blarmaBRla2CHAOBKNiBeGSX+ ZRAI3QyFBwj24rwkf+23CvtCAJ7Ko/E= 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-460-UEMG2VGiOQ2WtfXysDEXWA-1; Fri, 04 Jul 2025 06:25:46 -0400 X-MC-Unique: UEMG2VGiOQ2WtfXysDEXWA-1 X-Mimecast-MFC-AGG-ID: UEMG2VGiOQ2WtfXysDEXWA_1751624745 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4ff581df3so389273f8f.1 for ; Fri, 04 Jul 2025 03:25:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624745; x=1752229545; 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=ONGts7/hBJv/SI9LHH6S4PEHXTtUzsYSWsi4Xmz5Gpg=; b=ptNrZUZ4WiVH2XniLNWZFf62hNLNac11eZvY5V/JaV4VGe79id7pEJDwZUTPOkGSd+ fI06l9RbS5CesT2WFSJHcCbAsct8S7J9p5Mpu1KWAqRO5pWlABGijlKiUuo/mu2v4pnb L8UUPGmqoOQLaVnsdZ1IqmnuX08/FBFchGvGGSrRYi6xLZiE7/rcde0j3oDZpNbAPmAR U03o1VhSBBCF10m+6FMKtDWP67XRD2raLOflPBZX6SymSlu/ogKtSkvWhLDLHmbyXSmj ApJI99V4zu9B1Fqith50ilvbo3AzUCsxmJc9fUbnt1gE+LB9nQvA1Y2BON9Atxrt9Gke jd2g== X-Gm-Message-State: AOJu0Yw4+RvNlrsPfkxO/EqIl2MFn+pXGZ/kr7Q+K48SsCu8xTj8xZBg IXi6+AT7PjJeZZjcI4S7OGYvbI/lAMCCgWNFmphaiMStOmy5W2443esNzO44j+PsS4C+JBUp9P8 Nv6guhMwsSWT62cGKSzq2TqsF6P+nPdy9MEytO7oHtHFsChIZLKbRyXpnH3z1EcMykCg8+QAKt7 +I1wzeX8dX7N0cHc6rPeNyKWdLhX72eaGtjwawmMhN7xz8dQ== X-Gm-Gg: ASbGncvlVqrqALJ00PC35SejjRTqqcFBvVwyOg5NEsDCVeyYWp39ivqnI02iqTXdyAN sl6FIJ+DR3DwjufsQ+S+5T0IRRzfbEj42TC8cpGR4KvQZxigFhF767iCXzAuM4sIjtRb8MNubUR HG8lR/5xI6i1etTmNAVJ/2c0a0zEdX2oFrF3zI5BG2RiVpkpNZ+E/eNsCsb7QVOxdE2AihAnnB9 Aslge8qVrmdWL+I6Jh7UnnB9uyoxm41N+WnLvW5qbpBJrcsl5vca0YbLwEsK1Wiu1Pf+FVfNcm6 VJFaCoyHNAlfeDRIJ7bWuNOAevsdUOBa1T+IpudM5LDbSNERnJN4SDAM2h9A8CITSp8mh6Vgcei Vc8Zaag== X-Received: by 2002:a5d:5846:0:b0:3a5:7991:fd3 with SMTP id ffacd0b85a97d-3b495b94916mr2217884f8f.11.1751624745123; Fri, 04 Jul 2025 03:25:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECnxpY/j05u6/I6xCq4leYolGKDWTZ8k8uJQRmE44kdkts1pPfCbxB96EsSkR3GWRBi0mgpw== X-Received: by 2002:a5d:5846:0:b0:3a5:7991:fd3 with SMTP id ffacd0b85a97d-3b495b94916mr2217787f8f.11.1751624744465; Fri, 04 Jul 2025 03:25:44 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47030ba14sm2117357f8f.6.2025.07.04.03.25.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25:44 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 06/29] mm/zsmalloc: make PageZsmalloc() sticky until the page is freed Date: Fri, 4 Jul 2025 12:25:00 +0200 Message-ID: <20250704102524.326966-7-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let the page freeing code handle clearing the page type. Being able to identify balloon pages until actually freed is a requirement for upcoming movable_ops migration changes. Acked-by: Zi Yan Reviewed-by: Sergey Senozhatsky Acked-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/zpdesc.h | 5 ----- mm/zsmalloc.c | 4 ++-- 2 files changed, 2 insertions(+), 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..626f09fb27138 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -244,6 +244,7 @@ static inline void free_zpdesc(struct zpdesc *zpdesc) { struct page *page =3D zpdesc_page(zpdesc); =20 + /* PageZsmalloc is sticky until the page is freed to the buddy. */ __free_page(page); } =20 @@ -880,7 +881,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 +1056,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 Tue Oct 7 22:50:53 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 928502F4A09 for ; Fri, 4 Jul 2025 10:25:51 +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=1751624753; cv=none; b=el77a2OuhABZNpMxZ5TfCINTzM1Y+dxhCpL+lydiGTB3VA4ViYwIuGRf5N1c9t5yJas5+JWgc5635ZHp9FO1uf1j39HJBmZdy1seqhbNO5HvyoB4veaBS+3zBhu1ICF/QeSyal2J1SYc7lWKJNdIfjNV2YWjDEhXQJR4TJlN48c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624753; c=relaxed/simple; bh=7TUaaUyg2IzBDFvzKzP8aimVtjWSRKkvRG2kLM2JAsE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oWJZhE377ifgcqS0c12CKjMCFCvT+PIuOUDqVlUJ4plEyfoTzaBg8pLEQ0NguMV1xamJOTHBycdeRwIaXLEd0yLfmh0TwstNRTFQZltoWpAMGIA2+qHShISz2mldAFnG5+s1Ra4rXcjPhtNNXMSqOpaNLOL4ndvzJ4i29zV30BE= 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=PETP7Poa; 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="PETP7Poa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624750; 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=2hFW2iBTC0y3bbUq+s26fylaJsmqdGOzvykr6tgw4lA=; b=PETP7PoaerG7EkauzVfDDRSa1FjJWmtm7e99idQQO2mAdIHC0oeLSs98D0X2wFFVB2GEZT rp3LU+hOXphvsW//kXIkBFwIRAy3RuoFFW/Lum796JTRVolOhMBic8mTmucNtUAi4N+eLK ThHsUYVAg1KGseFDbgJw6A7JexTKxmk= 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-578-lc8GVaY0NB-1ihwd8pNwkA-1; Fri, 04 Jul 2025 06:25:49 -0400 X-MC-Unique: lc8GVaY0NB-1ihwd8pNwkA-1 X-Mimecast-MFC-AGG-ID: lc8GVaY0NB-1ihwd8pNwkA_1751624748 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43e9b0fd00cso4597575e9.0 for ; Fri, 04 Jul 2025 03:25:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624748; x=1752229548; 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=2hFW2iBTC0y3bbUq+s26fylaJsmqdGOzvykr6tgw4lA=; b=bblzKhwhVXHilK2SCnQee9IEJlXohBDMVUJW0E6BcEQU4//lj1zG5b+bOlT0egCs9V kbJe0xnLOzaft4slJ5t2RZNRi7JnFYV0YIb30sEf39l7TjLvwTNzQHb3/rPGEFIXFg85 wSCGFu+FFf33yhhZHmACtp06x3DHRmRHwfjygVSwdqUChDjHrsF/9C9Psq2GHr/+rLxw Ew7/pxPUdH/B3FlF3AT+KX+n5MJbAtue4yXMcplE4/59Wj+w5/UQFBu+PuJOCWi39M9q 5CIx0RnnWMigcNtNa5VIQSA13ZKwG7gMDkekUeBDnWbtCuNAXvI1GrIoEin8+9QpD2rV EeNw== X-Gm-Message-State: AOJu0YyRJSTHgv/gmITMPObqUKrQlIV8r6rV07qmOpI6JiU28Q8eDFBk hC7MwV9HATZygfABUbdsm4603hYHu7YxxzV3qShCWxRByqlaQ1OFvqPkr02KX4xPQkN4ZrAW1AX +W7wKVpdAcFNepF6TjbuWm7bCDX0VJJqrDODGIcYApaBJ8Tuioh2+4YslX91FiT7SLxVvXp2Vid S8p0Y9K7Kgi75zCduw2k4b7xTcuE9PEvcb1lFsIV7MaI5PQg== X-Gm-Gg: ASbGncvQDk5X3sLDipYcHPF60y1AleGBIbepEvWLUPftQd/L96cXiCb2rh9FJyVrhXU OL/R/nBe/QqJuiZ4J3IwY89VbmkSiIjnPVzb0pazHbSHH1TDJURpn9khBIaagppl8vMVY3zw5PJ RcwbtvmbHVWsTPY/GKw9lOgFjtF5UEutqhsP2tSe7R+suKWMnSIWj4CDvPCr3Sunj0IZTV4HF1t 9ej+YaHhgbFm8WiqHOXBR2v2XYKmCPp5ZcQkKJyv8RxKYyyHKRrrgY6ugZNHEgnECWnrCCYYoq8 Hz1e3mU8PhgzNjpIlN7hbyJHx3o7JfAE5YFsg/76Y4NvO28EcBE/vni5Hs0hK0Lxk7MsUvhoYMs Wu67QLw== X-Received: by 2002:a05:600c:4fc9:b0:439:4b23:9e8e with SMTP id 5b1f17b1804b1-454b3ab874dmr19033105e9.3.1751624748305; Fri, 04 Jul 2025 03:25:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYcpd9SFcoaWfQeqRe14xBG83tSrWUHlht+bCd9eNO7YiXJuE62xvkx/e2Wc1s4dDi7NCxDg== X-Received: by 2002:a05:600c:4fc9:b0:439:4b23:9e8e with SMTP id 5b1f17b1804b1-454b3ab874dmr19032085e9.3.1751624747587; Fri, 04 Jul 2025 03:25:47 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a9bcef22sm52038125e9.19.2025.07.04.03.25.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25:46 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 07/29] mm/migrate: rename isolate_movable_page() to isolate_movable_ops_page() Date: Fri, 4 Jul 2025 12:25:01 +0200 Message-ID: <20250704102524.326966-8-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ... and start moving back to per-page things that will absolutely not be folio things in the future. Add documentation and a comment that the remaining folio stuff (lock, refcount) will have to be reworked as well. While at it, convert the VM_BUG_ON() into a WARN_ON_ONCE() and handle it gracefully (relevant with further changes), and convert a WARN_ON_ONCE() into a VM_WARN_ON_ONCE_PAGE(). Note that we will leave anything that needs a rework (lock, refcount, ->lru) to be using folios for now: that perfectly highlights the problematic bits. Reviewed-by: Zi Yan Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- 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 208d2d4a2f8d4..2e648d75248e4 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 Tue Oct 7 22:50:53 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 CD40F2F430D for ; Fri, 4 Jul 2025 10:25:54 +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=1751624756; cv=none; b=l9f6B0FTGWpsHJ1bIqT4rLSV/ztrmZK7q/1/33na0pY0o1BiW5tGIua7uYieetb0tWw69jyWpVgFvK0n65oU2ZimUOWT5lwrCsOxts/pDDLM5V39HP/7ByuiHo+jQ5+2ilbLXpap5fZUMOJSncbmCfG7voHira9IGrqYEFCEpt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624756; c=relaxed/simple; bh=cpXSWX6aTPOh+pmlPrRH6DoAXsk2bYocWaGA0TOO5Uw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nr7DyO9kC3oXxZZPODhFAVSdiun3Cma87p4Mx1Kra7eOSoTSIG7inHSjQnT0T1vCZH1rBTZFIKH6klElmqr7xryF5h42rVrgB0nLirDeXKRVpm8zpsmPLW6CVXew3c1wBC7ukO9Bx5x/hzPO+myjGVasThiqpJUMPeYSZM0lY28= 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=Xt8up5Ay; 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="Xt8up5Ay" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624754; 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=OVyour2UNFNS7aNaSR0hE5hzdL3B1bhwCvX/GUFQiSw=; b=Xt8up5AySavAvEx9qxpOwNV+rjLcRshFO/bPhWiittVu6T+GKAft0tNbaeQbj+nK2IJ2nW zsMOcs0fUd6lLaKiXBR6aQ7qmeDYHPSmg13HTsSCT+cmoukZNXrCT/sF1HODYn4QhAi4MO Z1vvwfj8EMAIQ5P90QxyuBF4E4BB9L0= 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-662-9XoVg4YoMqywyTLL30oBUA-1; Fri, 04 Jul 2025 06:25:53 -0400 X-MC-Unique: 9XoVg4YoMqywyTLL30oBUA-1 X-Mimecast-MFC-AGG-ID: 9XoVg4YoMqywyTLL30oBUA_1751624752 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-454acc74f22so5102755e9.2 for ; Fri, 04 Jul 2025 03:25:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624752; x=1752229552; 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=OVyour2UNFNS7aNaSR0hE5hzdL3B1bhwCvX/GUFQiSw=; b=SjaaNqOI/UzZapZUU/oUS76aMWuMHEzwXD+NhQ7vWwm+/0m4MphTAvlQLisre8y8SG ejcbIc+i4geC1nAUXFCMpV0+qpcr7XwE5g+5xGDidAzZYrs4nq21OnDTdl4uTrp7a9br o0cycPaR/vBpNHDuimuJTMV80cI/0dnhCObk1qOjNBW5EgyVfmNkK5cY9YER2Bs8ZzM1 4U48hnCOqDo9kN48bvshxPNJPRJ/v4sYYg8YXlFN+Er85jk7j8nGH7JEpPD5uMx60wd2 R8+bV1raFTwddhVuUs3i4wb16aqxj9w0fpNSgzuqHRPiABZ81OkXf2+tB/UegAf9R3Bz H1/g== X-Gm-Message-State: AOJu0YwVRCMn/38R4+1YIKG9ToeqUSdH6sUAQPg71HcviA/g3oqqtBYr ekptqEBs3BHAhGie1j+ZDmbg1kRdqslSbVAyxNDvkmTBKUwRMuDoc8yXwPuv6n4haHA7yjzwfG6 Xex5Py6KzRaupiLy0e4BY0xUqA/gudrfwFPHp0oWOn6J32j5SJ2ee1GwMuTaGn6wKdhX/jWYYEp IcK6hkmYdFNJFQQJM/G1chT5fTCHdV0oj51Y7Zcz+6TZHLug== X-Gm-Gg: ASbGncs/ckTP6163hFhh9BGlJdbvQNzLdQbkMBuRNsZH0xezXcb4e1sBEFp5C6Lm2lS d1JyevR/V6AG/ljAGmpfJEM3GS8K3FaH7lnwMuunipBXJhYpIpP32enugnjeUl3iFaJYUl7/DhK DKQm/t8ISiD0m+V85rxXgWmpfBNXp/k6qdc7jK5WP8wyo5Hfs6T4aBX+9uSyweCTbtRCDuvRT/7 +teGKlKfztIbxmIOcFHE1f+ZLXv9O1zzj7Jp4TnZcgACw6kfZBuGCnUQ9s+R5+h1kRK4pT2RgGp jmHIWqQZ2mvLngmPnbmW1F7YLYiNA+iqDpHCoXCv4R5w+fycXrkrj3s2HDcAAERtQnuH2IQxgr5 V8AvGwA== X-Received: by 2002:a05:600c:4f07:b0:43b:cc42:c54f with SMTP id 5b1f17b1804b1-454b835631bmr1456435e9.14.1751624751730; Fri, 04 Jul 2025 03:25:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2Rez8KVGPQFiDbU29hzAgNjBI7xFdtw4twkMv/+PHLeFt8+nZnPGBAy1buVfR9Z9nLRQVCg== X-Received: by 2002:a05:600c:4f07:b0:43b:cc42:c54f with SMTP id 5b1f17b1804b1-454b835631bmr1455215e9.14.1751624750855; Fri, 04 Jul 2025 03:25:50 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454b1634b0fsm22804075e9.17.2025.07.04.03.25.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25:49 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 08/29] mm/migrate: rename putback_movable_folio() to putback_movable_ops_page() Date: Fri, 4 Jul 2025 12:25:02 +0200 Message-ID: <20250704102524.326966-9-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ... 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(). Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Reviewed-by: Zi Yan Signed-off-by: David Hildenbrand --- mm/migrate.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 2e648d75248e4..c3cd66b05fe2f 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 Tue Oct 7 22:50:53 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 C757B2F5328 for ; Fri, 4 Jul 2025 10:25: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=1751624760; cv=none; b=Auy6uXosspOOlBHNAjnLoGAk9FpNzIXCb1wKN6tRlYCd0A5AAjiWEdwlNSks2Xqw6iEuNKSkSIO43U4Xdy5w/79j4HKoK1nRMn9BMzDHEcnTZgpm+bW0fukiPrPAEbCgCJm42W93BTczlLYxB3KrmnxVBxUvbetC6UuuccpQ8Is= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624760; c=relaxed/simple; bh=H2phfaA1UHj2m35/TopTQ1tPJK7fzhUyx1mWAfz2IOM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C9TuOErKqgPsqoGMt/jvrBJHA6Fuoe8Hh/0BdBw5LQ9uyac0JXTU5NcNllxvXNv6rglVYpP6Y6u81XNwY8B2hh4yWrf+ugWle9HnyO5wV214KHyUhDVaRsEklenFJX5O5qBK+2zqfD2Q0phDnHmDdc5nYo/AtcHKIPsxqsV+FPY= 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=ifM7RPDB; 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="ifM7RPDB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624757; 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=QfBSPQaG9xeZudkGcFWJAgBBxYLZuNBkDrffE/+eDPg=; b=ifM7RPDBHUqmYPBoCYBP+qxzKw0Okj9DLWBCPkDyio7UNceVRClepPCRMUWrJ+LjVrfYn+ EbBZ8r9sUhTI9rudMb5GjUpFwQOF4ClcDDvOGNFEmlfR+OhxogA3I+MTz17Amxxye9txLV orQ5cOo9y0l8g/29O5umP4sMXwHcu0o= 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-536-OiFbqQ8uMBOUyRPRz8Uf3g-1; Fri, 04 Jul 2025 06:25:56 -0400 X-MC-Unique: OiFbqQ8uMBOUyRPRz8Uf3g-1 X-Mimecast-MFC-AGG-ID: OiFbqQ8uMBOUyRPRz8Uf3g_1751624755 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-451d2037f1eso4655535e9.0 for ; Fri, 04 Jul 2025 03:25:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624755; x=1752229555; 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=QfBSPQaG9xeZudkGcFWJAgBBxYLZuNBkDrffE/+eDPg=; b=I0pSiZGj1ysUF62bgFpmtqIrd8l6hYRQJ99yzY3vn9n5ObDgT0YfC2fJpJWMXs2wzG VhgS3ZjJwgwYiRNgyzWtGvtZWjCoqQb1AwSparAfnAjGQB2037+MJoE5xL+lYacK3u3q J1EVLwm7FCVtkQCXQZ2tJjMaTEmAsI9s2mZDZ43vsgdwghXWPRdJQ7xucGpw3FYHvB+C PoglPZCJJFyosOdhokQeUrVXG1oAo75DXV/ehLlMDUwnXT0Q3tV0l39YpyyYM/Pq+XOT JZC1mK/vfKWiGFkKjBbMHvhvsWv1IaN6jE+pNHX6HfDn66eQZMElSix+RTyF3Shf8Ii1 VOZw== X-Gm-Message-State: AOJu0YzJv+FGRxTWc6TSMPOYV3EbmWB48hvRyI0jbEWTlLY/z7NpJiHa KE7hGlwkVdo48AIBTbCE9yrkHXd2wVik3svm+WW+23Lf/HR4Q+HApgODy1DeaimtFtqssr9MNY4 TRc4JgTaLdR0gJWb+3nOYhJC3u0f88Pb0EBux4Z3hqTPNscv2jAQMmWl/NdPx6/POZQ7+U6raS1 5JjCRF4au0FCn+fgkoU2tykLCgpeRwQEqWlCY6p6dNs2EJTA== X-Gm-Gg: ASbGncs09UN5vTmq1D/Y1gjbHcKRvnwPe9RLvnI0H519OXeaGXHiQwNanE5IjzZDluL 6CCc+e8mLgLj8CI+1ofjyIiXko0elZPNbM8zofqBkoKqRUdUwMosBRpX+m3pKEoizs6MdrLaydL T6DcF81bp5zGtATjys7vOz62mPt18WuxWZLZsW76wZLFC7SKibT6iehMSDz2b/JhYSOfh8sr9fX NNYmj+OFcHO9Lr0jJbvzMU3gvNhrG0g9+eoQqnK+AjNKyG3qdn1zfx2msGBx1VLGMkZRAjvlxC2 Vgjt9mTH0aKcKSSQ29aiLoO357pDldDhCm78YOJvfyUwREGLhuweuM1i4fgLKW7uoNR6HPAOOhS t/OylCw== X-Received: by 2002:a05:6000:2312:b0:3a4:e54c:adf2 with SMTP id ffacd0b85a97d-3b497011964mr1275761f8f.5.1751624754924; Fri, 04 Jul 2025 03:25:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfrhXd/yIZyYpWVcak9U+vZiPIE1G2M2XMax2kqYgfF02lLZKKCminarbrdx4X4RqYGyvSNg== X-Received: by 2002:a05:6000:2312:b0:3a4:e54c:adf2 with SMTP id ffacd0b85a97d-3b497011964mr1275679f8f.5.1751624754226; Fri, 04 Jul 2025 03:25:54 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47285e241sm2143549f8f.94.2025.07.04.03.25.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 09/29] mm/migrate: factor out movable_ops page handling into migrate_movable_ops_page() Date: Fri, 4 Jul 2025 12:25:03 +0200 Message-ID: <20250704102524.326966-10-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's factor it out, simplifying the calling code. Before this change, we would have called flush_dcache_folio() also on movable_ops pages. As documented in Documentation/core-api/cachetlb.rst: "This routine need only be called for page cache pages which can potentially ever be mapped into the address space of a user process." So don't do it for movable_ops pages. If there would ever be such a movable_ops page user, it should do the flushing itself after performing the copy. Note that we can now change folio_mapping_flags() to folio_test_anon() to make it clearer, because movable_ops pages will never take that path. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes 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 c3cd66b05fe2f..d66d0776036c3 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 Tue Oct 7 22:50:53 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 F42322F533F for ; Fri, 4 Jul 2025 10:26:00 +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=1751624762; cv=none; b=bRJ5gnPhnhMxDo58EOXehBv1vNeoik8xiut4FcGovHHrF5iZpiWz5dXFrt6Xdkjl+mjCuAi2uWMGDRI7qGo4yJr8BMAbJ2JsyblwzoX4qXWJt7RivXslajBglIr7sajZlvWwUmMA5iMtxiFY3eWo9N6bpgweolOKzjRGn8i59Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624762; c=relaxed/simple; bh=Wr+Kn1AL8lzxIZAskivxC/G+Yen/YkPljMI4x8om+J8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SF/rrAno51KCzG5S2hkjDlY64sL3lTx2wKFE9vFkbl3NWmeOtXnYWMQlEeO9XI7taJ/rbI3u4pWW5dVx0HJvosHAmAXt2k/SK9RWT3NsaPL7QLJf/OHJVIT5OWF7DJX4C0VG7QqexHKVtBSOXzjxiG7hFnzE0mm7j/wS7LagHWw= 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=gz7pRfUu; 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="gz7pRfUu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624759; 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=YZJ0pN+qk8np2TVjDZumvdXYQEUJdQ541mKybIkqdFY=; b=gz7pRfUudMau/EDR1GDfJiwnKBy8+IPwj9325vhC5MLE1wnFjCB+9dxa/XOKlKX8CNo7ki 4N+0MGrO147BluQkXVWpOtb7wNFtvsQnTWtiDOKUN7VQFOOiNwisgfwnCsGo9s3vYWWaTN 0FIjljEIPYDDkrU7DSLd04dUYX+Uxzw= 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-586-ETBGd-MeOw6GXsTBvbUL5w-1; Fri, 04 Jul 2025 06:25:59 -0400 X-MC-Unique: ETBGd-MeOw6GXsTBvbUL5w-1 X-Mimecast-MFC-AGG-ID: ETBGd-MeOw6GXsTBvbUL5w_1751624758 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4eb6fcd88so475429f8f.1 for ; Fri, 04 Jul 2025 03:25:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624757; x=1752229557; 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=YZJ0pN+qk8np2TVjDZumvdXYQEUJdQ541mKybIkqdFY=; b=QgANQkweE2zZlJAdvcSD8zc4mshUPoN2CBqFI8iZ6YHvmM/UNK1O1oVKr1mXu6/kHP r9U1NuZe04nOb1/FaaKFCec+AK/JOfgNUjj1RjTMpwqZzu6GbCFsq3JbuAwVF85NYvhd bdVAVolQtyqsHQyTXBPOW/1c//NcOenGUgeut4zELxNxM92G0s4pm1kmCouvIph0BdfE QPvVcmCi13U6CB86P474o+XSHvJl5UfwV234UMh9awntK+nBc/oTTQJ2BwRTwf8drGqF 6pVkUe11o12G5vHiLZfKW1Golx6XY6hX5FjkEhgXH7uBxSwjPCtH3bEVZyZrsDSNj3F1 5rog== X-Gm-Message-State: AOJu0Yw2I25AY88z0y3mJX4X2YVpte86EThhzAdj146HYlqi+rsbubvd xAwkwWaXO9hs7s+XfmdDhninDHWLCDlsts65MSXN0PdIw/Xb44ir9FhPhOcyzlXNe+nfP6GbfrX Gzhna/f/XbDOCikV4vn2DbOrYlWYtXxhPaInHS6lkDVwQxSimbfqtNQqenjlQ/+YrypeBe/AFG5 oBL5vaFvVVxNp8zUAFvuZwo9jVxS7JzZ24EpymV11lzMI6jw== X-Gm-Gg: ASbGncvZlggpFfaqeheugk2sqKTcjfYXkY9dOw2WgKhmGLdt7c6OTpDmukbQ/58205K H2oHK+Rp0/WuCgHcK64ve2kAfY8j+rR5LmZR7yjPCJulbJ/GVGCyUZwESSRloqol91kwMbSRQAz S1XX5bAjJQel0eeAyrgGsfKvfDskvhcV7Kutv6EvawFrhKnTvV4Oj75pIZh+rCHSH0NSakasKZi 5HCxzdbl+il1LQkYFTZZJbJASuC4WtkynKGtEMsdZSW6tQVjjh5FbPQj+mgRIrue9L9nxvmxBSr iHmtXYeT7T6UG1Brkgam54hUrS0zNDStU+SwrPkhx9WLi29GX3HYhGbWdP5ewLjYu0wZnI5XsH1 xB/6juQ== X-Received: by 2002:a05:6000:40e0:b0:3a5:26fd:d450 with SMTP id ffacd0b85a97d-3b49702e8bbmr1184033f8f.47.1751624757593; Fri, 04 Jul 2025 03:25:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjTF6Bi5YHLD4LeEN00n0rlH4Rvb7Qu4SkJgVJFS3bHVyzx6sYZQQ7vAELvz5hrZ++LyEv3g== X-Received: by 2002:a05:6000:40e0:b0:3a5:26fd:d450 with SMTP id ffacd0b85a97d-3b49702e8bbmr1183969f8f.47.1751624757061; Fri, 04 Jul 2025 03:25:57 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b4708d0fdfsm2172535f8f.32.2025.07.04.03.25.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 10/29] mm/migrate: remove folio_test_movable() and folio_movable_ops() Date: Fri, 4 Jul 2025 12:25:04 +0200 Message-ID: <20250704102524.326966-11-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Folios will have nothing to do with movable_ops page migration. These functions are now unused, so let's remove them. Note that __folio_test_movable() and friends will be removed separately next, after more rework. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 Tue Oct 7 22:50:53 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 2BFF32F549E for ; Fri, 4 Jul 2025 10:26:03 +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=1751624765; cv=none; b=HpFBN5T8pTRP9t3gIDO9HcTL92ZstdvsS4m49qC2SfAEOEm34hL50w4b1eU0QyBbjNbSZ3AQGLKMYA7eK2wceAFX/SN9puQot9Y9sMZv3LghHbOiuo3J/CTjuBqRVycGWHjMXiLecLW01MUIMggnMDqa7+7+F5KpnzpI7yvvVxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624765; c=relaxed/simple; bh=swel6heCLe+a58/SBtwcEbCcsdg+XKI9KJ3bEmmRbuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWgexzHBU+JbOgvbbTGBASF78nZQKK/d1h5rSJPb5WCt3Rh6QzYz6DqO/ituXxuB8OYlTv+BZ8PjpwgMwnfFTqRxFw5Bl/2rRo1HCg2UuFX9v4+aybua/vDtAz7uN4gkifck0+GEyoQ6DbSdonEFKTCzZeOh47RawWXkFCEzR9g= 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=SJexMRUk; 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="SJexMRUk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624763; 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=bNuyprjgbIdX6AHgfTXgzVcFKi/kDd27yjboz7bS+HY=; b=SJexMRUk6ak4CBfV8ZRzo+1L5DFrWhjAOkRsTovCFg8GBjA93gA18ft79tM/ve5ISyM8SP d4OWeqDMuiKcCoOEYpIauktS38kMsSsa5t5c5VydcGBnikASbnWfcWrXH0WDLlhi9G86mE I4/UWKgsGks35MQ2nUqLww7bWfnlK44= 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-104-SSrmQ7wXOsy4Hh7XttyKjQ-1; Fri, 04 Jul 2025 06:26:02 -0400 X-MC-Unique: SSrmQ7wXOsy4Hh7XttyKjQ-1 X-Mimecast-MFC-AGG-ID: SSrmQ7wXOsy4Hh7XttyKjQ_1751624761 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4539b44e7b1so5193205e9.1 for ; Fri, 04 Jul 2025 03:26:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624761; x=1752229561; 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=bNuyprjgbIdX6AHgfTXgzVcFKi/kDd27yjboz7bS+HY=; b=Zbo2+V7s+kKo7lhjFomrS+k5nSBav0PjGX7PkHBnvlyEIRkzewea2f1K/kwZeZqy+1 Se09WsZM3da4KSlGHpzLHFU8G0ge12dpqpGhBWv36u4l6e5K/G22lQkQt/oRKBxth3XZ /3jqrnr/9AEYQyEuNb6K5tqquEVdEBYamBucNd0x4Gzn6wpXbNRBw6+/fmrhsvS6jW2a MdnbNVP+LlabHgj+QSw5aGTADXPKa9TM/2LVYiciv4FM8WLCd4w+LiiHhEpxTxRRDUnk R8St7qy4Hr5f2x8S1UAVU9uen9Z02lbKWj0hCbRED4zbffrXV3I1AwMnOTPjeGtnLLD8 I4xQ== X-Gm-Message-State: AOJu0Yw9bF9ZG6yAedEFPiYwnIMLIGPA77i+7Dub6HPSeeob+/oWygLG e1s80SyzbRv7EgMTpJN3srVkINrUdopIEJGCrIJf/F+X038PMMozfj7hOhvfnU1y+XYpE+yxRGC DHuy4Oi2YghqFsnLS+HlJ2vlt08Ef0eaH1d3/EYC3itDDEj0lvY6KpZeAv1sZfUEkpJ8Xg3Iy1r qOXfzWr13Lc6hNeK+hIUKSDLezH2YsAk0piPTKAgDDWCZloQ== X-Gm-Gg: ASbGncvW2EfbffxswCdNfjKlFEo+z/tKX2/9TPfFG9vgwLckYZmRZGo3DkNMBJgs64W JkVUoDU6K7GwMKcw6tyAGS67voAmJqZfDK5ZA8DXiWHeyAtfbh/F39LmTFrmynNM64Xv18af4sZ sbUvrP134/gd4V9Hn/ZhoPVPt30eMExc+CnNDIqt7PJiqiUIgpIjuWl8HVUeO6TIlC/p4d+OuIY lU9kTaoF1qijX3NdoLwjF0IFuXtESMrZSZGLC80BwKm5eary9l5FIjCrRsAGTjBQOU+Q5mSviOx Zkg54lPTxzwNBiCa/5XaowcT/Z+F2FeH7CGoYNB2wKezGw7oPARXdsl3SIGkRR45VkpscuxwtMv Fsh+9yA== X-Received: by 2002:a05:600c:8214:b0:450:d568:909b with SMTP id 5b1f17b1804b1-454b4e74957mr16128155e9.14.1751624760674; Fri, 04 Jul 2025 03:26:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8vCOgrvNVf6Wu0EKSuY1xmeHKjerawOF5tOLzHfBQzCNUvjojZFchXxtXOEn9U9CGQYVIhQ== X-Received: by 2002:a05:600c:8214:b0:450:d568:909b with SMTP id 5b1f17b1804b1-454b4e74957mr16127045e9.14.1751624759877; Fri, 04 Jul 2025 03:25:59 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47030bd42sm2093511f8f.5.2025.07.04.03.25.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:25: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 v2 11/29] mm/migrate: move movable_ops page handling out of move_to_new_folio() Date: Fri, 4 Jul 2025 12:25:05 +0200 Message-ID: <20250704102524.326966-12-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's move that handling directly into migrate_folio_move(), so we can simplify move_to_new_folio(). While at it, fixup the documentation a bit. Note that unmap_and_move_huge_page() does not care, because it only deals with actual folios. (we only support migration of individual movable_ops pages) Reviewed-by: Zi Yan Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- mm/migrate.c | 63 +++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index d66d0776036c3..9a63bd338d30b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1024,11 +1024,12 @@ static int fallback_migrate_folio(struct address_sp= ace *mapping, } =20 /* - * Move a page to a newly allocated page - * The page is locked and all ptes have been successfully removed. + * Move a src folio to a newly allocated dst folio. * - * The new page will have replaced the old page if this function - * is successful. + * The src and dst folios are locked and the src folios was unmapped from + * the page tables. + * + * On success, the src folio was replaced by the dst folio. * * Return value: * < 0 - error code @@ -1037,34 +1038,30 @@ static int fallback_migrate_folio(struct address_sp= ace *mapping, static int move_to_new_folio(struct folio *dst, struct folio *src, enum migrate_mode mode) { + struct address_space *mapping =3D folio_mapping(src); int rc =3D -EAGAIN; - bool is_lru =3D !__folio_test_movable(src); =20 VM_BUG_ON_FOLIO(!folio_test_locked(src), src); VM_BUG_ON_FOLIO(!folio_test_locked(dst), dst); =20 - if (likely(is_lru)) { - struct address_space *mapping =3D folio_mapping(src); - - if (!mapping) - rc =3D migrate_folio(mapping, dst, src, mode); - else if (mapping_inaccessible(mapping)) - rc =3D -EOPNOTSUPP; - else if (mapping->a_ops->migrate_folio) - /* - * Most folios have a mapping and most filesystems - * provide a migrate_folio callback. Anonymous folios - * are part of swap space which also has its own - * migrate_folio callback. This is the most common path - * for page migration. - */ - rc =3D mapping->a_ops->migrate_folio(mapping, dst, src, - mode); - else - rc =3D fallback_migrate_folio(mapping, dst, src, mode); + if (!mapping) + rc =3D migrate_folio(mapping, dst, src, mode); + else if (mapping_inaccessible(mapping)) + rc =3D -EOPNOTSUPP; + else if (mapping->a_ops->migrate_folio) + /* + * Most folios have a mapping and most filesystems + * provide a migrate_folio callback. Anonymous folios + * are part of swap space which also has its own + * migrate_folio callback. This is the most common path + * for page migration. + */ + rc =3D mapping->a_ops->migrate_folio(mapping, dst, src, + mode); + else + rc =3D fallback_migrate_folio(mapping, dst, src, mode); =20 - if (rc !=3D MIGRATEPAGE_SUCCESS) - goto out; + if (rc =3D=3D MIGRATEPAGE_SUCCESS) { /* * For pagecache folios, src->mapping must be cleared before src * is freed. Anonymous folios must stay anonymous until freed. @@ -1074,10 +1071,7 @@ static int move_to_new_folio(struct folio *dst, stru= ct folio *src, =20 if (likely(!folio_is_zone_device(dst))) flush_dcache_folio(dst); - } else { - rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); } -out: return rc; } =20 @@ -1328,20 +1322,23 @@ static int migrate_folio_move(free_folio_t put_new_= folio, unsigned long private, int rc; int old_page_state =3D 0; struct anon_vma *anon_vma =3D NULL; - bool is_lru =3D !__folio_test_movable(src); struct list_head *prev; =20 __migrate_folio_extract(dst, &old_page_state, &anon_vma); prev =3D dst->lru.prev; list_del(&dst->lru); =20 + if (unlikely(__folio_test_movable(src))) { + rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); + if (rc) + goto out; + goto out_unlock_both; + } + rc =3D move_to_new_folio(dst, src, mode); if (rc) goto out; =20 - if (unlikely(!is_lru)) - goto out_unlock_both; - /* * When successful, push dst to LRU immediately: so that if it * turns out to be an mlocked page, remove_migration_ptes() will --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 E79F42F5C31 for ; Fri, 4 Jul 2025 10:26:06 +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=1751624768; cv=none; b=QeN9rB5DD8M2cisYeghxKsFTFxOhzRbMrRyrc5/c2CbfEVJTpnE/5F+B5vvEJ+OhEi8ccQ911t1i5B67mosdc3e2BX8S/fnc1btZ55XYpnPMo62EiNvtFkDY+iqzV3cICtbS4g71A9y+v8/hvV7Ef3paCRGd/Xp0QlkrpIKYaaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624768; c=relaxed/simple; bh=CJvf72yESzg/zFJwrDYpnMTY8h01EO1RxbRXdSXev+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dR4078M71wYnW61FY2VASBR7eIOqcTXlCCLpPwUpwqLi8TOwqtkHVKmmPWjz5Wp8nwrLlKf2girJL0r+lqiDHWEXK8YCClxvN97KZiCNPAuULOcks1G7VF/f0iAuAAtfe2JHEsh0jHH2xPdG6w8nWNhspDX5sD80q5ryyHAn9yc= 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=V2cJwc9X; 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="V2cJwc9X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624766; 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=eEGwdfNaBPNS/8dJw0FmIxAN0KCCoCPylWzGW8IBtSE=; b=V2cJwc9Xu6FIzJNGADWcqCOCiPrUcmWIuDo3Lnpt0r+V3/dkJzrapsKZMtfLgaYKWHMOMY mG0rrOIYtFOgF0S8lHmqB5wHOFLVfXrzKzOQG+95lkLF8z/dCGUYqoP/8ht4g1ZgRfbEqC hoimNjYlORY2MADccJG8uugAvNIr9vg= 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-502-UXHxKK1PMp-84qQy9jYUsw-1; Fri, 04 Jul 2025 06:26:04 -0400 X-MC-Unique: UXHxKK1PMp-84qQy9jYUsw-1 X-Mimecast-MFC-AGG-ID: UXHxKK1PMp-84qQy9jYUsw_1751624764 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-450eaae2934so6578355e9.2 for ; Fri, 04 Jul 2025 03:26:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624764; x=1752229564; 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=eEGwdfNaBPNS/8dJw0FmIxAN0KCCoCPylWzGW8IBtSE=; b=WTf001Z2DkPbpDDml5RFPVbUZkY9e1Y8JuLLQFkBi6WTEkg9Wc4VDsKL08KREfFdUx Te5kJohHjlKT+k1QigT/YY3+O5/l8vsZhrc/3vbKkeQVIR/snqK4FYHEooMh0UoJ4YxQ lTfQVBeUAMzSk9CPcFPAJAX45FAU3KmiY/kZN69cIqQ9qUR9iduudvPqCQE6ShWrWXL7 QbrwWXY+hsyvwDE0RMcdlq95eOJQeJy0caoqFc1vGADncsj9uJnNDj9vTh3ctFiBjNOZ v594lbo9Tsn0BEiq1FXIw+tbIlbuOsx4BzmRliivVjSiyco658p7+sbVBQMpFZoUcVDP o5fg== X-Gm-Message-State: AOJu0YzugkcwvXUHmqL26HPoXyF8Ba5OMRDCtN43FuTQxzfwV6oK2RyB yNKkjZ2Y13xFrE39pHkYEzBYoBuNfMSYHqrYW3RhGYpwIjzkXffHWvag/9KYTVgJ/dDgOzkU7mW PfRJz/XOaeEx0vgKglROLGI4xU0KOyO6d2AxJq3Xu7VQxcXA9WE+OKOLBvSwxudrI1F7HE6Nt9k IynRpKn3RnIzABVU4cu9/atCULMVow3azWD2akaG17/+/YqA== X-Gm-Gg: ASbGnctwlp3HD/vNotBJkf6EgVLR5cH4KPMyoQ1dvwDYqnzqUkszN5bzcCKlK6/GL3O aDpFm9TfmSDlu+wPMjle47rQw9yd7eMhOiJ/Q196cVFn/X2hMevmiW4P57TSPm6ShBxVzbOnYkc /7QKG3AH0Fz00HxmmHhujyGEHQNYcpRaWqkLOUPACWcD1EU2c4GO32tmDqS5I9VKhnoEKGEeUtn hO2bHK7goyUe5bvO/FBLoLILrOCJYV8BejSkaCabCT5rjYnqDTF7BEllOVh5E9bqa0bSUpZXQbt BftjUIWOowGoKyWeMZojqkRgERyXTukcbO1jtW1nTX23brpBuUL3pJDQSlr4kusrjfWguY0DVhS HtfqlWA== X-Received: by 2002:a05:600c:6488:b0:441:d437:e3b8 with SMTP id 5b1f17b1804b1-454b30fd93dmr18455265e9.23.1751624763487; Fri, 04 Jul 2025 03:26:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaIuaoI26pT9FgBV1ege1h6FCnLUNFU1vB3jXtS4mgBNx0jG0s+pACxWtozwax9rYlgVZB5g== X-Received: by 2002:a05:600c:6488:b0:441:d437:e3b8 with SMTP id 5b1f17b1804b1-454b30fd93dmr18454285e9.23.1751624762724; Fri, 04 Jul 2025 03:26:02 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a9bde3b9sm52654415e9.28.2025.07.04.03.26.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 12/29] mm/zsmalloc: stop using __ClearPageMovable() Date: Fri, 4 Jul 2025 12:25:06 +0200 Message-ID: <20250704102524.326966-13-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand Reviewed-by: Sergey Senozhatsky --- mm/zsmalloc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 626f09fb27138..b12250e219bb7 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -877,7 +877,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; @@ -1716,10 +1715,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, @@ -1737,6 +1737,16 @@ 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 + * it is isolated for migration, as the page lock is temporarily + * dropped after zs_page_isolate() succeeded: we should rework that + * and defer destroying such pages once they are un-isolated (putback) + * instead. + */ + 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 Tue Oct 7 22:50:53 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E1B32F6F8B for ; Fri, 4 Jul 2025 10:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624772; cv=none; b=OFU3yEqsRCGEQfDlcjBBilddSrmPdH9z/RRTPykZxPmiqL4xdhQxSigUTSW7QZqSt/zPRae3sJt9M/EgDg+FsTXyPZycxKylHOzUKkRDVIgSZSq6ZNPsqoshusEPkeRgm4GLv5ZJ0XNFdQr4tzqPczBOoQRh5YCcpkqG6jQkabM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624772; c=relaxed/simple; bh=oaSTbzQ3dv0aK/zBA0y8w/GgIiybny/jYiHjyAxnR0o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JA/+BhWqTnz1g7jJ6Rx6oNJikhsFqOSnNXqYw6qWWOqeoosRglZqmVprqG5KUVFEZ7jGIy8BZfkV7FdVfKZVx2MDHl5fcwDC5y9SjJqmyFPJMYhFGj0tl7/6bvbuKnGTLX5UFGkARacz9AIu1UWSuDNcw/qPtcUDklm5hy+csTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=blUE6qi0; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="blUE6qi0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NMn47cTQVrdLq38vaZj//jvNYLvXfWrM/D4yqUNgXk8=; b=blUE6qi02WQHKJbTYH5D66fp7uR1atjjlhkcwXv+H163Sv/lbKZ9GWi0EG9lO48iW5kNnI DyNF/EILjNAWawzXhfMVI+FpCKsdrA7YYA35gQZUVoKr2W0S7n+ZZcQOIZOrmU4efxZjPo fq+ONp9FTsZ04NkFpY+YwItAY8RzPmM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-34kTjpTdNIeKzOA26B_Nog-1; Fri, 04 Jul 2025 06:26:07 -0400 X-MC-Unique: 34kTjpTdNIeKzOA26B_Nog-1 X-Mimecast-MFC-AGG-ID: 34kTjpTdNIeKzOA26B_Nog_1751624766 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4530ec2c87cso6379185e9.0 for ; Fri, 04 Jul 2025 03:26:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624766; x=1752229566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMn47cTQVrdLq38vaZj//jvNYLvXfWrM/D4yqUNgXk8=; b=RIZCHVMqnK6PB4L7n31YVYDdd1AHGIpbblwJLJT5f9/B/csZxiCmYz+qRyJS7tlOAX jFlpmm11ZrhU1msYrs7sb6TZnjqnIA37DGek5hFVDPvhreQCoQanUDhC2iGtbIPzj3Yt ApG2qtDLoimbleMojA3cUV9Owyyf/YhAalGyoW1R9G36Rf3BsTBJyxElurXpYy40uwBg K4rHj5bAVWfB9+UrZD6iNxIPdZArMeGvFTBpx2sHvI8rU8bD/pzKBcC9i1pFVcZEN7Q4 RWd6mfQzWE8hjK+GFPCqHi0Iqphn6lM+9McHVJfX1JUWQ3TYx0kGz+xjq85bUAxAcrQu +wkA== X-Gm-Message-State: AOJu0Yycehcol7oPoAC9BS3+o7ui7F+2TwsuiAM6d8wKCWHbxixaC3SN KUQskUh4DIFthOYKfvarNOm1REx/ba51PXfdSxyCTQG/5BLJ+SEhejXVtoTmN/G5YQnJ3TL6uq+ KT7Z8mwgQP+G8PnjXLBn8Cli58oTdQo+SDH4WKLvK/zj6TlrLOeo6etVV1klDhkhkDVNzHc6Uxw iHRoRJaHRBNeJSVYj1pN/TN2OtVU3SkyWqAeIfYR23XHUp8Q== X-Gm-Gg: ASbGncuIV+lanHm0kL8jWqsfDg7/8hzzaaH+GmxJJkASAADOXtKq67zyZ0XTPfbumXC 5Y+tq/y/XP4dq8E0hZksC2ZG1EmCxs5W9oJo2JdXHE8LKFTBX4C8IIBHGNjnzmBe1ie/+DhTxW+ u+eQyGV1J1OLwnocIzNm8lwjaKU2DFdrdDj1nZH2E0BkjTU11OYg4G6cA2mCHtYRF9VCuOP26r9 nRnmHGmzKOKl8urUrZpcyfhi4tj05w7e8Zowl1PVgNJerPa1nMDQ/01dBU7UVuuOaCXAtnK/ykL K0YtC4xpq1O8vvZuY65Z3/9Bx0ElAVdXYk9w2LKz2iFuKLgLNRiChlPoh4DpidpPPAb9HdEzwZd AclNh/g== X-Received: by 2002:a05:600c:34d2:b0:441:b3eb:574e with SMTP id 5b1f17b1804b1-454b306a0efmr19575995e9.5.1751624766067; Fri, 04 Jul 2025 03:26:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOOTyF2MeOIC1dyzcwecIwxCxQh4QIfn5IAcyJ3Cqp147OZBgMH5DYs267rEpv1i04qDIM8Q== X-Received: by 2002:a05:600c:34d2:b0:441:b3eb:574e with SMTP id 5b1f17b1804b1-454b306a0efmr19575125e9.5.1751624765503; Fri, 04 Jul 2025 03:26:05 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454b1628ff9sm22617005e9.11.2025.07.04.03.26.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:05 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 13/29] mm/balloon_compaction: stop using __ClearPageMovable() Date: Fri, 4 Jul 2025 12:25:07 +0200 Message-ID: <20250704102524.326966-14-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We can just look at the balloon device (stored in page->private), to see if the page is still part of the balloon. As isolated balloon pages cannot get released (they are taken off the balloon list while isolated), we don't have to worry about this case in the putback and migration callback. Add a WARN_ON_ONCE for now. Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 4 +--- mm/balloon_compaction.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index bfc6e50bd004b..9bce8e9f5018c 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -136,10 +136,8 @@ static inline gfp_t balloon_mapping_gfp_mask(void) */ static inline void balloon_page_finalize(struct page *page) { - if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { - __ClearPageMovable(page); + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) set_page_private(page, 0); - } /* PageOffline is sticky until the page is freed to the buddy. */ } =20 diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index ec176bdb8a78b..e4f1a122d786b 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -206,6 +206,9 @@ static bool balloon_page_isolate(struct page *page, iso= late_mode_t mode) struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); unsigned long flags; =20 + if (!b_dev_info) + return false; + spin_lock_irqsave(&b_dev_info->pages_lock, flags); list_del(&page->lru); b_dev_info->isolated_pages++; @@ -219,6 +222,10 @@ static void balloon_page_putback(struct page *page) struct balloon_dev_info *b_dev_info =3D balloon_page_device(page); unsigned long flags; =20 + /* Isolated balloon pages cannot get deflated. */ + if (WARN_ON_ONCE(!b_dev_info)) + return; + spin_lock_irqsave(&b_dev_info->pages_lock, flags); list_add(&page->lru, &b_dev_info->pages); b_dev_info->isolated_pages--; @@ -234,6 +241,10 @@ static int balloon_page_migrate(struct page *newpage, = struct page *page, VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); =20 + /* Isolated balloon pages cannot get deflated. */ + if (WARN_ON_ONCE(!balloon)) + return -EAGAIN; + return balloon->migratepage(balloon, newpage, page, mode); } =20 --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 642EF2F6FA0 for ; Fri, 4 Jul 2025 10:26:12 +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=1751624773; cv=none; b=b0mdINI+MHn++XTKKkMit6x0th0NbjYHQpH2frwsSxfLZlT3PrgGI2rN56jL7dXOI9olrCAnth3xO+r8x+TWI3qo2dM+C/dhPntUs2c5MqswsGsRwSPmz3s8745hZyc7OIROAVeWHnG1/3wNwRfmgBY/UNK1mr4isgL9wi8vUAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624773; c=relaxed/simple; bh=9ampJPvcNYsRFz7oDnoiAgEw+Je4opPgPkQZSBZIrqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T5MWX9i/VztwiDAexR/odICEDmmILf00BHTlq3mpQlZ5iYTLDJoD/MDoyL9905lcGUdH+AoexBqwmKi5gur4ebVB+bnk+p7UtyS2yIIWjbJ1CLtZwT+neSCuHZQW23HV6fCVodQhA8meIe2zH57k7XRkRRTAgZY5xx7SQnL04Xg= 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=QHk83vAZ; 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="QHk83vAZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624771; 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=0v9UDDMP4rF7Dl8ADVUR+GZMZCj14eHRzzjvBkF5+v8=; b=QHk83vAZ4Bhzk3MSce4ERV7y+dXpc3I3es3aXdZnol45asWicUdRZbo3C86+Xers01heCJ 4A/4zcO32iyN78i+ODQCw5We+TbD0SfxESygA8zwb4Jw+OXTIRIjP96jaGHkNNgixO6NIH Fp0MQfhQnYfyxbfrsw7UbwPkj3zt99M= 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-342-6rxs7wTWMuSxnG2GuoTsyw-1; Fri, 04 Jul 2025 06:26:10 -0400 X-MC-Unique: 6rxs7wTWMuSxnG2GuoTsyw-1 X-Mimecast-MFC-AGG-ID: 6rxs7wTWMuSxnG2GuoTsyw_1751624769 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3b39cc43f15so440014f8f.2 for ; Fri, 04 Jul 2025 03:26:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624769; x=1752229569; 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=0v9UDDMP4rF7Dl8ADVUR+GZMZCj14eHRzzjvBkF5+v8=; b=Hsqg464uActAYILbDT8cIz2uj+5qp6/Jpl2Wlg0HNeWdG+uOrfSjbznOs97r865sEc wiZ2qFHchfSS0yFfnvWbvYvsKoI6noJ7k4WV2sOc+uqPCYit4r8ZyfNINtQ1SJaH2qos GOv/+o/y864MgkuGVC6th9/yVZHpkGf5ewpKZwLhWJL9sZh+9tsd8cqmRr3UjHweiOOn gVVcMyv5kIx5FVoEW6/Yj7c4dLK6C/3v9lCl5u92EQUMB1Eu03dSLvOBeK/lH51mmPaV ftNZ76fcOgKd0b9FwdG59n8fRgv3udK8SPrREBr4beQEkNvluL2eO3bZel66mlLQt+/C FrdA== X-Gm-Message-State: AOJu0YyTiN4v/Y0XXEUywNXV1UXqI9QZM7YjhnkNGfJb1wLhsS2kVriq E2h+y0n3b7staxHacUov5KChVaiNzsUrWs8zpdjeY+Fcg/dLWic6yzNgXLSq3K8OmOuEhCEl4Ys pwzszfOwIaBcQgc8E/KELrH6EKgQCj4gK1l8Vg7DDHIzycW9kuq6/FkR5p/jw8ovjoY35JUp1tY RA4aUgXNzjT8JhJ85PC69bFL8S5gbHI1jpNoT+Tah4ztjQ7g== X-Gm-Gg: ASbGnct67v92l+a8O2u4Bd0/xhGrvVELMhooLpwz1JuaqJBCYaEvcDZDsn/ABrW5iWv H0+GD2BKxkgmTCxHyGUqUi1avwJxa/iK0cgo0r0xFjMEerfdTTOzRGuVkirGQAj4WMAYWwgxg7A hoV3CL0txXa+s2VCBBvrTelKXjdACFSbr0ubZWlTk4/5a2MolivaVe7BgRlv2FzYpJc5Abyafvb 4+o/VBkidibLFYiBWtFddTcA4tJNv3VuMz+BDWSyaFAkpWOCqZs4yxJXQQkfj1L4BvVSQar/0RX egmpB/JspiV2UqgQqF1jWS1JwgDaWeS7mtJySp30yLI/JXtocwVhwLwohjO12EVH8XDKaCrlDbe Mn/F3ew== X-Received: by 2002:a05:6000:1a88:b0:3b4:58ff:ed1 with SMTP id ffacd0b85a97d-3b4966267b8mr1677220f8f.52.1751624769205; Fri, 04 Jul 2025 03:26:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOt865rvlOHIOEECbMk+LvbVs6qEWcN/5MI9jLz/1+4Qw68QFcrUmFxGowYoL4Q/9NBp5iRA== X-Received: by 2002:a05:6000:1a88:b0:3b4:58ff:ed1 with SMTP id ffacd0b85a97d-3b4966267b8mr1677111f8f.52.1751624768501; Fri, 04 Jul 2025 03:26:08 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47285c90esm2150789f8f.91.2025.07.04.03.26.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 14/29] mm/migrate: remove __ClearPageMovable() Date: Fri, 4 Jul 2025 12:25:08 +0200 Message-ID: <20250704102524.326966-15-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Unused, let's remove it. The Chinese docs in Documentation/translations/zh_CN/mm/page_migration.rst still mention it, but that whole docs is destined to get outdated and updated by somebody that actually speaks that language. Reviewed-by: Zi Yan Reviewed-by: Harry Yoo Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 8 ++------ mm/compaction.c | 11 ----------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c99a00d4ca27d..6eeda8eb1e0d8 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -35,8 +35,8 @@ struct migration_target_control; * @src page. The driver should copy the contents of the * @src page to the @dst page and set up the fields of @dst page. * Both pages are locked. - * If page migration is successful, the driver should call - * __ClearPageMovable(@src) and return MIGRATEPAGE_SUCCESS. + * If page migration is successful, the driver should + * return MIGRATEPAGE_SUCCESS. * If the driver cannot migrate the page at the moment, it can return * -EAGAIN. The VM interprets this as a temporary migration failure and * will retry it later. Any other error value is a permanent migration @@ -106,16 +106,12 @@ static inline int migrate_huge_page_move_mapping(stru= ct address_space *mapping, #ifdef CONFIG_COMPACTION bool PageMovable(struct page *page); void __SetPageMovable(struct page *page, const struct movable_operations *= ops); -void __ClearPageMovable(struct page *page); #else static inline bool PageMovable(struct page *page) { return false; } static inline void __SetPageMovable(struct page *page, const struct movable_operations *ops) { } -static inline void __ClearPageMovable(struct page *page) -{ -} #endif =20 static inline diff --git a/mm/compaction.c b/mm/compaction.c index 17455c5a4be05..889ec696ba96a 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -137,17 +137,6 @@ void __SetPageMovable(struct page *page, const struct = movable_operations *mops) } EXPORT_SYMBOL(__SetPageMovable); =20 -void __ClearPageMovable(struct page *page) -{ - VM_BUG_ON_PAGE(!PageMovable(page), page); - /* - * This page still has the type of a movable page, but it's - * actually not movable any more. - */ - page->mapping =3D (void *)PAGE_MAPPING_MOVABLE; -} -EXPORT_SYMBOL(__ClearPageMovable); - /* Do not skip compaction more than 64 times */ #define COMPACT_MAX_DEFER_SHIFT 6 =20 --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 A005F2F3640 for ; Fri, 4 Jul 2025 10:26:15 +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=1751624777; cv=none; b=Rw7XLsqYUlEl3zw8Pa4SIgRxxl02A3e3jG3F21BKHMqvpYi2G1zNQvoD+rK1xCbdR6ki3zAcFqjqZn3xwMT01qgA7v7tbxmHZKC+7ueJTF35OY0IQVPnvsxz5787OdKiI5pjJdZrfloRBKoQ9mGjRw7EwDbkxuOtT3jGnDGwxtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624777; c=relaxed/simple; bh=xp8NbfYpTMv4FsMLVs/wu/k+oe5U+/lKYXQQnLBQbmc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qwgHawzIhKnLtbTmK/fa3x8xJO5eVv/xSgKw09FeetSorTkdaahCaJGGC65DT7ko0ifrfeY1HV/7poOQM0M3kQKoXzGv3b/vMyv4jahwJsl2J67Bvbrv7hMiN9j2Uw+tJQKZ4IQQeMX5Oyybvr9ZSLp27QqDds3HnPM6wPBi0tM= 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=U+ZVYSp9; 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="U+ZVYSp9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624774; 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=pR0cJEJLX/Xckea5AegahrKaeIbiLpLeDpONSEjx7tI=; b=U+ZVYSp9Gw60xTBnvB+SKctbLUtzTmJhX1e++uqYHhgGMeJWhAexklZx4+uqWO+ebNhKIV b1SjKfaumtvL1oIn8TkOjn5USzbBN/awiBuccjdCn/bqDoDVVHVJx/h2M0XMnblrzmVhIh fqH80J6qPQsHBY+cSwnulN0+XPZbTZ8= 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-204-dx3FPHAbMOm1-_krBqZDHw-1; Fri, 04 Jul 2025 06:26:13 -0400 X-MC-Unique: dx3FPHAbMOm1-_krBqZDHw-1 X-Mimecast-MFC-AGG-ID: dx3FPHAbMOm1-_krBqZDHw_1751624772 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45311704d1fso4476995e9.1 for ; Fri, 04 Jul 2025 03:26:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624772; x=1752229572; 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=pR0cJEJLX/Xckea5AegahrKaeIbiLpLeDpONSEjx7tI=; b=IYKO/Rj4hEdo1U9h0SXwPqwHkUWu6qDTlm92gyBX1vX1zl2F4uH1acWim82lmR11Lu EqELHdIKcZ00spcFHS/gNzvL9N6Hes3ogbhwyuY5wW1Yd6tz0SnadSIuDfYtD/eWqQux FrLK3MjIs5qfbdKsysSrJjxPrjMZEGYQPpHL3mmhHCR7UR1nM02octTxfazvQabdlTJv w/9FmYFcNLifTBoRlo6iryeQltZOQwsUu6gBuHKCpiIlmARheja6GnnrMnmVuSic/BuZ L05KxgT3QAMnBFOxEqivHJDb0zd0kQkGcLFGRG5Ak9Gb/b+rIc4OJz9aZsPAYVgxZLld 7WlQ== X-Gm-Message-State: AOJu0YyG//BSiw0/DjiY6W8oDnjYLWhixLRA35q1WHc7YzpOK5whqFMn J3L5ZdLyZapzRmfp1nX15T8rSRHOmLF9pFWuLvRNmdxjw2ppnBmT9eTgueukWgQQy4/tAVPzg2W 1nATobFeheOXvTMpeExoTCfsPFW+Rq4fcrEj1xlPACXIuKUsSg67gjhMnMrLZqOxqvppuWWe4we AAQeuliodaqr0ywDkGCGJI0fCScjauDp0FaZ/p8U75lUNHzg== X-Gm-Gg: ASbGncvgazeJGUEr5oAZZ+sf6TYeBI0EtYuA7Si3wDL8x/4eiY9wP4yPo0AG8HUIZJB IfkcRZWHF9t0a4/BVvjGHViIy1RrpeslB1sGxWArBt2aONCAYUQ5/UnJ4yABQ2T1tDXuugFkz9a Y2hsUdjMEf32+5KKWiMiHAMuDWqZc7yG3WZwRyToSio/ItDFjRLf+VwGp+vNiQlCJg6UF2fiU8c VitA/1oTWQnKeroa9GdaWQ/qmtjl1fFirkqdyn9a0rlw3s3NZwVw9yZahLz0wtUIVtBCEnP7CzL iAVynE0LunfUCc5DIKq8ei1iuws2H2dfu+2mHxmckOHrEmsly6uKwumFtT1SaMsio+Cg9xQeb3+ cp1UZdA== X-Received: by 2002:a05:600c:502b:b0:450:ceb2:67dd with SMTP id 5b1f17b1804b1-454b3196658mr16378015e9.33.1751624772117; Fri, 04 Jul 2025 03:26:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEp08CEDtezTqVTL+O56wTX6rAd2DO6G5SD1z9P14Ak5Y4B7FcklsRB1svcNIkfJhaHfAdZdQ== X-Received: by 2002:a05:600c:502b:b0:450:ceb2:67dd with SMTP id 5b1f17b1804b1-454b3196658mr16377165e9.33.1751624771466; Fri, 04 Jul 2025 03:26:11 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a1705ed5sm44913475e9.2.2025.07.04.03.26.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 15/29] mm/migration: remove PageMovable() Date: Fri, 4 Jul 2025 12:25:09 +0200 Message-ID: <20250704102524.326966-16-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously, if __ClearPageMovable() were invoked on a page, this would cause __PageMovable() to return false, but due to the continued existence of page movable ops, PageMovable() would have returned true. With __ClearPageMovable() gone, the two are exactly equivalent. So we can replace PageMovable() checks by __PageMovable(). In fact, __PageMovable() cannot change until a page is freed, so we can turn some PageMovable() into sanity checks for __PageMovable(). Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 2 -- mm/compaction.c | 15 --------------- mm/migrate.c | 18 ++++++++++-------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 6eeda8eb1e0d8..25659a685e2aa 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -104,10 +104,8 @@ static inline int migrate_huge_page_move_mapping(struc= t address_space *mapping, #endif /* CONFIG_MIGRATION */ =20 #ifdef CONFIG_COMPACTION -bool PageMovable(struct page *page); void __SetPageMovable(struct page *page, const struct movable_operations *= ops); #else -static inline bool PageMovable(struct page *page) { return false; } static inline void __SetPageMovable(struct page *page, const struct movable_operations *ops) { diff --git a/mm/compaction.c b/mm/compaction.c index 889ec696ba96a..5c37373017014 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,21 +114,6 @@ static unsigned long release_free_list(struct list_hea= d *freepages) } =20 #ifdef CONFIG_COMPACTION -bool PageMovable(struct page *page) -{ - const struct movable_operations *mops; - - VM_BUG_ON_PAGE(!PageLocked(page), page); - if (!__PageMovable(page)) - return false; - - mops =3D page_movable_ops(page); - if (mops) - return true; - - return false; -} - void __SetPageMovable(struct page *page, const struct movable_operations *= mops) { VM_BUG_ON_PAGE(!PageLocked(page), page); diff --git a/mm/migrate.c b/mm/migrate.c index 9a63bd338d30b..63a8c94c165e2 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 Tue Oct 7 22:50:53 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 A37E22F949B for ; Fri, 4 Jul 2025 10:26: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=1751624780; cv=none; b=Rc/e72r4ZNmjh2wb06OgeRWyvy56mkOzmOiF4wZZhGKmjCvLzlZBKt5p+QXDF4KI7wWx3JEhOeRmfIV8oFpiReLph7nOGsTWSQYegTUEwXJ6QUM7l9bItLLVzvA0H2X2p6Qb5Fwv3sl8snTdkLSEd7qTJX354Dt7u1ek9c6RGgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624780; c=relaxed/simple; bh=jJmEqah3OQjU6vk82e0dwqh1tVfbFSGJ5XPmd3r+RAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bkIXEZHNTKWsUzeGYzLobLlFT2kpX42Ox1usPpuDTk0GwwGFYcp+p11f5G0yKx+oTWBoyYOp/6wZiBsD/5Qccu01ZEShUELi/DZJLgkQCUH2uPYg7yV3HBTXFzjHn9IBcQngYWbyPe/jtjFjpsCAo7R7yzZC0tkbcmQJJxDEIBE= 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=eYNf1nTA; 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="eYNf1nTA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624777; 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=0BL6qvlJKb8bmxpRl18Ncv/RX/ffBcxhvATfsQs5MSw=; b=eYNf1nTAx+ZHCmhA4q7cbNG4gaaIrzyGWv2kZbMD1f/sHkwZworZlBOEEzwriSXAX2vj98 gbR14Px/t3Pb2eY860jwCgcE/qhUG0kxzq2+2w5JK6TnNJtwl6g8H/dmiJfZK9iSAyIzgd SUNK5RPDUFGW9w1W1F0srZ9QcsGrpz4= 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-556-M5MpnoW7PQ6mKo0ky7SsfQ-1; Fri, 04 Jul 2025 06:26:16 -0400 X-MC-Unique: M5MpnoW7PQ6mKo0ky7SsfQ-1 X-Mimecast-MFC-AGG-ID: M5MpnoW7PQ6mKo0ky7SsfQ_1751624775 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-451d7de4ae3so4254915e9.2 for ; Fri, 04 Jul 2025 03:26:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624775; x=1752229575; 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=0BL6qvlJKb8bmxpRl18Ncv/RX/ffBcxhvATfsQs5MSw=; b=bcw8Gh8MV/GNdJJB2SVqVT+mPMZQ9569UrRvKaJtm8wV1vvzDr+1sG/xAGcLLDhti3 dQLt4DwWKeLdkY9wp1pPp1a0H9PiwdMaxSjlmLzma7nGoTAMQYKME/o71JqCPFMxHE0W pCEcAn+3JctIIQXPX0pT05NKaUboAI16bLErsLJYi7Fnf047IhyLKyHXELL3EjJiZ0la FqRnWTxp1QL85fenXGY7XXcdIBNze8fvAoXEOmfgxLD0saUsscFCw1OzI9KIAvMvjCWq dpzhWWqniCRaMLeVvsDPdh40UC52Nbj+JM1nwnUvOqzXXz1+r1cs5vDLgB7X+tXb2zFH i3bw== X-Gm-Message-State: AOJu0YwJ/pNnlxMip1dUjmYtZmVHjikkLevV+gvLaAdCIcn6qXSJabST i6KmvT5xVV9okZlow/B3yn3TzvkLEGisoiM/g1i/2pueD60zDa3XvjBi4ubn4oU4ywbML+PdjDu wnRiN3OHzDZlbIkzwh3ZHaz1J+IBKq06KWxDx4Srq8A5Fh606cUNVdyLPp9oDD3gULkBsHp+WMr Ry3s4eSkmx5ML5svoIQex7pq7esx5lCgHmhgbWH+tg4Yea/w== X-Gm-Gg: ASbGncsJtUjdYcqOa58aHllndo2DpVDwhbn7diRE01odSgbsbHicqKd2hZTE8QJDuMV l8cWcOf3vLVha+nCeMKRT0fdCwr7vMPDZV//uiKjSRA0koYN+C3ON+dmtWQa3lknahtsUoSYm+F CGtyky+A4tqRp72SU1cM2D5mcKnILeiMhKjoCCCBFu67IrsiVPnkJ9a6VtstpZmYDcQNinLSZuf kpE71ZPvV0sUf2HOu2YtlIuLzFLHSS+eR5xnrJYvlXiLdvgg9tsA0Fc+AXt3xqAoQmsHLtMne+5 VUj6noTPBwF4IW/s80mZu7FPtcgBAuAXqO/ZLNH8BIVvT2s4kYrKx7Cm1Dm9nKlFtV+yiWy6CrW 3eedNWA== X-Received: by 2002:a5d:5f04:0:b0:3a5:7991:ff6 with SMTP id ffacd0b85a97d-3b4964bc845mr1662819f8f.1.1751624775148; Fri, 04 Jul 2025 03:26:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm2OJrY/VRHhz8rrdEvEy9XnpRFVoifs27nJth9wopnF7vUfEB7/wKIPCCX3g/OmgYPHMZeA== X-Received: by 2002:a5d:5f04:0:b0:3a5:7991:ff6 with SMTP id ffacd0b85a97d-3b4964bc845mr1662735f8f.1.1751624774556; Fri, 04 Jul 2025 03:26:14 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b4708d0ed9sm2154538f8f.38.2025.07.04.03.26.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 16/29] mm: rename __PageMovable() to page_has_movable_ops() Date: Fri, 4 Jul 2025 12:25:10 +0200 Message-ID: <20250704102524.326966-17-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's make it clearer that we are talking about movable_ops pages. While at it, convert a VM_BUG_ON to a VM_WARN_ON_ONCE_PAGE. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/migrate.h | 2 +- include/linux/page-flags.h | 2 +- mm/compaction.c | 7 ++----- mm/memory-failure.c | 4 ++-- mm/memory_hotplug.c | 10 ++++------ mm/migrate.c | 8 ++++---- mm/page_alloc.c | 2 +- mm/page_isolation.c | 10 +++++----- 8 files changed, 20 insertions(+), 25 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 25659a685e2aa..e04035f70e36f 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -115,7 +115,7 @@ static inline void __SetPageMovable(struct page *page, static inline const struct movable_operations *page_movable_ops(struct page *page) { - VM_BUG_ON(!__PageMovable(page)); + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); =20 return (const struct movable_operations *) ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4fe5ee67535b2..c67163b73c5ec 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -750,7 +750,7 @@ static __always_inline bool __folio_test_movable(const = struct folio *folio) PAGE_MAPPING_MOVABLE; } =20 -static __always_inline bool __PageMovable(const struct page *page) +static __always_inline bool page_has_movable_ops(const struct page *page) { return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) =3D=3D PAGE_MAPPING_MOVABLE; diff --git a/mm/compaction.c b/mm/compaction.c index 5c37373017014..41fd6a1fe9a33 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1056,11 +1056,8 @@ isolate_migratepages_block(struct compact_control *c= c, unsigned long low_pfn, * Skip any other type of page */ if (!PageLRU(page)) { - /* - * __PageMovable can return false positive so we need - * to verify it under page_lock. - */ - if (unlikely(__PageMovable(page)) && + /* Isolation code will deal with any races. */ + if (unlikely(page_has_movable_ops(page)) && !PageIsolated(page)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b91a33fb6c694..9e2cff1999347 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1388,8 +1388,8 @@ static inline bool HWPoisonHandlable(struct page *pag= e, unsigned long flags) if (PageSlab(page)) return false; =20 - /* Soft offline could migrate non-LRU movable pages */ - if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page)) + /* Soft offline could migrate movable_ops pages */ + if ((flags & MF_SOFT_OFFLINE) && page_has_movable_ops(page)) return true; =20 return PageLRU(page) || is_free_buddy_page(page); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 62d45752f9f44..69a636e20f7bb 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,13 +1759,11 @@ static int scan_movable_pages(unsigned long start, = unsigned 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 /* - * PageOffline() pages that are not marked __PageMovable() and + * PageOffline() pages that do not have movable_ops and * have a reference count > 0 (after MEM_GOING_OFFLINE) are * definitely unmovable. If their reference count would be 0, * they could at least be skipped when offlining memory. diff --git a/mm/migrate.c b/mm/migrate.c index 63a8c94c165e2..3be7a53c13b66 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 b825f224af01f..4aefeb2ae927f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2006,7 +2006,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 Tue Oct 7 22:50:53 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 398EF2FC3BB for ; Fri, 4 Jul 2025 10:26: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=1751624792; cv=none; b=eO6cXWD4uFCeZHh3ATAdfm90aWI5Rsko6wZATx1k+8qkEIbqaZ3DY8OI08KkxGiMnfAdsNXEl6NxSdKUezncT/p4sHfBStNbHIcb4aktw5po4vD3/Bkd8TuLUSuUYAh/rGhKOAr9otoqXRylYQIj0HxBnE3LfcVn/GUYk05RbyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624792; c=relaxed/simple; bh=C6jPkBseruyPYB2V4vPia4YjzGxO7oc6LRdQsocjdPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oaFxqoTHuiZffNuyLVh8Jp8Mk2Tt+y0zX4tArHGPVpE6QaI270BGm0JYhm19dPVMhnOFacuxadHbTDLU20fGx3Uf1MZtu7T//0MfdsBGRIf18G5D1hZsfJ7CHEe+hSjIO9uek7rx12X8UQYeZCh6EReBULA8+m4Ju2YlOXdK71w= 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=QQSf7MCH; 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="QQSf7MCH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624790; 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=cJheLoKLsD44QkJTGnHlicWVVgB1MKf4t1jgEN3k6qA=; b=QQSf7MCHJ0+6djILhVCdnykQZFP+3tHzG84xOreUSIcBgtFvzru7IQWhMnfbjLHEV8TLbk epBxvee05TRoCKuNn3bQgHGuFIQ5w2EogHLTPfeBkdjuQljV7oNGQ824sUD6JOUAD6/j1x XSwQZ0pMHhjtbOMehkvxpGRLCLRT7xE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-fMc5h8GpM8Cwwtr7OKfn2g-1; Fri, 04 Jul 2025 06:26:19 -0400 X-MC-Unique: fMc5h8GpM8Cwwtr7OKfn2g-1 X-Mimecast-MFC-AGG-ID: fMc5h8GpM8Cwwtr7OKfn2g_1751624778 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a6df0c67a6so416095f8f.3 for ; Fri, 04 Jul 2025 03:26:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624778; x=1752229578; 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=cJheLoKLsD44QkJTGnHlicWVVgB1MKf4t1jgEN3k6qA=; b=oehaySEbcpKIXsFNSNixKoUq7sJn6fX24UCspeabLnEzNt9lLRg+vAkA0tAkvMV8kR gL55iHOIT1TOiCfSojxrRXj0ENZAFVs/qYaOcCbqWeH9qUHwrHqd1157ybnjUVs4dhSu Uy+pTAxWhDVp7C6A13Xd9rCbLfsOCW7k1r/m69AJEAsLKFxRuYYgclzBEXx6bDP6fSBs gvkZYoPuHPBA9dQswZzTu34C0F0z4sID+a0y1zNtviTBM82RXN1ClV16i8xmrzdJSWLX zHcVUYmKoAFU7gvlYkLyBCHFeqnSXqtr66Wcj7fM3dn2pcKOgH9cQPTPHPnTxr96dfUs nEeA== X-Gm-Message-State: AOJu0YyJVO6oK3i+pwRmfbTGAwSWyQXFCa7p+HJA7RxRD6suf4SC8VyT dDjHwwJYZchdUFu5B01wFNrwd/qeCerBU32PdyStKbQMpdSSZEzrkm6sdpkqVUcjxy7kR9ClIky ErIsAOLMl8j9jL0OF9nNEDihj+r16VqIbuiOJ4G9mAmGHw00+igDv72s2pcBM7/ocTzacYARfeV we7L/DmX4AUdZPrgnX3mTXD650+PJ89EctJe6Uihl9bZfmCQ== X-Gm-Gg: ASbGnctvi7P2PI3/2HoFUTixc1OEqW4LU81Wp4bV9y+LaaBeYDzsWFRtJ02Rhpup/Hn ISENK+2BM4SkOjPEiwdJt5edbv8P+mbIxIpxHWCoPvXVfCJpNaakudMCLAU/ukL9vh/FxNGNOOM +uNCq9bnP219nUz3NWNRge40YkvIzHSmP0BATyJGKwjQx3xO2QIwd4W8RL0YMVR04hHpU6XBpsV CyuuZLEGFRNEjidMAdgXFtfENMiRoHta/QJgAEhfs45s0+jrgosnUdenOpvZmV190MOrWbzCQ/o 2aBEfVGXBFxfcqi9uZbYvBe6/tQqQXNnn4PWlEyaoXWXUv2ywWSrKoD8Ez4lksdSjbPT+IUUw57 T0kdLfw== X-Received: by 2002:a05:6000:2f85:b0:3a5:57b7:cd7b with SMTP id ffacd0b85a97d-3b497019684mr1247119f8f.22.1751624778043; Fri, 04 Jul 2025 03:26:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsIhm+puni7M70O9UOfmv7nAn160MUBp8IUwHGoHgLCi+2FqWLpmioUQXF2wdRtw6a1cigug== X-Received: by 2002:a05:6000:2f85:b0:3a5:57b7:cd7b with SMTP id ffacd0b85a97d-3b497019684mr1247037f8f.22.1751624777474; Fri, 04 Jul 2025 03:26:17 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a9969a8bsm51842365e9.2.2025.07.04.03.26.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 17/29] mm/page_isolation: drop __folio_test_movable() check for large folios Date: Fri, 4 Jul 2025 12:25:11 +0200 Message-ID: <20250704102524.326966-18-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, we only support migration of individual movable_ops pages, so we can not run into that. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 Tue Oct 7 22:50:53 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 279B42F3C04 for ; Fri, 4 Jul 2025 10:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624786; cv=none; b=L1LMaRSULRojMYGIaiTqkgbJ5AqpvHoAaoXN1Gdtl+lj52nZZ67f648c0YLZ0URxt0Ruvu5EZ7kGc/xFgv9BuocSSvLifBrMQ4BWDhLOCwYmIv4JKyfGAmO0qNjijTtu2lshUqeSEFKRmtUTOvDYPse6RJCtGFhXjhBJq9vrZhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624786; c=relaxed/simple; bh=CEOWBR0ho45KHBlgU76irVulTR2FPeYP8m0twAminTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kDB2gd4QUZBBYk4rAAwXZi+eSS8dHXu3IQPmjM2DBHrFmdSoBdBg0LCHzfIjVihIgjdEZJAKDRX2N9nbH8Mb5j4J4hQKJs0y3x5/cBddbRTwIvXjXtv/oSrirADi4nCzFn8N6cPINZSVQgsf7kjtDcxznxDyuR2ieqRrCf6ThiE= 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=bRe2DMzt; 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="bRe2DMzt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624783; 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=oECXrV5Dx+HlyT4DmzhVSvU+dpZiU/Jf4ByqsPae79M=; b=bRe2DMztSP+dOQPpEDzkZ0OvXJ82XKzpi4MN91WvyoIHei8VmBT7VoC3F+s6vH7k+YkEGr Zd5qCucojFyFCJBkQPvzUCE7hRomSXEFgsQVTmk87zq8LI6hWrgGbTkTzSYzYgdpS6X6Am VajQsiVcDsIdDu/bQIEJWfsY/wLyDHU= 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-7GN7KdLmOKWc5XCZTvo6dA-1; Fri, 04 Jul 2025 06:26:22 -0400 X-MC-Unique: 7GN7KdLmOKWc5XCZTvo6dA-1 X-Mimecast-MFC-AGG-ID: 7GN7KdLmOKWc5XCZTvo6dA_1751624781 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-453018b4ddeso4616195e9.3 for ; Fri, 04 Jul 2025 03:26:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624781; x=1752229581; 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=oECXrV5Dx+HlyT4DmzhVSvU+dpZiU/Jf4ByqsPae79M=; b=Fb1fjQUg2NPmKf9Tq2Mf2fXbxwLfGr9hzvrv/kmXYUQP15T556Hwkzw+/QJIEqsKYK R2TVvBSABtEDTkWQYbGNPI8lupArIbzUnqnc/C5sGleydufVe1+JAK7y7FKiqyZDp40T F1bjCWjtIrV0BQl0YRs2R96ogMpO3Lf8QsZm412LCl7euM44xG88ScynuCF484Nepi5D Fe4IaC1tDkzHxNVaGjZKlpN6pVQYXS5qNaF1WLHtbSlA1KDIm3Fjhxyjun8gSTXzvQtg IYN6LGPk9wK7zaKfbc46BM7TKln7lX1kMdxHVcMU/bAJ71KZ8vzaJTWao486KA/HScOp zQOg== X-Gm-Message-State: AOJu0YyS7qy4u5boCvmjyGo1IuNFGHwo5KwH+v5j5DrsOD/h5eTnJr1z ePyI/fzTRv6ljssAWIDo/akKA202XUU03I43rWGmsg280jiBXodO45vmb2IsAfpWEOKuoXPH/Dp Ykkj2og9o+W4aMG+oOAB1gDK8I+c/cQDpp0jPk2SRSe9s5uSu4toFDxDHEI3Qm5Ft85u7fQGX4i tcFtJdmvrPjkYx7o7JNMEbKYLoIJl92sUmOwlfoUT86fSDrQ== X-Gm-Gg: ASbGncvkxTp7XT1ZCMAvp1CBB2GyeMuPU5IhxG2Q4Chjva5RNAQFotXgQ9Ufl4iyhq6 BBAuTLH66sovk/JH7f2+74pMzIKu+gIxmWuc8ByGnSGxWED6Vqb1s02iwLBMlftS6juW5qiFNNi gGjbsLEPmeNqJPS/EH2HBsxwMnsdjuf716ink/QQpFjyoyIrksen2fxzn2gk2zoNrKXwcFM6y28 lfckS3/1WQ1ims3BAF9+VygoWvluiw4LG448e+xSlH73hujW1CEnlTagSpy2tX1bcwvg9OFViel roZfC9a4dHfO0/1Of23scHwgXhEVOFwwh+pBnjaJgmM0j0S8ZCZnmRxwghtFT2bVwNZ9vfEg3oB l3zftGA== X-Received: by 2002:a05:6000:18a3:b0:3a4:cf10:28f with SMTP id ffacd0b85a97d-3b4965fa4b0mr1306265f8f.31.1751624780898; Fri, 04 Jul 2025 03:26:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbtvCxrQrQrYrJp00fZP6RxGB4BHMLsK8k2E+KsEE1fK7HT/hfJLD1aXJjlmgOs0fjfm/CXw== X-Received: by 2002:a05:6000:18a3:b0:3a4:cf10:28f with SMTP id ffacd0b85a97d-3b4965fa4b0mr1306179f8f.31.1751624780162; Fri, 04 Jul 2025 03:26:20 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b4708d0ae0sm2166343f8f.33.2025.07.04.03.26.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 18/29] mm: remove __folio_test_movable() Date: Fri, 4 Jul 2025 12:25:12 +0200 Message-ID: <20250704102524.326966-19-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert to page_has_movable_ops(). While at it, cleanup relevant code a bit. The data_race() in migrate_folio_unmap() is questionable: we already hold a page reference, and concurrent modifications can no longer happen (iow: __ClearPageMovable() no longer exists). Drop it for now, we'll rework page_has_movable_ops() soon either way to no longer rely on page->mapping. Wherever we cast from folio to page now is a clear sign that this code has to be decoupled. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 3be7a53c13b66..e307b142ab41a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -219,12 +219,7 @@ void putback_movable_pages(struct list_head *l) continue; } list_del(&folio->lru); - /* - * We isolated non-lru movable folio so here we can use - * __folio_test_movable because LRU folio's mapping cannot - * have PAGE_MAPPING_MOVABLE. - */ - if (unlikely(__folio_test_movable(folio))) { + if (unlikely(page_has_movable_ops(&folio->page))) { putback_movable_ops_page(&folio->page); } else { node_stat_mod_folio(folio, NR_ISOLATED_ANON + @@ -237,26 +232,20 @@ void putback_movable_pages(struct list_head *l) /* Must be called with an elevated refcount on the non-hugetlb folio */ bool isolate_folio_to_list(struct folio *folio, struct list_head *list) { - bool isolated, lru; - if (folio_test_hugetlb(folio)) return folio_isolate_hugetlb(folio, list); =20 - lru =3D !__folio_test_movable(folio); - if (lru) - isolated =3D folio_isolate_lru(folio); - else - isolated =3D isolate_movable_ops_page(&folio->page, - ISOLATE_UNEVICTABLE); - - if (!isolated) - return false; - - list_add(&folio->lru, list); - if (lru) + if (page_has_movable_ops(&folio->page)) { + if (!isolate_movable_ops_page(&folio->page, + ISOLATE_UNEVICTABLE)) + return false; + } else { + if (!folio_isolate_lru(folio)) + return false; node_stat_add_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio)); - + } + list_add(&folio->lru, list); return true; } =20 @@ -1140,12 +1129,7 @@ static void migrate_folio_undo_dst(struct folio *dst= , bool locked, static void migrate_folio_done(struct folio *src, enum migrate_reason reason) { - /* - * Compaction can migrate also non-LRU pages which are - * not accounted to NR_ISOLATED_*. They can be recognized - * as __folio_test_movable - */ - if (likely(!__folio_test_movable(src)) && reason !=3D MR_DEMOTION) + if (likely(!page_has_movable_ops(&src->page)) && reason !=3D MR_DEMOTION) mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + folio_is_file_lru(src), -folio_nr_pages(src)); =20 @@ -1164,7 +1148,6 @@ static int migrate_folio_unmap(new_folio_t get_new_fo= lio, int rc =3D -EAGAIN; int old_page_state =3D 0; struct anon_vma *anon_vma =3D NULL; - bool is_lru =3D data_race(!__folio_test_movable(src)); bool locked =3D false; bool dst_locked =3D false; =20 @@ -1265,7 +1248,7 @@ static int migrate_folio_unmap(new_folio_t get_new_fo= lio, goto out; dst_locked =3D true; =20 - if (unlikely(!is_lru)) { + if (unlikely(page_has_movable_ops(&src->page))) { __migrate_folio_record(dst, old_page_state, anon_vma); return MIGRATEPAGE_UNMAP; } @@ -1330,7 +1313,7 @@ static int migrate_folio_move(free_folio_t put_new_fo= lio, unsigned long private, prev =3D dst->lru.prev; list_del(&dst->lru); =20 - if (unlikely(__folio_test_movable(src))) { + if (unlikely(page_has_movable_ops(&src->page))) { rc =3D migrate_movable_ops_page(&dst->page, &src->page, mode); if (rc) goto out; diff --git a/mm/vmscan.c b/mm/vmscan.c index 331f157a6c62a..935013f73fff6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1658,9 +1658,11 @@ unsigned int reclaim_clean_pages_from_list(struct zo= ne *zone, unsigned int noreclaim_flag; =20 list_for_each_entry_safe(folio, next, folio_list, lru) { + /* TODO: these pages should not even appear in this list. */ + if (page_has_movable_ops(&folio->page)) + continue; if (!folio_test_hugetlb(folio) && folio_is_file_lru(folio) && - !folio_test_dirty(folio) && !__folio_test_movable(folio) && - !folio_test_unevictable(folio)) { + !folio_test_dirty(folio) && !folio_test_unevictable(folio)) { folio_clear_active(folio); list_move(&folio->lru, &clean_folios); } --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 0910B2FBFF5 for ; Fri, 4 Jul 2025 10:26:26 +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=1751624789; cv=none; b=Sc6LKc6qTAs888NCk8z0gA68X8NtfrQC2ToLpWVdgdXttfUAbAJ1fCv8I98hTiaxez+W013+t9+F83WTLpZzuCkKc0rr4bRrWB04sogLXWtNFrFcQ/IPKx7R/1Ihcsj6829AXicJUhSBW1JKKloiFnypOjaM0PjkrN8EqeMquWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624789; c=relaxed/simple; bh=b0liUSSY47DTw9qNi2DwJdqsrOCQtLkQU9HwOq+xPDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DGePHR3olK6pYYSDGxvJZ24E0Nfvfl6O3iKvM4Q2+kjdPYD1TT9gQFPl/0pqx+wfTEBzJv2TBmtJoSPSuUJxZtbGVDAQRZdA5mxG6MY7oDr0qbRZCP2zUNEtkZbSBKBcYdqSGKHT+Fa3/2GE5foISx9QYs+CRqgIwDr9bECDuQY= 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=JYP3KaWJ; 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="JYP3KaWJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624786; 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=QHTcY4lGBgipsSfC0DkPJInFiJB34Dm8315TxjfyzWo=; b=JYP3KaWJsT4pDsIeDugqbAFcVoV8cqzk6mVG+VMM+wxsTxulzuq2yEFtAseBFZ5D48Gt/Y QixyttjO9VIUgPwwavr72Tg2PUTi1cMxbRx2hncF9Wj89Yj7x7YjfWaQcF80LrNQVej1ny jrw0EouxOXa/zu+UmueVxgZRsUupNAM= 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-690-1yYvJwXeNlKBp2P-CTfeqg-1; Fri, 04 Jul 2025 06:26:25 -0400 X-MC-Unique: 1yYvJwXeNlKBp2P-CTfeqg-1 X-Mimecast-MFC-AGG-ID: 1yYvJwXeNlKBp2P-CTfeqg_1751624784 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45311704d1fso4478385e9.1 for ; Fri, 04 Jul 2025 03:26:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624784; x=1752229584; 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=QHTcY4lGBgipsSfC0DkPJInFiJB34Dm8315TxjfyzWo=; b=a8j0gZaKbrFoDZ20AfujKkFmVx+Nn1OkzDN1AfcqipGlqyiRBrkTU6hPtlrQfkjsRd B8pi5bBbqY/c1ZKtaHNJAdKu2xwaSRBj/7Y/Ar44g3T+J4AphekJkeU7TTVLJIWw9TYt C/skom/ZkX39f5zI7fg5Qy1VhWf134wDzuWe97AMzt6lzO5vTsSwSQsqw8ze8CfgntYB EBEkC8S2Nhi0Mu8SV9qcVzhtF9chDbjM6+iWsnKoDFr9h46Mj0GDqzoaODtpAjDYJarr A7XXqTZ79Q1eo0Tuy0qJkSe3vZ0SkQuhVSC+fA9knkY2TkaTGWoi2hcwkW2rr3ErjLI+ Nb4w== X-Gm-Message-State: AOJu0YyX0dxE6vbjCFtsC+1uEwVyCePADHgk/di/nMepxcFFGD7YHT2o c4aFUfS7sBa/moDK+p831iSr24yqgrl3HesZScOm9h8/Yt70iZ3fwRvxw1zo3s6VGg8vJeDNsee ai/fDPF+Z17xXytlGeqlp8gSoYf59sD0wOodqeCw+1Q8u0CYO7nyC9FKnxeFL/nsZCBM2VZijzQ 167VBA1AUkaKnfu58k6H0H6EAE/kdZaD1GyfogAI9eGWMquA== X-Gm-Gg: ASbGnctyLxq+HtxqLHSIvTMDCkTIlFlhbfcPcw97XFYY7FlGV0wjvxNlRSyogF0cazF J7B8EpFLF6JHdBFkzbvsu1y8bRpCuush59TKHavE7I6Gjy78NoOxMaEL8kWOUV9BITcpoVOAtYZ uZAWj8p4aYVi1ZUM3PZx+Dq328eMBngpQYhddlbKiDFwiGxV/7wJ+1chW+DLZXPUDnZyacEiR7p B5jNEiU76v0Iydqv6NIbhVNQFAVPPmJRjh1S0ijc/hEEn1wIQRWMCnVvJkszUqWTHMO5j/uoCqB 03QRPtENQPovp2ULdW5uOfogeRIdGvOL0an9LP6MAH5IWhzD2H8mz8i4HhG6fLQQ7Qyj1+YoD5F kqeOm8Q== X-Received: by 2002:a05:6000:4383:b0:3a0:b84d:60cc with SMTP id ffacd0b85a97d-3b4964bbb0emr1665050f8f.2.1751624783767; Fri, 04 Jul 2025 03:26:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFo0T/pNI/Of6mHqiHSOPVoLeJ7bI5rRnJeuA800PIc1+OxXRdj+3LOyAd04sXSWw3NJAHS6g== X-Received: by 2002:a05:6000:4383:b0:3a0:b84d:60cc with SMTP id ffacd0b85a97d-3b4964bbb0emr1664957f8f.2.1751624783096; Fri, 04 Jul 2025 03:26:23 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47030cdf5sm2101401f8f.1.2025.07.04.03.26.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:22 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 19/29] mm: stop storing migration_ops in page->mapping Date: Fri, 4 Jul 2025 12:25:13 +0200 Message-ID: <20250704102524.326966-20-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ... instead, look them up statically based on the page type. Maybe in the future we want a registration interface? At least for now, it can be easily handled using the two page types that actually support page migration. The remaining usage of page->mapping is to flag such pages as actually being movable (having movable_ops), which we will change next. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h | 14 ++------------ include/linux/zsmalloc.h | 2 ++ mm/balloon_compaction.c | 1 - mm/compaction.c | 5 ++--- mm/migrate.c | 23 +++++++++++++++++++++++ mm/zpdesc.h | 5 ++--- mm/zsmalloc.c | 8 +++----- 8 files changed, 35 insertions(+), 25 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index 9bce8e9f5018c..a8a1706cc56f3 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -92,7 +92,7 @@ static inline void balloon_page_insert(struct balloon_dev= _info *balloon, struct page *page) { __SetPageOffline(page); - __SetPageMovable(page, &balloon_mops); + __SetPageMovable(page); set_page_private(page, (unsigned long)balloon); list_add(&page->lru, &balloon->pages); } diff --git a/include/linux/migrate.h b/include/linux/migrate.h index e04035f70e36f..6aece3f3c8be8 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -104,23 +104,13 @@ static inline int migrate_huge_page_move_mapping(stru= ct address_space *mapping, #endif /* CONFIG_MIGRATION */ =20 #ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page, const struct movable_operations *= ops); +void __SetPageMovable(struct page *page); #else -static inline void __SetPageMovable(struct page *page, - const struct movable_operations *ops) +static inline void __SetPageMovable(struct page *page) { } #endif =20 -static inline -const struct movable_operations *page_movable_ops(struct page *page) -{ - VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); - - return (const struct movable_operations *) - ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); -} - #ifdef CONFIG_NUMA_BALANCING int migrate_misplaced_folio_prepare(struct folio *folio, struct vm_area_struct *vma, int node); diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h index 13e9cc5490f71..f3ccff2d966cd 100644 --- a/include/linux/zsmalloc.h +++ b/include/linux/zsmalloc.h @@ -46,4 +46,6 @@ void zs_obj_read_end(struct zs_pool *pool, unsigned long = handle, void zs_obj_write(struct zs_pool *pool, unsigned long handle, void *handle_mem, size_t mem_len); =20 +extern const struct movable_operations zsmalloc_mops; + #endif diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index e4f1a122d786b..2a4a649805c11 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -253,6 +253,5 @@ const struct movable_operations balloon_mops =3D { .isolate_page =3D balloon_page_isolate, .putback_page =3D balloon_page_putback, }; -EXPORT_SYMBOL_GPL(balloon_mops); =20 #endif /* CONFIG_BALLOON_COMPACTION */ diff --git a/mm/compaction.c b/mm/compaction.c index 41fd6a1fe9a33..348eb754cb227 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,11 +114,10 @@ static unsigned long release_free_list(struct list_he= ad *freepages) } =20 #ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page, const struct movable_operations *= mops) +void __SetPageMovable(struct page *page) { VM_BUG_ON_PAGE(!PageLocked(page), page); - VM_BUG_ON_PAGE((unsigned long)mops & PAGE_MAPPING_MOVABLE, page); - page->mapping =3D (void *)((unsigned long)mops | PAGE_MAPPING_MOVABLE); + page->mapping =3D (void *)(PAGE_MAPPING_MOVABLE); } EXPORT_SYMBOL(__SetPageMovable); =20 diff --git a/mm/migrate.c b/mm/migrate.c index e307b142ab41a..fde6221562399 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include =20 #include =20 @@ -51,6 +53,27 @@ #include "internal.h" #include "swap.h" =20 +static const struct movable_operations *page_movable_ops(struct page *page) +{ + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); + + /* + * If we enable page migration for a page of a certain type by marking + * it as movable, the page type must be sticky until the page gets freed + * back to the buddy. + */ +#ifdef CONFIG_BALLOON_COMPACTION + if (PageOffline(page)) + /* Only balloon compaction sets PageOffline pages movable. */ + return &balloon_mops; +#endif /* CONFIG_BALLOON_COMPACTION */ +#if defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) + if (PageZsmalloc(page)) + return &zsmalloc_mops; +#endif /* defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) */ + return NULL; +} + /** * isolate_movable_ops_page - isolate a movable_ops page for migration * @page: The page. diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 5763f36039736..6855d9e2732d8 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -152,10 +152,9 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long = pfn) return page_zpdesc(pfn_to_page(pfn)); } =20 -static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, - const struct movable_operations *mops) +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc) { - __SetPageMovable(zpdesc_page(zpdesc), mops); + __SetPageMovable(zpdesc_page(zpdesc)); } =20 static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b12250e219bb7..4aaff7c26ea96 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1685,8 +1685,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) { @@ -1709,7 +1707,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) @@ -1819,7 +1817,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, @@ -1882,7 +1880,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 Tue Oct 7 22:50:53 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 B768C2FC01F for ; Fri, 4 Jul 2025 10:26:29 +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=1751624791; cv=none; b=GpTTIzXzZf+xJCVAX1y9lbrnY1tmImV2kPuOn1Xyfd6VNgbuTB2iCi3wDwj22tpTX5Oua4SkVINK5UtAcXN6PDHEG+hCo9jn1yFEbiDQKxobsBg1cHA7QKd713yu/ZrjscTOPXZl4x7rj94h9GAWTmSR4L0Aay2vhtFOTmyGGIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624791; c=relaxed/simple; bh=g8pdy1DKrW7JXLanGhBhAjfwcy+F0V2q4a+pmUjqPhU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aIPZavZWlVW0X3RQFcykKxxvkFXH7Kom9Q0QJ2ePF79TKeWGlVVuHUcs+XV7l55FyA5ogdNZXM/aj4bfPYFUdUWbd2BQ2GQE2XZnyFJ+IgzAR/IRUqWaeuPs3bsBp5eLYRnm9XsNnCSIsl3lmqAPmG2lCzg78A3BitzkaG0uKu0= 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=Tu+jsXLe; 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="Tu+jsXLe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624789; 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=yV5TxHJVxkcIeudKWCbk5OXSzT/72+A13Qm9FGClEWo=; b=Tu+jsXLel38g/TKneztx7wu6FQEWyMp6qWGmWB6dDbryo9i1hkrWWMZoxXp851SzC08ubt XsZ21LmTBcgADgrmjJiufL5Db2/lar++/pvtNXzLbqw2IBk/KmP1O5hMNzIfmNNiQTRnB9 wzTZUc4RDqp4JG+7ItfpK2Ek6B3Ew1Q= 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-146-w6xQHWslM56SUrki8ntdMw-1; Fri, 04 Jul 2025 06:26:27 -0400 X-MC-Unique: w6xQHWslM56SUrki8ntdMw-1 X-Mimecast-MFC-AGG-ID: w6xQHWslM56SUrki8ntdMw_1751624787 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4f6ff23ccso494926f8f.2 for ; Fri, 04 Jul 2025 03:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624786; x=1752229586; 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=yV5TxHJVxkcIeudKWCbk5OXSzT/72+A13Qm9FGClEWo=; b=AuTF0MucaHbD75hCA3v9G953PzyILgyql7xihnsH/DQAvifggkvtTOzjmH3T44Gi4q Lzk35jB3ACb8chmFYV44giksszXA1hdidkKAhxw3CRAaALXFOUlVh7vZwih+xdbxRBpX is00w2j+/ob/ezv9twF+BdyLPMrcWthLuYvF1QxxItrzG1iJ5hEcFvoHRse1VvtK4PDw pkHzWI2fC+tAY/0wBpaC7NL8zW7GSxWumZqg7Hv+jbrEAI262rnEy0s+0vxrXUIVzFj2 2Y3rjNOlbPQcOeVEQKt7BXu7EDfHrMhx5f7U0WkXkhVjlounk1f+G9bJ/NwjolHmDi+k Txkg== X-Gm-Message-State: AOJu0Ywuw38Ks9v2xKNsFv2HHWGYwHBy4I/uH4MF3PFuzUqVSMK+oQCp 7l+1owAesb+nupHUuue5AWx8ZszhGJHS+W8TtHKGSG0Bf92Ca54OS4S5gFWdwskVSmc/fSgzd8C AeFe+VSEsQuI8dkuMyNoO3LEMNhtZbFtOb0eSPqAtMF+7w7YMQjyyjSVPwQlMhzRvHYCakMavNQ e/CAIPHKCw2DBGNK2OsfMbALCCFW7ZrWmGvd3ttQquQer6Zw== X-Gm-Gg: ASbGncuGlF6V77BGuUhBDBRQvMmxcLytfsTy01azIp8KEzn1AiGn4DqvxuYYSrMbHnM SkY4mPgb9VGACjVYzjqwslUmRaf91VB/lCjBYw/k3PlMe5NKIx2+KwuhoA5g4KMsCVDf7xFhSn1 9GbuzjdjnYbFUIvdrNrh2dtuPB/Y75jEoGVWuAoAfwwb5PIv92hVhtnO25hii+TwDEYRYZYVBsD wZydSMPhIruS7GCGeqESppYW7IXODxSVe37Zg6MvZHEGxwWDnXKfPoDZYiEPjJzXoyiJ8RRqO3J 9j13kBh+o7oKF3b7m7rRsUlPus5soMYDrvIltRauqcOHcC/dVKKUqJExlBffML5Ht2KkGjuTjIS +oKpFSQ== X-Received: by 2002:a05:6000:250f:b0:3a4:ebc2:d6ec with SMTP id ffacd0b85a97d-3b4964f8b3cmr1912208f8f.14.1751624786435; Fri, 04 Jul 2025 03:26:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYzN00fFm73NixytzJyssEXPIKOjCSlRb2NM6DBPHsu+yzHnAEmiJul0LvFdC9y1xbNexZhg== X-Received: by 2002:a05:6000:250f:b0:3a4:ebc2:d6ec with SMTP id ffacd0b85a97d-3b4964f8b3cmr1912120f8f.14.1751624785787; Fri, 04 Jul 2025 03:26:25 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b4708d0aebsm2166371f8f.37.2025.07.04.03.26.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:25 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 20/29] mm: convert "movable" flag in page->mapping to a page flag Date: Fri, 4 Jul 2025 12:25:14 +0200 Message-ID: <20250704102524.326966-21-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. We are reusing PG_uptodate, that is for example used to track file system state and does not apply to movable_ops pages. So warning in case it is set in page_has_movable_ops() on other page types could result in false-positive warnings. Likely we could set the bit using a non-atomic update: in contrast to page->mapping, we could have others trying to update the flags concurrently when trying to lock the folio. In isolate_movable_ops_page(), we already take care of that by checking if the page has movable_ops before locking it. Let's start with the atomic variant, we could later switch to the non-atomic variant once we are sure other cases are similarly fine. Once we perform the switch, we'll have to introduce __SETPAGEFLAG_NOOP(). Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Signed-off-by: David Hildenbrand --- include/linux/balloon_compaction.h | 2 +- include/linux/migrate.h | 8 ----- include/linux/page-flags.h | 54 ++++++++++++++++++++++++------ mm/compaction.c | 6 ---- mm/zpdesc.h | 2 +- 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_com= paction.h index a8a1706cc56f3..b222b0737c466 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -92,7 +92,7 @@ static inline void balloon_page_insert(struct balloon_dev= _info *balloon, struct page *page) { __SetPageOffline(page); - __SetPageMovable(page); + SetPageMovableOps(page); set_page_private(page, (unsigned long)balloon); list_add(&page->lru, &balloon->pages); } diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 6aece3f3c8be8..acadd41e0b5cf 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -103,14 +103,6 @@ static inline int migrate_huge_page_move_mapping(struc= t address_space *mapping, =20 #endif /* CONFIG_MIGRATION */ =20 -#ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page); -#else -static inline void __SetPageMovable(struct page *page) -{ -} -#endif - #ifdef CONFIG_NUMA_BALANCING int migrate_misplaced_folio_prepare(struct folio *folio, struct vm_area_struct *vma, int node); diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4c27ebb689e3c..5f2b570735852 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,45 @@ 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. + */ +TESTPAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL); +SETPAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL); +#else /* !CONFIG_MIGRATION */ +TESTPAGEFLAG_FALSE(MovableOps, movable_ops); +SETPAGEFLAG_NOOP(MovableOps, movable_ops); +#endif /* CONFIG_MIGRATION */ + +/** + * page_has_movable_ops - test for a movable_ops page + * @page The page to test. + * + * Test whether this is a movable_ops page. Such pages will stay that + * way until freed. + * + * Returns true if this is a movable_ops page, otherwise false. + */ +static inline bool page_has_movable_ops(const struct page *page) +{ + return PageMovableOps(page) && + (PageOffline(page) || PageZsmalloc(page)); +} + static __always_inline int PageAnonExclusive(const struct page *page) { VM_BUG_ON_PGFLAGS(!PageAnon(page), page); diff --git a/mm/compaction.c b/mm/compaction.c index 348eb754cb227..349f4ea0ec3e5 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,12 +114,6 @@ static unsigned long release_free_list(struct list_hea= d *freepages) } =20 #ifdef CONFIG_COMPACTION -void __SetPageMovable(struct page *page) -{ - VM_BUG_ON_PAGE(!PageLocked(page), page); - page->mapping =3D (void *)(PAGE_MAPPING_MOVABLE); -} -EXPORT_SYMBOL(__SetPageMovable); =20 /* Do not skip compaction more than 64 times */ #define COMPACT_MAX_DEFER_SHIFT 6 diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 6855d9e2732d8..25bf5ea0beb83 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -154,7 +154,7 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long p= fn) =20 static inline void __zpdesc_set_movable(struct zpdesc *zpdesc) { - __SetPageMovable(zpdesc_page(zpdesc)); + SetPageMovableOps(zpdesc_page(zpdesc)); } =20 static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 439A92FC3C9 for ; Fri, 4 Jul 2025 10:26:32 +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=1751624794; cv=none; b=VlYT22TxIrotRgaR3wHzSPzZO3SxrCkktNoXZhLZKSGeOehmxptbRyctHlQeWCvXHiFpBiQwMnzcUFJ3VxhzpZMUbOm5cOWCQ5D+F2QS2rr0HDGgf2fSncBZt/ZnFVFbPCZUH4ep76YEgi8IQOL+mo4t9PDQnkYkmYcX8lBKuKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624794; c=relaxed/simple; bh=jqBiKE3ljFPLtpUV52bcJzPXSrwMCijt0l7mZnej4RU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aBULW5ucalseuu/scWLN1uKaJYvnIbOgXgD/ZV4UEGjFQTitaD9t6OzSw+jlT7+O+LQ0I2UVmX3shJ912dlebeIGVIYcp+BFWbTmPFu7LjAqqa9R+eOKYATnBB5OQgf1tfTGDROFugTwZ0/Gpa4g/UxBf9WChEab1zVEww3gsUc= 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=JMfYfOfh; 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="JMfYfOfh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624791; 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=oIfhqplW92Whs4rQ5a+bzpcvmYNnoFDclaHeGz5GfJE=; b=JMfYfOfhNVuRV1MugkJIuX9/kuuZAB/gpWi9jgYRhx6vYVxzzw8jhgd+amM6GzHJuWHS6o H45OCIAnk/qLYC+wJD8tAynrtBc8mBEn+ioWyfLV51t/MkozZvuuWg7nyVlEUV1W/cg2RZ 07Pl9WPIb7I0L+wVCXvIpEGDbgGbyKQ= 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-252-a7P2cLmWMciLbKEmY2ykbw-1; Fri, 04 Jul 2025 06:26:30 -0400 X-MC-Unique: a7P2cLmWMciLbKEmY2ykbw-1 X-Mimecast-MFC-AGG-ID: a7P2cLmWMciLbKEmY2ykbw_1751624789 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-454acc74f22so5106355e9.2 for ; Fri, 04 Jul 2025 03:26:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624789; x=1752229589; 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=oIfhqplW92Whs4rQ5a+bzpcvmYNnoFDclaHeGz5GfJE=; b=rpZSoJ6eNIyTWtnC39cLOimgkvi82Gwi6IcS5UNkSBMhygwPF2iSiMWJ7nlN+mdwfh 46Ewiz4wW3auNdYON9XwWhxPs0V2mCM1Y2+zZnM83fAPAC/FnywWLgDNra2aX2JY/sOo +UgK+XoXMN5+BcQGOopN6NOl6/EBHSXr2guodnxJjUqXCxcyy4Ro+O9DOLTVJnQkr5W8 HysaZJD7mdKYFQrEM9GgfK1ykgpvWSZT43ZU8qu2IffHG7MKZn8ZcqndJFEQ2XRqZYeC nkgSBZCLH91dUHREumZPNN3Ky7KfdGhxoWtfXdwQISZ5MAS6r2SxfFcHb0KUJXkfH9AP CveA== X-Gm-Message-State: AOJu0YxVj6kTomQ6YRjRzCwrcukh10qIEx8mSZsRKNezujDqDaYBgbxC 91CyeSF6HrLZBLFPSUQdSQRZt8tPkWLbIef7/QgC6725rgdNc/mmDkJdrYA/H29iFQ9xC0DwJ0R DiOMKn/q7UdBGIPMLGW0d+ZyZQFki4njp7GmvhT9Y4CAWi3qKdiob9Y8/6KuvcGTxQziz5Y+16d 2AvfnVQiTMsZCxLbFa2tAPzO2Wac5zxFMQA3XiGbKdBICXWA== X-Gm-Gg: ASbGncsKFzW28wRz0ozz3e8dyiMD81YGNuyPqQ6LRbiHgzZRd8dY/mqdIoiO/P3UOwP LTWyWmucmghWhn4fOW81dVhBr9n0jIdIzWjc1C5W2GABG69HbpieJNAU3sTLv7dQ0ypOJ/l0Zbv qOIw00P3KWTGJdTlLBANROGRY1xzRc1LgjCvVIkvtEdYLgFv4LTA5mpRuadVzOZ+yfGryC5JUiv p0k1ut9xmOFo8p2iVPKWnpSt6WbYw7mRPnlriqAwygtXmEu5CbN7rS45OQelo0Ra4SP9pVA6N/4 aCoSvZS4wU7hfUfS0e/SK60Ap0Hlz4AfHGOXQn/L66XotgMIytTQQbmZEsaSEt/i9INgkXMGonh 3TXs6Ig== X-Received: by 2002:a05:6000:3ce:b0:3b2:ef53:5818 with SMTP id ffacd0b85a97d-3b4964eb1dfmr1524574f8f.5.1751624788992; Fri, 04 Jul 2025 03:26:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6/dh0H9/LpgMHN6+E5K8aCm2QgibuKB8jFRjnybENn7lard2NaLBEO46u6eT1pnDUCzj4ag== X-Received: by 2002:a05:6000:3ce:b0:3b2:ef53:5818 with SMTP id ffacd0b85a97d-3b4964eb1dfmr1524493f8f.5.1751624788372; Fri, 04 Jul 2025 03:26:28 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454a9bde954sm50967885e9.33.2025.07.04.03.26.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 21/29] mm: rename PG_isolated to PG_movable_ops_isolated Date: Fri, 4 Jul 2025 12:25:15 +0200 Message-ID: <20250704102524.326966-22-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's rename the flag to make it clearer where it applies (not folios ...). While at it, define the flag only with CONFIG_MIGRATION. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 5f2b570735852..8b0e5c7371e67 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 @@ -1147,9 +1144,18 @@ PAGEFLAG(Isolated, isolated, PF_ANY); */ TESTPAGEFLAG(MovableOps, movable_ops, PF_NO_TAIL); SETPAGEFLAG(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 /* !CONFIG_MIGRATION */ TESTPAGEFLAG_FALSE(MovableOps, movable_ops); SETPAGEFLAG_NOOP(MovableOps, movable_ops); +PAGEFLAG_FALSE(MovableOpsIsolated, movable_ops_isolated); #endif /* CONFIG_MIGRATION */ =20 /** diff --git a/mm/compaction.c b/mm/compaction.c index 349f4ea0ec3e5..bf021b31c7ece 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1051,7 +1051,7 @@ isolate_migratepages_block(struct compact_control *cc= , unsigned long low_pfn, if (!PageLRU(page)) { /* Isolation code will deal with any races. */ if (unlikely(page_has_movable_ops(page)) && - !PageIsolated(page)) { + !PageMovableOpsIsolated(page)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); locked =3D NULL; diff --git a/mm/migrate.c b/mm/migrate.c index fde6221562399..7fd3d38410c42 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 Tue Oct 7 22:50:53 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 0797B2FCE1C for ; Fri, 4 Jul 2025 10:26: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=1751624796; cv=none; b=iNfrQdnPyTgEZBdfMsDvN8ALCXpI1YmbqlqFkqoLSGKkktcUPT8FJa5Vy6tuEXPGNMttEk+SJM86v+8LVhFVavYqJaGZkOXozsMsUtR5EzkewAcf3njLeGGo0/9+bSFM4PUG5m1PlEfQkLhjLJbp2UJO+oDxfQtSKHxjSdDcBXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624796; c=relaxed/simple; bh=pHyy8UC6aDtzrad/rUQe1SyqR3fae/2pllZmxoCrbEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rBt0EqJgSQhBNXikqvb4+zzNjGMudyzJ+aypRXr/ljF+B7heeBUzVKsmHJqmqgw754K3hMv06fYQ/s2rFFkk+Bn1mLLfFhiTmxedwHYaeYNsX4YSQmhbtrHk02NS6oHE1eXud44FVQdWXqRzoof8Dul0Z81u0z6OGcHReGgpjeg= 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=GNsUcNcQ; 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="GNsUcNcQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624794; 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=Pi83bTeEFwDlpM8pJuM4mqXwpOj3VH8gXnt6oQN+QH8=; b=GNsUcNcQpY1m2me+d0hH+J0RNWvi7Wr3zHKamu2rSkbtohJRrZhi3j6CABfFIUdIUNQiKx v2RoJ6JthDd9IBos3XpAhf8gNK120b8Q9L9MLkHfmpzjq2jqegSPPLNG3/DJ0vlaqa7Brn 2Dhp9J68Ytb/KWhmIPQ58BT9R06bKgU= 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-256-GWgS70NhOpu2tz2KV8lxPw-1; Fri, 04 Jul 2025 06:26:32 -0400 X-MC-Unique: GWgS70NhOpu2tz2KV8lxPw-1 X-Mimecast-MFC-AGG-ID: GWgS70NhOpu2tz2KV8lxPw_1751624792 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a4e713e05bso317752f8f.3 for ; Fri, 04 Jul 2025 03:26:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624792; x=1752229592; 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=Pi83bTeEFwDlpM8pJuM4mqXwpOj3VH8gXnt6oQN+QH8=; b=U3uE6Z57eJD6gAxKjiNYXp7DQ7qDYjiutgfFPNzIW36UKNosG1bIg4HF3vWNFjzMz6 BJcTXGs7MxWT5FZMwdgfY4p18LBzPRNfjpl9XgE3OG3X3Hp4aPJwmC9/c+WPVY4GCseQ PJcDx4j9fNlbcksY3VXEYprf5ZxfJU+EVDMDODYU+gj0OdEXWh9wFGxEOMgpCREs1GzL 8EBHa+x2U/zcK9JYDsWUAZSuaB5SGIg7jEMpKFGKE3+dqld46Vfw9M6cWQkqu55o4KoR A0sSCxTawHB8u6ce8ryr+3X339lvQpSscKEB65hFHrf0/TV+hVp5bTx39my71VsJ7Qkp cj3Q== X-Gm-Message-State: AOJu0YwQX/r3o7ivY5D5lbrrGfC1M92KPnetPDYY4Yw/6PKkViDlfrg7 0GeTspC0T+b8nvVRRee0XWavk2GzxUD1yylhJPfEsXTY3QoWWIgyJ9hPDX5tShfMi6QNEUNb+Gk 6tFZjbIIniXxMngDEMpFJ+FZPw3x8t4V7ARzWCgkl3hqdhbPHlO0u5Xvnj3pUIFS53f6aYS/XHA /LD5EW4+JUJ/aNWDVq+H0hXM/TR9T2QWZ3C1llEpBHhLvhXQ== X-Gm-Gg: ASbGncuXbxdNi7nPaGJq/lVIyqB2c+rik0NBGC3sQxAxVW94yXw+qaPTLYzaxxJR2Tg u67fFzsuldibrVPzjZAZsp6iTa9SLLCT7tfUBIG0Bqt8VUBzHawr6FH/BCWSi+7PIrMkmJMgSpC F6tl1nS9nosn+5+LbZacjEDQ5ln6HgfQsFsE3csDQ7gTCMIfwzgJJZJcctGrx31C47RKyh0Rgri eM+icYDu4gFTFdqGDjkeIErHN1KwD2bRYUefoSnobyNwSXtYxsq0Rfn8ONiQEU0d5M9KQl+S7ls VUXhdgASCbhvTRcFGhvIdieybMeDajz8I9gGiygp26h8offZzAyJYilcS8iee1jAfaLkU54Mxtx /viyKSQ== X-Received: by 2002:a05:6000:420f:b0:3a5:25e0:ab53 with SMTP id ffacd0b85a97d-3b497038f53mr1271136f8f.32.1751624791658; Fri, 04 Jul 2025 03:26:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrTbC9DKT0t3aMKhVtx8nltW/QfximYUsOEu1FNJGdEflOepjIkffBp71QlqU0uLEDVp5xtw== X-Received: by 2002:a05:6000:420f:b0:3a5:25e0:ab53 with SMTP id ffacd0b85a97d-3b497038f53mr1271044f8f.32.1751624790899; Fri, 04 Jul 2025 03:26:30 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b471b97732sm2167298f8f.59.2025.07.04.03.26.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:30 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 22/29] mm/page-flags: rename PAGE_MAPPING_MOVABLE to PAGE_MAPPING_ANON_KSM Date: Fri, 4 Jul 2025 12:25:16 +0200 Message-ID: <20250704102524.326966-23-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" KSM is the only remaining user, let's rename the flag. While at it, adjust to remaining page -> folio in the doc. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 8b0e5c7371e67..094c8605a879e 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 Tue Oct 7 22:50:53 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 7635A2FCE38 for ; Fri, 4 Jul 2025 10:26:37 +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=1751624799; cv=none; b=R7XXNA46QsrZU1uLBQdxQJ/oeLdfC9M42WO7HKv5A/KsSbbiodjnldbejzQL5igUUFhVE/jfX6t7WL2AOuf+mxUYnX3g7/9QlpBKo0Ce2HmmTzhOL5kmxd8tA8Oajlm/7UJEadKMWhqiEutNLYCr7syrq3/OvtW1wRdZbahaXaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624799; c=relaxed/simple; bh=s9je96qO6r5yAAE/tRQstaImZtvw0D0SBMiOehTSPeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ifUGa2MIEbw9Jlcnqujo86cffpztFZKEJgbg2GEw5LA/vouZxW/Z2uJ+SdRg25UZmFXlHdy6IcJB145NOMGheHIjh5bHmxudq79s+0zpavWAy/96hPbaGhQbeQe8DWSsaIoe7/4s3AYdRHACals2ccto50uH4ekYykKazuYQ2bA= 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=Eb0leDh3; 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="Eb0leDh3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624796; 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=fs/e8+Swpq2YGTbmX8ig9Uwxi9FIgSmYum8BwX+79CI=; b=Eb0leDh3vnxoajmPejIxQqniasqUmcEQXIYNzfZQ5dtpcZNcgqQfzDvdlZhxHO3XPgEJvC D4vuRydR/ySvMiQSwHZNyhvcS64GYZhcNPmpVtfYGbpdDvGAiVxc12123VzU3MJg7tpXNV OwlxsJ0de8u6JpljIkteFlzY3/K/jvc= 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-204-ThCyvK29M_a-Go_lQcQm7g-1; Fri, 04 Jul 2025 06:26:35 -0400 X-MC-Unique: ThCyvK29M_a-Go_lQcQm7g-1 X-Mimecast-MFC-AGG-ID: ThCyvK29M_a-Go_lQcQm7g_1751624794 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4f65a705dso452080f8f.2 for ; Fri, 04 Jul 2025 03:26:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624794; x=1752229594; 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=fs/e8+Swpq2YGTbmX8ig9Uwxi9FIgSmYum8BwX+79CI=; b=VOwwJl/UUPCDB6fzoixjuXiHUJEE2yD1N77vBctCrMUaHsIfaCI3ICXLXfG0LAblYG UadamWK/HLcZin2rfE4tlIApkdLjUtosbwcFqgZ4XLcXC3TLQZcexTNC/Rd8jwJadI9c 6Nm+zx4UE1vijVQTPtlZEVE0rFtTL4JilL7jHRLu2godrWmFa0cIIPGBem32XQbqspIg bKgw9nu4lQbcI4rWcztbhPXIa5eumnPImQidQhkUnnMleBnePN3B5QuhPm7Jbg0Bqi/5 sWKwWARzcZlFqVeeFdpbKPasCwAwAqpfnxR4hS2tfC/PRkMBjPsbJRKgTG/SAUSmDoil zNpg== X-Gm-Message-State: AOJu0YzCJKC1bjbqSMFJ3Y+wPICv7X7y4iDt+l+3XoJpEEl/TgIVR/UF q88AxRoyKO4x/0zqOTcUaIZRXim9FC6gDIxs0osUxGcaDAs7M86Nr1WPw4Z4DaOsKA3fS/uxf8k uK0QsbHORH2Vg7E6HqmPy0qaVEk0kw8QS4neY4TqKBOhMJ6IIG7kZXPBlKZMCRGnlNqF19CCYH5 E+d0QQx9LQ70vT0m60Jk0nEgE2CBcaeN2xDlnDA8WsLHAjVQ== X-Gm-Gg: ASbGnctFNQ3W+kxWGB2BxR5rnlGt3AJzsB/MEIVsFlHauCxZBh4xPbfQGy7NZrUJhWi OoXzLgu0ovF+mz4p8Aqu9lCbSOSqRztXh+1e0+ALh0Q7Ese72z/2hZq1mB96LTptQ882YyjLSsf eBIR7pvPmVPSl42R/k0d+iHFMQ9DekltdwvE2QgrSb65BXoAqv+ihCKh0neMos0GnqWNWtgvN43 clXRZr3Ml+p4qcWS+Hxc1z12rzu94dxBOmBza727Wr7SYcM80xA8ROiIqMVz/4NPl08gFRybVnu i8rVxWf7mec4l6FHWAm13PkWIpsTh4L6hm2eJOtrlBVPfmZOyleytjgySN+NwiO3//MtIJQ2KaC kT0nlkA== X-Received: by 2002:a05:6000:24c9:b0:3a4:e667:922e with SMTP id ffacd0b85a97d-3b49700c540mr1015648f8f.4.1751624794143; Fri, 04 Jul 2025 03:26:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFv4//fTRSt2GT11U1TkRjsS9jXLC3kcU+xe7g60I+SsSxP4GVJGQoWX7WuUGQypypw/2H7pw== X-Received: by 2002:a05:6000:24c9:b0:3a4:e667:922e with SMTP id ffacd0b85a97d-3b49700c540mr1015567f8f.4.1751624793449; Fri, 04 Jul 2025 03:26:33 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47285c6c9sm2093397f8f.89.2025.07.04.03.26.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 23/29] mm/page-alloc: remove PageMappingFlags() Date: Fri, 4 Jul 2025 12:25:17 +0200 Message-ID: <20250704102524.326966-24-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As PageMappingFlags() now only indicates anon (incl. KSM) folios, we can now simply check for PageAnon() and remove PageMappingFlags(). ... and while at it, use the folio instead and operate on folio->mapping. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 094c8605a879e..fc159fa945351 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 4aefeb2ae927f..78ddf1d43c6c1 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))) /* Reset the page_type (which overlays _mapcount) */ --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 7283B2FD583 for ; Fri, 4 Jul 2025 10:26:40 +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=1751624802; cv=none; b=WbOaK3vRrhb1AAIpNxewibiHejbmWj605yX31ieiW6TTd/3E6bR3RY7wh31z3bdLtM3gItptOJKfsOmQsg5DYYsQABY4OcrQ/PUjnUHGV1gQX+Wdf8Iezceaic0k2RAH8ep/ZGsUZYMntrptfFlh+4lNod1MlSpmjlPQv35J7Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624802; c=relaxed/simple; bh=1ETQVwTWSzuFM96Cj9uVjywNtHELv/PpY51PqKnqH4A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bImSxQVEc1pYe5Bg+FsDSbNUYCYVyOdVyXed98iPMdQbO3MZRfsmG55aPT3+18HInNH3xscrnHfHp8kzccrAnhILGVoEa1RCrruIiJiG7m7iOn+K4koyAAHyiDuoCgzSeDHhbSe3+kQ9rPm0LXLvr3afaFIPmyOVWjL10QHbPKA= 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=Kg4WjpIM; 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="Kg4WjpIM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624799; 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=NiR5g77+dfB6TjFQFOB3xNqG4FRd5Im1/1G4CsJHDLI=; b=Kg4WjpIMmyvlE3jnyoCcv6dY3XDVGNFEgMH1Vh35GzAeJyqKV+U5H+651dttLpSrVFnLDE TbxgyuiZSbOLm2N7/eRsvRpZ4NNh0tvq2mTbucxLVIBYV3mcYnATFP1ajjaJxhtMB/j29y y4P3dMBmgmQBO9M3RYvi4NB5/XzY6rQ= 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-66-S3rV3uSwO7eaTur2rVt0Dg-1; Fri, 04 Jul 2025 06:26:38 -0400 X-MC-Unique: S3rV3uSwO7eaTur2rVt0Dg-1 X-Mimecast-MFC-AGG-ID: S3rV3uSwO7eaTur2rVt0Dg_1751624797 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a4f858bc5eso538347f8f.0 for ; Fri, 04 Jul 2025 03:26:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624797; x=1752229597; 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=NiR5g77+dfB6TjFQFOB3xNqG4FRd5Im1/1G4CsJHDLI=; b=ICbkqX5AO/LOTFPJno9giFZioz0bEiAOGGEFw+JhBrzWptf+9qgWDce8Kb3hxeJ3Tv Q1tcOOGS4ilmbZ012p5wOI1D5De7oLgxaZwjO6erFYMMzOfikbSz5CgLE2KRn1cR0P8h sCWB1iStGYop5G5odSWFBZ94Kqk5u9O2+gXzcKRDClD+E6yEKjgzY0hSR1q7jVcP8q3g bYvDXs0FZVHt9beBI5aVSOGH6owDfafhxr6OHPeqNnTYzqgF78hiYpPKJ3cF+gb26SQ8 0kmby360OJmkE48TgZHOp/ER5EOQrx/McwyuMAEVCzJPs6dkcJ/GY+dAXajl0e57IRp3 0NKA== X-Gm-Message-State: AOJu0Yx/7DNVEPmRmVJksiHZPcQanLHkOA3i7EI6gi7NHyP1ilRJoX4a lnDfNHx10/JvnMgPU+tHIhS/lUOkd7ekXMhdQDLjJkcKI8AS030HPA+VeJoB5U3sxvAWmYYhS7C btTNl5x+wqTMzU5AA2l0QcuAZjFoqE/PsNdGDJZTqACFIXyb8n6Lqkd8RozinZtv+ppVazay9z8 Sh4w4qzNuKuJV+zz0Glnr32P6efg+NQuFlnbNK54XhP6Rimw== X-Gm-Gg: ASbGncsprPs/0Nf7YzmTvWg/IvA7AmSRrJdBkQ3q+wQq0E3jj/PVTSALOElzvwEozl5 wfJV1Kx2lGZa7GzviXJFMpUsz/OwkvoutiZW95HHrA45KltiJ6gEwnKcdU0zCecuS999iUDyvvz Vun7dW2VmAUxFS0EqSzgQYsJzmGyf0JCvuVt/E0EOP5sSUXXcbn00IvDnJXuSxG49V6zM85PllR BJ60ua+q+PWKlTLPePvBL85DZ0WY+7a5hl649VmSU4p6CAdjbzjOMrNej3LicheJYzk3t9/6vux EtzHJH+RvWwx+k+hQHTExSGjs2+l8bZPrBtTZP5mtFTLU+99S5Ga6eL6QaoHNOQo33I+9Ihn1Ud +XJuEtA== X-Received: by 2002:a05:6000:2112:b0:3a4:ec23:dba5 with SMTP id ffacd0b85a97d-3b49700c571mr954086f8f.5.1751624797091; Fri, 04 Jul 2025 03:26:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtfbiTuj+217pme6OFEkgrGo09w9YBtXxahiaI+UfZ531v1EH5FnBXh5DrYfR2GN/01q/x/g== X-Received: by 2002:a05:6000:2112:b0:3a4:ec23:dba5 with SMTP id ffacd0b85a97d-3b49700c571mr954008f8f.5.1751624796346; Fri, 04 Jul 2025 03:26:36 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47225985csm2148740f8f.69.2025.07.04.03.26.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26: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 v2 24/29] mm/page-flags: remove folio_mapping_flags() Date: Fri, 4 Jul 2025 12:25:18 +0200 Message-ID: <20250704102524.326966-25-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It's unused and the page counterpart is gone, so let's remove it. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 fc159fa945351..e575ecf880e59 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 Tue Oct 7 22:50:53 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 119A72FD5AD for ; Fri, 4 Jul 2025 10:26: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=1751624804; cv=none; b=oLYnn6EL4MOb1p6IP5G6LhQzv4V2XE/+n5rRF2F/jcYlEpN7wLCkE96+Gi5XW4hBo4UVGqZzOtg3UF4FvbM78CD7ao9E1bTV7Cp0e5JKfcGpjN0kDRgoQoBiH8KfcE0tQhpdkYPWa8xGOtr+QyYfJXq6BhK+ahBVOHbWnUiYDN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624804; c=relaxed/simple; bh=E7QNy7Hdv+Y8vIwxIlhZiDTu7KEk+npvDBgCx+4vSO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AjFJ4jKizMtgYgLRpPpAWdjgiHRPAeK0jW6+HlpE2a8QlZHphgBgSTQlVPf/6ee3E2Mt+7wrLAMQrOYHBbv/1BKkIyMmLBOw7EHbWZCE3zykL64MTftQRjHeoPtyoMFVPF3bNOFo2rTzgVo4rf4wEbilYBPtqLVwoJsSpLK2Y8k= 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=VxjtwtOB; 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="VxjtwtOB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624802; 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=PJaNSOUY9l76maSUsyNVNOCD+/VPGSxzGfUbWAq4maw=; b=VxjtwtOB/X0IPPDaEVLwvXMHqPwLNLrRmwpUZbId9BrF/qjVx2YryyyxEg0D+cLxo53Ypk JqmkolI65KN/x4mWLQKB6xIa+n793QJJWffDIoX5gkS2VFo3Wr5NxAQcyNGzIn5VOsW540 enaT1QBFoQyBwuU+8klWU3rn3K9yUgA= 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-616-rWOFYEoePeKlQrLPzx7qbA-1; Fri, 04 Jul 2025 06:26:41 -0400 X-MC-Unique: rWOFYEoePeKlQrLPzx7qbA-1 X-Mimecast-MFC-AGG-ID: rWOFYEoePeKlQrLPzx7qbA_1751624800 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450db029f2aso3495655e9.3 for ; Fri, 04 Jul 2025 03:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624800; x=1752229600; 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=PJaNSOUY9l76maSUsyNVNOCD+/VPGSxzGfUbWAq4maw=; b=gs5JxXdUVvMDusWqZW3ZG7+tJelmd/Dfaa2f/K6+6vNwH8Zhwm7izHZV0A0OelTSaY EiFMo37VODZaLapaiyLqrhfCiQiFXVO1hAB897vYhJUgF7L5cH4f+KoV6Zj0KOLw0eJX 5IhQz+kpsck0DAFG8SZ8MapoQfGvnnaYZpuwyAcSOU4J/At0Ip+Ih/Vj++8dFt3tjV0G 6OdZA+zYP37fCk3oOEEf0cDKU4oNzgRyrrVJsUW1Q+oBfmubqFwej9x+dF6+vSWNucMu mDO51Opd4dgIxiIzdMUhlUPh/X9pinG96Iv5hH1L9C+VnjDbXRo5BKB3yi5QiRwyYHgP M9IQ== X-Gm-Message-State: AOJu0Ywlvk6OEvTIgEr0nqXK+tw2Y35qEO7BlyumItCbzk6nno/33SKw cxjdMAZ4HSNi3x6bRfTUGSPSvGXfuPLGncWX0aJdT/njuRGnAVoUWEH0Ipwgv5LspbaPNHethFB KrHcj7QLHH8MGIYMOdorD+OQYW8x9gze1EMoRKK2y/eNLYaOBstO06FnhOON9/FxhD9j3/gWBdr zCbGuT7GO2VRKep8wwV0/IjeCqCcpyHDT7RmFC8YzKeDdSZA== X-Gm-Gg: ASbGncu3hEt514kCVK977R/iTGopsYf3k1pvAauMDvBVaw1fAb+MTNgxthDoXtPyQWC hNJ99GgrGziVHB2/BSpDUSrnkAd44z4ytGatgAGBCM9QEMqrFRFKu6DmUOnvrTzogX6Y7OCWV0g 88/VjIH5bYuAQPMsNgmNGMg2tDCjV2Cr/+52HD7tlRHCHAMn/OuaniWnEDZI32MMs/gj4Svp8B5 ux8nFpTQQL9Hri7wZwkHTytHdlJOewQIOn6fMLOqn7Rkvi2NgF5lvk8a5KIZP+giar0dJmE2SFb PPBxPGEez4RmfKHz+zPPUYgtEf+roeUQPj33mzfEDcopPkVVcM5+9x0/FCEqpzxWZp+GkrwzNR4 GqXYHyg== X-Received: by 2002:a05:6000:24c1:b0:3a1:f564:cd9d with SMTP id ffacd0b85a97d-3b4964dbbcemr1548432f8f.36.1751624799879; Fri, 04 Jul 2025 03:26:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG//N9DaWJpqR05PkmLCvqepmh6sjEbIjzOMJ6H89vpgrAi3DitTSNnZ5FWKxlekTJwwx1oMQ== X-Received: by 2002:a05:6000:24c1:b0:3a1:f564:cd9d with SMTP id ffacd0b85a97d-3b4964dbbcemr1548348f8f.36.1751624799228; Fri, 04 Jul 2025 03:26:39 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454b1628d6csm23008015e9.10.2025.07.04.03.26.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:38 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 25/29] mm: simplify folio_expected_ref_count() Date: Fri, 4 Jul 2025 12:25:19 +0200 Message-ID: <20250704102524.326966-26-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that PAGE_MAPPING_MOVABLE is gone, we can simplify and rely on the folio_test_anon() test only. ... but staring at the users, this function should never even have been called on movable_ops pages. E.g., * __buffer_migrate_folio() does not make sense for them * folio_migrate_mapping() does not make sense for them * migrate_huge_page_move_mapping() does not make sense for them * __migrate_folio() does not make sense for them * ... and khugepaged should never stumble over them Let's simply refuse typed pages (which includes slab) except hugetlb, and WARN. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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 ef40f68c1183d..805108d7bbc31 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 Tue Oct 7 22:50:53 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 1C1E72FD875 for ; Fri, 4 Jul 2025 10:26:46 +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=1751624808; cv=none; b=N6jkNGIgmIZUBekhPN1aaCbaLPCkXGskeY+qZo0MqCTXlqmSX18C0r9b0ZADHveGaVJeQnWGQW8952B+V5dWc9xLP0nvPE2nXK4XvejHNkpW62vI1VwUIUn/JcYPSz5GlMrDk2os0h61S4OHizq6b2YkH1D3XLAE6zDpfK/8+lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624808; c=relaxed/simple; bh=vLPZe/AETOSx+MqNKvXX8AgfD+g/9x5PZ18a44XXkJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YpEDmXAMp2EE1UdswsVMAG0eEdENq1MOXB9VcBSiJAEYa7p7wpVHjBLON5sgrF8VOs4WsEDemFbKeC760K0WLCOYEIoj1B36TdNhYrherHMK9Heo7z/Hk7dk+lO5YMg/ihbNcMzVjEZi99Q7EHtx8Xq4aEPzL0GctP7HlIxcHuU= 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=EMi/HW9/; 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="EMi/HW9/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624805; 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=WbsxMz4pnUtjte7Dwwcfz26G/fUwTmSxga2gzR0g2S8=; b=EMi/HW9/MjVS20D6rtQwx2vp3VctFTNvDSdYrHz5KTYa0Ye5AjfsWn/C9YY0442rjnQ5hI OhDILQriBijMaZSvekV3EzkY1hFPttFdeVDdzuH+l51P+jQauqYnZAflaD0hUnAxdQWkOm 83QzkKzIvQ+2FQ9FfwW2Yk1Gk1jDy60= 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-184-2bP78L_6M1aOYB3q4zLTww-1; Fri, 04 Jul 2025 06:26:44 -0400 X-MC-Unique: 2bP78L_6M1aOYB3q4zLTww-1 X-Mimecast-MFC-AGG-ID: 2bP78L_6M1aOYB3q4zLTww_1751624803 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-451ecc3be97so3903225e9.0 for ; Fri, 04 Jul 2025 03:26:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624803; x=1752229603; 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=WbsxMz4pnUtjte7Dwwcfz26G/fUwTmSxga2gzR0g2S8=; b=YOAoJawJOBjOVayLp71ADpoL9a7BuhapGLHKOxYCCucF2JIdAP2w5cwh0J8skb2QiS ct4RxL1Og6xJffHO6caI3E9VaP0RtuAm3Rf/Ld5h0/aXxet71g5/Y81xFxaRKL/rnsIl jvCTLh99RZqlSnMGfuP8CcX/pTcDXoTtLczjC2TF0mM6YGU5mrT0ZICuax8+01xiXxi3 re0J9vsap1hvtzptnSrb5l1aM+p0jFjn4SniVE4woHgehopPUrFSrKEzRFVxTymCPh6c c1zbuJMexnp7vLWKUx2l1kEU2Yuo5Q4M6o42PVHogU5cPaBqX07RreYhRTkEY/WvQUPT PEag== X-Gm-Message-State: AOJu0YxUILzFCoVUKePzAxt8hNT8K++BNVzucVGTfR3iBmrP5M4sG3WU RLQaWUQjdCnBAm5fgOcouwUAAep+lDEgK0ZQZwoF7OoTTRne6OH9vG/sJzaUodqKhrMH801aT5a kdJQvtkWpZfhEj16NGnntRFsQnzajUtpeJyInwfzM28J7rOUHV5fxKk4hJAV4AVQlDC1cOGnrIk HB//TsTmEYfk7CmC8gXWTHkXT0O/edtgsyQSczttWV2JstJA== X-Gm-Gg: ASbGncs2ESaiItPXu1G6e4+1g6HdJ8Z+odTduz/n0UInr8bgakosCOLBbR0D0OiREuT wv7IiMxRepUv8cJv6lTwEl6YrrB3p++i0QVuZ4jhLfhHXIQlecg5jtL4pbnqj9BmI4MYIrxh03b SQroQmuIyg5yWoS/NwXyql69+uObBdulJLe5pBQtzVDDEZZX8VTO7olLQ39/txP5tjD99VKFXMj yZiIFvjcGGSJVOq+WFnAsr/UOXk18ZK2YBhqBuMZKMn1DHz2xl1NI1RaypnVh/yMpMp83RH1CMc gpe7HQSBWAFQQXU97XVjsT1a+3B1AE+H/sqMTS8dN/4Xzkaq+bKSsKh+XK3L9Rkq67dJgiOlev1 lc5TsVg== X-Received: by 2002:a05:6000:18a3:b0:3a3:7753:20ff with SMTP id ffacd0b85a97d-3b4965fa2e1mr1774338f8f.35.1751624802744; Fri, 04 Jul 2025 03:26:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsSNFCdzwlfszOvmyvFL++7oCCWdECVfxUvS2Goz3Q6PQO8mU3XMxflzhs2qhG7E3kmUYu5Q== X-Received: by 2002:a05:6000:18a3:b0:3a3:7753:20ff with SMTP id ffacd0b85a97d-3b4965fa2e1mr1774243f8f.35.1751624801975; Fri, 04 Jul 2025 03:26:41 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-454b1628fcdsm22862115e9.16.2025.07.04.03.26.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:41 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 26/29] mm: rename PAGE_MAPPING_* to FOLIO_MAPPING_* Date: Fri, 4 Jul 2025 12:25:20 +0200 Message-ID: <20250704102524.326966-27-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that the mapping flags are only used for folios, let's rename the defines. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- fs/proc/page.c | 4 ++-- include/linux/fs.h | 2 +- include/linux/mm_types.h | 1 - include/linux/page-flags.h | 20 ++++++++++---------- include/linux/pagemap.h | 2 +- mm/gup.c | 4 ++-- mm/internal.h | 2 +- mm/ksm.c | 4 ++-- mm/rmap.c | 16 ++++++++-------- mm/util.c | 6 +++--- 10 files changed, 30 insertions(+), 31 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 999af26c72985..0cdc78c0d23fa 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -149,7 +149,7 @@ u64 stable_page_flags(const struct page *page) =20 k =3D folio->flags; mapping =3D (unsigned long)folio->mapping; - is_anon =3D mapping & PAGE_MAPPING_ANON; + is_anon =3D mapping & FOLIO_MAPPING_ANON; =20 /* * pseudo flags for the well known (anonymous) memory mapped pages @@ -158,7 +158,7 @@ u64 stable_page_flags(const struct page *page) u |=3D 1 << KPF_MMAP; if (is_anon) { u |=3D 1 << KPF_ANON; - if (mapping & PAGE_MAPPING_KSM) + if (mapping & FOLIO_MAPPING_KSM) u |=3D 1 << KPF_KSM; } =20 diff --git a/include/linux/fs.h b/include/linux/fs.h index c68c9a07cda33..9b0de18746815 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -526,7 +526,7 @@ struct address_space { /* * On most architectures that alignment is already the case; but * must be enforced here for CRIS, to let the least significant bit - * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. + * of struct folio's "mapping" pointer be used for FOLIO_MAPPING_ANON. */ =20 /* XArray tags, for tagging dirty and writeback pages in the pagecache. */ diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 804d269a4f5e8..1ec273b066915 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -105,7 +105,6 @@ struct page { unsigned int order; }; }; - /* See page-flags.h for PAGE_MAPPING_FLAGS */ struct address_space *mapping; union { pgoff_t __folio_index; /* Our offset within mapping. */ diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index e575ecf880e59..970600d79daca 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -695,10 +695,10 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) /* * On an anonymous folio mapped into a user virtual memory area, * folio->mapping points to its anon_vma, not to a struct address_space; - * with the PAGE_MAPPING_ANON bit set to distinguish it. See rmap.h. + * with the FOLIO_MAPPING_ANON bit set to distinguish it. See rmap.h. * * On an anonymous folio in a VM_MERGEABLE area, if CONFIG_KSM is enabled, - * the PAGE_MAPPING_ANON_KSM bit may be set along with the PAGE_MAPPING_AN= ON + * the FOLIO_MAPPING_ANON_KSM bit may be set along with the FOLIO_MAPPING_= ANON * bit; and then folio->mapping points, not to an anon_vma, but to a priva= te * structure which KSM associates with that merged folio. See ksm.h. * @@ -713,21 +713,21 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) * false before calling the following functions (e.g., folio_test_anon). * See mm/slab.h. */ -#define PAGE_MAPPING_ANON 0x1 -#define PAGE_MAPPING_ANON_KSM 0x2 -#define PAGE_MAPPING_KSM (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) -#define PAGE_MAPPING_FLAGS (PAGE_MAPPING_ANON | PAGE_MAPPING_ANON_KSM) +#define FOLIO_MAPPING_ANON 0x1 +#define FOLIO_MAPPING_ANON_KSM 0x2 +#define FOLIO_MAPPING_KSM (FOLIO_MAPPING_ANON | FOLIO_MAPPING_ANON_KSM) +#define FOLIO_MAPPING_FLAGS (FOLIO_MAPPING_ANON | FOLIO_MAPPING_ANON_KSM) =20 static __always_inline bool folio_test_anon(const struct folio *folio) { - return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) !=3D 0; + return ((unsigned long)folio->mapping & FOLIO_MAPPING_ANON) !=3D 0; } =20 static __always_inline bool PageAnonNotKsm(const struct page *page) { unsigned long flags =3D (unsigned long)page_folio(page)->mapping; =20 - return (flags & PAGE_MAPPING_FLAGS) =3D=3D PAGE_MAPPING_ANON; + return (flags & FOLIO_MAPPING_FLAGS) =3D=3D FOLIO_MAPPING_ANON; } =20 static __always_inline bool PageAnon(const struct page *page) @@ -743,8 +743,8 @@ static __always_inline bool PageAnon(const struct page = *page) */ static __always_inline bool folio_test_ksm(const struct folio *folio) { - return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) =3D=3D - PAGE_MAPPING_KSM; + return ((unsigned long)folio->mapping & FOLIO_MAPPING_FLAGS) =3D=3D + FOLIO_MAPPING_KSM; } #else FOLIO_TEST_FLAG_FALSE(ksm) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index e63fbfbd5b0f3..10a222e68b851 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -502,7 +502,7 @@ static inline pgoff_t mapping_align_index(struct addres= s_space *mapping, static inline bool mapping_large_folio_support(struct address_space *mappi= ng) { /* AS_FOLIO_ORDER is only reasonable for pagecache folios */ - VM_WARN_ONCE((unsigned long)mapping & PAGE_MAPPING_ANON, + VM_WARN_ONCE((unsigned long)mapping & FOLIO_MAPPING_ANON, "Anonymous mapping always supports large folio"); =20 return mapping_max_folio_order(mapping) > 0; diff --git a/mm/gup.c b/mm/gup.c index 30d320719fa23..adffe663594dc 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2804,9 +2804,9 @@ static bool gup_fast_folio_allowed(struct folio *foli= o, unsigned int flags) return false; =20 /* Anonymous folios pose no problem. */ - mapping_flags =3D (unsigned long)mapping & PAGE_MAPPING_FLAGS; + mapping_flags =3D (unsigned long)mapping & FOLIO_MAPPING_FLAGS; if (mapping_flags) - return mapping_flags & PAGE_MAPPING_ANON; + return mapping_flags & FOLIO_MAPPING_ANON; =20 /* * At this point, we know the mapping is non-null and points to an diff --git a/mm/internal.h b/mm/internal.h index b7131bd3d1ad1..5b0f71e5434b2 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -149,7 +149,7 @@ static inline void *folio_raw_mapping(const struct foli= o *folio) { unsigned long mapping =3D (unsigned long)folio->mapping; =20 - return (void *)(mapping & ~PAGE_MAPPING_FLAGS); + return (void *)(mapping & ~FOLIO_MAPPING_FLAGS); } =20 /* diff --git a/mm/ksm.c b/mm/ksm.c index ef73b25fd65a6..2b0210d41c553 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -893,7 +893,7 @@ static struct folio *ksm_get_folio(struct ksm_stable_no= de *stable_node, unsigned long kpfn; =20 expected_mapping =3D (void *)((unsigned long)stable_node | - PAGE_MAPPING_KSM); + FOLIO_MAPPING_KSM); again: kpfn =3D READ_ONCE(stable_node->kpfn); /* Address dependency. */ folio =3D pfn_folio(kpfn); @@ -1070,7 +1070,7 @@ static inline void folio_set_stable_node(struct folio= *folio, struct ksm_stable_node *stable_node) { VM_WARN_ON_FOLIO(folio_test_anon(folio) && PageAnonExclusive(&folio->page= ), folio); - folio->mapping =3D (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM= ); + folio->mapping =3D (void *)((unsigned long)stable_node | FOLIO_MAPPING_KS= M); } =20 #ifdef CONFIG_SYSFS diff --git a/mm/rmap.c b/mm/rmap.c index a15939453c41a..f93ce27132abc 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 ce826ca82a11d..68ea833ba25f1 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 Tue Oct 7 22:50:53 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 A1D0C2FD87D for ; Fri, 4 Jul 2025 10:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624810; cv=none; b=M2ET0XS+BEcKVTNI8M0BTJ3Ea9AhTtItGFrQyCE+rpttcrYpfxxRZPLp46af/NYrXEKq7k5hUxaZ8usFYJ1d36clpbudwmKXWAk+8PGKUg6jaRAAfixPHIyy2/YI0r0kUKL7dFJ/z0BJyxYe+xc8C3/0qhwYQ04lgzLgPJUKyCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624810; c=relaxed/simple; bh=8rQqgJp11Lk6antrmn+yK+r+00c98BCFbnlbAAQikq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=II/aUc2AHkRU44jqQxckFVzYppmzViAMFI/OKodtqV2Jo5iqLnyKuR3sFFIGhBuv4KoBZImgNbHCBZQcnuSfYKDBCl3Fz8+ULQTTLudnpmtgCUmg1CvbkI0ERuXLQj3iVcFbfVmqpcCtEC3WXcM+oZKif9+9odWUDYWTNtfsVOY= 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=OK56u9HP; 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="OK56u9HP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624807; 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=egdaFmDJBU0TtndNYiZ6nPcRML2Mxu7RUt3KjMyWE24=; b=OK56u9HPfDiPZJeQemFNx21e+7OGxwPQ0L4T28kY2Dg9Z8Dc1MA4+8PHaCHeMSH3BWNuZ6 V79vqB4VwZOHp+ksLdwtmjKgdL54kFnsAYHOdEq+GFkyvf2j2fD6WiAFcOksrTB8/oNH5+ kAC3U6nNFRx72fwqL4e4oj6NE5UIRw8= 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-388-X249fEfXNGeyYggX84UNrg-1; Fri, 04 Jul 2025 06:26:46 -0400 X-MC-Unique: X249fEfXNGeyYggX84UNrg-1 X-Mimecast-MFC-AGG-ID: X249fEfXNGeyYggX84UNrg_1751624806 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a52bfda108so375428f8f.3 for ; Fri, 04 Jul 2025 03:26:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624805; x=1752229605; 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=egdaFmDJBU0TtndNYiZ6nPcRML2Mxu7RUt3KjMyWE24=; b=NvBWbEnii1Zanc190n4BCyNF7nCqKLgxquV8OKfwrbi+eOEdGNA3Xl4ExfYtJJcqJT gX5QlNzcBZ/g5S6qPM+/24JaUBOJVZ5ly+tkAT5DGrSncQ/AjMftoGl6ULMST5Vmx/+J p/X+T0nGw/Ru7pkXn4ZUJtIUi0C/3Bj/BxkSBnsCHVP5woXsQ8RzJZDMBhl2OINOaHr0 OwFGaiy1Fl3HBJxo5eaNaC76Tki0ru2Thzog1LGyxiLYAJd9ip+viosC7REVnUkefJGw ToPxKK4z3VjcHav96bXXCvlFCYZYrpqJltJJP4qezU49fMUHKmQeJsa6XEhnzCEVvSGC gZRA== X-Gm-Message-State: AOJu0Ywaf0QqrmAliOyHubXFp8NByGyNgMrWpi9Iz4l23olEoTkyJ7nR 0cPSC93r4GsPHwjbjA9eZFEQHA7dnpMhQQaWeb3Ovz8iE3SnL8KwJ0ztBIr8b6qg4OH75IUcIzO bvvEwUoeM20Jp0B5fcQbQmdmZ2PXnKzPbMjs7ge+Y34qmX7e0dky2PcqFY3DyM+/heCql/6w2us xRe9D7abJ3KgqKYjFP54nSJnNzwhNXQgVa9AsG1UCUAbJgNw== X-Gm-Gg: ASbGncu1G24M57Psr8n0gmIaDRxeEuLCh7rLU6yRMxWIk8f0dsouw277np2C2UnJA78 xTr9uV4e+orl9MM8y91OiZq/GTyh38NcU7zgqw2J1LNYwlXMB9Y9CwRgawXNA9kAVBGlTCyAwk0 0ejV0kFBqH8vXA3XwVkPApCdNdmt5H+VWIY4lNivbmam73aabSdW9P21eQobrat9h1q0+TCs3l+ p4P+UaIc9AZateKUjrtrRw3Yv+hqIqk17IhXSq6+KUHnWZ7mQ8WXKw3iY4NkkgNyfPvgYCQ2dlR Y//jwSHtAzM7Do54KHCnZSpOA0xUaQ4HVB4uS4CNJ0dJNnWmBquAN5CQWAI1db/fkG2Et9FaAsO H2xdguw== X-Received: by 2002:a05:6000:41eb:b0:3b3:a6c2:1a10 with SMTP id ffacd0b85a97d-3b4964eb8c5mr1818995f8f.12.1751624805434; Fri, 04 Jul 2025 03:26:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEReO138rar0bBMYwWljLx+rr/cG2x6KKHBHNt6saeQjtIgYNeV27GRLz6HCnNXsrL9yURvTg== X-Received: by 2002:a05:6000:41eb:b0:3b3:a6c2:1a10 with SMTP id ffacd0b85a97d-3b4964eb8c5mr1818905f8f.12.1751624804727; Fri, 04 Jul 2025 03:26:44 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47285c90esm2152102f8f.91.2025.07.04.03.26.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:44 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 27/29] docs/mm: convert from "Non-LRU page migration" to "movable_ops page migration" Date: Fri, 4 Jul 2025 12:25:21 +0200 Message-ID: <20250704102524.326966-28-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's bring the docs up-to-date. Reviewed-by: Zi Yan Reviewed-by: Lorenzo Stoakes Reviewed-by: Harry Yoo Signed-off-by: David Hildenbrand --- 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..34602b254aa63 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_movable_ops() based on the page + type +(d) not reusing the PG_movable_ops and PG_movable_ops_isolated page flags + for other purposes + +For example, balloon drivers can make use of this framework through the +balloon-compaction infrastructure residing in the core kernel. =20 Monitoring Migration =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.49.0 From nobody Tue Oct 7 22:50:53 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 4421E2FE30C for ; Fri, 4 Jul 2025 10:26:51 +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=1751624812; cv=none; b=C0uqvGs2zJDDzPffbXMOQ1I5Chjguf477JTTn91qaVPVlgPYKolVsLTY/JfK2jKtU66C80iIZ9rAV2wr3m8GA2TVhqPLlkINnFXlwBC/hNAKyi3maYkTQvEVnsdDYo921HxUl4i8hRKZ33iGb4w1TyKhutc8jxXs8HaAcs5ljx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624812; c=relaxed/simple; bh=9t4RJIUzQtVpC+ufH2qeXROpTaW+ImBuVkRcsBTUgQk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q338QyqG88d/yo/9ZTZ3shsh0imJNTL0D2qhcVldkFCfuwi0UUwYvT+de2Mh11ab4k192JkalQhK9sDDmAdY6Dab9ek5szdOQV9EYf/dbLbkabX9BioWkYxxJn9BD2wHk6H7Ls6SjefZANso/WN00m0C+HQMmtFC9ImapJKu9OI= 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=esL/z+PL; 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="esL/z+PL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624810; 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=mQ0XfChfbxm2lnvJaf8puphZG2XMtd7Fe0eRXg0ZpMo=; b=esL/z+PLls6K2fyxFk0u3ZVkF6qmNw7CaXXHTlLxQifRt4sPsATBRwhw4Nxg07yg0u8rGC x7nj6lOsIsFzlcF7IB3XO05P3YdeoCdslyHBlN1y1ix2pxoLnKP0IB9wU42hdWm0/rf7W7 rJ1+VaDkjmQukxeCGROb6yu1OZEPAYQ= 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-448-CUIhV3d7OEKc9OKFpUF9jg-1; Fri, 04 Jul 2025 06:26:49 -0400 X-MC-Unique: CUIhV3d7OEKc9OKFpUF9jg-1 X-Mimecast-MFC-AGG-ID: CUIhV3d7OEKc9OKFpUF9jg_1751624808 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43e9b0fd00cso4603035e9.0 for ; Fri, 04 Jul 2025 03:26:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624808; x=1752229608; 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=mQ0XfChfbxm2lnvJaf8puphZG2XMtd7Fe0eRXg0ZpMo=; b=bgcQPdpFobxVKhCRMmxvjwiuWUR3vYSFRZumQQQqRakvVU+cUtWL1LbJMVuF0jMqNI 7HKNTfQe2yDmLyQGbBKjbeykD7GBpLyAA2C2DHtPKbGVT9XT1QR28qTc3lqtzlJ+dXSG 9gyk91lhx4ymkodxjD8C7jXMXAcKwAM9X7aD92J+tHd/0DzMSFNydRa13038t76QdBq3 QpbO6xuOHbYbd+Is2/vVvDkqtSR/TqVJk+eBoyJ+K1OTgRrzNlSvwPLW566uBpDfkskM sfzEggS16eFWGQ3NTXHGavttkVFoDDCj+HP1i3Bz12q+Q3wXcSXnN2uLJlgffL/jgGmo jqNg== X-Gm-Message-State: AOJu0YwxleD04Gyfote7ELcRihrrcn9ko5IpPkjihxMFM+s/W8Ui19ka 5FgN6/viuCntX+btZe7Gv3QdNlEciKbdQr4xpIWGWP3cQ1uMrw4Ghp8ibAjlfzEtNi1NjULoeeu UfszoAejFZXh4Ohtn+oHGBV5VdLTChSdvNrBIyulqF/8gv9UyoakCbrnEY6pKr4eZy22VDNDHeC c4QZ9nEnR/1LybwyxEDYAtRu8eMjm40H4kYyTIpVWpKotukw== X-Gm-Gg: ASbGncuXmmUk2wO2G8mv0+akF3wrxqE7sYOVynabuLzbZl7G7nJRdONnCPniKUM1QgA oSsYCbb2VuKcOw0wtE/dE5T+ezwwnbgWfjKsxAyZECx0iWYQ+zrJ2cCEiyG3pllfnZs4+1YVGQy f56qufH6Gj8+yGGpFV5RNrqpIG0I/ecN1IYTFzsLoI1ekIb+sI14k5N7Pe6qb0G58COphIC1aGh oH4qcfs6sJXM6mzhaOcDitjXLYI8rvTvaKzIZuucmRko1Y6q+Mmr49WxkXl2nVXaNsRFMb7gOw5 PVv5aYKvN8i6XeK0RZDi1wpYe8ImEM8BjvtyCGjDb7Ba7/sPDIRJ6QgZDwXCERy8mB56/LuQpbu 81m9Nag== X-Received: by 2002:a05:600c:8219:b0:442:f4a3:a2c0 with SMTP id 5b1f17b1804b1-454b30c46ecmr22270305e9.13.1751624808009; Fri, 04 Jul 2025 03:26:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDbvyyEAOAh2zTRSLUq2RLyWuJqmjCfdM4cRksQAqvl8abasokMK1aTRkGvgAfFTh32vAJjQ== X-Received: by 2002:a05:600c:8219:b0:442:f4a3:a2c0 with SMTP id 5b1f17b1804b1-454b30c46ecmr22269355e9.13.1751624807380; Fri, 04 Jul 2025 03:26:47 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b471b9671asm2135708f8f.53.2025.07.04.03.26.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:46 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 28/29] mm/balloon_compaction: "movable_ops" doc updates Date: Fri, 4 Jul 2025 12:25:22 +0200 Message-ID: <20250704102524.326966-29-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Lorenzo Stoakes 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 Tue Oct 7 22:50:53 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 74E122F3C2E for ; Fri, 4 Jul 2025 10:26: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=1751624820; cv=none; b=axSCuIJ9yOJnqNR/MM9vqO6FXD1M3GWKthYonvrGqVjnWQpY16FkRsJqxkawuJLImrbKulnrKlqMhW9DBndVdRCtSkGpaQMoOcQH768ThY+9WsbZKhBFhopS/1OCj+Yf0FLqT2Jit5RgKP3n4hCJKU4T2GDl2GQTxHlWCDF4YjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751624820; c=relaxed/simple; bh=EzLnGXHkuZsrbU+9yZ2bD2FaU0ugKSCfE5X54vg+vxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ae2hKWoQcbyL6b1qLivw2868WUH9dqNAHCogoBFFQYGgq3dP9UYDGg3XmfBWHN7ZYCpLezjMHzlKwFTQrkBO5TuUJDAPWkKzTyvXNwackB5aagEaTbmvM9e7a/NEdCr/Q0B7I4e6CiKNeClMIald23Dvyc/quahZ7VpFHWgPYgo= 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=StAQGxJP; 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="StAQGxJP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751624817; 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=DAmNizoml8pi0FWiSRf1K1mTve+PnYDWvVyOK7ajbGc=; b=StAQGxJPacJtJejWR8F90AqxDkYLIycwS8WPtT+gBYH8Ph7T9keBq4ZC5Fw4JsY5wYbAjd 97/1A4RZ3pWSHLvI/HE64dWfDpayMWWhK/H6Z2fNpv6+kRBXYteJQh8WyFqMdBq0tTA7a2 RZLTx39zXw1WVtOwX1T+s+Jtaz22HNE= 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-686-g1qyVvnaNxiqJlFx4mN_rQ-1; Fri, 04 Jul 2025 06:26:51 -0400 X-MC-Unique: g1qyVvnaNxiqJlFx4mN_rQ-1 X-Mimecast-MFC-AGG-ID: g1qyVvnaNxiqJlFx4mN_rQ_1751624810 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a4f7f1b932so500535f8f.2 for ; Fri, 04 Jul 2025 03:26:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751624810; x=1752229610; 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=DAmNizoml8pi0FWiSRf1K1mTve+PnYDWvVyOK7ajbGc=; b=eAdjMm7h3IbRuh22XVpLIYMXCBb4hZY8OP6oAk6cxTLAOdNCFAdXvCq9Rk+IxB626v OaFDd0goBSzZBDtxNwISnv0RXbgTytuv9+q+sllYIov/tcJu1i4q1ypNwvBJkhbrYLhI hk3Gt+72rzH9VmtkUPYipXKVhp9dW1+Ghue8nuD0ltenxCkhafjdObKTgW1SUHL1kDZc qpXe9CjqUZe0/MicxbEC/TQYpcUHXPqjCNk8V/veMjzvH64g4EaW6k1hyVR4RcC/YuHS Yh/dCnxZjVKOLoDx603DQNj7H62ZvT3B/mOrx3RBKBcG5MzqxwxZvJx9XrtRXnW4kny6 WXQw== X-Gm-Message-State: AOJu0YzsrQMPu7rfFlF/cEdmqHkrr5s8aiC1y7HUUaJxj24hfRe5xcDk bwzpb1Otliz/DfTXi+IVR8UVTzliCXA4FIxF6uDMD0ex1/l+p35Fs8UlurxI5fJh9YuNVvkGmaX wi51onfaR3ZsiwRXeq2Igj7dtYQuU7Suy4btSLiUT5u+P8OC077bDENHSbbbT9P74Qb9zllVp+5 M82B4p+HaXeS/ia/XTLIIuArG531wla/hVfVilt0u8rrLZNg== X-Gm-Gg: ASbGncse6aQYEJh6rY3x5z6rAqRLen52xmpli3QrZ1f9XbdqnMklH+dtKU6YmoN7o84 oVcZRbHBgLeUE1q7jDczCWYlzCcAwtrGL+y9h7ffhvbnTzaQG7nf9bft6XESFfbWXElNdgUQ54/ VpbJksc+9fDPB4qQYUsR/QGfYsjLzM6Pnh++m/mNQP9247BBLm0Kz3R/QMK0pPTvADGxgexGlAX 1QbAYFyKsUyGVpLUT5qCNjT2isLlU3Lgb0PqpH92/dT2xB0i2/z1MId4HL4XDUUsyfl1dFbUH4M YrR1VA+aqnUEbiYmrVqJJQFM56qyOPPn+1wqmOtm2Yb1g0HjdzeCmfiO57yx/Y/a0zXtSn9kBhN YwUYIpw== X-Received: by 2002:a05:6000:2906:b0:3a6:e2d5:f14c with SMTP id ffacd0b85a97d-3b4970294bamr1229518f8f.30.1751624810387; Fri, 04 Jul 2025 03:26:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU9MKO4L2eImwXLAzlEGTAbbgXQLTQHWpn061Frnhroy+xSoAIVNW9jaIe3vRaTd6Fz7itPA== X-Received: by 2002:a05:6000:2906:b0:3a6:e2d5:f14c with SMTP id ffacd0b85a97d-3b4970294bamr1229434f8f.30.1751624809815; Fri, 04 Jul 2025 03:26:49 -0700 (PDT) Received: from localhost (p200300d82f2c5500098823f9faa07232.dip0.t-ipconnect.de. [2003:d8:2f2c:5500:988:23f9:faa0:7232]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3b47030bc5asm2113887f8f.20.2025.07.04.03.26.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 03:26:49 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH v2 29/29] mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask() Date: Fri, 4 Jul 2025 12:25:23 +0200 Message-ID: <20250704102524.326966-30-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250704102524.326966-1-david@redhat.com> References: <20250704102524.326966-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's just special-case based on IS_ENABLED(CONFIG_BALLOON_COMPACTION) like we did for balloon_page_finalize(). Reviewed-by: Lorenzo Stoakes 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