From: Vlastimil Babka <vbabka@suse.cz>
To: Mel Gorman <mgorman@techsingularity.net>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Nicolas Saenz Julienne <nsaenzju@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Michal Hocko <mhocko@kernel.org>, Hugh Dickins <hughd@google.com>,
Yu Zhao <yuzhao@google.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/page_alloc: replace local_lock with normal spinlock -fix -fix
Date: Fri, 8 Jul 2022 16:54:47 +0200 [thread overview]
Message-ID: <a78f95e9-298a-bc97-9776-14e0f02f62b9@suse.cz> (raw)
In-Reply-To: <20220708144406.GJ27531@techsingularity.net>
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. */
next prev parent reply other threads:[~2022-07-08 14:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 14:44 Mel Gorman
2022-07-08 14:54 ` Vlastimil Babka [this message]
2022-07-08 15:58 ` Mel Gorman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a78f95e9-298a-bc97-9776-14e0f02f62b9@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=mtosatti@redhat.com \
--cc=nsaenzju@redhat.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox