Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 May 2009 11:40:40 +0200
From:      Attilio Rao <attilio@freebsd.org>
To:        Ben Kelly <ben@wanderview.com>
Cc:        Adam McDougall <mcdouga9@egr.msu.edu>, freebsd-current@freebsd.org, Artem Belevich <fbsdlist@src.cx>
Subject:   Re: [patch] zfs livelock and thread priorities
Message-ID:  <3bbf2fe10905190240g3e6dd267nf1621ca4e54d7a85@mail.gmail.com>
In-Reply-To: <34451C28-9ADF-467B-B2C8-43498C87C0C2@wanderview.com>
References:  <08D7DC2A-68BE-47B6-8D5D-5DE6B48F87E5@wanderview.com> <200905181129.51526.jhb@freebsd.org> <3bbf2fe10905181012t4bde260bp31181e3ea7b03a42@mail.gmail.com> <200905181331.11174.jhb@freebsd.org> <3bbf2fe10905181038geaec26csffea4788a40feaca@mail.gmail.com> <34451C28-9ADF-467B-B2C8-43498C87C0C2@wanderview.com>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/5/19 Ben Kelly <ben@wanderview.com>:
> On May 18, 2009, at 1:38 PM, Attilio Rao wrote:
>>
>> OMG.
>> This still doesn't explain priorities like 49 or such seen in the
>> first report as long as we don't set priorities by hand,
>
> I'm trying to understand why this particular priority value is so
> concerning, but I'm a little bit confused. =C2=A0Can you elaborate on why=
 you
> think its a problem? =C2=A0From previous off-list e-mails I get the impre=
ssion
> that you are concerned that it does not fall on an RQ_PPQ boundary. =C2=
=A0Is this
> the case? =C2=A0Again, I may be completely confused, but ULE does not see=
m to
> consider RQ_PPQ when it assigns priorities for interactive threads. =C2=
=A0Here is
> how I came to this conclusion:

I'm concerned because the first starvation I saw in this thread was
caused by the proprity lowered inappropriately (it was 49 on 45 IIRC).
49 means that the thread will never be choosen when the 45s are still
in the runqueue. I'm not concerned on RQ_PPQ boundaries.

> From what I can tell a thread's priority might be adjusted for interactiv=
ity
> in sched_priority() around line 1421 of sched_ule:
>
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0score =3D imax(0, sched_interact_score(td) - =
td->td_proc->p_nice);
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0if (score < sched_interact) {
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pri =3D PRI_MIN_R=
EALTIME;
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pri +=3D ((PRI_MA=
X_REALTIME - PRI_MIN_REALTIME) /
>> sched_interact)
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* s=
core;
>
> One my machine (PRI_MAX_REALTIME - PRI_MIN_REALTIME) / sched_interact
> resolves to a value of 1. =C2=A0So the priority is being set to PRI_MIN_R=
EALTIME
> plus the value of score. =C2=A0According to the comment on sched_interact=
_score()
> the returned value ranges from 0 to 100. =C2=A0As far as I can tell from =
looking
> at the code the calculations based on the ration of ts_runtime to
> ts_sleeptime aren't guaranteed to return a value divisible by RQ_PPQ. =C2=
=A0For
> example, on my machine tickincr turns out to be 8000. =C2=A0So if ts_slee=
ptime is
> 16000 and ts_runtime is 8000 sched_interact_score() will return a value o=
f
> 25. =C2=A0Which then means the thread will be assigned a priority of
> PRI_MIN_REALTIME + 25.
>
> Also, looking at my currently idle system I actually have many priorities
> that do not fall on RQ_PPQ boundaries:
>
>> ianto# ps ax -opri | grep 43 | wc -l
>> =C2=A0 =C2=A0 =C2=A014
>> ianto# ps ax -opri | grep 44 | wc -l
>> =C2=A0 =C2=A0 =C2=A070
>> ianto# ps ax -opri | grep 45 | wc -l
>> =C2=A0 =C2=A0 =C2=A0 4
>> ianto# ps ax -opri | grep 46 | wc -l
>> =C2=A0 =C2=A0 =C2=A0 3
>> ianto# ps ax -opri | grep 47 | wc -l
>> =C2=A0 =C2=A0 =C2=A0 2
>> ianto# ps ax -opri | grep 48 | wc -l
>> =C2=A0 =C2=A0 =C2=A0 1
>> ianto# ps ax -opri | grep 49 | wc -l
>> =C2=A0 =C2=A0 =C2=A0 1
>
> I'm running a non-SMP kernel with ULE last synced with subversion on Marc=
h
> 16. =C2=A0 Full system info can be found here:
>
> =C2=A0http://www.wanderview.com/svn/public/misc/zfs_livelock/
>
> Anyway, I apologize if I'm missing something. =C2=A0I'd be happy to do mo=
re
> investigation if you'd like. =C2=A0Just let me know.

I still need to check the ktr/datas you sent me that time, I just need
to find the time to do that, sorry.

Thanks,
Attilio


--=20
Peace can only be achieved by understanding - A. Einstein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3bbf2fe10905190240g3e6dd267nf1621ca4e54d7a85>