Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-11 Thread Andrew Morton
On Mon, 9 Sep 2019 00:10:16 -0600 Yu Zhao wrote: > If we are already under list_lock, don't call kmalloc(). Otherwise we > will run into deadlock because kmalloc() also tries to grab the same > lock. > > Instead, allocate pages directly. Given currently page->objects has > 15 bits, we only need

Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-10 Thread Kirill A. Shutemov
On Mon, Sep 09, 2019 at 03:39:38PM -0600, Yu Zhao wrote: > On Tue, Sep 10, 2019 at 05:57:22AM +0900, Tetsuo Handa wrote: > > On 2019/09/10 1:00, Kirill A. Shutemov wrote: > > > On Mon, Sep 09, 2019 at 12:10:16AM -0600, Yu Zhao wrote: > > >> If we are already under list_lock, don't call kmalloc(). O

Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-09 Thread Yu Zhao
On Tue, Sep 10, 2019 at 10:41:31AM +0900, Tetsuo Handa wrote: > Yu Zhao wrote: > > I think we can safely assume PAGE_SIZE is unsigned long aligned and > > page->objects is non-zero. But if you don't feel comfortable with these > > assumptions, I'd be happy to ensure them explicitly. > > I know PAG

Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-09 Thread Tetsuo Handa
Yu Zhao wrote: > I think we can safely assume PAGE_SIZE is unsigned long aligned and > page->objects is non-zero. But if you don't feel comfortable with these > assumptions, I'd be happy to ensure them explicitly. I know PAGE_SIZE is unsigned long aligned. If someone by chance happens to change fr

Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-09 Thread Yu Zhao
On Tue, Sep 10, 2019 at 05:57:22AM +0900, Tetsuo Handa wrote: > On 2019/09/10 1:00, Kirill A. Shutemov wrote: > > On Mon, Sep 09, 2019 at 12:10:16AM -0600, Yu Zhao wrote: > >> If we are already under list_lock, don't call kmalloc(). Otherwise we > >> will run into deadlock because kmalloc() also tr

Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-09 Thread Tetsuo Handa
On 2019/09/10 1:00, Kirill A. Shutemov wrote: > On Mon, Sep 09, 2019 at 12:10:16AM -0600, Yu Zhao wrote: >> If we are already under list_lock, don't call kmalloc(). Otherwise we >> will run into deadlock because kmalloc() also tries to grab the same >> lock. >> >> Instead, allocate pages directly.

Re: [PATCH] mm: avoid slub allocation while holding list_lock

2019-09-09 Thread Kirill A. Shutemov
On Mon, Sep 09, 2019 at 12:10:16AM -0600, Yu Zhao wrote: > If we are already under list_lock, don't call kmalloc(). Otherwise we > will run into deadlock because kmalloc() also tries to grab the same > lock. > > Instead, allocate pages directly. Given currently page->objects has > 15 bits, we only

[PATCH] mm: avoid slub allocation while holding list_lock

2019-09-08 Thread Yu Zhao
If we are already under list_lock, don't call kmalloc(). Otherwise we will run into deadlock because kmalloc() also tries to grab the same lock. Instead, allocate pages directly. Given currently page->objects has 15 bits, we only need 1 page. We may waste some memory but we only do so when slub de