Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617448

Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free

From "Huang\, Ying" <ying.huang@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free
Date 2017-04-06 02:50 +0200
Message-ID <tt3MC-1i6-5@gated-at.bofh.it> (permalink)
References <tsNou-7Zm-17@gated-at.bofh.it> <tsUpY-3RS-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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)

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH -mm -v2] mm, swap: Sort swap entries before free "Huang, Ying" <ying.huang@intel.com> - 2017-04-05 09:20 +0200
  Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free Rik van Riel <riel@redhat.com> - 2017-04-05 16:50 +0200
    Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free "Huang\, Ying" <ying.huang@intel.com> - 2017-04-06 02:50 +0200

csiph-web