Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-22 Thread Igor Stoppa
On 21/02/18 14:01, Igor Stoppa wrote: > it seems to return garbage also without this patch, but I need to clean > up the code, try it again and possibly come up with a demo patch for > triggering the problem. > > I'll investigate it more. However it doesn't seem to be related to the > functionali

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-21 Thread Igor Stoppa
On 20/02/18 22:54, Matthew Wilcox wrote: > On Tue, Feb 20, 2018 at 09:53:30PM +0200, Igor Stoppa wrote: [...] >> It was found while testing on a configuration with framebuffer. > > ... ah. You tried to use vmalloc_to_page() on something which wasn't > backed by a struct page. That's *suppose

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-20 Thread Matthew Wilcox
On Tue, Feb 20, 2018 at 09:53:30PM +0200, Igor Stoppa wrote: > The patch relies on the function vmalloc_to_page ... which will return > NULL when applied to huge mappings, while the original implementation > will still work. Huh? vmalloc_to_page() should work for huge mappings... > It was found

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-20 Thread Igor Stoppa
On 12/02/18 18:24, Igor Stoppa wrote: > > > On 11/02/18 23:16, Matthew Wilcox wrote: >> On Sun, Feb 11, 2018 at 05:19:17AM +0200, Igor Stoppa wrote: >>> The struct page has a "mapping" field, which can be re-used, to store a >>> pointer to the parent area. This will avoid more expensive searche

[PATCH 3/6] struct page: add field for vm_struct

2018-02-12 Thread Igor Stoppa
When a page is used for virtual memory, it is often necessary to obtian a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-12 Thread Igor Stoppa
On 11/02/18 23:16, Matthew Wilcox wrote: > On Sun, Feb 11, 2018 at 05:19:17AM +0200, Igor Stoppa wrote: >> The struct page has a "mapping" field, which can be re-used, to store a >> pointer to the parent area. This will avoid more expensive searches. >> >> As example, the function find_vm_area is

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-11 Thread Matthew Wilcox
On Sun, Feb 11, 2018 at 05:19:17AM +0200, Igor Stoppa wrote: > The struct page has a "mapping" field, which can be re-used, to store a > pointer to the parent area. This will avoid more expensive searches. > > As example, the function find_vm_area is reimplemented, to take advantage > of the newly

[PATCH 3/6] struct page: add field for vm_struct

2018-02-10 Thread Igor Stoppa
When a page is used for virtual memory, it is often necessary to obtian a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-09 Thread Igor Stoppa
On 06/02/18 14:37, Matthew Wilcox wrote: [...] > LOCAL variable names should be short, and to the point. [...] > (Documentation/process/coding-style.rst) ok, will do, thanks for the pointer! -- igor

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-09 Thread Igor Stoppa
On 05/02/18 17:33, Christopher Lameter wrote: > On Sat, 3 Feb 2018, Igor Stoppa wrote: > >> - the property of the compound page will affect the property of all the >> pages in the compound, so when one is write protected, it can generate a >> lot of wasted memory, if there is too much slack (bec

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-06 Thread Matthew Wilcox
On Tue, Jan 30, 2018 at 05:14:43PM +0200, Igor Stoppa wrote: > @@ -1744,6 +1748,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned > long align, > const void *caller) > { > struct vm_struct *area; > + unsigned int page_counter; > void *addr; >

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-05 Thread Christopher Lameter
On Sat, 3 Feb 2018, Igor Stoppa wrote: > - the property of the compound page will affect the property of all the > pages in the compound, so when one is write protected, it can generate a > lot of wasted memory, if there is too much slack (because of the order) > With vmalloc, I can allocate any n

[PATCH 3/6] struct page: add field for vm_struct

2018-02-04 Thread Igor Stoppa
When a page is used for virtual memory, it is often necessary to obtian a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This

[PATCH 3/6] struct page: add field for vm_struct

2018-02-03 Thread Igor Stoppa
When a page is used for virtual memory, it is often necessary to obtian a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-03 Thread Igor Stoppa
On 02/02/18 20:43, Christopher Lameter wrote: > On Thu, 1 Feb 2018, Igor Stoppa wrote: > >>> Would it not be better to use compound page allocations here? [...] > Ok its compound_head(). See also the use in the SLAB and SLUB allocator. > >> During hardened user copy permission check, I need t

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-02 Thread Christopher Lameter
On Thu, 1 Feb 2018, Igor Stoppa wrote: > > Would it not be better to use compound page allocations here? > > page_head(whatever) gets you the head page where you can store all sorts > > of information about the chunk of memory. > > Can you please point me to this function/macro? I don't seem to be

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-02 Thread Igor Stoppa
On 01/02/18 23:11, Kees Cook wrote: > IIUC, he means PageHead(), which is also hard to grep for, since it is > a constructed name, via Page##uname in include/linux/page-flags.h: > > __PAGEFLAG(Head, head, PF_ANY) CLEARPAGEFLAG(Head, head, PF_ANY) Thank you, I'll try to provide a meaningful rep

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-01 Thread Kees Cook
On Thu, Feb 1, 2018 at 11:42 PM, Igor Stoppa wrote: > On 01/02/18 02:00, Christopher Lameter wrote: >> Would it not be better to use compound page allocations here? >> page_head(whatever) gets you the head page where you can store all sorts >> of information about the chunk of memory. > > Can you

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-02-01 Thread Igor Stoppa
On 01/02/18 02:00, Christopher Lameter wrote: > On Tue, 30 Jan 2018, Igor Stoppa wrote: > >> @@ -1769,6 +1774,9 @@ void *__vmalloc_node_range(unsigned long size, >> unsigned long align, >> >> kmemleak_vmalloc(area, size, gfp_mask); >> >> +for (page_counter = 0; page_counter < area->nr_

Re: [PATCH 3/6] struct page: add field for vm_struct

2018-01-31 Thread Christopher Lameter
On Tue, 30 Jan 2018, Igor Stoppa wrote: > @@ -1769,6 +1774,9 @@ void *__vmalloc_node_range(unsigned long size, unsigned > long align, > > kmemleak_vmalloc(area, size, gfp_mask); > > + for (page_counter = 0; page_counter < area->nr_pages; page_counter++) > + area->pages[page_

[PATCH 3/6] struct page: add field for vm_struct

2018-01-30 Thread Igor Stoppa
When a page is used for virtual memory, it is often necessary to obtian a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This

[PATCH 3/6] struct page: add field for vm_struct

2018-01-24 Thread Igor Stoppa
When a page is used for virtual memory, it is often necessary to obtian a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This