]> git.droids-corp.org - dpdk.git/commit
eal: get/set thread priority per thread identifier
authorTyler Retzlaff <roretzla@linux.microsoft.com>
Tue, 24 May 2022 11:08:36 +0000 (04:08 -0700)
committerDavid Marchand <david.marchand@redhat.com>
Tue, 7 Jun 2022 11:33:14 +0000 (13:33 +0200)
commitca04c78b6262145ce8b878ec5a5b824fd118b55f
treecde14f54346367364d30ce67655845308a0e8f78
parent0bee0709079b0e3a460e41a6ab9891335d7d26e7
eal: get/set thread priority per thread identifier

Add functions for setting and getting the priority of a thread.
Priorities on multiple platforms are similarly determined by a priority
value and a priority class/policy.

Currently in DPDK most threads operate at the OS-default priority level
but there are cases when increasing the priority is useful. For
example, high performance applications may require elevated priority
levels.

For these reasons, EAL will expose two priority levels which are named
suggestively "normal" and "realtime_critical" and are computed as
follows:

  On Linux, the following mapping is created:
    RTE_THREAD_PRIORITY_NORMAL corresponds to
      * policy SCHED_OTHER
      * priority value:   (sched_get_priority_min(SCHED_OTHER) +
   sched_get_priority_max(SCHED_OTHER))/2;
    RTE_THREAD_PRIORITY_REALTIME_CRITICAL corresponds to
      * policy SCHED_RR
      * priority value: sched_get_priority_max(SCHED_RR);

  On Windows, the following mapping is created:
    RTE_THREAD_PRIORITY_NORMAL corresponds to
      * class NORMAL_PRIORITY_CLASS
      * priority THREAD_PRIORITY_NORMAL
    RTE_THREAD_PRIORITY_REALTIME_CRITICAL corresponds to
      * class REALTIME_PRIORITY_CLASS (when running with privileges)
      * class HIGH_PRIORITY_CLASS (when running without privileges)
      * priority THREAD_PRIORITY_TIME_CRITICAL

Note that on Linux the resulting priority value will be 0, in
accordance to the documentation that mention the value should be 0 for
SCHED_OTHER policy.

Signed-off-by: Narcisa Vasile <navasile@linux.microsoft.com>
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
lib/eal/include/rte_thread.h
lib/eal/unix/rte_thread.c
lib/eal/version.map
lib/eal/windows/rte_thread.c