Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/balloon_compaction: provide single balloon_page_insert() and balloon_mapping_gfp_mask()

Let's just special-case based on IS_ENABLED(CONFIG_BALLOON_COMPACTION)
like we did for balloon_page_finalize().

Link: https://lkml.kernel.org/r/20250704102524.326966-30-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Eugenio Pé rez <eperezma@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Gregory Price <gourry@gourry.net>
Cc: Harry Yoo <harry.yoo@oracle.com>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: xu xin <xu.xin16@zte.com.cn>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
9640b17a f5e43012

+15 -27
+15 -27
include/linux/balloon_compaction.h
··· 77 77 78 78 #ifdef CONFIG_BALLOON_COMPACTION 79 79 extern const struct movable_operations balloon_mops; 80 + /* 81 + * balloon_page_device - get the b_dev_info descriptor for the balloon device 82 + * that enqueues the given page. 83 + */ 84 + static inline struct balloon_dev_info *balloon_page_device(struct page *page) 85 + { 86 + return (struct balloon_dev_info *)page_private(page); 87 + } 88 + #endif /* CONFIG_BALLOON_COMPACTION */ 80 89 81 90 /* 82 91 * balloon_page_insert - insert a page into the balloon's page list and make ··· 100 91 struct page *page) 101 92 { 102 93 __SetPageOffline(page); 103 - SetPageMovableOps(page); 104 - set_page_private(page, (unsigned long)balloon); 105 - list_add(&page->lru, &balloon->pages); 106 - } 107 - 108 - /* 109 - * balloon_page_device - get the b_dev_info descriptor for the balloon device 110 - * that enqueues the given page. 111 - */ 112 - static inline struct balloon_dev_info *balloon_page_device(struct page *page) 113 - { 114 - return (struct balloon_dev_info *)page_private(page); 115 - } 116 - 117 - static inline gfp_t balloon_mapping_gfp_mask(void) 118 - { 119 - return GFP_HIGHUSER_MOVABLE; 120 - } 121 - 122 - #else /* !CONFIG_BALLOON_COMPACTION */ 123 - 124 - static inline void balloon_page_insert(struct balloon_dev_info *balloon, 125 - struct page *page) 126 - { 127 - __SetPageOffline(page); 94 + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) { 95 + SetPageMovableOps(page); 96 + set_page_private(page, (unsigned long)balloon); 97 + } 128 98 list_add(&page->lru, &balloon->pages); 129 99 } 130 100 131 101 static inline gfp_t balloon_mapping_gfp_mask(void) 132 102 { 103 + if (IS_ENABLED(CONFIG_BALLOON_COMPACTION)) 104 + return GFP_HIGHUSER_MOVABLE; 133 105 return GFP_HIGHUSER; 134 106 } 135 - 136 - #endif /* CONFIG_BALLOON_COMPACTION */ 137 107 138 108 /* 139 109 * balloon_page_finalize - prepare a balloon page that was removed from the