From: linmiaohe <linmiaohe@huawei.com>
To: "akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: swap: Use memset to fill the swap_map with SWAP_HAS_CACHE
Date: Wed, 7 Oct 2020 02:49:53 +0000 [thread overview]
Message-ID: <bd833f513d2a47daaa55099421bd4f7a@huawei.com> (raw)
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
>
next reply other threads:[~2020-10-07 2:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 2:49 linmiaohe [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-10-26 3:03 linmiaohe
2020-09-21 12:22 Miaohe Lin
2020-10-26 0:14 ` Andrew Morton
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=bd833f513d2a47daaa55099421bd4f7a@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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