@@ -505,6 +505,7 @@ static inline long get_nr_swap_pages(void)
extern int init_swap_address_space(unsigned int type, unsigned long nr_pages);
extern void exit_swap_address_space(unsigned int type);
extern struct swap_info_struct *get_swap_device(swp_entry_t entry);
+extern bool if_swap_zram_only(void);
sector_t swap_page_sector(struct page *page);
static inline void put_swap_device(struct swap_info_struct *si)
@@ -9,5 +9,4 @@
extern struct swap_info_struct *swap_info[];
extern unsigned long generic_max_swapfile_size(void);
extern unsigned long max_swapfile_size(void);
-
#endif /* _LINUX_SWAPFILE_H */
@@ -3663,6 +3663,13 @@ void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)
}
#endif
+bool if_swap_zram_only(void)
+{
+ return ((nr_swapfiles == 1)
+ && !strncmp(swap_info[0]->bdev->bd_disk->disk_name, "zram", 4));
+}
+EXPORT_SYMBOL_GPL(if_swap_zram_only);
+
static int __init swapfile_init(void)
{
int nid;
@@ -1770,7 +1770,8 @@ static unsigned int shrink_page_list(struct list_head *page_list,
*/
if (folio_test_anon(folio) && folio_test_swapbacked(folio)) {
if (!folio_test_swapcache(folio)) {
- if (!(sc->gfp_mask & __GFP_IO))
+ if (!(sc->gfp_mask & __GFP_IO)
+ && !if_swap_zram_only())
goto keep_locked;
if (folio_maybe_dma_pinned(folio))
goto keep_locked;