From: "Huang\, Ying" <ying.huang@intel.com>
To: Rik van Riel <riel@redhat.com>
Cc: "Huang, Ying" <ying.huang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Hugh Dickins <hughd@google.com>, Shaohua Li <shli@kernel.org>,
Minchan Kim <minchan@kernel.org>
Subject: Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free
Date: Thu, 06 Apr 2017 08:47:30 +0800 [thread overview]
Message-ID: <87k26ye50d.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <1491403231.16856.11.camel@redhat.com> (Rik van Riel's message of "Wed, 5 Apr 2017 10:40:31 -0400")
Rik van Riel <riel@redhat.com> writes:
> On Wed, 2017-04-05 at 15:10 +0800, Huang, Ying wrote:
>> To solve the issue, the per-CPU buffer is sorted according to the
>> swap
>> device before freeing the swap entries.A A Test shows that the time
>> spent by swapcache_free_entries() could be reduced after the patch.
>
> That makes a lot of sense.
>
>> @@ -1075,6 +1083,8 @@ void swapcache_free_entries(swp_entry_t
>> *entries, int n)
>> A
>> A prev = NULL;
>> A p = NULL;
>> + if (nr_swapfiles > 1)
>> + sort(entries, n, sizeof(entries[0]), swp_entry_cmp,
>> NULL);
>
> But it really wants a comment in the code, so people
> reading the code a few years from now can see why
> we are sorting things we are about to free.
>
> Maybe something like:
> A A A A /* Sort swap entries by swap device, so each lock is only taken
> once. */
Good suggestion! I will add it in the next version.
Best Regards,
Huang, Ying
>> A for (i = 0; i < n; ++i) {
>> A p = swap_info_get_cont(entries[i], prev);
>> A if (p)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: "Huang\, Ying" <ying.huang@intel.com>
To: Rik van Riel <riel@redhat.com>
Cc: "Huang\, Ying" <ying.huang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, Hugh Dickins <hughd@google.com>,
Shaohua Li <shli@kernel.org>, Minchan Kim <minchan@kernel.org>
Subject: Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free
Date: Thu, 06 Apr 2017 08:47:30 +0800 [thread overview]
Message-ID: <87k26ye50d.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <1491403231.16856.11.camel@redhat.com> (Rik van Riel's message of "Wed, 5 Apr 2017 10:40:31 -0400")
Rik van Riel <riel@redhat.com> writes:
> On Wed, 2017-04-05 at 15:10 +0800, Huang, Ying wrote:
>> To solve the issue, the per-CPU buffer is sorted according to the
>> swap
>> device before freeing the swap entries. Test shows that the time
>> spent by swapcache_free_entries() could be reduced after the patch.
>
> That makes a lot of sense.
>
>> @@ -1075,6 +1083,8 @@ void swapcache_free_entries(swp_entry_t
>> *entries, int n)
>>
>> prev = NULL;
>> p = NULL;
>> + if (nr_swapfiles > 1)
>> + sort(entries, n, sizeof(entries[0]), swp_entry_cmp,
>> NULL);
>
> But it really wants a comment in the code, so people
> reading the code a few years from now can see why
> we are sorting things we are about to free.
>
> Maybe something like:
> /* Sort swap entries by swap device, so each lock is only taken
> once. */
Good suggestion! I will add it in the next version.
Best Regards,
Huang, Ying
>> for (i = 0; i < n; ++i) {
>> p = swap_info_get_cont(entries[i], prev);
>> if (p)
next prev parent reply other threads:[~2017-04-06 0:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-05 7:10 [PATCH -mm -v2] mm, swap: Sort swap entries before free Huang, Ying
2017-04-05 7:10 ` Huang, Ying
2017-04-05 14:40 ` Rik van Riel
2017-04-06 0:47 ` Huang, Ying [this message]
2017-04-06 0:47 ` Huang, Ying
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=87k26ye50d.fsf@yhuang-dev.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=shli@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.