NetBSD Problem Report #52826

From o.vd.linden@quicknet.nl  Sat Dec 16 16:55:10 2017
Return-Path: <o.vd.linden@quicknet.nl>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 4F9667A182
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 16 Dec 2017 16:55:10 +0000 (UTC)
Message-Id: <20171216153900.GA7442@sheep>
Date: Sat, 16 Dec 2017 16:39:00 +0100
From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Subject: sched_get_priority functions return wrong value for SCHED_OTHER
 priority

>Number:         52826
>Category:       lib
>Synopsis:       sched_get_priority functions return wrong value for SCHED_OTHER priority
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 16 17:00:00 +0000 2017
>Closed-Date:    Thu Jun 21 20:28:09 +0000 2018
>Last-Modified:  Sat Jun 23 11:05:01 +0000 2018
>Originator:     Onno van der Linden
>Release:        NetBSD 8.99.8
>Organization:
>Environment:
System: NetBSD sheep 8.99.8 NetBSD 8.99.8 (SHEEPKMS) #1: Mon Dec 4 16:43:49 CET 2017 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386
Architecture: i386
Machine: i386
>Description:
While trying to build mono 5.4.1.6 I bumped into a problem
with pthread_setschedparam not being able to set a priority.
That's partly caused by the fact that the sched_get_priority functions
will return their respective sysconf values
(_SC_SCHED_PRI_MIN and SC_SCHED_PRI_MAX) without taking the
policy parameter into account. The sched(3) manual page says that 
the sched_priority parameter for SCHED_OTHER must be PRI_NONE.
If (like the mono code) you expect the min and max code to be
correct and base a pthread_setschedparam on them you'll get
an error in return.
>How-To-Repeat:
call sched_get_priority_max(SCHED_OTHER) and it returns 63.
>Fix:
In /usr/src/lib/libc/sys/sched.c change the return statements
to return policy == SCHED_OTHER ? PRI_NONE : (int)sysconf(_SC_SCHED_PRI_MAX)
for sched_get_priority_max
and
return policy == SCHED_OTHER ? PRI_NONE : (int)sysconf(_SC_SCHED_PRI_MAX)
for sched_get_priority_min

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52826 CVS commit: src/lib/libc/sys
Date: Sat, 16 Dec 2017 13:31:36 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sat Dec 16 18:31:36 UTC 2017

 Modified Files:
 	src/lib/libc/sys: sched.c

 Log Message:
 PR/52826: Onno van der Linden: Return PRI_NONE for sched_get_priority_m{in,ax}
 and SCHED_OTHER.


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/lib/libc/sys/sched.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Mon, 04 Jun 2018 11:25:03 +0000
State-Changed-Why:
Is this working now? (if so, wemight want pullups, too...)


From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/52826 (sched_get_priority functions return wrong value for
 SCHED_OTHER priority)
Date: Mon, 4 Jun 2018 17:02:59 +0200

 On Mon, Jun 04, 2018 at 11:25:03AM +0000, maya@NetBSD.org wrote:
 > Synopsis: sched_get_priority functions return wrong value for SCHED_OTHER priority
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: maya@NetBSD.org
 > State-Changed-When: Mon, 04 Jun 2018 11:25:03 +0000
 > State-Changed-Why:
 > Is this working now? (if so, wemight want pullups, too...)

 Worked for my mono testcase

 Onno

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/52826 (sched_get_priority functions return wrong value for
 SCHED_OTHER priority)
Date: Thu, 21 Jun 2018 20:11:18 +0200

 On Wed, Jun 20, 2018 at 05:08:43AM +0000, NetBSD Problem Report DB Administrator wrote:
 > This is an infrequent reminder that there is 1 Problem Report
 > (PR) of yours in the NetBSD GNATS database in "feedback" state.

 Close it, worked for my testcase.

 Onno

State-Changed-From-To: feedback->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Thu, 21 Jun 2018 20:28:09 +0000
State-Changed-Why:
works now, thanks.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52826 CVS commit: [netbsd-8] src/lib/libc/sys
Date: Sat, 23 Jun 2018 11:01:14 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Jun 23 11:01:14 UTC 2018

 Modified Files:
 	src/lib/libc/sys [netbsd-8]: sched.c

 Log Message:
 Pull up following revision(s) (requested by maya in ticket #892):

 	lib/libc/sys/sched.c: revision 1.5

 PR/52826: Onno van der Linden: Return PRI_NONE for sched_get_priority_m{in,ax}
 and SCHED_OTHER.


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.4.24.1 src/lib/libc/sys/sched.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.