From: Costa Shulyupin <costa.shul@redhat.com>
To: longman@redhat.com, ming.lei@redhat.com, pauld@redhat.com,
juri.lelli@redhat.com, vschneid@redhat.com,
"Jens Axboe" <axboe@kernel.dk>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Peter Zijlstra" <peterz@infradead.org>,
"Zefan Li" <lizefan.x@bytedance.com>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Costa Shulyupin" <costa.shul@redhat.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org
Subject: [RFC PATCH v3 1/3] sched/isolation: Add infrastructure for dynamic CPU isolation
Date: Tue, 29 Oct 2024 14:05:32 +0200 [thread overview]
Message-ID: <20241029120534.3983734-2-costa.shul@redhat.com> (raw)
In-Reply-To: <20241029120534.3983734-1-costa.shul@redhat.com>
Introduce the infrastructure function housekeeping_update()
to modify housekeeping_cpumask at runtime and update the
configurations of dependent subsystems accordingly in
following patches.
Parent patch:
sched/isolation: Exclude dynamically isolated CPUs from housekeeping masks
https://lore.kernel.org/lkml/20240821142312.236970-1-longman@redhat.com/
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
Note: In theory, updating housekeeping.flags only once is possible.
However, this approach would make this and following code less clear
and harder to follow and review.
Changes in v3:
- Remove redundant WRITE_ONCE. The first WRITE_ONCE is located
in housekeeping_update() because this function will
update dependent subsystems with changes of the housekeeping masks.
Changes in v2:
- remove unnecessary `err` variable
- add for_each_clear_bit... to clear isolated CPUs
- Address Gleixner's comments:
- use WRITE_ONCE to change housekeeping.flags
- use `struct cpumask *update` in signature of housekeeping_update
v1:
- https://lore.kernel.org/lkml/20240516190437.3545310-2-costa.shul@redhat.com/
---
kernel/sched/isolation.c | 43 ++++++++++++++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 2ee47bc25aea..ebbb215505e8 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -127,6 +127,40 @@ static void __init housekeeping_setup_type(enum hk_type type,
housekeeping_staging);
}
+/*
+ * housekeeping_update - change housekeeping.cpumasks[type] and propagate the
+ * change.
+ */
+static int housekeeping_update(enum hk_type type, const struct cpumask *update)
+{
+ struct {
+ struct cpumask changed;
+ struct cpumask enable;
+ struct cpumask disable;
+ } *masks;
+
+ masks = kmalloc(sizeof(*masks), GFP_KERNEL);
+ if (!masks)
+ return -ENOMEM;
+
+ lockdep_assert_cpus_held();
+ cpumask_xor(&masks->changed, housekeeping_cpumask(type), update);
+ cpumask_and(&masks->enable, &masks->changed, update);
+ cpumask_andnot(&masks->disable, &masks->changed, update);
+ cpumask_copy(housekeeping.cpumasks[type], update);
+ WRITE_ONCE(housekeeping.flags, housekeeping.flags | BIT(type));
+ if (!static_branch_unlikely(&housekeeping_overridden))
+ static_key_enable_cpuslocked(&housekeeping_overridden.key);
+
+ /* Add here code to update dependent subsystems with
+ * changes of the housekeeping masks.
+ */
+
+ kfree(masks);
+
+ return 0;
+}
+
static int __init housekeeping_setup(char *str, unsigned long flags)
{
cpumask_var_t non_housekeeping_mask, housekeeping_staging;
@@ -330,10 +364,12 @@ int housekeeping_exlude_isolcpus(const struct cpumask *isolcpus, unsigned long f
/*
* Reset housekeeping to bootup default
*/
+
+ for_each_clear_bit(type, &boot_hk_flags, HK_TYPE_MAX)
+ housekeeping_update(type, cpu_possible_mask);
for_each_set_bit(type, &boot_hk_flags, HK_TYPE_MAX)
- cpumask_copy(housekeeping.cpumasks[type], boot_hk_cpumask);
+ housekeeping_update(type, boot_hk_cpumask);
- WRITE_ONCE(housekeeping.flags, boot_hk_flags);
if (!boot_hk_flags && static_key_enabled(&housekeeping_overridden))
static_key_disable_cpuslocked(&housekeeping_overridden.key);
return 0;
@@ -358,9 +394,8 @@ int housekeeping_exlude_isolcpus(const struct cpumask *isolcpus, unsigned long f
cpumask_andnot(tmp_mask, src_mask, isolcpus);
if (!cpumask_intersects(tmp_mask, cpu_online_mask))
return -EINVAL; /* Invalid isolated CPUs */
- cpumask_copy(housekeeping.cpumasks[type], tmp_mask);
+ housekeeping_update(type, tmp_mask);
}
- WRITE_ONCE(housekeeping.flags, boot_hk_flags | flags);
excluded = true;
if (!static_key_enabled(&housekeeping_overridden))
static_key_enable_cpuslocked(&housekeeping_overridden.key);
--
2.47.0
next prev parent reply other threads:[~2024-10-29 12:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 12:05 [RFC PATCH v3 0/3] genirq/cpuhotplug: Adjust managed interrupts according to change of housekeeping cpumask Costa Shulyupin
2024-10-29 12:05 ` Costa Shulyupin [this message]
2024-10-29 12:05 ` [RFC PATCH v3 2/3] DO NOT MERGE: test for managed irqs adjustment Costa Shulyupin
2024-10-29 12:05 ` [RFC PATCH v3 3/3] genirq/cpuhotplug: Adjust managed irqs according to change of housekeeping CPU Costa Shulyupin
2024-10-29 18:54 ` Thomas Gleixner
2025-01-06 14:39 ` Costa Shulyupin
-- strict thread matches above, loose matches on Subject: below --
2024-09-16 12:20 [RFC PATCH v3 0/3] genirq/cpuhotplug: Adjust managed interrupts according to change of housekeeping cpumask Costa Shulyupin
2024-09-16 12:20 ` [RFC PATCH v3 1/3] sched/isolation: Add infrastructure for dynamic CPU isolation Costa Shulyupin
2024-10-02 9:44 ` Thomas Gleixner
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=20241029120534.3983734-2-costa.shul@redhat.com \
--to=costa.shul@redhat.com \
--cc=axboe@kernel.dk \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=ming.lei@redhat.com \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=pauld@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®