Re: sched_pin() bug in SCHED_ULE

From: Andriy Gapon <avg_at_icyb.net.ua>
Date: Fri, 27 Aug 2010 01:10:41 +0300
on 27/08/2010 00:20 mdf_at_FreeBSD.org said the following:
> 
> I tried making sched_pin() a real function which used
> intr_disable/intr_restore around saving off td->td_oncpu,
> td->td_lastcpu and ts->ts_cpu, and the stack at the time of call.  In
> sched_switch when I saw an unexpected migration I printed all that
> out.  I found that on my boxes, at sched_pin() time ts_cpu was already
> different from td->td_oncpu, so the specific problem I was having was
> that while another thread can change ts_cpu it has no way to force
> that thread to immediately migrate.

Like e.g. in sched_affinity where ts_cpu is first changed and then the old cpu
is ipi-ed?

> I believe the below patch fixes the issue, though I'm open to other methods:
> 
> 
> Index: kern/sched_ule.c
> ===================================================================
> --- kern/sched_ule.c	(.../head/src/sys)	(revision 158279)
> +++ kern/sched_ule.c	(.../branches/BR_BUG_67957/src/sys)	(revision 158279)
> _at__at_ -112,6 +112,7 _at__at_
>  /* flags kept in ts_flags */
>  #define	TSF_BOUND	0x0001		/* Thread can not migrate. */
>  #define	TSF_XFERABLE	0x0002		/* Thread was added as transferable. */
> +#define	TSF_BINDING	0x0004		/* Thread is being bound. */

I don't really follow why TSF_BINDING is needed, i.e. why TSF_BOUND is not
sufficient in this case?

-- 
Andriy Gapon
Received on Thu Aug 26 2010 - 20:10:46 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:06 UTC