[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250819144421.7a52f8df3f0fe5c315f90aa2@linux-foundation.org>
Date: Tue, 19 Aug 2025 14:44:21 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Joshua Hahn <joshua.hahnjy@...il.com>
Cc: Johannes Weiner <hannes@...xchg.org>, Chris Mason <clm@...com>,
Vlastimil Babka <vbabka@...e.cz>, Suren Baghdasaryan <surenb@...le.com>,
Michal Hocko <mhocko@...e.com>, Brendan Jackman <jackmanb@...gle.com>, Zi
Yan <ziy@...dia.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org,
kernel-team@...a.com
Subject: Re: [PATCH] mm/page_alloc: Occasionally relinquish zone lock in
batch freeing
On Tue, 19 Aug 2025 08:18:45 -0700 Joshua Hahn <joshua.hahnjy@...il.com> wrote:
> > Pretty this isn't.
> >
> > Sigh, we do so much stuff here and in __free_one_page().
> >
> > What sort of guarantee do we have that the contending task will be able
> > to get in and grab the spinlock in that tiny time window?
>
> Thank you for pointing this out -- I don't think there is any guarantee.
> Kiryl suggested that I put a cond_resched() here, in order to guarantee that
> the contending tasks will be able to grab the spinlock. I think that's a great
> idea -- I'll make this change in v2.
cond_resched() might help because it takes more CPU cycles and expands
the window. A udelay() would of course do this more nicely.
But the contending task is already in state TASK_RUNNING so a
cond_resched() won't have any effect on it?
Also, callers hold pcp->lock, so cond_resched() cannot be called.
Sigh, I dunno, it's all very nasty. I have vague memories of there
being a way of relinquishing a lock to some other task which is
spinning on that lock. Or at least, a proposal. Or I dreamed it.
peterz would be a good person to ask.
Powered by blists - more mailing lists