From: "Huang\, Ying" <ying.huang@intel.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: <akpm@linux-foundation.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <tim.c.chen@linux.intel.com>
Subject: Re: [PATCH 3/4] mm/swapfile.c: compare tmp and max after trying to iterate on swap_map
Date: Tue, 21 Apr 2020 07:51:02 +0800 [thread overview]
Message-ID: <87h7xdsom1.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <20200420213726.juehv5yr5kyhlbxv@master> (Wei Yang's message of "Mon, 20 Apr 2020 21:37:26 +0000")
Wei Yang <richard.weiyang@gmail.com> writes:
> On Mon, Apr 20, 2020 at 09:03:43AM +0800, Huang, Ying wrote:
>>Wei Yang <richard.weiyang@gmail.com> writes:
>>
>>> There are two duplicate code to handle the case when there is no
>>> available swap entry. Just let the code go through and do the check at
>>> second place.
>>>
>>> No functional change is expected.
>>>
>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>> ---
>>> mm/swapfile.c | 4 ----
>>> 1 file changed, 4 deletions(-)
>>>
>>> diff --git a/mm/swapfile.c b/mm/swapfile.c
>>> index 3aae700f9931..07b0bc095411 100644
>>> --- a/mm/swapfile.c
>>> +++ b/mm/swapfile.c
>>> @@ -629,10 +629,6 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si,
>>> tmp = cluster->next;
>>> max = min_t(unsigned long, si->max,
>>> (cluster_next(&cluster->index) + 1) * SWAPFILE_CLUSTER);
>>> - if (tmp >= max) {
>>> - cluster_set_null(&cluster->index);
>>> - goto new_cluster;
>>> - }
>>
>>The code is to avoid to acquire the cluster lock unnecessarily. So I think
>>we should keep this.
>>
>
> If you really want to avoid the lock, my suggestion is to add:
>
> if (tmp < max) {
> ci = lock_cluster(si, tmp);
> while (tmp < max) {
> ...
> }
> unlock_cluster(ci);
> }
>
> Instead of do the similar thing twice.
This is a coding style problem. The original code is common to avoid
too many nested code block. But in this case, I think both works.
Best Regards,
Huang, Ying
>>Best Regards,
>>Huang, Ying
>>
>>> ci = lock_cluster(si, tmp);
>>> while (tmp < max) {
>>> if (!si->swap_map[tmp])
prev parent reply other threads:[~2020-04-20 23:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-19 1:39 [PATCH 1/4] mm/swapfile.c: found_free could be represented by (tmp < max) Wei Yang
2020-04-19 1:39 ` [PATCH 2/4] mm/swapfile.c: tmp is always smaller than max Wei Yang
2020-04-19 1:39 ` [PATCH 4/4] mm/swapfile.c: move new_cluster to check free_clusters directly Wei Yang
2020-04-20 1:41 ` Huang, Ying
2020-04-20 21:45 ` Wei Yang
[not found] ` <20200419013921.14390-3-richard.weiyang@gmail.com>
2020-04-20 1:03 ` [PATCH 3/4] mm/swapfile.c: compare tmp and max after trying to iterate on swap_map Huang, Ying
2020-04-20 21:37 ` Wei Yang
2020-04-20 23:51 ` Huang, Ying [this message]
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=87h7xdsom1.fsf@yhuang-dev.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=richard.weiyang@gmail.com \
--cc=tim.c.chen@linux.intel.com \
/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).