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:   Wed, 5 Dec 2018 09:28:44 +0100
From:   David Hildenbrand <david@...hat.com>
To:     Matthew Wilcox <willy@...radead.org>,
        Anthony Yznaga <anthony.yznaga@...cle.com>
Cc:     linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        adobriyan@...il.com, akpm@...ux-foundation.org, vbabka@...e.cz,
        sfr@...b.auug.org.au, kirill.shutemov@...ux.intel.com,
        rppt@...ux.vnet.ibm.com, mhocko@...e.com,
        alexander.h.duyck@...ux.intel.com, hannes@...xchg.org,
        miles.chen@...iatek.com, n-horiguchi@...jp.nec.com
Subject: Re: [PATCH] /proc/kpagecount: return 0 for special pages that are
 never mapped

On 05.12.18 01:48, Matthew Wilcox wrote:
> On Tue, Dec 04, 2018 at 02:45:26PM -0800, Anthony Yznaga wrote:
>> Certain pages that are never mapped to userspace have a type
>> indicated in the page_type field of their struct pages (e.g. PG_buddy).
>> page_type overlaps with _mapcount so set the count to 0 and avoid
>> calling page_mapcount() for these pages.
>>
>> Signed-off-by: Anthony Yznaga <anthony.yznaga@...cle.com>
>> ---
>>  fs/proc/page.c             | 2 +-
>>  include/linux/page-flags.h | 7 +++++++
>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/proc/page.c b/fs/proc/page.c
>> index 6c517b11acf8..40b05e0d4274 100644
>> --- a/fs/proc/page.c
>> +++ b/fs/proc/page.c
>> @@ -46,7 +46,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
>>  			ppage = pfn_to_page(pfn);
>>  		else
>>  			ppage = NULL;
>> -		if (!ppage || PageSlab(ppage))
>> +		if (!ppage || PageSlab(ppage) || page_has_type(ppage))
>>  			pcount = 0;
>>  		else
>>  			pcount = page_mapcount(ppage);
>> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
>> index 50ce1bddaf56..f9a1c50ccefc 100644
>> --- a/include/linux/page-flags.h
>> +++ b/include/linux/page-flags.h
>> @@ -673,10 +673,17 @@ static inline int TestClearPageDoubleMap(struct page *page)
>>  #define PG_balloon	0x00000100
>>  #define PG_kmemcg	0x00000200
>>  #define PG_table	0x00000400
>> +#define PAGE_TYPE_ALL	(PG_buddy | PG_balloon | PG_kmemcg | PG_table)
>>  
>>  #define PageType(page, flag)						\
>>  	((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
>>  
>> +static inline int page_has_type(struct page *page)
>> +{
>> +	return (PageType(page, 0) &&
>> +	       ((page->page_type & PAGE_TYPE_ALL) != PAGE_TYPE_ALL));
>> +}
>> +
>>  #define PAGE_TYPE_OPS(uname, lname)					\
> 
> I think this is a bit complex, and a bit of a pain to update as we add
> new page types.  How about this?
> 
> 	return (int)page_type < -128;
> 
> (I'm open to appropriate #defines to make this more obvious that it's ~0x7F)
> 
There was already a collision on linux-next, where PG_balloon was
renamed to PG_offline.

-- 

Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ