linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	Zhaoyang Huang <huangzhaoyang@gmail.com>, <linux-mm@kvack.org>,
	<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<ke.wang@unisoc.com>, <steve.kang@unisoc.com>
Subject: [RFC PATCH] mm: skip GFP_IO if swap is zram only
Date: Mon, 10 Oct 2022 19:00:22 +0800	[thread overview]
Message-ID: <1665399622-20236-1-git-send-email-zhaoyang.huang@unisoc.com> (raw)

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

__GFP_IO is believed to prevent the allocation being suspended due to accessing
physical block devices when reclaiming dirty pages. Zram is not considered as
such kind of device from kernel perspective of view. Do swap things if the system
is zram only.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 include/linux/swap.h     | 1 +
 include/linux/swapfile.h | 1 -
 mm/swapfile.c            | 7 +++++++
 mm/vmscan.c              | 3 ++-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 43150b9..c160b2e 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -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)
diff --git a/include/linux/swapfile.h b/include/linux/swapfile.h
index 5407854..e229c36 100644
--- a/include/linux/swapfile.h
+++ b/include/linux/swapfile.h
@@ -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 */
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 1fdccd2..e1b2969 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -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;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index b2b1431..37500b5 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -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;
-- 
1.9.1



             reply	other threads:[~2022-10-10 11:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 11:00 zhaoyang.huang [this message]
2022-10-10 13:09 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1665399622-20236-1-git-send-email-zhaoyang.huang@unisoc.com \
    --to=zhaoyang.huang@unisoc.com \
    --cc=akpm@linux-foundation.org \
    --cc=huangzhaoyang@gmail.com \
    --cc=ke.wang@unisoc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=steve.kang@unisoc.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox