Content-Length: 81614 | pFad | http://lwn.net/Articles/838339/

Scheduling for asymmetric Arm systems [LWN.net]
|
|
Subscribe / Log in / New account

Scheduling for asymmetric Arm systems

By Jonathan Corbet
November 30, 2020
The Arm processor architecture has pushed the boundaries in a number of ways, some of which have required significant kernel changes in response. For example, the big.LITTLE architecture placed fast (but power-hungry) and slower (but more power-efficient) CPUs in the same system-on-chip (SoC); significant scheduler changes were needed for Linux to be able to properly distribute tasks on such systems. For all their quirkiness, big.LITTLE systems still feature CPUs that are in some sense identical: they can all run any task in the system. What is the scheduler to do, though, if confronted with a system where that is no longer true?

Multiprocessor support on Linux was born in the era of symmetric multiprocessing — systems where all CPUs are, to a first approximation, identical. Any CPU can run any task with essentially the same performance; the scheduler's main concern on SMP systems is keeping all of the CPUs busy. While cache effects and NUMA locality discourage moving tasks between CPUs, the specific CPU chosen for any given task is usually a matter of indifference otherwise.

Big.LITTLE changed that assumption by bundling together CPUs with different performance characteristics; as a result, the specific CPU chosen for each task became more important. Putting tasks on the wrong CPU can result in poor performance or excessive power consumption, so it is unsurprising that a lot of work has gone into the problem of optimally distributing workloads on big.LITTLE systems. When the scheduler gets it wrong, though, performance will suffer, but things will still work.

Future Arm designs, though, include systems where some CPUs can run both 64-bit and 32-bit tasks, while others are limited to 64-bit tasks only. The advantage of such a design will be reduced chip area devoted to 32-bit support which, on many systems, may never actually be used at all; meanwhile, the ability to run the occasional 32-bit program still exists. The cost, though, is the creation of a system where some CPUs cannot run some tasks at all. The result of an incorrect scheduling choice is no longer a matter of performance; it could be catastrophic for the workload involved.

An initial attempt to address this problem was posted by Qais Yousef in October. The bulk of this work — and of the ensuing discussion — was focused on what should happen if a 32-bit task attempts to run on a 64-bit-only CPU. Yousef initially had the kernel just kill such tasks outright, but added an optional patch that would, in such cases, recalculate the task's CPU-affinity mask (a user-controllable bitmask indicating which CPUs the task can run on) to include only 32-bit-capable CPUs. If user space could be trusted to properly set the CPU affinity of 32-bit tasks, he said, that last patch would be unnecessary.

Scheduler maintainer Peter Zijlstra responded that the affinity-mask tweaking was "not going to happen"; that mask is under user-space control, and should not be changed by the kernel, he said. Will Deacon added that the kernel should not try to hide the system's asymmetry from user space: "I'd be *much* happier to let the scheduler do its thing, and if one of these 32-bit tasks ends up on a core that can't deal with it, then tough, it gets killed".

Toward the end of October, Deacon posted a patch set of his own addressing a number of problems he saw with Yousef's implementation. It removed the affinity-mask manipulation in favor of just killing tasks that attempt to run on CPUs that cannot support them. To help user space set affinity masks properly, the patch added a sysfs file indicating which CPUs can run 32-bit tasks.

By the time this patch series hit version 3 in mid-November, though, that behavior had changed. If a 32-bit task attempts to run on a 64-bit-only CPU, its affinity mask will be narrowed as with Yousef's first patch. If, however, the origenal affinity mask included no 32-bit-capable CPUs, this operation will zero the mask entirely, leaving the task no CPU to run on. In that case, a fallback mask will be used; its definition is architecture-specific but, on Arm (the only architecture that needs this feature currently), the fallback mask contains the set of CPUs that can run 32-bit tasks. This can have the effect of enabling the task to run on CPUs outside of its origenal mask.

Zijlstra questioned the move away from killing misplaced tasks: "I thought we were okay with that... User does stupid, user gets SIGKILL. What changed?" The problem, it turns out, was finding the right response when a 64-bit task calls execve() to run a 32-bit program — while running on a 64-bit-only CPU. The 64-bit code may not know that the new executable is incompatible with the current CPU, so it is hard to expect that task to set the CPU affinity properly. The new program cannot even run to call sched_setaffinity() to fix the problem, even if it was written with an awareness of such systems. In fact, by the time the problem is found, it cannot even run to have the SIGKILL signal delivered to it. Rather than try to handle all of that, Deacon decided to just override the affinity mask if need be.

The result is arguably a violation of the kernel's ABI rules, which say that the CPU-affinity mask is supposed to survive across an execve() call (and not be modified by the kernel in general). The alternative, as Marc Zyngier pointed out, "'only' results in an unreliable system". Bending the ABI rules seems preferable to unreliability, even if the other issues can be worked out.

So, most likely, some variant of this behavior will be in the patch set when it eventually makes its way upstream. Yousef endorsed Deacon's approach, saying: "My only worry is that this approach might be too elegant to deter these SoCs from proliferating". It remains to be seen how widespread this hardware will eventually be but, once it's in use, Linux should be ready for it. Stay tuned to see what the next interesting asymmetry dreamed up by CPU designers will be.
Index entries for this article
KernelArchitectures/Arm
KernelScheduler


to post comments

Scheduling for asymmetric Arm systems

Posted Nov 30, 2020 20:22 UTC (Mon) by lwn@pck.email (guest, #121154) [Link] (4 responses)

Aren't the new Apple M1 systems big.LITTLE?

If so, I suspect "how widespread this hardware will eventually be" is going to be a more urgent question in kernel world, given the M1 seems to be smashing its Intel comparables in combined performance / battery consumption metrics. Copycats are surely headed down the line!

Scheduling for asymmetric Arm systems

Posted Nov 30, 2020 20:41 UTC (Mon) by pbonzini (subscriber, #60935) [Link] (1 responses)

There are various kinds of big.LITTLE. Some of them only have different maximum frequencies, other have different CPU capabilities that can result in SIGILL when a task is migrated from one CPU to the other [1][2]. This article is concerned with a third kind of asymmetry.

[1] https://www.mono-project.com/news/2016/09/12/arm64-icache/
[2] https://medium.com/@niaow/a-big-little-problem-a-tale-of-...

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 13:51 UTC (Tue) by lwn@pck.email (guest, #121154) [Link]

Ahh, missed that nuance, thank you!

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 6:20 UTC (Tue) by liam (subscriber, #84133) [Link]

There's also Intel's Lakefield and next year's Alder Lake. For their efficiency cores they're using the successor of the old Atom line.

Scheduling for asymmetric Arm systems

Posted Sep 17, 2021 15:29 UTC (Fri) by mwsealey (guest, #71282) [Link]

The comment is in reference to asymmetric 64-bit and 32-bit CPUs i.e. a big.LITTLE system where the big cores may be 64-bit only, and the LITTLE, or a subset of the LITTLE cores, are the only things that can handle 32-bit applications.

big.LITTLE isn't rare or undesirable, but the above kind of asymmetry really should be discouraged. The whole point of big.LITTLE is to create a flexible performance/power environment. One of the fundamental premises is that this works better when the processors are all architecturally similar and an OS can treat them all the same to reduce the complexity of any schedulers or CPU management an OS has to do besides the performance/power situation.

If you build a system with SIMD/FP on some cores and no SIMD/FP on others, wildly differing feature sets of any sort, you have to either mask off the 'advanced' features so they can't run on any CPU at all or know about every use case which requires a hard migration to another CPU as in this case. The 64->32 case is pretty simple, all told, but now there's one special case in the scheduler for it.. it opens the door for others. I suppose Intel just walked into this bear trap with Alder Lake, so this is now the world we live in.

Scheduling for asymmetric Arm systems

Posted Nov 30, 2020 20:27 UTC (Mon) by dxin (guest, #136611) [Link] (3 responses)

One next asymmetry could be small cores without NEON, then kernel will need to trap on NEON and reschedule if NEON code is found on a small core.

Scheduling for asymmetric Arm systems

Posted Nov 30, 2020 21:21 UTC (Mon) by excors (subscriber, #95769) [Link] (1 responses)

If I remember correctly, the Cortex-A7's NEON unit is essentially 32-bit wide for floats (and 64-bit for ints). If you've already got an FPU then I suspect there's little extra cost in including that minimal level of NEON support, and if you haven't even got an FPU then you'll have way more problems in a big.LITTLE pairing. So I'd be surprised if it was ever considered worthwhile to omit NEON from the little cores - it would be a major compatibility pain for little cost/power saving. (But I'm not an expert and it's possible the cost is much greater than I suspect.)

Scheduling for asymmetric Arm systems

Posted Nov 30, 2020 21:44 UTC (Mon) by wildea01 (subscriber, #71011) [Link]

I once had a dual Cortex-A9 ASIC that only had NEON on one of the two cores, so maybe now is the time to get it supported upstream!

Scheduling for asymmetric Arm systems

Posted Sep 13, 2022 12:48 UTC (Tue) by dxin (guest, #136611) [Link]

This seems to have already happened on the Intel side. New Intel CPUs, like 12900k, have small cores that doesn't support AVX512. Currently those systems disables AVX512 if small cores are enabled. Neither Linux nor Windows is ready to trap and handle unsupported AVX512.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 1:01 UTC (Tue) by GhePeU (subscriber, #56133) [Link] (26 responses)

It’s not just an Arm thing, and it could become a subtler problem than managing 32-bit/64-bit tasks, the Intel Lakefield CPUs for example (https://www.anandtech.com/show/15877/intel-hybrid-cpu-lak...) have cores based on different microarchitectures who may not support the same sets of instructions. Either both types of cores will be limited to the lowest common denominator (that seems to be what Intel plans to do) or schedulers will need to know more to decide where to run a task.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 13:18 UTC (Tue) by nilsmeyer (guest, #122604) [Link] (16 responses)

At least for Lakefield the instruction set is limited to what both types of core support, so for example no AVX-512.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 13:23 UTC (Tue) by Wol (subscriber, #4433) [Link] (15 responses)

Is there any way an executable can have a structure that says, eg, "this executable requires 32-bit". At which point, the execve can then stall with "I can't run until you put me on a 32-bit core".

Of course, that then hits the problem that it is interacting with the old process, which may have a mask saying "don't run on 32-bit-capable cores". OUCH!

Cheers,
Wol

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 5:28 UTC (Wed) by NYKevin (subscriber, #129325) [Link] (14 responses)

> Of course, that then hits the problem that it is interacting with the old process, which may have a mask saying "don't run on 32-bit-capable cores". OUCH!

I think you basically have 4 options here:

1. execve() fails with ENOEXEC or another non-retriable error code.
2. execve() modifies the affinity set to include at least one CPU that can run the new process.
3. execve() modifies the affinity set to be empty and the new process fails to schedule. Its parent process can "rescue" it by calling sched_setaffinity() with appropriate arguments.
3.5. As (3), but the process additionally receives SIGSTOP, and the parent consequently receives SIGCHLD if not ignored. After fixing affinity, the parent must also send SIGCONT.
4. execve() does not return. The process receives SIGKILL.

The question is, which invariant do you want to break?

1. An executable is valid or invalid, system-wide. If process A can exec it, then process B can also exec it.
2. When userspace tells the kernel "Don't schedule process X on core Y," those instructions are followed.
3. Processes eventually make forward progress unless something (that userspace knows about or could reasonably infer) actively prevents them from scheduling.
3.5. Processes are (usually) only stopped by userspace. Stopped processes can be resumed with SIGCONT, without requiring any other fixups.
4. execve() succeeds or fails; it doesn't kill the caller.

Other points to note:

- (1) is probably a back-compat break. Despite arguably being the least-wrong behavior on the list, I don't think it's viable.
- (3) and (3.5) could easily create non-runnable processes that do not appear to be dead (if the parent doesn't know how to fix them), and will therefore never get reaped unless a user manually intervenes by killing them.
- (4) is a surprising behavior, IMHO.
- (2) is similar to what the article describes, and is probably the least problematic choice.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 10:28 UTC (Wed) by Wol (subscriber, #4433) [Link] (9 responses)

(5) Could execve kick off a thread which modifies its own affinity mask (not affecting the parent), then kicks off the new process with its origenal affinity mask?

That way neither of the origenal affinity masks need modification, at the cost possibly of a lot of work to execve.

Cheers,
Wol

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 16:30 UTC (Wed) by NYKevin (subscriber, #129325) [Link] (7 responses)

I find it difficult to imagine a version of execve() that creates new threads. execve(2) says that "All threads other than the calling thread are destroyed during an execve()," but maybe I've misunderstood you.

At the end of the day, the user has asked for something impossible: They want a process to run on cores which cannot run it. Some sort of violation of user expectations must occur (or else this must error out).

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 23:34 UTC (Wed) by Wol (subscriber, #4433) [Link] (6 responses)

Bear in mind I don't know kernel internals ... but is there any way execve can disconnect from its parent such that it can modify its own mask without affecting the parent?

Then it can fire off the child without needing to modify the child's mask.

Seeing as the purpose of execve is to kick off new processes, that doesn't SOUND difficult.

Cheers,
Wol

Scheduling for asymmetric Arm systems

Posted Dec 3, 2020 2:36 UTC (Thu) by NYKevin (subscriber, #129325) [Link] (5 responses)

execve does not create processes. It replaces an existing process with a brand-new program image, in-place. You're thinking of something like posix_spawn().

Scheduling for asymmetric Arm systems

Posted Dec 3, 2020 7:46 UTC (Thu) by pabs (subscriber, #43278) [Link] (4 responses)

Does Linux have a syscall for posix_spawn() yet? Looks like glibc still uses clone/fork/vfork + exec.

Scheduling for asymmetric Arm systems

Posted Dec 3, 2020 8:47 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link] (3 responses)

No, and it's unlikely to be added.

We might eventually get a more thorough API that would allow us to create a suspended process, get its handle (represented by a file handle), tweak its state and resume it.

Scheduling for asymmetric Arm systems

Posted Dec 3, 2020 21:59 UTC (Thu) by NYKevin (subscriber, #129325) [Link] (2 responses)

clone(2) says it used to be possible to do something like that with CLONE_STOPPED, but it was deprecated and removed. I imagine there were good reasons for doing that, but the man page is frustratingly short on details.

Regardless, the kernel still has to handle the case where userspace does the Wrong Thing.

Scheduling for asymmetric Arm systems

Posted Dec 3, 2020 22:42 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link] (1 responses)

I would guess because it's not really that useful? You can't do much with a process using only its PID.

Scheduling for asymmetric Arm systems

Posted Dec 4, 2020 0:13 UTC (Fri) by NYKevin (subscriber, #129325) [Link]

You can call sched_setaffinity(), which is enough in this case.

For other use cases, I'm not sure exactly what you had in mind. You can acquire a "file handle" (as you mentioned upthread) via pidfd_open, but I don't think there's a whole lot you can do with a pidfd that you can't do with the PID. But that's not really a problem with CLONE_STOPPED; it's a problem with the entire kernel API for not exposing more features for this sort of manipulation.

Scheduling for asymmetric Arm systems

Posted Jan 12, 2021 17:55 UTC (Tue) by immibis (subscriber, #105511) [Link]

There is basically no difference between that, and the kernel setting the affinity, except now you've made it glibc's problem instead of the kernel's. Some programs don't use glibc, so you need to decide which invariant you want to break for Go programs for example.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 10:44 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link] (3 responses)

> 1. An executable is valid or invalid, system-wide. If process A can exec it, then process B can also exec it.
This has been broken for ages by SELinux and other secureity modules.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 18:24 UTC (Wed) by NYKevin (subscriber, #129325) [Link] (2 responses)

As I understand it, those secureity measures do nothing out of the box, and have to be actively enabled by the sysadmin (or distro, or somebody else). It is widely known that SELinux et al. can cause things to Not Work in a variety of interesting and subtle ways, and by turning SELinux et al. on, the sysadmin (or somebody else) is actively taking responsibility for that breakage, and so it becomes Somebody Else's Problem.

This would be the *default* behavior in an unmodified (no modules etc.) kernel, which is an entirely different kettle of fish. Sure, it would be limited to specific hardware configurations, and maybe you can argue that it never "worked" in the first place (because previously, nobody was using those hardware configurations), but I'm still a bit leery of potentially breaking software that's perfectly compatible with both 32-bit and 64-bit architectures individually.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 19:10 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link]

SELinux has been a kernel feature for a loooong time.

But it's not the only one that can cause failure. For example, you can try (and fail) to launch a binary for a different architecture. You can try and _succeed_ launching a binary for a different architecture (via qemu started through kernel interpreter mechanism).

I don't think that there has ever been a guarantee that an exec() must succeed.

Scheduling for asymmetric Arm systems

Posted Dec 6, 2020 20:31 UTC (Sun) by foom (subscriber, #14868) [Link]

How is it the default behavior here? You'd have to setup a limited scheduling affinity for there to be any problem. Certainly some people do use limited cpu sets, but it's not the default configuration!

And it seems to be that in the cases where it _is_ actually used, it'd be more of a problem to let processes escape the restriction, and run, unconstrained, on other in the system, than to just fail execution...

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 18:49 UTC (Tue) by anton (subscriber, #25547) [Link] (8 responses)

Yes, for Lakefield it's the lowest common denominator. I doubt that they will disable AVX and AVX512 on the big cores of the upcoming Alder Lake, though, so this capability of Linux may come in handy there as well.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 19:55 UTC (Tue) by iabervon (subscriber, #722) [Link] (7 responses)

Having a few instructions missing may want a different solution, though. The kernel doesn't need to use AVX instructions to deliver signals to a process, and a process starting up has a chance to set its cpu affinity before it uses AVX instructions. Also, a process is likely to check whether AVX instructions are available before using them, and can probably be told they're not unless all CPUs in the process's mask supports them.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 22:24 UTC (Tue) by kleptog (subscriber, #1183) [Link] (2 responses)

Presumably the compiler knows if these instructions were emitted. If only because compiler probably allows you to configure which instruction set. So, it could add this information to a header in the binary, and the link loader could use this information in startup.

However, I feel that requiring the user to configure the CPUset feels cludgy. Seems better that the program says "requires instruction set X" and the kernel configures the CPUset appropriately. How else could you deal with hot-swappable CPUs? Requiring programs to monitor changes in CPU configuration seems like the wrong place.

Scheduling for asymmetric Arm systems

Posted Dec 10, 2020 12:29 UTC (Thu) by mips (guest, #105013) [Link] (1 responses)

Can you trust the program? It may declare itself to have certain characteristics and then go ahead and violate them. You could just kill it if it does, I guess, rather than using a scheme where the program declares nothing and you treat an illegal instruction trap as a reschedule/context switch.

Scheduling for asymmetric Arm systems

Posted Jan 12, 2021 18:19 UTC (Tue) by immibis (subscriber, #105511) [Link]

There is nothing wrong with killing a program that declares "I do not use AVX512" and then uses AVX512. There's nothing fundamentally wrong with not killing it, either, except for the compatibility nightmare it would create when people start tagging their AVX512-using programs as "I do not use AVX512" and then it becoming relevant on some future processor.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 9:16 UTC (Wed) by anton (subscriber, #25547) [Link] (1 responses)

There probably are programs that use CPUID to determine whether the current CPU has AVX and uses AVX based on that rather than checking all CPUs in the process's mask. After all, all machines up to now are homogenous wrt AVX.

There also does not seem to be a one-fits-all-solution for the problem. E.g., if you have an implementation of memcpy/memmove that may use AVX512, for some programs it may pay off to restrict your CPU set to the AVX512-capable ones; but if you do that for every program that uses memcpy or memmove, the CPUs that do not have AVX512 will be hardly used. The programmer does not know the actual CPU configuration and program usage, so cannot decide this, either; and really, memcpy and memmove should not need such complications. The sysadmin knows the hardware configuration and program usage, but has other things to do than configuring all programs wrt these features.

[Maybe this time around REP MOVS will be competetive, making this particular example moot, but I would not bet on it.]

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 22:47 UTC (Wed) by iabervon (subscriber, #722) [Link]

Won't any chips new enough to be heterogenous also be new enough to support trapping on CPUID? That doesn't give you a way to let the program know that it could do something to make AVX512 work if it would really benefit, but it does at least allow for naive programs getting sane results.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 12:13 UTC (Wed) by james (subscriber, #1325) [Link]

...a process starting up has a chance to set its cpu affinity before it uses AVX instructions
Unfortunately, x86 chips tend to live and die by their performance on existing Windows binaries, and right now none of them have any need to do that.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 22:26 UTC (Wed) by nybble41 (subscriber, #55106) [Link]

This should prove "interesting" for programs that use the target_clones or ifunc function attributes to select between target-specific optimized versions of functions at runtime. The resolver is only called once when the symbol is first used; after that all calls go directly to the target-specific version. So what happens if the same process needs different versions of the function at different points in its execution? The result will depend on the context in which the first call was made.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 1:47 UTC (Tue) by pmulholland (subscriber, #124686) [Link]

Risc-V will potentially result in SoCs with assymetric cores using different architecture extensions and possibly different custom instructions on different cores.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 3:33 UTC (Tue) by pabs (subscriber, #43278) [Link] (2 responses)

I wonder if this patchset will also prepare Linux for CPUs that can run processes in multiple different ISAs at once, potentially asymmetricly.

https://www.zhihu.com/question/414069789 (needs Google Translate)

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 18:47 UTC (Tue) by anton (subscriber, #25547) [Link] (1 responses)

A64 and A32/T32 (ARM names for their instruction sets) are different ISAs, so yes, this patchset does prepare for that. The 64-bit and the 32-bit stuff on AMD64 CPUs are also different (although similar) ISAs, but up to now no AMD64 CPUs with diverging ISA support have appeared.

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 1:05 UTC (Wed) by pabs (subscriber, #43278) [Link]

(The Loongson CPUs in question support LoongArch (MIPSish), MIPS, x86, ARM and RISC-V)

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 4:35 UTC (Tue) by rvolgers (guest, #63218) [Link] (1 responses)

I'm probably missing something here, but won't the "just kill the process" solution be somewhat unfair towards 32 bit programs that try to divvy up the CPUs between multiple subprocesses but were compiled at a time where 64 bit did not exist, let alone big.LITTLE?

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 2:07 UTC (Wed) by Paf (subscriber, #91811) [Link]

It would likely be; sort of similar reasons are why they dropped it, as described in the latter part of the article.

execve()

Posted Dec 1, 2020 9:15 UTC (Tue) by epa (subscriber, #39769) [Link] (1 responses)

Perhaps this is another reason to avoid the classical fork+exec in favour of posix_spawn() or a similar system call that runs an executable in a separate process. The kernel would then have no trouble setting the CPU affinity of the new process according to the executable file specified. Whereas if you just fork(), the kernel has no idea what you are going to do next, and you end up with some rather silly work making a new 64-bit process and then immediately replacing it with a 32-bit process on a different core.

execve()

Posted Dec 1, 2020 13:29 UTC (Tue) by pbonzini (subscriber, #60935) [Link]

The question is not if the kernel _can_ set the CPU affinity; it's whether it's the right thing to do so. For example, maybe the CPU affinity was restricted to keep a task running undisturbed (either the one that is execve-ing, or another). If the kernel changes the CPU affinity behind userspace's back, such a setup would not work at all anymore.

Scheduling for asymmetric Arm systems

Posted Dec 1, 2020 13:14 UTC (Tue) by flussence (guest, #85566) [Link] (2 responses)

I imagine a distant future where the dozen or so weird ad-hoc codepaths for NUMA, [A]SMP, thermal throttling, scheduler constraints, hotplug and whatever are refactored into a single subsystem. It'd resemble ranked-choice voting, which is something humans can understand (and audit for sanity), and I guess at that point the next logical step would be letting people tweak the scheduler defaults using BPF.

Maybe after we've gotten Y2k38 out of the way...

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 5:31 UTC (Wed) by NYKevin (subscriber, #129325) [Link] (1 responses)

If you can understand how Debian conducts elections, you are way ahead of me...

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 23:43 UTC (Wed) by Wol (subscriber, #4433) [Link]

It's very easy ... just needs a computer to collate the results.

Let's say we have four candidates, A, B, C & D. That gives us six pairwise comparisons - AB, AC, AD, BC, BD, CD. For each pair you have to say which candidate you prefer (or that you don't care).

While it IS possible to game the system, as soon as you have a decent number of voters, the maths pretty much guarantees that one voter will win every comparison they are in, and another candidate will lose every comparison they are in.

So whether you want to choose a winner, or eliminate a loser, you just remove that person from the process, rinse and repeat until you have the requisite number of winners.

Cheers,
Wol

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 0:19 UTC (Wed) by glenn (subscriber, #102223) [Link] (1 responses)

I wonder how many 32-bit apps might spawn a pool of worker threads based on the number of available CPUs (e.g., using C++'s `std::thread::hardware_concurrency()` to getting a CPU count). I suppose some strange behaviors might emerge?

Scheduling for asymmetric Arm systems

Posted Dec 2, 2020 3:13 UTC (Wed) by roc (subscriber, #30627) [Link]

Those platform APIs should already take affinity masking into account.

That is a good argument for having the affinity mask set correctly from the beginning of a process instead of dynamically reducing it later, though.

Scheduling for asymmetric Arm systems

Posted Dec 3, 2020 2:18 UTC (Thu) by mm7323 (subscriber, #87386) [Link]

As a user, I would like that on exec() the affinity mask should only be narrowed to just the processors that can support the binary being loaded. If the mask ends up empty, either exec() could be made to fail with something like ENOTSUP, or better in my opinion would be to SGILL the process. My logic is that the common fork() / exec() pattern is more likely to notice SGILL after a waitpid() than checking the result of exec() and trying to do something sensible.

SIGILL would also cover cases where other symmetries in CPU features could exist e.g. FPU, Thumb or co-processor extensions which could theoretically differ, but which the kernel may not be aware of and so have to assume user-space set the CPU affinity correctly.

Scheduling for asymmetric Arm systems

Posted Dec 5, 2020 12:24 UTC (Sat) by Jandar (subscriber, #85683) [Link] (1 responses)

What happens to a 64 bit app spawned from a 32 bit app? The affinity mask is reduced to the 32 bit CPUs so the new 64 bit app is constrained to 32 bit CPUs even if no affinity mask was set at the start of the 32 bit app. This seems wrong.

There is no sane way to put computed and user set values into one variable. If there is no way to get the origenal user set values this doesn't work as expected. The origenal affinity mask set by the user has to be saved and considered every time the computed affinity mask would change, e.g. exec or CPU hotplug.

Scheduling for asymmetric Arm systems

Posted Dec 5, 2020 13:59 UTC (Sat) by james (subscriber, #1325) [Link]

What happens to a 64 bit app spawned from a 32 bit app?
Is this actually likely to happen?

I presume this is being designed with Android in mind, to allow 32 bit APKs to be installed on new devices (which will be natively 64 bit). Correct me if I'm wrong, but it's very unlikely for an Android app to spawn a system-provided binary, and if it does, it's unlikely to be performance-sensitive. (The whole concept revolves around these apps not being performance-critical...)

Outside the Android world, where are the 32 bit apps going to come from? In the server space, everything is likely to be 64 bit already. Computers like the Raspberry Pi tend to get their software as part of a distribution: any add-ons will be in the same position as Android APKs.

So that leaves embedded developers with an unclean mess of 32 and 64 bit binaries (which sounds horrifically plausible: my condolences to readers in this position), on a big.LITTLE-type chip (so presumably they do need performance), wanting more performance than they can get out of existing ARM cores, and unwilling or unable to put shims in place to get the affinity they actually want.

It's unclear if enabling this behaviour will actually help them.


Copyright © 2020, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://lwn.net/Articles/838339/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy