Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-06 Thread Andrew Morton
On Thu, 1 Nov 2018 18:41:33 -0600 William Kucharski wrote: > > > > On Nov 1, 2018, at 3:47 PM, Andrew Morton wrote: > > > > - count = count > PAGE_SIZE ? PAGE_SIZE : count; > > + count = min_t(size_t, count, PAGE_SIZE); > > kbuf = kmalloc(count, GFP_KERNEL); > > if (!kbuf) > >

Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-01 Thread William Kucharski
> On Nov 1, 2018, at 3:47 PM, Andrew Morton wrote: > > - count = count > PAGE_SIZE ? PAGE_SIZE : count; > + count = min_t(size_t, count, PAGE_SIZE); > kbuf = kmalloc(count, GFP_KERNEL); > if (!kbuf) > return -ENOMEM; Is the use of min_t vs. the C conditional

Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-01 Thread Matthew Wilcox
On Thu, Nov 01, 2018 at 04:30:12PM -0700, Joe Perches wrote: > On Thu, 2018-11-01 at 14:47 -0700, Andrew Morton wrote: > > +++ a/mm/page_owner.c > > @@ -351,7 +351,7 @@ print_page_owner(char __user *buf, size_ > > .skip = 0 > > }; > > > > - count = count > PAGE_SIZE ? PAGE_SIZE

Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-01 Thread Joe Perches
On Thu, 2018-11-01 at 14:47 -0700, Andrew Morton wrote: > On Fri, 2 Nov 2018 01:00:07 +0800 wrote: > > > From: Miles Chen > > > > The page owner read might allocate a large size of memory with > > a large read count. Allocation fails can easily occur when doing > > high order allocations. > >

Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-01 Thread Andrew Morton
On Fri, 2 Nov 2018 01:00:07 +0800 wrote: > From: Miles Chen > > The page owner read might allocate a large size of memory with > a large read count. Allocation fails can easily occur when doing > high order allocations. > > Clamp buffer size to PAGE_SIZE to avoid arbitrary size allocation > an

Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-01 Thread Michal Hocko
On Fri 02-11-18 01:00:07, miles.c...@mediatek.com wrote: > From: Miles Chen > > The page owner read might allocate a large size of memory with > a large read count. Allocation fails can easily occur when doing > high order allocations. > > Clamp buffer size to PAGE_SIZE to avoid arbitrary size a

[PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE

2018-11-01 Thread miles.chen
From: Miles Chen The page owner read might allocate a large size of memory with a large read count. Allocation fails can easily occur when doing high order allocations. Clamp buffer size to PAGE_SIZE to avoid arbitrary size allocation and avoid allocation fails due to high order allocation. Cha