Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1577351
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() |
| Date | 2017-02-09 08:20 +0100 |
| Message-ID | <t8QRY-2BZ-9@gated-at.bofh.it> (permalink) |
| References | (3 earlier) <t7QAG-4T3-29@gated-at.bofh.it> <t7RGs-5x6-61@gated-at.bofh.it> <t7ZXj-2yL-1@gated-at.bofh.it> <t8yim-81h-29@gated-at.bofh.it> <t8zHr-ku-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
* Peter Zijlstra <peterz@infradead.org> wrote:
> On Wed, Feb 08, 2017 at 11:20:19AM +0100, Thomas Gleixner wrote:
> > On Mon, 6 Feb 2017, Ingo Molnar wrote:
> > > * Peter Zijlstra <peterz@infradead.org> wrote:
> > > >
> > > > cpumasks are a pain, the above avoids allocating more of them.
> >
> > Indeed.
> >
> > > Yeah, so this could then be done by pointerifying ->cpus_allowed - more robust
> > > than the wrappery,
> >
> > You mean:
> >
> > struct task_struct {
> > cpumask_t cpus_allowed;
> > cpumask_t *effective_cpus_allowed;
> > };
Yeah. I'd name it a bit differently and constify the pointer to get type
safety and to make sure the mask is never modified through the pointer:
struct task_struct {
const cpumask_t *cpus_ptr;
cpumask_t cpus_mask;
};
( I'd drop the 'allowed' part, it's obvious enough what task->cpus_mask does,
right? )
and upstream would essentially just do:
t->cpus_allowed_ptr = &t->cpus_allowed;
And -rt, when it wants to pin a task, would do:
t->cpus_allowed_ptr = &cpumask_of(task_cpu(p));
The rules are:
- Code that 'uses' ->cpus_allowed would use the pointer.
- Code that 'modifies' ->cpus_allowed would use the direct mask.
The upstream advantages are:
- The type separation of modifications from usage.
- Removal of wrappery.
- Maybe sometime in the future upstream would want to disable migration too ...
In fact -rt gains something too:
- With this scheme we would AFAICS get slightly more optimal code on -rt.
(Because there's no __migration_disabled() branching anymore.)
- Plus all new code is automatically -rt ready - no need to maintain the wrappery
space. Much less code path forking.
So as I see it it's win-win for both upstream and for -rt!
> > and make the scheduler use effective_cpus_allowed instead of cpus_allowed? Or
> > what do you have in mind?
>
> That scheme is weird for nr_cpus_allowed. Not to mention that the
> pointer to the integer is larger than the integer itself.
So in the new scheme I don't think nr_cpus_allowed would have to be wrapped
at all: whenever the pointer (or mask) is changed in set_cpus_allowed_common()
nr_cpus_allowed is recalculated as well - like today.
It should be self-maintaining. Am I missing something?
> I really prefer the current wrappers, they're trivial and consistent
> with one another.
I think it's ugly wrappery and we can do better! ;-)
But of course if I cannot suggest a better alternative then it stands.
Thanks,
Ingo
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Mike Galbraith <efault@gmx.de> - 2017-02-06 05:30 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Ingo Molnar <mingo@kernel.org> - 2017-02-06 11:40 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Mike Galbraith <efault@gmx.de> - 2017-02-06 13:20 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Ingo Molnar <mingo@kernel.org> - 2017-02-06 13:30 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Mike Galbraith <efault@gmx.de> - 2017-02-06 13:50 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2017-02-06 14:40 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Ingo Molnar <mingo@kernel.org> - 2017-02-06 23:30 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Thomas Gleixner <tglx@linutronix.de> - 2017-02-08 12:10 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2017-02-08 13:40 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Ingo Molnar <mingo@kernel.org> - 2017-02-09 08:00 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Peter Zijlstra <peterz@infradead.org> - 2017-02-09 10:00 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Thomas Gleixner <tglx@linutronix.de> - 2017-02-09 10:40 +0100
Re: tip: demise of tsk_cpus_allowed() and tsk_nr_cpus_allowed() Ingo Molnar <mingo@kernel.org> - 2017-02-09 08:20 +0100
csiph-web