Re: [PATCH 7/7] mm/page_alloc: Replace local_lock with normal spinlock
From: Mel Gorman
Date: Tue Jun 21 2022 - 05:21:25 EST
On Wed, Jun 15, 2022 at 04:04:46PM -0700, Andrew Morton wrote:
> On Thu, 16 Jun 2022 00:48:55 +0200 Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> wrote:
>
> > In the logs I see lots of errors like:
> >
> > BUG: sleeping function called from invalid context at
> > ./include/linux/sched/mm.h:274
> >
> > BUG: scheduling while atomic: systemd-udevd/288/0x00000002
> >
> > BUG: sleeping function called from invalid context at mm/filemap.c:2647
> >
> > however there are also a fatal ones like:
> >
> > Unable to handle kernel paging request at virtual address 00000000017a87b4
> >
> >
> > The issues seems to be a bit random. Looks like memory trashing.
> > Reverting $subject on top of current linux-next fixes all those issues.
> >
> >
>
> This?
>
> --- a/mm/page_alloc.c~mm-page_alloc-replace-local_lock-with-normal-spinlock-fix
> +++ a/mm/page_alloc.c
> @@ -183,8 +183,10 @@ static DEFINE_MUTEX(pcp_batch_high_lock)
> type *_ret; \
> pcpu_task_pin(); \
> _ret = this_cpu_ptr(ptr); \
> - if (!spin_trylock_irqsave(&_ret->member, flags)) \
> + if (!spin_trylock_irqsave(&_ret->member, flags)) { \
> + pcpu_task_unpin(); \
> _ret = NULL; \
> + } \
> _ret; \
> })
>
This is the correct fix. I *had* a fix for this but in a patch that was
not posted that drops irqsave :(
--
Mel Gorman
SUSE Labs