lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 8 Jul 2022 16:54:47 +0200
From:   Vlastimil Babka <vbabka@...e.cz>
To:     Mel Gorman <mgorman@...hsingularity.net>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     Nicolas Saenz Julienne <nsaenzju@...hat.com>,
        Marcelo Tosatti <mtosatti@...hat.com>,
        Michal Hocko <mhocko@...nel.org>,
        Hugh Dickins <hughd@...gle.com>, Yu Zhao <yuzhao@...gle.com>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Linux-MM <linux-mm@...ck.org>
Subject: Re: [PATCH] mm/page_alloc: replace local_lock with normal spinlock
 -fix -fix

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@...hsingularity.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. */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ