From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<linmiaohe@huawei.com>
Subject: [PATCH] mm: avoid possible multiple call to swap_node()
Date: Thu, 17 Sep 2020 07:44:49 -0400 [thread overview]
Message-ID: <20200917114449.35285-1-linmiaohe@huawei.com> (raw)
Cache the swap_node() in a local variable to avoid possible multiple call
to swap_node(), though compiler may do this for us.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/swapfile.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 20012c0c0252..cd66b50f0490 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2454,7 +2454,7 @@ static void setup_swap_info(struct swap_info_struct *p, int prio,
unsigned char *swap_map,
struct swap_cluster_info *cluster_info)
{
- int i;
+ int i, node;
if (prio >= 0)
p->prio = prio;
@@ -2465,11 +2465,12 @@ static void setup_swap_info(struct swap_info_struct *p, int prio,
* low-to-high, while swap ordering is high-to-low
*/
p->list.prio = -p->prio;
+ node = swap_node(p);
for_each_node(i) {
if (p->prio >= 0)
p->avail_lists[i].prio = -p->prio;
else {
- if (swap_node(p) == i)
+ if (node == i)
p->avail_lists[i].prio = 1;
else
p->avail_lists[i].prio = -p->prio;
--
2.19.1
next reply other threads:[~2020-09-17 11:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 11:44 Miaohe Lin [this message]
2020-09-17 11:48 ` [PATCH] mm: avoid possible multiple call to swap_node() Matthew Wilcox
2020-09-17 11:54 linmiaohe
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=20200917114449.35285-1-linmiaohe@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;
as well as URLs for NNTP newsgroup(s).