From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9ADD7C7115A for ; Wed, 18 Jun 2025 17:42:53 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4bMrd63smSz30Wn; Thu, 19 Jun 2025 03:41:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1750268474; cv=none; b=FEHM2VupsB3HlkIphzus0YhXnk4Ztw4btBBzz5T5d2iji3VZg2x51E7QS5iDHKcAaz+Nw8t2sfR9oYJlt8QEcut79QzM9s8Xto1qYhN2M+oCivtwHbH2M7qHhhr8fG1H+Kuvl6Djyl7UTrsltFYMXKq9csnPliVRnT/MwjhtOvcg7oUfyiVDJlZ7XJDVFunHcDee+DUI76zEKTJbNDzSioxd+U0tynCC3/NaIblEXZPQH4U6myiOxRyYGy91Wt0wpgEo0PmlYJH3D7d0XiNgiR4sO94gidl4ddk6QxtdchX4m9w9Bfomgp+yxn191NkXVWpDvYx7VQqCyvTrGB7/PA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1750268474; c=relaxed/relaxed; bh=DzfM28AXUPw/AfYpLS1hZTUERIY8AF/rsj6KIsT8/ZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=AdRaIRBx4S2qnwCLb0h4QZSsucqIblQkw/Q3iaHzRODay3X75LPNT0hFrNldxpbhFGNDYxXycWFM+310GMXvryvdAVqhJEZxqF0A5DEOy03c13YQHmsPxRYGVjNjkl+R2OPtG/2a+j+2Bd9Aede+euyIZVzcjvHpZ8LvYLkglpviF63jrb3W+8f3x9+eQ9DGIJCNXY5ARWE1D2DEsAIzJgm738OM5zc0x5znB7aig0VmUlWkhgKGSqk+Nhft9x+/g+nLfgTbSS3tfwEdyCFqw1gqeHv8/TjEUSTXo5nHn3zx/HfGOY2Dvv9jXonRT6hB+BdxLAtbtA/M8OXJWPFdvw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EJ7S0thS; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EJ7S0thS; dkim-atps=neutral; spf=pass (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=dhildenb@redhat.com; receiver=lists.ozlabs.org) smtp.mailfrom=redhat.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EJ7S0thS; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EJ7S0thS; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=dhildenb@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4bMrd55Lhsz30DP for ; Thu, 19 Jun 2025 03:41:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DzfM28AXUPw/AfYpLS1hZTUERIY8AF/rsj6KIsT8/ZY=; b=EJ7S0thS7fBjU2Em9PMS76IjvMSQoWU01VlSuZOsRCTP8bO6fXUfjQQFrUrKtACUhpuv5A ndSwdydaFwqW1bKianJ27Pi8DvX/96OQ837e0wWgkCbazczBF6T46NSI/RjMw7xw9b2dob FFC2lhOS6AhlU4CVMkrtwSwA1paVwRU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750268471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DzfM28AXUPw/AfYpLS1hZTUERIY8AF/rsj6KIsT8/ZY=; b=EJ7S0thS7fBjU2Em9PMS76IjvMSQoWU01VlSuZOsRCTP8bO6fXUfjQQFrUrKtACUhpuv5A ndSwdydaFwqW1bKianJ27Pi8DvX/96OQ837e0wWgkCbazczBF6T46NSI/RjMw7xw9b2dob FFC2lhOS6AhlU4CVMkrtwSwA1paVwRU= 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-641-XKWdztyFOyWBPz70c6DgRw-1; Wed, 18 Jun 2025 13:41:09 -0400 X-MC-Unique: XKWdztyFOyWBPz70c6DgRw-1 X-Mimecast-MFC-AGG-ID: XKWdztyFOyWBPz70c6DgRw_1750268469 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-450d290d542so43198225e9.1 for ; Wed, 18 Jun 2025 10:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750268468; x=1750873268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DzfM28AXUPw/AfYpLS1hZTUERIY8AF/rsj6KIsT8/ZY=; b=FiI3nt5vhFTqJzEajXrm0TgG1UNDRfI//9Ww5AYSS29Y/zyjTwZD108oG1nQTwynd3 O6quyq0f3uSy6H5ZE5/fneXsHzSm0RQkfoSdqhHWXXe9Qq3Hi42Ua6zncrnn8WHpxSMG EvvJ9DCmwortEjskTXTyy2xBpjQHx8XbOMUUIiDGSZvAAXibj2lH67HYNPytRdgsy4nP /8xYDly2+D4Gi9I3dJgB0/DNZcQCgs7QUu3M3vZ6DydodQ6HWCoUo8l8aVRnyEPMZjgz 1LK0J7t1resPaGHSPfwS/WF1ffTKGQ/dwMfKpWNsq9hzXbORciDa9ywK5ot4FIJrPAD9 3TNQ== X-Forwarded-Encrypted: i=1; AJvYcCVZY+jdWLd/qcqpfO8eu/xWwgeKXmt3XcPkXIecQ2tFciwIREAuwKIj4zbS8mqki/CJWXDWZT8Pg4HKfb0=@lists.ozlabs.org X-Gm-Message-State: AOJu0YzuE2ipFkDi4iS32zX0H8BttveGSZRhACTMkYfh3itekk3QZcJ3 En4LQHvi1CyrpPfUQYIS+tJfNX6LmQek3f+MGu/jdJsCM1TfJ7L26AdNLQSqcRi9+9W5twPtPdB l2V+3EnNhbXc3MluK1TATIsZb7wzafFskgE/NBNm6+LQ2RehUPvAFOWrdWpXqh1oF3xFFBL1L30 BVbQ== X-Gm-Gg: ASbGncvurE+nXxygcIwY3GWrWym95Y2IY09H8iRHbqkM/qX47uTfoYrP4DER8TYXkQO KlfCPsg9Hgn3C8WLuRCiryOIRAte0VHIIomK37/qto8NwUNJgBUy3y82dz0mY5TtEAUbHg1WbY7 m6N96zlbzvW9KQLgebQADGQz/z0Eggl7cVtxc8qp6Eb5uojFjbaLxmPwKLenR67eHQnbqmJ9KaT lYbjdEY2II1yHpohN1ym/G9ENY4cK4qtg9WMD7W4z54rFj4fp2jGyiDMGwWy3+qQINFij65vLfA /Che9Tbeg3lW3x0ALPKuKE44foxyivJcs2E9wsNRadcYfblgaRw0oFYPu73ac3Xi0GwCitUTOmX FvxbYkQ== X-Received: by 2002:a05:600c:820c:b0:43c:fa24:8721 with SMTP id 5b1f17b1804b1-4533caa2186mr184243035e9.17.1750268468362; Wed, 18 Jun 2025 10:41:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKEjDqAoZjEM/lQyE0UXotydmkpa81gpxxIPt+zLIqzN6Ot9NSYzqnSxIiiN03uF8vCn5Ghw== X-Received: by 2002:a05:600c:820c:b0:43c:fa24:8721 with SMTP id 5b1f17b1804b1-4533caa2186mr184242395e9.17.1750268467893; Wed, 18 Jun 2025 10:41:07 -0700 (PDT) Received: from localhost (p200300d82f2d2400405203b5fff94ed0.dip0.t-ipconnect.de. [2003:d8:2f2d:2400:4052:3b5:fff9:4ed0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a568b087b4sm17884528f8f.51.2025.06.18.10.41.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jun 2025 10:41:07 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jerrin Shaji George , Arnd Bergmann , Greg Kroah-Hartman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Alexander Viro , Christian Brauner , Jan Kara , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , "Matthew Wilcox (Oracle)" , Minchan Kim , Sergey Senozhatsky , Brendan Jackman , Johannes Weiner , Jason Gunthorpe , John Hubbard , Peter Xu , Xu Xin , Chengming Zhou , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Rik van Riel , Harry Yoo , Qi Zheng , Shakeel Butt Subject: [PATCH RFC 19/29] mm: stop storing migration_ops in page->mapping Date: Wed, 18 Jun 2025 19:40:02 +0200 Message-ID: <20250618174014.1168640-20-david@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618174014.1168640-1-david@redhat.com> References: <20250618174014.1168640-1-david@redhat.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HSNbECPgw4y_rCzr78JfROtkH74luLdh5-Lkpv9b6eM_1750268469 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true ... instead, look them up statically based on the page type. Maybe in the future we want a registration interface? At least for now, it can be easily handled using the two page types that actually support page migration. The remaining usage of page->mapping is to flag such pages as actually being movable (having movable_ops), which we will change next. Signed-off-by: David Hildenbrand --- 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_compaction.h index 9bce8e9f5018c..a8a1706cc56f3 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -92,7 +92,7 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon, struct page *page) { __SetPageOffline(page); - __SetPageMovable(page, &balloon_mops); + __SetPageMovable(page); set_page_private(page, (unsigned long)balloon); list_add(&page->lru, &balloon->pages); } diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c575778456f97..64639dab92b91 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -104,23 +104,13 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping, #endif /* CONFIG_MIGRATION */ #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 -static inline -const struct movable_operations *page_movable_ops(struct page *page) -{ - VM_BUG_ON(!page_has_movable_ops(page)); - - return (const struct movable_operations *) - ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); -} - #ifdef CONFIG_NUMA_BALANCING int migrate_misplaced_folio_prepare(struct folio *folio, struct vm_area_struct *vma, int node); diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h index 13e9cc5490f71..f3ccff2d966cd 100644 --- a/include/linux/zsmalloc.h +++ b/include/linux/zsmalloc.h @@ -46,4 +46,6 @@ void zs_obj_read_end(struct zs_pool *pool, unsigned long handle, void zs_obj_write(struct zs_pool *pool, unsigned long handle, void *handle_mem, size_t mem_len); +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 = { .isolate_page = balloon_page_isolate, .putback_page = balloon_page_putback, }; -EXPORT_SYMBOL_GPL(balloon_mops); #endif /* CONFIG_BALLOON_COMPACTION */ diff --git a/mm/compaction.c b/mm/compaction.c index f8b7c09e2e48c..a10f23df9396e 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -114,11 +114,10 @@ static unsigned long release_free_list(struct list_head *freepages) } #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 = (void *)((unsigned long)mops | PAGE_MAPPING_MOVABLE); + page->mapping = (void *)(PAGE_MAPPING_MOVABLE); } EXPORT_SYMBOL(__SetPageMovable); diff --git a/mm/migrate.c b/mm/migrate.c index 37e722fbfee70..a36030de94f30 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include @@ -51,6 +53,27 @@ #include "internal.h" #include "swap.h" +static const struct movable_operations *page_movable_ops(struct page *page) +{ + VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); + + /* + * If we enable page migration for a page of a certain type by marking + * it as movable, the page type must be sticky until the page gets freed + * back to the buddy. + */ +#ifdef CONFIG_BALLOON_COMPACTION + if (PageOffline(page)) + /* Only balloon compaction sets PageOffline pages movable. */ + return &balloon_mops; +#endif /* CONFIG_BALLOON_COMPACTION */ +#ifdef CONFIG_ZSMALLOC + if (PageZsmalloc(page)) + return &zsmalloc_mops; +#endif /* CONFIG_ZSMALLOC */ + return NULL; +} + /** * isolate_movable_ops_page - isolate a movable_ops page for migration * @page: The page. diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 5763f36039736..6855d9e2732d8 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -152,10 +152,9 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long pfn) return page_zpdesc(pfn_to_page(pfn)); } -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)); } static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 72c2b7562c511..7192196b9421d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1684,8 +1684,6 @@ static void lock_zspage(struct zspage *zspage) #ifdef CONFIG_COMPACTION -static const struct movable_operations zsmalloc_mops; - static void replace_sub_page(struct size_class *class, struct zspage *zspage, struct zpdesc *newzpdesc, struct zpdesc *oldzpdesc) { @@ -1708,7 +1706,7 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, set_first_obj_offset(newzpdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) newzpdesc->handle = oldzpdesc->handle; - __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); + __zpdesc_set_movable(newzpdesc); } static bool zs_page_isolate(struct page *page, isolate_mode_t mode) @@ -1815,7 +1813,7 @@ static void zs_page_putback(struct page *page) { } -static const struct movable_operations zsmalloc_mops = { +const struct movable_operations zsmalloc_mops = { .isolate_page = zs_page_isolate, .migrate_page = zs_page_migrate, .putback_page = zs_page_putback, @@ -1878,7 +1876,7 @@ static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) do { WARN_ON(!zpdesc_trylock(zpdesc)); - __zpdesc_set_movable(zpdesc, &zsmalloc_mops); + __zpdesc_set_movable(zpdesc); zpdesc_unlock(zpdesc); } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); } -- 2.49.0