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]
Message-Id: <20250210163736.ed1c93a44a47e39820fb8d85@linux-foundation.org>
Date: Mon, 10 Feb 2025 16:37:36 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: I Hsin Cheng <richard120310@...il.com>
Cc: zhengqi.arch@...edance.com, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, jserv@...s.ncku.edu.tw
Subject: Re: [PATCH] mm: pgtable: Unlock pml without branches when
 !start_pte

On Mon, 10 Feb 2025 18:09:48 +0800 I Hsin Cheng <richard120310@...il.com> wrote:

> When !start_pte is true, the branch for "start_pte" in "out_ptl" label
> section is surely false, and "ptl != pml" must be true since "ptl" is
> NULL in this case.
> 
> It means both branches in "out_ptl" are redundant, only one thing to be
> done is to unlock "pml", make it directly unlock "pml" and return in
> this case.

Hopefully the compiler will skip the `if (start_pte)' test.

Generally, we try to avoid multiple function return points.  We could do

--- a/mm/pt_reclaim.c~mm-pgtable-unlock-pml-without-branches-when-start_pte
+++ a/mm/pt_reclaim.c
@@ -43,7 +43,7 @@ void try_to_free_pte(struct mm_struct *m
 	pml = pmd_lock(mm, pmd);
 	start_pte = pte_offset_map_rw_nolock(mm, pmd, addr, &pmdval, &ptl);
 	if (!start_pte)
-		goto out_ptl;
+		goto out_unlock;
 	if (ptl != pml)
 		spin_lock_nested(ptl, SINGLE_DEPTH_NESTING);
 
@@ -67,5 +67,6 @@ out_ptl:
 	if (start_pte)
 		pte_unmap_unlock(start_pte, ptl);
 	if (ptl != pml)
+out_unlock:
 		spin_unlock(pml);
 }
_

but that's really ugly.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ