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-next>] [day] [month] [year] [list]
Date:   Fri, 2 Sep 2022 11:04:27 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Kefeng Wang <wangkefeng.wang@...wei.com>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org
Cc:     Mike Rapoport <rppt@...nel.org>,
        Oscar Salvador <osalvador@...e.de>,
        linux-kernel@...r.kernel.org, Vlastimil Babka <vbabka@...e.cz>
Subject: Re: [PATCH 2/2] mm: add pageblock_aligned() macro

On 02.09.22 11:02, Kefeng Wang wrote:
> 
> On 2022/9/2 16:42, David Hildenbrand wrote:
>> On 02.09.22 08:47, Kefeng Wang wrote:
>>> Add pageblock_aligned() and use it to simplify code.
>>>
>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
>>> ---
>> [...]
>>
>>> -	unsigned long nr_pgmask = pageblock_nr_pages - 1;
>>>  	int nid = zone_to_nid(zone);
>>>  	unsigned long nr_pages = 0;
>>>  	int zid = zone_idx(zone);
>>> @@ -1977,7 +1974,7 @@ static unsigned long  __init deferred_init_pages(struct zone *zone,
>>>  		if (!deferred_pfn_valid(pfn)) {
>>>  			page = NULL;
>>>  			continue;
>>> -		} else if (!page || !(pfn & nr_pgmask)) {
>> I didn't sleep too well this night and am tired, please tell me why I'm
>> wrong :)
> Wish you have a good reset :)

Thanks, the headache isn't helping :D

>> "pfn & (pageblock_nr_pages - 1)" is true if the pageblock is not aligned
>>
>> E.g., pfn = 1, pageblock_nr_pages = 512
>>
>> pfn & (pageblock_nr_pages - 1)
>> -> 1 & (512 - 1)
>> -> 1 & 511
>> -> true
>>
>> "!(pfn & (pageblock_nr_pages - 1))" is true if the pageblock is aligned
>> -> !(true)
>> -> false
>>
>>
>> However, "!pageblock_aligned(1)" = true
>>
>>
>>> +		} else if (!page || !pageblock_aligned(pfn)) {
> 
> pageblock_aligned(pfn) IS_ALIGNED((unsigned long)(pfn), pageblock_nr_pages)
> 
> #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) (((pfn) &
> (pageblock_nr_pages - 1)) == 0) -> ((1 & 512 -1) == 0) -> ((1 & 511) ==
> 0) -> ((511) == 0) -> false
> right ? 

yes ... and inverting that would give you "true", which is not what we want?


Again, sorry if I'm wrong ...

-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ