diff options
author | Minchan Kim <minchan@kernel.org> | 2016-11-22 11:49:37 +0900 |
---|---|---|
committer | Minchan Kim <minchan@kernel.org> | 2016-11-22 18:42:05 +0900 |
commit | d7f9055144c5b3d2a2d22aae45f062f01fd8f630 (patch) | |
tree | 0ad7c818092ffaf66bf22725b9d707614dbfebd8 | |
parent | c76234982adbe6dea441f1dc9da17da2106c2a91 (diff) | |
download | linux-mm/swap-refact-v1r3.tar.gz |
swap: {inc,dec}_cluster_info tidy upmm/swap-refact-v1r3
Signed-off-by: Minchan Kim <minchan@kernel.org>
-rw-r--r-- | mm/swapfile.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index d1c8ceb7c31cf1..edd6fda98c87a6 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -362,16 +362,15 @@ static void swap_discard_work(struct work_struct *work) } /* - * The cluster corresponding to page_nr will be used. The cluster will be + * The cluster corresponding to offset will be used. The cluster will be * removed from free cluster list and its usage counter will be increased. */ static void inc_cluster_info_page(struct swap_info_struct *p, - struct swap_cluster_info *cluster_info, unsigned long page_nr) + unsigned long offset) { - unsigned long idx = page_nr / SWAPFILE_CLUSTER; + struct swap_cluster_info *cluster_info = p->cluster_info; + unsigned long idx = offset / SWAPFILE_CLUSTER; - if (!cluster_info) - return; if (cluster_is_free(&cluster_info[idx])) { VM_BUG_ON(cluster_list_first(&p->free_clusters) != idx); cluster_list_del_first(&p->free_clusters, cluster_info); @@ -384,17 +383,16 @@ static void inc_cluster_info_page(struct swap_info_struct *p, } /* - * The cluster corresponding to page_nr decreases one usage. If the usage + * The cluster corresponding to offset decreases one usage. If the usage * counter becomes 0, which means no page in the cluster is in using, we can * optionally discard the cluster and add it to free cluster list. */ static void dec_cluster_info_page(struct swap_info_struct *p, - struct swap_cluster_info *cluster_info, unsigned long page_nr) + unsigned long offset) { - unsigned long idx = page_nr / SWAPFILE_CLUSTER; + unsigned long idx = offset / SWAPFILE_CLUSTER; + struct swap_cluster_info *cluster_info = p->cluster_info; - if (!cluster_info) - return; VM_BUG_ON(cluster_count(&cluster_info[idx]) == 0); cluster_set_count(&cluster_info[idx], @@ -420,13 +418,13 @@ static void dec_cluster_info_page(struct swap_info_struct *p, static void ssd_swap_entry_alloc(struct swap_info_struct *si, unsigned long offset) { - inc_cluster_info_page(si, si->cluster_info, offset); + inc_cluster_info_page(si, offset); } static void ssd_swap_entry_free(struct swap_info_struct *si, unsigned long offset) { - dec_cluster_info_page(si, si->cluster_info, offset); + dec_cluster_info_page(si, offset); } /* @@ -2354,13 +2352,13 @@ static int ssd_cluster_init(struct swap_info_struct *p, for (i = 0; i < swap_header->info.nr_badpages; i++) { page_nr = swap_header->info.badpages[i]; if (page_nr < maxpages) - inc_cluster_info_page(p, cluster_info, page_nr); + inc_cluster_info_page(p, page_nr); } for (i = maxpages; i < round_up(maxpages, SWAPFILE_CLUSTER); i++) - inc_cluster_info_page(p, cluster_info, i); + inc_cluster_info_page(p, i); - inc_cluster_info_page(p, cluster_info, 0); + inc_cluster_info_page(p, 0); for (i = 0; i < nr_clusters; i++) { if (!cluster_count(&cluster_info[idx])) { |