lkml.org 
[lkml]   [2017]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -mm -v2] mm, swap: Sort swap entries before free
From
Date
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. */

>   for (i = 0; i < n; ++i) {
>   p = swap_info_get_cont(entries[i], prev);
>   if (p)
--
All rights reversed
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-04-05 16:43    [W:1.009 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site