All of lore.kernel.org
 help / color / mirror / Atom feed
From: alexs@kernel.org
Cc: linux-kernel@vger.kernel.org, Alex Shi <alexs@kernel.org>,
	Valentin Schneider <vschneid@redhat.com>,
	Ben Segall <bsegall@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: [PATCH 4/4] sched/isolation: don't alloc twice for housekeeping.cpumasks
Date: Thu, 10 Apr 2025 17:24:19 +0800	[thread overview]
Message-ID: <20250410092423.9831-4-alexs@kernel.org> (raw)
In-Reply-To: <20250410092423.9831-1-alexs@kernel.org>

From: Alex Shi <alexs@kernel.org>

The variable housekeeping.cpumasks[type] will be alloced twice if
nohz_full and isolcpus are both setup in cmdline, that shouldn't to do
so. Just alloc once is enough and save a bit memory.

Signed-off-by: Alex Shi <alexs@kernel.org>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Ben Segall <bsegall@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
---
 kernel/sched/isolation.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index e93776740725..44ab46b31f6b 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -103,10 +103,10 @@ void __init housekeeping_init(void)
 static void __init housekeeping_setup_type(enum hk_type type,
 					   cpumask_var_t housekeeping_staging)
 {
+	if (cpumask_empty(housekeeping.cpumasks[type]))
+		alloc_bootmem_cpumask_var(&housekeeping.cpumasks[type]);
 
-	alloc_bootmem_cpumask_var(&housekeeping.cpumasks[type]);
-	cpumask_copy(housekeeping.cpumasks[type],
-		     housekeeping_staging);
+	cpumask_copy(housekeeping.cpumasks[type], housekeeping_staging);
 }
 
 static int __init housekeeping_setup(char *str, unsigned long flags)
-- 
2.47.1


  parent reply	other threads:[~2025-04-10  9:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10  9:24 [PATCH 1/4] tick/nohz: remove function tick_nohz_full_add_cpus_to alexs
2025-04-10  9:24 ` [PATCH 2/4] sched/isolation: clean up housekeeping_cpu alexs
2025-04-10 13:20   ` Frederic Weisbecker
2025-04-11  0:58     ` Alex Shi
2025-04-11 11:08       ` Frederic Weisbecker
2025-04-10  9:24 ` [PATCH 3/4] sched/isolation: merge housekeeping_cpu() and housekeeping_test_cpu() alexs
2025-04-10  9:24 ` alexs [this message]
2025-05-13 14:49 ` [tip: timers/core] tick/nohz: Remove unused tick_nohz_full_add_cpus_to() tip-bot2 for Alex Shi

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=20250410092423.9831-4-alexs@kernel.org \
    --to=alexs@kernel.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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 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.