All of lore.kernel.org
 help / color / mirror / Atom feed
From: thunder.leizhen@huaweicloud.com
To: Mike Rapoport <rppt@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] mm/mm_init.c: eliminate a local variable in mem_debugging_and_hardening_init()
Date: Mon, 18 Mar 2024 21:57:14 +0800	[thread overview]
Message-ID: <20240318135715.312-1-thunder.leizhen@huaweicloud.com> (raw)

From: Zhen Lei <thunder.leizhen@huawei.com>

The local variable 'page_poisoning_requested' is assigned true at only
one point. It can be eliminated by moving the code that depends on it
to the location where it is assigned true. This also make the moved
code to be compiled only if CONFIG_PAGE_POISONING is set.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 mm/mm_init.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 549e76af8f82a8e..3eb217130bcb2b5 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2614,7 +2614,6 @@ DEFINE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled);
  */
 static void __init mem_debugging_and_hardening_init(void)
 {
-	bool page_poisoning_requested = false;
 	bool want_check_pages = false;
 
 #ifdef CONFIG_PAGE_POISONING
@@ -2626,18 +2625,16 @@ static void __init mem_debugging_and_hardening_init(void)
 	     (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) &&
 	      debug_pagealloc_enabled())) {
 		static_branch_enable(&_page_poisoning_enabled);
-		page_poisoning_requested = true;
 		want_check_pages = true;
-	}
-#endif
 
-	if ((_init_on_alloc_enabled_early || _init_on_free_enabled_early) &&
-	    page_poisoning_requested) {
-		pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
-			"will take precedence over init_on_alloc and init_on_free\n");
-		_init_on_alloc_enabled_early = false;
-		_init_on_free_enabled_early = false;
+		if (_init_on_alloc_enabled_early || _init_on_free_enabled_early) {
+			pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
+				"will take precedence over init_on_alloc and init_on_free\n");
+			_init_on_alloc_enabled_early = false;
+			_init_on_free_enabled_early = false;
+		}
 	}
+#endif
 
 	if (_init_on_alloc_enabled_early) {
 		want_check_pages = true;
-- 
2.34.1


             reply	other threads:[~2024-03-18 13:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 13:57 thunder.leizhen [this message]
2024-03-18 16:33 ` [PATCH 1/1] mm/mm_init.c: eliminate a local variable in mem_debugging_and_hardening_init() Mike Rapoport
2024-03-19  1:22   ` Leizhen (ThunderTown)
2024-03-19 15:01     ` Mike Rapoport
2024-03-20  1:18       ` Leizhen (ThunderTown)
2024-03-19  6:23   ` Anshuman Khandual

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=20240318135715.312-1-thunder.leizhen@huaweicloud.com \
    --to=thunder.leizhen@huaweicloud.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.