On Mon, Nov 30, 2020 at 03:18:58PM -0300, Marcelo Tosatti wrote: > On Sat, Nov 28, 2020 at 03:49:38AM +0000, Alex Belits wrote: > > > > On Fri, 2020-11-27 at 12:48 -0300, Marcelo Tosatti wrote: > > > External Email > > > > > > ------------------------------------------------------------------- > > > --- > > > On Fri, Nov 20, 2020 at 06:20:06PM +0000, Christopher Lameter wrote: > > > > On Tue, 17 Nov 2020, Marcelo Tosatti wrote: > > > > > > > > > > So what we would need would be something like a sysctl that > > > > > > puts the > > > > > > system into a quiet state by completing all workqueue items. > > > > > > Idle all > > > > > > subsystems that need it and put the cpu into NOHZ mode. > > > > > > > > > > Are you suggesting that instead of a specific file to control > > > > > vmstat > > > > > workqueue only, a more generic sysctl could be used? > > > > > > > > Yes. Introduce a sysctl to quiet down the system. Clean caches that > > > > will > > > > trigger kernel threads and whatever else is pending on that > > > > processor. > > > > > > > > > About NOHZ mode: the CPU should enter NOHZ automatically as soon > > > > > as > > > > > there is a single thread running, so unclear why that would be > > > > > needed. > > > > > > > > There are typically pending actions that still trigger > > > > interruptions. > > > > > > > > If you would immediately quiet down the system if there is only one > > > > thread > > > > runnable then you would compromise system performance through > > > > frequent > > > > counter folding and cache cleaning etc. > > > > > > Christopher, > > > > > > Decided to switch to prctl interface, and then it starts > > > to become similar to "task mode isolation" patchset API. > > > > > > In addition to quiescing pending activities on the CPU, it would > > > also be useful to assign a per-task attribute (which is then assigned > > > to a per-CPU attribute), indicating whether that CPU is running > > > an isolated task or not. > > > > This is what task isolation patch now does. Per-task attribute is used > > when dealing with a task (normally current task on its dedicated CPU), > > per-CPU attribute is used when other CPUs are involved (so they don't > > have to chase tasks that are running on other CPUs) or when performing > > low-level operations on entry and exit. Also since this per-CPU > > attribute is only updated from the local CPU, this significantly > > simplifies access to it. > > > > The difficult part of this approach is how to properly handle a > > situation when for whatever reason isolation must be broken by an > > interrupt of whatever origin, and there is no way to avoid it. > > Right. > > > And, of course, there is a matter of having to clean up all other > > sources of avoidable interrupts. > > Two questions: > > What is the reason for not allowing _any_ interruption? Because > it might be the case (and it is in the vRAN use cases our customers > target), that some amount of interruption is tolerable. > > For example, for one use case 20us (of interruptions) every 1ms of > elapsed time is tolerable. > > > Since I first and foremost care about eliminating all disturbances for > > a running userspace task, > > Why? > > > my approach is to allow disabling everything > > including "unavoidable" synchronization IPIs, and make kernel entry > > procedure recognize that some delayed synchronization is necessary > > while avoiding race conditions. As far as I can tell, not everyone > > wants to go that far, > > Suppose it depends on how long each interruption takes. Upon the > suggestion from Thomas and Frederic, i've been thinking it should > be possible, with the tracing framework, to record the length of > all interruptions to a given CPU and, every second check how many > have happened (and whether the sum of interruptions exceeds the > acceptable threshold). > > Its not as nice as the task isolation patch (in terms of spotting > the culprit, since one won't get a backtrace on the originating > CPU in case of an IPI for example), but it should be possible > to verify that the latency threshold is not broken (which is > what the application is interested in, isnt it?). > > > and it may make sense to allow "almost isolated > > tasks" that still receive normal interrupts, including IPIs and page > > faults. > > > > While that would be useless for the purposes that task > > isolation patch was developed for, I recognize that some might prefer > > that to be one of the options set by the same prctl call. This still > > remains close enough to the design of task isolation -- same idea of > > something that affects CPU but being tied to a given task (and dying > > with it), same model of handling attributes, etc. > > > > Maybe there can be a mask of what we do and don't want to avoid for the > > task. Say, some may want to only allow page faults or syscalls. Or re- > > enter isolation on breaking without notifying the userspace. > > OK, i will try to come up with an interface that allows additional > attributes - please review and let me know if it works for task > isolation patchset. > > Can you talk a little about the signal handling part? What type > of applications are expected to perform once isolation is broken? Hi Alex, Say, couldnt a notification from the trace-latency infrastructure, notifying the admin that latency was exceeded due to interruptions x us (backtrace of x) + y us (backtrace of y) + z us (backtrace of z) >= maxlatency us With an application which continue to handle traffic, be as functional as the signal? (then again, don't know exactly what you do in the signal handler...). Could also count "enter kernel <-> exit kernel" window as in interruption such a scheme. > Thanks! > > > Then we may be able to combine those things, or make them separate > > features that can be enabled and disabled, but all tied to a single > > prctl. It will be possible to, say, check which features are > > implemented and then set a mode for the current task. > > > > > This per-CPU attribute can be used to, for example, return -EBUSY > > > from ring_buffer_resize() (or any other IPI generating activity > > > which can return an error to userspace). > > > > > > So rather than: > > > > > > prctl(PR_QUIESCE_CPU) (current interface, similar to > > > initial message on the thread but with prctl rather than > > > sysfs) > > > > > > To be called before real time loop, one would have: > > > > > > prctl(PR_SET_TASK_ISOLATION, ISOLATION_ENABLE) [1] > > > real time loop > > > prctl(PR_SET_TASK_ISOLATION, ISOLATION_DISABLE) > > > > > > (with the attribute also being cleared on task exit). > > > > > > The general description would be: > > > > > > "Set task isolated mode for a given task, returning an error > > > if the task is not pinned to a single CPU. > > > > > > In this mode, the kernel will avoid interruptions to isolated > > > CPUs when possible." > > > > > > Any objections against such an interface ? > > > > > > > > > [1] perhaps a name that does not conflict with "task mode" patchset > > > is a better idea. > > > > >