Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - priority level shortage: (5 Items)
   
priority level shortage  
As we knew that most QNX service and utilities use default highest priority 21 and lowest priority 10. For example, io-
net use priority level 21 for interrrupt handling, and io-hid, io-usb, etc. Therefore there will be left 20~10 priority 
level ranges for normal user applications.

As I knew the history coming from QNX 4 that only 32 priorities. It make sense that io-net and io-hid use 21 as default.
 However, QNX 6 has 255 priority levels and io-usb/io-hid still uses 21 which did NOT extend priority range for user 
applications. 

For example, if there are six applications reside on the same CPU each need 10 thread priority levels (Our target 
porting from legacy system which has six independent CPUs for each application). There will be totally 60 threads needed
. Even the priority levels can be simplified to 30 levels after review. The default ten (20~10) priority level range is 
still too few.

As I knew that io-net can adjust priority by "'priority=50' to extend user application level range to 49~10. However, io
-hid an d io-usb have no way to adjust. 

Therefore, is any QNX technical article or guideline to adjust QNX default priority for specific services?

Re: priority level shortage  
Tsung-Hsun Wu wrote:
>  As we knew that most QNX service and utilities use default highest
>  priority 21 and lowest priority 10. For example, io-net use priority
>  level 21 for interrrupt handling, and io-hid, io-usb, etc. Therefore
>  there will be left 20~10 priority level ranges for normal user
>  applications.
>
>  As I knew the history coming from QNX 4 that only 32 priorities. It
>  make sense that io-net and io-hid use 21 as default. However, QNX 6
>  has 255 priority levels and io-usb/io-hid still uses 21 which did NOT
>  extend priority range for user applications.

Actually .. QNX6 evolved to 255 priorities over the last couple of releases
from a smaller number similar to QNX4.

In any case most servers/apps that need to generate additional 
pulses/threads
etc that are not within the main thread will honour the priority that 
you start
the main application at, so if you wanted to start io-net at a higher 
priority,
you could use the 'on' command and :

% on -p <prio> io-net ...

... or for an already running process/thread,  you can use the 'slay' 
command
to force an external adjustment of the priority.  Whether this will 
stick or not
is dependant on the actual code of the thing being targetted:

% slay -P <prio> <targetprocess>

Now as a server, the majority of the threads are going to be RECEIVE blocked
and waiting for clients to connect and drive their priority, so the actual

Also note that by default, non-root applications are limited to run at 
priority
levels <64 unless you adjust the procnto command line.

Hope this helps,
 Thomas
Re: priority level shortage  
Hi Thomas,

I think the OP has a point.  The out-of-the-box default priorities for these drivers no longer make sense since the 
priority cap has been raised to 255.  This is especially true since, as you mention, by default even non-root users can 
starve out interrupt handling!   Using a standard interrupt/device priority of 21 made sense when non-root users were 
capped at 20, but with the extended range the default out-of-the-box values should at least be raised above what non-
root users can reach.

The answer "you can always adjust the priorities yourself" isn't particularly satisfying, either.  There are two 
problems with it:

One, we have no idea what sort of testing you've done with an altered device priority scheme.  We can safely assume that
 you've done regression testing with the default values - but have you tested how io-usb behaves if io-net or devb-eide 
is raised to a higher priority and it suffers from higher interrupt latency as a result?  Or any other combination of 
the above?  At what point does the behavior of the code break down?  As a developer, I don't even have any way of 
assessing the possible risks of such a change (though fortunately this aspect is slowly being rectified as more driver 
source becomes available - kudos again to the Foundry27 project as a whole :).

Two, the overwhelming majority of QNX-supplied device drivers either (a) only offer a custom, non-standard way of 
adjusting their primary device handling priority; or (b) don't offer any such mechanism at all (io-hid, for example).  
Under the hood, they all do the same thing: they use a pulse on their device-event handling thread, and thus they 
completely ignore the on -p or slay -P commands in terms of changing what priority they handle device events at (since 
the priority will be based on the value stored in the pulse, which does not seem to pay any attention to the startup 
thread priority).  Tracking down the myriad of custom options for every driver launched by the system is a daunting task
 at best, and error prone at worst - especially when you end up hacking the binaries because there isn't any such option
 presented and the priority value is simply hardcoded.

To sum up, I'd recommend making two specific changes:
1) For all drivers and driver-like code, immediately adjust the default priority scheme to raise the default priority 
above userland.
2) Wherever a fixed-priority pulse is used, calculate the default priority by (startup_thread_priority + offset) and 
ensure that the offset is documented.  This will at least allow nice or on -p to be used in a consistent manner.  
Respecting the old priority options and allowing a new option to adjust the priority offset would be a plus.

These comments are based on the first 6.4.0 alpha release - if things have changed since then, please disregard this 
post.

-Will

PS.  To the OP:  Make sure you get your block device drivers too (they also use the priority= argument scheme).  io-usb 
can be adjusted using the -P argument (see the use message).   We also boosted the priority of system services (using 6.
3.0); it's been working OK for us so far, but we made sure to raise them all to the same level (ie. there's still no 
prioritization of one over another).
Re: priority level shortage  
Will Miles wrote:
>  Hi Thomas,
>
>  I think the OP has a point.  The out-of-the-box default priorities
>  for these drivers no longer make sense since the priority cap has
>  been raised to 255.  This is especially true since, as you mention,
>  by default even non-root users can starve out interrupt handling!
>  Using a standard interrupt/device priority of 21 made sense when
>  non-root users were capped at 20, but with the extended range the
>  default out-of-the-box values should at least be raised above what
>  non-root users can reach.
>
>  The answer "you can always adjust the priorities yourself" isn't
>  particularly satisfying, either.  There are two problems with it:
>
>  One, we have no idea what sort of testing you've done with an altered
>  device priority scheme.  We can safely assume that you've done
>  regression testing with the default values - but have you tested how
>  io-usb behaves if io-net or devb-eide is raised to a higher priority
>  and it suffers from higher interrupt latency as a result?  Or any
>  other combination of the above?  At what point does the behavior of
>  the code break down?  As a developer, I don't even have any way of
>  assessing the possible risks of such a change (though fortunately
>  this aspect is slowly being rectified as more driver source becomes
>  available - kudos again to the Foundry27 project as a whole :).

Do you beleive that QNX tests every combination of server with every
other server?  As soon as you get multiple clients and servers running,
pretty much every environment becomes a custom "analysis" that has
to be done for your specific product and environment.  Also I suspect
(though I can't prove it at this point in time =;-) that you'd find most of
the labs run with different command line options and parameters based
on the goal's of the labs and tests.

Adjusting the priorities on specific services 'up' won't (or shouldn't) 
provide any additional comfort to you if it is just done en-masse (ie
121 becomes the new 21 =;-)

>  Two, the overwhelming majority of QNX-supplied device drivers either
>  (a) only offer a custom, non-standard way of adjusting their primary
>  device handling priority; or (b) don't offer any such mechanism at
>  all (io-hid, for example).  Under the hood, they all do the same
>  thing: they use a pulse on their device-event handling thread, and
>  thus they completely ignore the on -p or slay -P commands in terms of
>  changing what priority they handle device events at (since the
>  priority will be based on the value stored in the pulse, which does
>  not seem to pay any attention to the startup thread priority).
>  Tracking down the myriad of custom options for every driver launched
>  by the system is a daunting task at best, and error prone at worst -
>  especially when you end up hacking the binaries because there isn't
>  any such option presented and the priority value is simply hardcoded.

There was a significant effort to address this some time ago, and those
changes should be rolled out with the 6.4.x binaries I imagine.  For those
who are trapped in a 6.3.x world, then on and slay are your best bets =;-)

Thanks,
 Thomas ... not against up'ing the priorities, but also not seeing it as 
a silver
                  bullet to the problem originally expressed.
Re: priority level shortage  
> Do you beleive that QNX tests every combination of server with every
> other server?  As soon as you get multiple clients and servers running,
> pretty much every environment becomes a custom "analysis" that has
> to be done for your specific product and environment.  Also I suspect
> (though I can't prove it at this point in time =;-) that you'd find most of
> the labs run with different command line options and parameters based
> on the goal's of the labs and tests.

Heck no - which is precisely my point; the only levels we can expect /were/ tested are the defaults.  Changing those 
levels means taking an unknown risk.

> 
> Adjusting the priorities on specific services 'up' won't (or shouldn't) 
> provide any additional comfort to you if it is just done en-masse (ie
> 121 becomes the new 21 =;-)

Changing the default levels upwards does however provide two immediate benefits:
1) Out of the box, non-root users can't starve out the disk, network, or input subsystems.
2) As a developer, I now have a large range of unused priorities I can use for my own programs without needing to change
 any of the services from their default value (and thus take the risk as mentioned above).

The point being that if "121 was the new 21" it'd still be an improvement for us. :)

> There was a significant effort to address this some time ago, and those
> changes should be rolled out with the 6.4.x binaries I imagine.  For those
> who are trapped in a 6.3.x world, then on and slay are your best bets =;-)

Indeed, I recall seeing some of the bits and pieces of that effort floating around on the newsgroups.   The situation 
has definitely improved dramatically since then - there does exist /some/ mechanism to set the device event priority for
 the vast majority of drivers (io-hid seems to be the notable exception, though again I don't have a fresh copy to check
 against).

My contention here is that those mechanisms when available are always local - there's no one tool or syntax that works 
in every circumstance.  IMHO, it would be really nice if there was a standardized way to adjust the effective priority 
of these processes.   Making "on -p" work as expected on driver processes would be one way.   Ensuring a totally 
standard command-line option ("-P 121" - ie not one that lives in the "device specific" options secton) could be another
.  Drawing the priority value from an environment or getconf value (DRIVER_INTERRUPT_PRIORITY = 121) could be another.  
As long as it's standard and everyone respects it.

> 
> Thanks,
>  Thomas ... not against up'ing the priorities, but also not seeing it as 
> a silver bullet to the problem originally expressed.

You're absolutely right, it's not a silver bullet - a standard or centralized way of setting our own target would be 
much better.  Given that that's a harder problem to solve, though, raising the defaults would still be a big help.

Thanks for reading,
-Will