* [PATCH] swap: Delete the "last_in_cluster < scan_base" loop in the body of scan_swap_map()
@ 2014-06-02 11:54 Chen Yucong
2014-06-02 23:26 ` Hugh Dickins
0 siblings, 1 reply; 2+ messages in thread
From: Chen Yucong @ 2014-06-02 11:54 UTC (permalink / raw)
To: shli; +Cc: hughd, akpm, linux-mm, linux-kernel, Chen Yucong
>From commit ebc2a1a69111, we can find that all SWP_SOLIDSTATE "seek is cheap"(SSD case)
has already gone to si->cluster_info scan_swap_map_try_ssd_cluster() route. So that the
"last_in_cluster < scan_base" loop in the body of scan_swap_map() has already become a
dead code snippet, and it should have been deleted.
This patch is to delete the redundant loop as Hugh and Shaohua suggested.
Signed-off-by: Chen Yucong <slaoub@gmail.com>
---
mm/swapfile.c | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index beeeef8..1b44bd9 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -549,26 +549,6 @@ static unsigned long scan_swap_map(struct swap_info_struct *si,
}
}
- offset = si->lowest_bit;
- last_in_cluster = offset + SWAPFILE_CLUSTER - 1;
-
- /* Locate the first empty (unaligned) cluster */
- for (; last_in_cluster < scan_base; offset++) {
- if (si->swap_map[offset])
- last_in_cluster = offset + SWAPFILE_CLUSTER;
- else if (offset == last_in_cluster) {
- spin_lock(&si->lock);
- offset -= SWAPFILE_CLUSTER - 1;
- si->cluster_next = offset;
- si->cluster_nr = SWAPFILE_CLUSTER - 1;
- goto checks;
- }
- if (unlikely(--latency_ration < 0)) {
- cond_resched();
- latency_ration = LATENCY_LIMIT;
- }
- }
-
offset = scan_base;
spin_lock(&si->lock);
si->cluster_nr = SWAPFILE_CLUSTER - 1;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] swap: Delete the "last_in_cluster < scan_base" loop in the body of scan_swap_map()
2014-06-02 11:54 [PATCH] swap: Delete the "last_in_cluster < scan_base" loop in the body of scan_swap_map() Chen Yucong
@ 2014-06-02 23:26 ` Hugh Dickins
0 siblings, 0 replies; 2+ messages in thread
From: Hugh Dickins @ 2014-06-02 23:26 UTC (permalink / raw)
To: Chen Yucong; +Cc: shli, hughd, akpm, linux-mm, linux-kernel
On Mon, 2 Jun 2014, Chen Yucong wrote:
> From commit ebc2a1a69111, we can find that all SWP_SOLIDSTATE "seek is cheap"(SSD case)
> has already gone to si->cluster_info scan_swap_map_try_ssd_cluster() route. So that the
> "last_in_cluster < scan_base" loop in the body of scan_swap_map() has already become a
> dead code snippet, and it should have been deleted.
>
> This patch is to delete the redundant loop as Hugh and Shaohua suggested.
>
> Signed-off-by: Chen Yucong <slaoub@gmail.com>
That is very nice, thank you.
Acked-by: Hugh Dickins <hughd@google.com>
But it does beg for just a little more: perhaps Andrew can kindly fold in:
---
mm/swapfile.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
--- chen/mm/swapfile.c 2014-06-02 15:55:44.812368186 -0700
+++ hugh/mm/swapfile.c 2014-06-02 16:15:20.344396124 -0700
@@ -505,13 +505,10 @@ static unsigned long scan_swap_map(struc
/*
* If seek is expensive, start searching for new cluster from
* start of partition, to minimize the span of allocated swap.
- * But if seek is cheap, search from our current position, so
- * that swap is allocated from all over the partition: if the
- * Flash Translation Layer only remaps within limited zones,
- * we don't want to wear out the first zone too quickly.
+ * If seek is cheap, that is the SWP_SOLIDSTATE si->cluster_info
+ * case, just handled by scan_swap_map_try_ssd_cluster() above.
*/
- if (!(si->flags & SWP_SOLIDSTATE))
- scan_base = offset = si->lowest_bit;
+ scan_base = offset = si->lowest_bit;
last_in_cluster = offset + SWAPFILE_CLUSTER - 1;
/* Locate the first empty (unaligned) cluster */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-02 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02 11:54 [PATCH] swap: Delete the "last_in_cluster < scan_base" loop in the body of scan_swap_map() Chen Yucong
2014-06-02 23:26 ` Hugh Dickins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).