From owner-freebsd-current@FreeBSD.ORG Tue May 19 02:13:03 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D15C9106564A; Tue, 19 May 2009 02:13:03 +0000 (UTC) (envelope-from ben@wanderview.com) Received: from mail.wanderview.com (mail.wanderview.com [66.92.166.102]) by mx1.freebsd.org (Postfix) with ESMTP id 7013F8FC19; Tue, 19 May 2009 02:13:03 +0000 (UTC) (envelope-from ben@wanderview.com) Received: from harkness.in.wanderview.com (harkness.in.wanderview.com [10.76.10.150]) (authenticated bits=0) by mail.wanderview.com (8.14.3/8.14.3) with ESMTP id n4J2Cw5R018174 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 19 May 2009 02:12:59 GMT (envelope-from ben@wanderview.com) Message-Id: <34451C28-9ADF-467B-B2C8-43498C87C0C2@wanderview.com> From: Ben Kelly To: Attilio Rao In-Reply-To: <3bbf2fe10905181038geaec26csffea4788a40feaca@mail.gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Date: Mon, 18 May 2009 22:12:58 -0400 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> X-Mailer: Apple Mail (2.935.3) X-Spam-Score: -1.44 () ALL_TRUSTED X-Scanned-By: MIMEDefang 2.64 on 10.76.20.1 Cc: Adam McDougall , freebsd-current@freebsd.org, Artem Belevich Subject: Re: [patch] zfs livelock and thread priorities X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 02:13:04 -0000 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. Can you elaborate on why you think its a problem? From previous off-list e-mails I get the impression that you are concerned that it does not fall on an RQ_PPQ boundary. Is this the case? Again, I may be completely confused, but ULE does not seem to consider RQ_PPQ when it assigns priorities for interactive threads. Here is how I came to this conclusion: From what I can tell a thread's priority might be adjusted for interactivity in sched_priority() around line 1421 of sched_ule: > score = imax(0, sched_interact_score(td) - td->td_proc- > >p_nice); > if (score < sched_interact) { > pri = PRI_MIN_REALTIME; > pri += ((PRI_MAX_REALTIME - PRI_MIN_REALTIME) / > sched_interact) > * score; One my machine (PRI_MAX_REALTIME - PRI_MIN_REALTIME) / sched_interact resolves to a value of 1. So the priority is being set to PRI_MIN_REALTIME plus the value of score. According to the comment on sched_interact_score() the returned value ranges from 0 to 100. As 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. For example, on my machine tickincr turns out to be 8000. So if ts_sleeptime is 16000 and ts_runtime is 8000 sched_interact_score() will return a value of 25. Which 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 > 14 > ianto# ps ax -opri | grep 44 | wc -l > 70 > ianto# ps ax -opri | grep 45 | wc -l > 4 > ianto# ps ax -opri | grep 46 | wc -l > 3 > ianto# ps ax -opri | grep 47 | wc -l > 2 > ianto# ps ax -opri | grep 48 | wc -l > 1 > ianto# ps ax -opri | grep 49 | wc -l > 1 I'm running a non-SMP kernel with ULE last synced with subversion on March 16. Full system info can be found here: http://www.wanderview.com/svn/public/misc/zfs_livelock/ Anyway, I apologize if I'm missing something. I'd be happy to do more investigation if you'd like. Just let me know. Thanks! - Ben