lkml.org 
[lkml]   [2018]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 2/7] mm/swapfile.c: Replace some #ifdef with IS_ENABLED()
Date
Dave Hansen <dave.hansen@linux.intel.com> writes:

>> @@ -878,6 +877,11 @@ static int swap_alloc_cluster(struct swap_info_struct *si, swp_entry_t *slot)
>> unsigned long offset, i;
>> unsigned char *map;
>>
>> + if (!IS_ENABLED(CONFIG_THP_SWAP)) {
>> + VM_WARN_ON_ONCE(1);
>> + return 0;
>> + }
>
> I see you seized the opportunity to keep this code gloriously
> unencumbered by pesky comments. This seems like a time when you might
> have slipped up and been temped to add a comment or two. Guess not. :)
>
> Seriously, though, does it hurt us to add a comment or two to say
> something like:
>
> /*
> * Should not even be attempting cluster allocations when
> * huge page swap is disabled. Warn and fail the allocation.
> */
> if (!IS_ENABLED(CONFIG_THP_SWAP)) {
> VM_WARN_ON_ONCE(1);
> return 0;
> }

I totally agree with you that we should add more comments for THP swap
to improve the code readability. As for this specific case,
VM_WARN_ON_ONCE() here is just to capture some programming error during
development. Do we really need comments here?

I will try to add more comments for other places in code regardless this
one.

Best Regards,
Huang, Ying

\
 
 \ /
  Last update: 2018-07-18 05:26    [W:0.062 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site