lkml.org 
[lkml]   [2018]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -mm -v4 04/21] mm, THP, swap: Support PMD swap mapping in swapcache_free_cluster()
From
Date
On 07/09/2018 11:53 PM, Huang, Ying wrote:
> Dave Hansen <dave.hansen@linux.intel.com> writes:
>>> +#ifdef CONFIG_THP_SWAP
>>> +static inline int cluster_swapcount(struct swap_cluster_info *ci)
>>> +{
>>> + if (!ci || !cluster_is_huge(ci))
>>> + return 0;
>>> +
>>> + return cluster_count(ci) - SWAPFILE_CLUSTER;
>>> +}
>>> +#else
>>> +#define cluster_swapcount(ci) 0
>>> +#endif
>>
>> Dumb questions, round 2: On a CONFIG_THP_SWAP=n build, presumably,
>> cluster_is_huge()=0 always, so cluster_swapout() always returns 0. Right?
>>
>> So, why the #ifdef?
>
> #ifdef here is to reduce the code size for !CONFIG_THP_SWAP.

I'd just remove the !CONFIG_THP_SWAP version entirely.

>>> @@ -1288,24 +1301,30 @@ static void swapcache_free_cluster(swp_entry_t entry)
>>>
>>> ci = lock_cluster(si, offset);
>>> VM_BUG_ON(!cluster_is_huge(ci));
>>> + VM_BUG_ON(!is_cluster_offset(offset));
>>> + VM_BUG_ON(cluster_count(ci) < SWAPFILE_CLUSTER);
>>> map = si->swap_map + offset;
>>> - for (i = 0; i < SWAPFILE_CLUSTER; i++) {
>>> - val = map[i];
>>> - VM_BUG_ON(!(val & SWAP_HAS_CACHE));
>>> - if (val == SWAP_HAS_CACHE)
>>> - free_entries++;
>>> + if (!cluster_swapcount(ci)) {
>>> + for (i = 0; i < SWAPFILE_CLUSTER; i++) {
>>> + val = map[i];
>>> + VM_BUG_ON(!(val & SWAP_HAS_CACHE));
>>> + if (val == SWAP_HAS_CACHE)
>>> + free_entries++;
>>> + }
>>> + if (free_entries != SWAPFILE_CLUSTER)
>>> + cluster_clear_huge(ci);
>>> }
>>
>> Also, I'll point out that cluster_swapcount() continues the horrific
>> naming of cluster_couunt(), not saying what the count is *of*. The
>> return value doesn't help much:
>>
>> return cluster_count(ci) - SWAPFILE_CLUSTER;
>
> We have page_swapcount() for page, swp_swapcount() for swap entry.
> cluster_swapcount() tries to mimic them for swap cluster. But I am not
> good at naming in general. What's your suggestion?

I don't have a suggestion because I haven't the foggiest idea what it is
doing. :)

Is it the number of instantiated swap cache pages that are referring to
this cluster? Is it just huge pages? Huge and small? One refcount per
huge page, or 512?

\
 
 \ /
  Last update: 2018-07-10 15:55    [W:0.140 / U:5.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site