lkml.org 
[lkml]   [2020]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/4] mm/swap: use SECTORS_PER_PAGE_SHIFT to clean up code
From
Date


On 2020/5/6 9:33, Leizhen (ThunderTown) wrote:
>
>
> On 2020/5/6 1:25, Matthew Wilcox wrote:
>> On Tue, May 05, 2020 at 07:55:41PM +0800, Zhen Lei wrote:
>>> +++ b/mm/swapfile.c
>>> @@ -177,8 +177,8 @@ static int discard_swap(struct swap_info_struct *si)
>>>
>>> /* Do not discard the swap header page! */
>>> se = first_se(si);
>>> - start_block = (se->start_block + 1) << (PAGE_SHIFT - 9);
>>> - nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9);
>>> + start_block = (se->start_block + 1) << SECTORS_PER_PAGE_SHIFT;
>>> + nr_blocks = ((sector_t)se->nr_pages - 1) << SECTORS_PER_PAGE_SHIFT;
>>
>> Thinking about this some more, wouldn't this look better?
>>
>> start_block = page_sectors(se->start_block + 1);
>> nr_block = page_sectors(se->nr_pages - 1);
>>
>
> OK,That's fine, it's clearer. And in this way, there won't be more than 80 columns.

Should we rename "page_sectors" to "page_to_sectors"? Because we may need to define
"sectors_to_page" also.

>
>>
>> .
>>

\
 
 \ /
  Last update: 2020-05-06 05:48    [W:0.070 / U:0.400 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site