From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<linmiaohe@huawei.com>
Subject: [PATCH] mm/pgtable-generic.c: optimize the VM_BUG_ON condition in pmdp_huge_clear_flush()
Date: Wed, 3 Feb 2021 03:41:37 -0500 [thread overview]
Message-ID: <20210203084137.25522-1-linmiaohe@huawei.com> (raw)
The developer will have trouble figuring out why the BUG actually triggered
when there is a complex expression in the VM_BUG_ON. Because we can only
identify the condition triggered BUG via line number provided by VM_BUG_ON.
Optimize this by spliting such a complex expression into two simple
conditions.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/pgtable-generic.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index fa1375f3e3b2..c2210e1cdb51 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -135,8 +135,9 @@ pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address,
{
pmd_t pmd;
VM_BUG_ON(address & ~HPAGE_PMD_MASK);
- VM_BUG_ON(!pmd_present(*pmdp) || (!pmd_trans_huge(*pmdp) &&
- !pmd_devmap(*pmdp)));
+ VM_BUG_ON(!pmd_present(*pmdp));
+ /* Below assumes pmd_present() is true */
+ VM_BUG_ON(!pmd_trans_huge(*pmdp) && !pmd_devmap(*pmdp));
pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
return pmd;
--
2.19.1
next reply other threads:[~2021-02-03 8:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 8:41 Miaohe Lin [this message]
2021-02-04 12:36 ` [PATCH] mm/pgtable-generic.c: optimize the VM_BUG_ON condition in pmdp_huge_clear_flush() Matthew Wilcox
2021-02-05 3:22 ` Miaohe Lin
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=20210203084137.25522-1-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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;
as well as URLs for NNTP newsgroup(s).