lkml.org 
[lkml]   [2020]   [Oct]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] mm: swap: Use memset to fill the swap_map with SWAP_HAS_CACHE
Date
Friendly ping.

> We could use helper memset to fill the swap_map with SWAP_HAS_CACHE instead of a direct loop here to simplify the code. Also we can remove the local variable i and map this way.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> mm/swapfile.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c index 8feaab31a3a9..b0b629b24e3a 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -975,8 +975,7 @@ static int swap_alloc_cluster(struct swap_info_struct *si, swp_entry_t *slot) {
> unsigned long idx;
> struct swap_cluster_info *ci;
> - unsigned long offset, i;
> - unsigned char *map;
> + unsigned long offset;
>
> /*
> * Should not even be attempting cluster allocations when huge @@ -996,9 +995,7 @@ static int swap_alloc_cluster(struct swap_info_struct *si, swp_entry_t *slot)
> alloc_cluster(si, idx);
> cluster_set_count_flag(ci, SWAPFILE_CLUSTER, CLUSTER_FLAG_HUGE);
>
> - map = si->swap_map + offset;
> - for (i = 0; i < SWAPFILE_CLUSTER; i++)
> - map[i] = SWAP_HAS_CACHE;
> + memset(si->swap_map + offset, SWAP_HAS_CACHE, SWAPFILE_CLUSTER);
> unlock_cluster(ci);
> swap_range_alloc(si, offset, SWAPFILE_CLUSTER);
> *slot = swp_entry(si->type, offset);
> --
> 2.19.1
>

\
 
 \ /
  Last update: 2020-10-07 04:51    [W:0.300 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site