Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions boot-qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_smp_value(args):

# Use the minimum of the number of usable processors for the script or
# CONFIG_NR_CPUS.
usable_cpus = len(os.sched_getaffinity(0))
usable_cpus = os.cpu_count()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had originally gone with cpu_count() but switched to sched_getaffinity() after learning that it would respond to external resource limitations, such as limiting the number of cores that a program can actually use. I do not care much but we could do something like

usable_cpus = len(os.sched_getaffinity(0)) if hasattr(os, 'sched_getaffinity') else os.cpu_count()

I do not care much though.

return min(usable_cpus, config_nr_cpus)


Expand Down Expand Up @@ -326,7 +326,7 @@ def get_linux_ver_code(decomp_cmd):
input=decomp.stdout)

linux_version = None
for line in strings.stdout.decode("UTF-8").split("\n"):
for line in strings.stdout.decode("UTF-8", "ignore").split("\n"):
if re.search(r"Linux version \d+\.\d+\.\d+", line):
linux_version = re.search(r"\d+\.\d+\.\d+", line)[0].split(".")
break
Expand Down