From: John Kacur <jkacur@redhat.com>
To: Tomas Glozar <tglozar@redhat.com>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH 1/6] rteval: Detect isolcpus in systopology
Date: Tue, 25 Jul 2023 09:33:34 -0400 (EDT) [thread overview]
Message-ID: <7280cd6-361b-b973-491e-a41a8f07bcf@redhat.com> (raw)
In-Reply-To: <20230630091951.916865-2-tglozar@redhat.com>
On Fri, 30 Jun 2023, Tomas Glozar wrote:
> Works similarly to online_cpus:
> - add CpuList.isolated_cpulist to filter isolated CPUs
> - add SysTopology.isolated_cpus to get list of isolated CPUs
> - add CpuList.nonisolated_cpulist to do the opposite filter
> - add SysTopology.default_cpus to get CPUs that are used for scheduling
> by default, i.e. online and non-isolated CPUs
>
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---
> rteval/systopology.py | 47 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/rteval/systopology.py b/rteval/systopology.py
> index c8f85c5..19443f9 100644
> --- a/rteval/systopology.py
> +++ b/rteval/systopology.py
> @@ -127,6 +127,11 @@ class CpuList:
> return True
> return False
>
> + @staticmethod
> + def isolated_file_exists():
> + """ Check whether machine / kernel is configured with isolated file """
> + return os.path.exists(os.path.join(CpuList.cpupath, "isolated"))
> +
> @staticmethod
> def longest_sequence(cpulist):
> """ return index of last element of a sequence that steps by one """
> @@ -214,6 +219,24 @@ class CpuList:
> newlist.append(cpu)
> return newlist
>
> + @staticmethod
> + def isolated_cpulist(cpulist):
> + """Given a cpulist, return a cpulist of isolated CPUs"""
> + if not CpuList.isolated_file_exists():
> + return cpulist
> + isolated_cpulist = sysread(CpuList.cpupath, "isolated")
> + isolated_cpulist = CpuList.expand_cpulist(isolated_cpulist)
> + return list(set(isolated_cpulist) & set(cpulist))
> +
> + @staticmethod
> + def nonisolated_cpulist(cpulist):
> + """Given a cpulist, return a cpulist of non-isolated CPUs"""
> + if not CpuList.isolated_file_exists():
> + return cpulist
> + isolated_cpulist = sysread(CpuList.cpupath, "isolated")
> + isolated_cpulist = CpuList.expand_cpulist(isolated_cpulist)
> + return list(set(cpulist).difference(set(isolated_cpulist)))
> +
> #
> # class to abstract access to NUMA nodes in /sys filesystem
> #
> @@ -362,11 +385,35 @@ class SysTopology:
> cpulist.sort()
> return cpulist
>
> + def isolated_cpus(self):
> + """ return a list of integers of all isolated cpus """
> + cpulist = []
> + for n in self.nodes:
> + cpulist += CpuList.isolated_cpulist(self.getcpus(n))
> + cpulist.sort()
> + return cpulist
> +
> + def default_cpus(self):
> + """ return a list of integers of all default schedulable cpus, i.e. online non-isolated cpus """
> + cpulist = []
> + for n in self.nodes:
> + cpulist += CpuList.nonisolated_cpulist(self.getcpus(n))
> + cpulist.sort()
> + return cpulist
> +
> def online_cpus_str(self):
> """ return a list of strings of numbers of all online cpus """
> cpulist = [str(cpu) for cpu in self.online_cpus()]
> return cpulist
>
> + def isolated_cpus_str(self):
> + cpulist = [str(cpu) for cpu in self.isolated_cpus()]
> + return cpulist
> +
> + def default_cpus_str(self):
> + cpulist = [str(cpu) for cpu in self.default_cpus()]
> + return cpulist
> +
> def invert_cpulist(self, cpulist):
> """ return a list of online cpus not in cpulist """
> return [c for c in self.online_cpus() if c not in cpulist]
> --
> 2.41.0
>
>
Signed-off-by: John Kacur <jkacur@redhat.com>
--
The code is good, but I don't love the name "default_cpus", but it will
do. isolated_cpus_str() and default_cpus_str() require docstrings.
I'm signing off on this to move it forward so please send that in a
separate patch.
next prev parent reply other threads:[~2023-07-25 13:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 9:19 [PATCH 0/6] rteval: Handle isolcpus correctly Tomas Glozar
2023-06-30 9:19 ` [PATCH 1/6] rteval: Detect isolcpus in systopology Tomas Glozar
2023-07-25 13:33 ` John Kacur [this message]
2023-07-25 13:36 ` John Kacur
2023-06-30 9:19 ` [PATCH 2/6] rteval: Report isolated CPUs Tomas Glozar
2023-07-25 13:38 ` John Kacur
2023-06-30 9:19 ` [PATCH 3/6] rteval: Exclude isolcpus from kcompile by default Tomas Glozar
2023-07-25 13:40 ` John Kacur
2023-06-30 9:19 ` [PATCH 4/6] rteval: Exclude isolcpus from stressng " Tomas Glozar
2023-07-25 13:42 ` John Kacur
2023-06-30 9:19 ` [PATCH 5/6] rteval: Fix CPU count calculation for hackbench Tomas Glozar
2023-07-25 13:44 ` John Kacur
2023-06-30 9:19 ` [PATCH 6/6] rteval: Exclude isolcpus from loads report Tomas Glozar
2023-07-25 14:32 ` John Kacur
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=7280cd6-361b-b973-491e-a41a8f07bcf@redhat.com \
--to=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=tglozar@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;
as well as URLs for NNTP newsgroup(s).