* [PATCH] mm/page_alloc: replace local_lock with normal spinlock -fix -fix
@ 2022-07-08 14:44 Mel Gorman
2022-07-08 14:54 ` Vlastimil Babka
0 siblings, 1 reply; 3+ messages in thread
From: Mel Gorman @ 2022-07-08 14:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Nicolas Saenz Julienne, Marcelo Tosatti, Vlastimil Babka,
Michal Hocko, Hugh Dickins, Yu Zhao, Marek Szyprowski, LKML,
Linux-MM
pcpu_spin_unlock and pcpu_spin_unlock_irqrestore both unlock
pcp->lock and then enable preemption. This lacks symmetry against
both the pcpu_spin helpers and differs from how local_unlock_* is
implemented. While this is harmless, it's unnecessary and it's generally
better to unwind locks and preemption state in the reverse order as
they were acquired.
This is a fix on top of the mm-unstable patch
mm-page_alloc-replace-local_lock-with-normal-spinlock-fix.patch
Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
mm/page_alloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 934d1b5a5449..d0141e51e613 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -192,14 +192,14 @@ static DEFINE_MUTEX(pcp_batch_high_lock);
#define pcpu_spin_unlock(member, ptr) \
({ \
- spin_unlock(&ptr->member); \
pcpu_task_unpin(); \
+ spin_unlock(&ptr->member); \
})
#define pcpu_spin_unlock_irqrestore(member, ptr, flags) \
({ \
- spin_unlock_irqrestore(&ptr->member, flags); \
pcpu_task_unpin(); \
+ spin_unlock_irqrestore(&ptr->member, flags); \
})
/* struct per_cpu_pages specific helpers. */
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mm/page_alloc: replace local_lock with normal spinlock -fix -fix
2022-07-08 14:44 [PATCH] mm/page_alloc: replace local_lock with normal spinlock -fix -fix Mel Gorman
@ 2022-07-08 14:54 ` Vlastimil Babka
2022-07-08 15:58 ` Mel Gorman
0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2022-07-08 14:54 UTC (permalink / raw)
To: Mel Gorman, Andrew Morton
Cc: Nicolas Saenz Julienne, Marcelo Tosatti, Michal Hocko,
Hugh Dickins, Yu Zhao, Marek Szyprowski, LKML, Linux-MM
On 7/8/22 16:44, Mel Gorman wrote:
> pcpu_spin_unlock and pcpu_spin_unlock_irqrestore both unlock
> pcp->lock and then enable preemption. This lacks symmetry against
> both the pcpu_spin helpers and differs from how local_unlock_* is
> implemented. While this is harmless, it's unnecessary and it's generally
> better to unwind locks and preemption state in the reverse order as
> they were acquired.
Hm I'm confused, it seems it's done in reverse order (which I agree with)
before this -fix-fix, but not after it?
before, pcpu_spin_lock() (and variants) do pcpu_task_pin() and then
spin_lock() (or variant), and pcpu_spin_unlock() does spin_unlock() and then
pcpu_task_unpin(). That seems symmetrical, i.e. reverse order to me? And
seems to match what local_lock family does too.
> This is a fix on top of the mm-unstable patch
> mm-page_alloc-replace-local_lock-with-normal-spinlock-fix.patch
>
> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
> ---
> mm/page_alloc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 934d1b5a5449..d0141e51e613 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -192,14 +192,14 @@ static DEFINE_MUTEX(pcp_batch_high_lock);
>
> #define pcpu_spin_unlock(member, ptr) \
> ({ \
> - spin_unlock(&ptr->member); \
> pcpu_task_unpin(); \
> + spin_unlock(&ptr->member); \
> })
>
> #define pcpu_spin_unlock_irqrestore(member, ptr, flags) \
> ({ \
> - spin_unlock_irqrestore(&ptr->member, flags); \
> pcpu_task_unpin(); \
> + spin_unlock_irqrestore(&ptr->member, flags); \
> })
>
> /* struct per_cpu_pages specific helpers. */
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mm/page_alloc: replace local_lock with normal spinlock -fix -fix
2022-07-08 14:54 ` Vlastimil Babka
@ 2022-07-08 15:58 ` Mel Gorman
0 siblings, 0 replies; 3+ messages in thread
From: Mel Gorman @ 2022-07-08 15:58 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Andrew Morton, Nicolas Saenz Julienne, Marcelo Tosatti,
Michal Hocko, Hugh Dickins, Yu Zhao, Marek Szyprowski, LKML,
Linux-MM
On Fri, Jul 08, 2022 at 04:54:47PM +0200, Vlastimil Babka wrote:
> On 7/8/22 16:44, Mel Gorman wrote:
> > pcpu_spin_unlock and pcpu_spin_unlock_irqrestore both unlock
> > pcp->lock and then enable preemption. This lacks symmetry against
> > both the pcpu_spin helpers and differs from how local_unlock_* is
> > implemented. While this is harmless, it's unnecessary and it's generally
> > better to unwind locks and preemption state in the reverse order as
> > they were acquired.
>
> Hm I'm confused, it seems it's done in reverse order (which I agree with)
> before this -fix-fix, but not after it?
>
> before, pcpu_spin_lock() (and variants) do pcpu_task_pin() and then
> spin_lock() (or variant), and pcpu_spin_unlock() does spin_unlock() and then
> pcpu_task_unpin(). That seems symmetrical, i.e. reverse order to me? And
> seems to match what local_lock family does too.
>
You're not confused, I am. The patch and the changelog are outright brain
damage from excessive context switching and a sign that it's time for the
weekend to start.
Sorry for this absolute misfortune.
--
Mel Gorman
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-08 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-08 14:44 [PATCH] mm/page_alloc: replace local_lock with normal spinlock -fix -fix Mel Gorman
2022-07-08 14:54 ` Vlastimil Babka
2022-07-08 15:58 ` Mel Gorman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).