lkml.org 
[lkml]   [2014]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/2] sched: schedule_tail() should disable preemption
On 10/09, Peter Zijlstra wrote:
>
> On Thu, Oct 09, 2014 at 07:28:34PM +0200, Peter Zijlstra wrote:
> > On Thu, Oct 09, 2014 at 06:57:13PM +0200, Oleg Nesterov wrote:
> > > @@ -2333,10 +2336,12 @@ context_switch(struct rq *rq, struct task_struct *prev,
> > > #endif
> > >
> > > context_tracking_task_switch(prev, next);
> > > +
> > > + pc = preempt_count();
> >
> > The only problem here is that you can loose PREEMPT_NEED_RESCHED, I
> > haven't thought about whether that is a problem here or not.

No, it must not be set. It was cleared by clear_preempt_need_resched()
in __schedule(), and nobody can set it.

(schedule_tail() also relies on fact it runs with irqs disabled).

But,

> Also, if you make that preempt_count_save(), to mirror the restore,

Yes, agreed. That is why I said we probably want preempt_count_raw()
(or _save). This way we avoid the unnecessary "&= ~PREEMPT_NEED_RESCHED"
on x86.

> can both preserve PREEMPT_NEED_RESCHED and avoid emitting code on !x86.

This too, although gcc should optimize this code out anyway. At least
it seems to do on x86 if I make preempt_count_restore() empty.

Oleg.



\
 
 \ /
  Last update: 2014-10-09 20:41    [W:0.142 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site