From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 1 16:42:44 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F3DE106564A for ; Wed, 1 Jun 2011 16:42:44 +0000 (UTC) (envelope-from krivenok.dmitry@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2117C8FC17 for ; Wed, 1 Jun 2011 16:42:43 +0000 (UTC) Received: by bwz12 with SMTP id 12so313482bwz.13 for ; Wed, 01 Jun 2011 09:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=Z7fEjoOFze+FTpKPZmA+1I9RVmWaLpz5tS0b638/Mi4=; b=qXkLYrOYN26ZNjVzLNgOYeshGiMBmLkzTKZVZGBzdx1Bx7VCa32zze9tnMBKVJ6dLk SnVs+B4Efa5OmvuXXrzL9uHChiMh377LkJWeCtY+cksk/Qm6BVdDw6bvpawPCFqMQ7D1 7R6ed72vH5ECFy2Wo73qje2EpCcb+cqN29BU4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=tGPu4aSVphNsNaX+d3OXHyi6fVb18psXfjqC4PAYqGdD3XA4FkFD2NbYHUBQ7+EQ4f 1Z5BK8d5EPM0KYnIlA71mszbQGGP4i40YAjBVuUSz1cTAAPDZgjpHPjwydxNsJKemYVP tt6LzrGlE4f4vDGghD88uheoWTRLYNAoUMKSs= MIME-Version: 1.0 Received: by 10.204.128.85 with SMTP id j21mr1760032bks.89.1306946562862; Wed, 01 Jun 2011 09:42:42 -0700 (PDT) Received: by 10.204.3.149 with HTTP; Wed, 1 Jun 2011 09:42:42 -0700 (PDT) Date: Wed, 1 Jun 2011 20:42:42 +0400 Message-ID: From: Dmitry Krivenok To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Bug in ksched_setscheduler? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 16:42:44 -0000 Hello Hackers, I think I found a bug in ksched_setscheduler() function. 178 int 179 ksched_setscheduler(struct ksched *ksched, 180 struct thread *td, int policy, const struct sched_param *param) 181 { 182 int e = 0; 183 struct rtprio rtp; 184 185 switch(policy) 186 { 187 case SCHED_RR: 188 case SCHED_FIFO: 189 190 if (param->sched_priority >= P1B_PRIO_MIN && 191 param->sched_priority <= P1B_PRIO_MAX) 192 { 193 rtp.prio = p4prio_to_rtpprio(param->sched_priority); 194 rtp.type = (policy == SCHED_FIFO) 195 ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; 196 197 rtp_to_pri(&rtp, td); 198 } 199 else 200 e = EPERM; 201 202 203 break; 204 205 case SCHED_OTHER: 206 if (param->sched_priority >= 0 && 207 param->sched_priority <= (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) { 208 rtp.type = RTP_PRIO_NORMAL; 209 rtp.prio = p4prio_to_rtpprio(param->sched_priority); 210 rtp_to_pri(&rtp, td); 211 } else 212 e = EINVAL; 213 214 break; 215 216 default: 217 e = EINVAL; 218 break; 219 } 220 221 return e; 222 } Shouldn't we use p4prio_to_tsprio instead of p4prio_to_rtpprio at the line 209? This macro is defined but never used in kernel code: $ grep -r 'p4prio_to_tsprio' /usr/src/sys/ /usr/src/sys/kern/ksched.c:#define p4prio_to_tsprio(P) ((PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE) - (P)) $ Is it a real bug or just my misunderstanding of something? Thanks! -- Sincerely yours, Dmitry V. Krivenok e-mail: krivenok.dmitry@gmail.com skype: krivenok_dmitry jabber: krivenok_dmitry@jabber.ru icq: 242-526-443