mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Gabriele Monaco <gmonaco@redhat.com>,
	linux-kernel@vger.kernel.org,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v10 6/8] sched/isolation: Force housekeeping if isolcpus and nohz_full don't leave any
Date: Wed, 6 Aug 2025 16:38:52 -0400	[thread overview]
Message-ID: <9184eaa2-40cf-43ce-b060-2a3b18aeca85@redhat.com> (raw)
In-Reply-To: <20250806093855.86469-7-gmonaco@redhat.com>

On 8/6/25 5:38 AM, Gabriele Monaco wrote:
> Currently the user can set up isolcpus and nohz_full in such a way that
> leaves no housekeeping CPU (i.e. no CPU that is neither domain isolated
> nor nohz full). This can be a problem for other subsystems (e.g. the
> timer wheel imgration).
>
> Prevent this configuration by invalidating the last setting in case the
> union of isolcpus (domain) and nohz_full covers all CPUs.
>
> Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
> ---
>   kernel/sched/isolation.c | 23 +++++++++++++++++++++++
>   1 file changed, 23 insertions(+)
>
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index a4cf17b1fab0..0bf7b91684c0 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -167,6 +167,29 @@ static int __init housekeeping_setup(char *str, unsigned long flags)
>   			}
>   		}
>   
> +		/*
> +		 * Check the combination of nohz_full and isolcpus=domain,
> +		 * necessary to avoid problems with the timer migration
> +		 * hierarchy. managed_irq is ignored by this check since it
> +		 * isn't considered in the timer migration logic.
> +		 */
> +		iter_flags = housekeeping.flags & (HK_FLAG_KERNEL_NOISE | HK_FLAG_DOMAIN);
> +		type = find_first_bit(&iter_flags, HK_TYPE_MAX);
> +		/*
> +		 * Pass the check if none of these flags were previously set or
> +		 * are not in the current selection.
> +		 */
> +		iter_flags = flags & (HK_FLAG_KERNEL_NOISE | HK_FLAG_DOMAIN);
> +		first_cpu = type == HK_TYPE_MAX || !iter_flags ? 0 :
> +			    cpumask_first_and_and(cpu_present_mask,
> +				    housekeeping_staging, housekeeping.cpumasks[type]);
This statement is a bit hard to read as I have to look up the C operator 
precedence table to make sure that I get the precedence right. It will 
be easier if parentheses are used to make it easier to read.
> +		if (first_cpu >= nr_cpu_ids || first_cpu >= setup_max_cpus) {

Perhaps you can simplify it to "if (first_cpu >= min(nr_cpu_ids, 
setup_max_cpus))".

Other than that, the logic looks right to me.

Cheers,
Longman


> +			pr_warn("Housekeeping: must include one present CPU "
> +				"neither in nohz_full= nor in isolcpus=domain, "
> +				"ignoring setting %s\n", str);
> +			goto free_housekeeping_staging;
> +		}
> +
>   		iter_flags = flags & ~housekeeping.flags;
>   
>   		for_each_set_bit(type, &iter_flags, HK_TYPE_MAX)


  reply	other threads:[~2025-08-06 20:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06  9:38 [PATCH v10 0/8] timers: Exclude isolated cpus from timer migration Gabriele Monaco
2025-08-06  9:38 ` [PATCH v10 1/8] timers/migration: Postpone online/offline callbacks registration to late initcall Gabriele Monaco
2025-08-07 12:42   ` Frederic Weisbecker
2025-08-06  9:38 ` [PATCH v10 2/8] timers: Rename tmigr 'online' bit to 'available' Gabriele Monaco
2025-08-06  9:38 ` [PATCH v10 3/8] timers: Add the available mask in timer migration Gabriele Monaco
2025-08-06  9:38 ` [PATCH v10 4/8] timers: Use scoped_guard when setting/clearing the tmigr available flag Gabriele Monaco
2025-08-06  9:38 ` [PATCH v10 5/8] cgroup/cpuset: Rename update_unbound_workqueue_cpumask() to update_exclusion_cpumasks() Gabriele Monaco
2025-08-06  9:38 ` [PATCH v10 6/8] sched/isolation: Force housekeeping if isolcpus and nohz_full don't leave any Gabriele Monaco
2025-08-06 20:38   ` Waiman Long [this message]
2025-08-06  9:38 ` [PATCH v10 7/8] cgroup/cpuset: Fail if isolated and nohz_full don't leave any housekeeping Gabriele Monaco
2025-09-02 14:33   ` Frederic Weisbecker
2025-09-02 19:14   ` Waiman Long
2025-08-06  9:38 ` [PATCH v10 8/8] timers: Exclude isolated cpus from timer migration Gabriele Monaco

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=9184eaa2-40cf-43ce-b060-2a3b18aeca85@redhat.com \
    --to=llong@redhat.com \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=gmonaco@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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®