lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 14 Jul 2020 11:22:03 +0200
From:   Vlastimil Babka <vbabka@...e.cz>
To:     Wei Yang <richard.weiyang@...ux.alibaba.com>,
        mike.kravetz@...cle.com, akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/hugetlb: hide nr_nodes in the internal of
 for_each_node_mask_to_[alloc|free]

On 7/14/20 11:13 AM, Vlastimil Babka wrote:
> On 7/14/20 9:34 AM, Wei Yang wrote:
>> The second parameter of for_each_node_mask_to_[alloc|free] is a loop
>> variant, which is not used outside of loop iteration.
>> 
>> Let's hide this.
>> 
>> Signed-off-by: Wei Yang <richard.weiyang@...ux.alibaba.com>
>> ---
>>  mm/hugetlb.c | 38 ++++++++++++++++++++------------------
>>  1 file changed, 20 insertions(+), 18 deletions(-)
>> 
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 57ece74e3aae..9c3d15fb317e 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -1196,17 +1196,19 @@ static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed)
>>  	return nid;
>>  }
>>  
>> -#define for_each_node_mask_to_alloc(hs, nr_nodes, node, mask)		\
>> -	for (nr_nodes = nodes_weight(*mask);				\
>> -		nr_nodes > 0 &&						\
>> +#define for_each_node_mask_to_alloc(hs, node, mask)			\
>> +	int __nr_nodes;							\
>> +	for (__nr_nodes = nodes_weight(*mask);				\
> 
> The problem with this is that if I use the macro twice in the same block, this
> will redefine __nr_nodes and fail to compile, no?
> In that case it's better to avoid setting up this trap, IMHO.

Ah, and it will also generate the following warning, if the use of for_each*
macro is not the first thing after variable declarations, but there's another
statement before:

warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

Instead we should switch to C99 and declare it as "for (int __nr_nodes" :P

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ