Ethernet communication from real time thread
Subsystems (3)
Hi all,
I have an application which is (so far) running using Xenomai and Rtnet.
I am about to evaluate this using the rt_preemption patch (V2.6.29.1-rt9).
It works quite smoothly, however I have some questions on the priorities that are used for Ethernet, UDP/IP based network communication.
I have one separate NIC in my (Intel QuadCore) PC, that is used for a point-to-point connection with an embedded device. Communication is done via UDP.
I have now a user thread (RT prio: 80) to do some computation and also the communication with the embedded device. This thread is the only running on core 3.
My questions are now:
A call of send() in my user space application to transmit a UDP message ends up in the network stack of Linux.
Which real time priority will be used in the network stack? Is it the priority of the user space thread that is calling send()? Or is it the priority of the kernel thread [sirq-net-tx/3]?
On the receive side (calling recv()):
Which threads are relevant here?
IRQ-XX for the NIC's irq thread, [sirq-net-rx/3] or also the user space thread that is calling recv()?
Thanks for all feedback on that basic question!
Best regards
Mathias
Signature · 11 lines
Mathias Koehrer [email protected] Arcor.de Gaming Area - kostenfrei daddeln bis der Arzt kommt! Jetzt checken und aus über 80 Spielen wählen! http://www.arcor.de/footer-gaming/ -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
think there are few questions you will have to answer before you end up with
an solution.
1. Is Xenomai is Configured to take care of Multicore Hard real time Computation? Since
you say that the Thread is running in Processor 3. How is Xenomai
Configured in case
of the Multicore Solution
2. What are these hard real time computations in this particular thread?
3. How is Xenomai Taking care of this thread?
4. RTNET is running the UDP Part of Thread or Does not fork in Xenomai.
Quoted 42 lines · M. Koehrer
Hi all,
I have an application which is (so far) running using Xenomai and Rtnet.
I am about to evaluate this using thert_preemptionpatch (V2.6.29.1-rt9).
It works quite smoothly, however I have some questions on the priorities that are used for Ethernet, UDP/IP based network communication.
I have one separate NIC in my (Intel QuadCore) PC, that is used for a point-to-point connection with an embedded device. Communication is done via UDP.
I have now a user thread (RT prio: 80) to do some computation and also the communication with the embedded device. This thread is the only running on core 3.My questions are now:
A call ofsend()in my user space application to transmit a UDP message ends up in the network stack of Linux.
Which real time priority will be used in the network stack? Is it the priority of the user space thread that is callingsend()? Or is it the priority of the kernel thread [sirq-net-tx/3]?On the receive side (calling
recv()):
Which threads are relevant here?
IRQ-XX for the NIC's irq thread, [sirq-net-rx/3] or also the user space thread that is callingrecv()?Thanks for all feedback on that basic question!
Best regards
Mathias
--
Mathias Koehrer
[email protected]Arcor.de Gaming Area - kostenfrei daddeln bis der Arzt kommt! Jetzt checken und aus über 80 Spielen wählen!
http://www.arcor.de/footer-gaming/
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
-- Sujit K M -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Sujit,
thanks for your response.
I am actually interested in the way, the communication with the RT_PREEMPT patch works to get an understanding what pieces of the overall system can be tuned and which priorities of threads are relevant and which SMP affinities are relevant.
As rtnet can only handle UDP it is obvious, that it is performing slightly better, however a good understanding is important in any case.
Quoted 9 lines
1. Is Xenomai is Configured to take care of Multicore Hard real time Computation? Since
you say that the Thread is running in Processor 3. How is Xenomai
Configured in case
of the Multicore Solution
2. What are these hard real time computations in this particular thread?
3. How is Xenomai Taking care of this thread?
4. RTNET is running the UDP Part of Thread or Does not fork in Xenomai.
Regards
Mathias
Signature · 11 lines
Mathias Koehrer [email protected] Arcor.de Gaming Area - kostenfrei daddeln bis der Arzt kommt! Jetzt checken und aus über 80 Spielen wählen! http://www.arcor.de/footer-gaming/ -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
I think you have a point it certainly needs to be checked whether the RT_PREEMPT patch behaves with an package like Xenomai. My initial reaction is just that in the case of Xenomai, it just applies an Hard Real time constraint on the RT_PREEMPT patch.
But it is certainly much better to investigate what happens when we have an Xenomai like RT System behave otherwise. Does it change the RT_PREEMPT patch.
Quoted 33 lines · M. Koehrer
Hi Sujit,
thanks for your response.
I am actually interested in the way, the communication with theRT_PREEMPTpatch works to get an understanding what pieces of the overall system can be tuned and which priorities of threads are relevant and which SMP affinities are relevant.As rtnet can only handle UDP it is obvious, that it is performing slightly better, however a good understanding is important in any case.
Quoted 9 lines
1. Is Xenomai is Configured to take care of Multicore Hard real time Computation? Since
you say that the Thread is running in Processor 3. How is Xenomai Configured in case
of the Multicore Solution
2. What are these hard real time computations in this particular thread?
3. How is Xenomai Taking care of this thread?
4. RTNET is running the UDP Part of Thread or Does not fork in Xenomai.Regards
Mathias
--
Mathias Koehrer
[email protected]Arcor.de Gaming Area - kostenfrei daddeln bis der Arzt kommt! Jetzt checken und aus über 80 Spielen wählen!
http://www.arcor.de/footer-gaming/
Signature · 5 lines
-- Sujit K M -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Sujit,
now I got your point!
I think I did not tell it clearly:
I want to replace a running Xenomai/RTNET approach by completely
using the RT_PREEMPT patch. I do not want to do any mix of Xenomai and RT_PREEMPT. The target is to have a RT_PREEMPT only system that performs similar to the Xenomai/rtnet approach.
Sorry for any confusion here...
Thus, the concrete question (in short) is:
- Which (user/kernel) threads (prio, affinity) are relevant for using Ethernet (UDP/IP) communication with the RT_PREEMPT patch.
Quoted 9 lines
I think you have a point it certainly needs to be checked whether the
RT_PREEMPTpatch behaves with an package like Xenomai. My initial reaction is just that in the case of Xenomai, it just applies an Hard Real time constraint on theRT_PREEMPTpatch.But it is certainly much better to investigate what happens when we have an Xenomai like RT System behave otherwise. Does it change the
RT_PREEMPTpatch.
Regards
Mathias
Signature · 11 lines
Mathias Koehrer [email protected] Arcor.de Gaming Area - kostenfrei daddeln bis der Arzt kommt! Jetzt checken und aus über 80 Spielen wählen! http://www.arcor.de/footer-gaming/ -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines
now I got your point!
I think I did not tell it clearly:
I want to replace a running Xenomai/RTNET approach by completely
using theRT_PREEMPTpatch. I do not want to do any mix of Xenomai andRT_PREEMPT. The target is to have aRT_PREEMPTonly system that performs similar to the Xenomai/rtnet approach.
What you mean to say is the pthread library.
http://en.wikipedia.org/wiki/POSIX_Threads
http://www.net.t-labs.tu-berlin.de/~gregor/tools/pthread-scheduling.html
How will you replace Xenomai/RTNET Completely. You don't even know how it behaves withRT_PREEMPT patch. Also why do you think it necessary to have an common guide line
on Priorities on thread's. I dont think they follow any standard on this regard. For Example QT might be following some other Thread Priority standard in regards to number
of levels, thread nomenclature etc.
Quoted 5 lines
Sorry for any confusion here...
Thus, the concrete question (in short) is:
- Which (user/kernel) threads (prio, affinity) are relevant for using Ethernet (UDP/IP) communication with theRT_PREEMPTpatch.
you could look up these articles. based on what i have discussed.
http://lists.trolltech.com/qt-interest/2007-05/thread00746-0.html
Quoted 38 lines · M. Koehrer
Hi Sujit,
now I got your point!
I think I did not tell it clearly:
I want to replace a running Xenomai/RTNET approach by completely
using theRT_PREEMPTpatch. I do not want to do any mix of Xenomai andRT_PREEMPT. The target is to have aRT_PREEMPTonly system that performs similar to the Xenomai/rtnet approach.Sorry for any confusion here...
Thus, the concrete question (in short) is:
- Which (user/kernel) threads (prio, affinity) are relevant for using Ethernet (UDP/IP) communication with theRT_PREEMPTpatch.Quoted 9 lines
I think you have a point it certainly needs to be checked whether the
RT_PREEMPTpatch behaves with an package like Xenomai. My initial reaction is just that in the case of Xenomai, it just applies an Hard Real time constraint on theRT_PREEMPTpatch.But it is certainly much better to investigate what happens when we have an Xenomai like RT System behave otherwise. Does it change the
RT_PREEMPTpatch.Regards
Mathias
--
Mathias Koehrer
[email protected]Arcor.de Gaming Area - kostenfrei daddeln bis der Arzt kommt! Jetzt checken und aus über 80 Spielen wählen!
http://www.arcor.de/footer-gaming/
Signature · 5 lines
-- Sujit K M -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Mathias,
From: M. Koehrer <[email protected]>>
Quoted 4 lines
My questions are now:
A call ofsend()in my user space application to transmit a UDP message ends up in the network stack of Linux.
Which real time priority will be used in the network stack?
When you make a system call (e.g. socket) then your system call is processed in the same thread as your application is running... Just in kernel space
Quoted 1 line
Is it the priority of the user space thread that is calling
send()?
Therefor, yes!
Quoted 1 line
Or is it the priority of the kernel thread [sirq-net-tx/3]?
Yes too, because your network packet will be put in a queue, which is processed by sirq-net-tx. (Altough, on my system sending packet are processed by sirq-net-rx, it might be a bug...)
Quoted 4 lines
On the receive side (calling
recv()):
Which threads are relevant here?
IRQ-XX for the NIC's irq thread, [sirq-net-rx/3] or also the user space thread that is callingrecv()?
Your IRQ-XX thread is relevant too. Interrupts can be shared, and they are first dispatched by this IRQ-XX thread, which then calls the sirq-net-rx. So you need to prioritize both threads... And you're final reciption thread too...
To be sure that you take the right IRQ-XX thread you can look up which IRQ is used by your network card by invoking this:
cat /proc/interrupts
To be sure you took every thread which is used by your application you can do a function trace, or a scheduling trace, which might be less verbose. You need to enable that in your kernel (onder kernel hacking, Tracers...)
Mount you're debug fs:
sudo mount -t debugfs debugfs /debug
Get available tracers
cat /debug/tracing/available_tracers
Enable one and do a the trace, while you're app is running:
echo sched_switch > /debug/tracing/current_tracer echo 1 > /debug/tracing/tracing_enabled
wait a short while
echo 0 > /debug/tracing/tracing_enabled
cat /debug/tracing/trace > /tmp/yourtrace
Thats how i understand the thing atm, Im pretty new to preempt rt and linux kernel hacking too, so some of my explanations might be wrong... :-)
I send network packets with preempt rt too, it might be interessting to share some expirences... With which frequency do you send packets? Does it happen for you that you're top is somehow messed up? I use to have different cpu usages each time i start my application... It seems that the scheduler has some problems with short period tasks, networking and accounting...
Bye
Stefan
How to change the ISR kthread priority in 2.6.26 series
In driver init function after registering IRQ, I want to raise the thread priority to default + 1, but am unable to find the suitable API's.
I am using 2.6.26 series with rt-patch.
regards,
Suresh
Re: How to change the ISR kthread priority in 2.6.26 series
Hello Suresh,
Quoted 3 lines
In driver init function after registering IRQ, I want to raise the thread priority to default + 1, but am unable to find the suitable API's. I am using 2.6.26 series with rt-patch.
I use the attached patches for this.
Did not found the time yet to push them upstream. (But they were discussed about quite some time ago on lkml and the comments are reworked.)
Apply these patches in this order:
1. add-map-functionality-to-kernel-cmdline.patch
2. changing_interrupt_prios_from_kernel_cmdline.patch
3. changing_softirq_prios_from_kernel_cmdline.patch
Kind regards,
Remy
Add generic routine for parsing map-like options on kernel cmd-line
This patch adds a generic routine to the kernel, so that a map of settings can be entered on the kernel commandline.
---
--- include/linux/kernel.h | 1 lib/cmdline.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 4 deletions(-)
include/linux/kernel.h +1 -0
@@ -174,6 +174,7 @@ extern int vsscanf(const char *, const cextern int get_option (char **str,int *pint);extern char *get_options (const char *str,int nints,int *ints); +extern int get_map_option (const char *str,const char *key,int *pint);extern unsigned long long memparse (char *ptr,char **retptr);extern int core_kernel_text (unsigned long addr);
lib/cmdline.c +74 -4
100 lines not on this page · raw message
The RT-patch originally creates all its IRQ-threads at priority 50. Of course, this is not a usable default for many realtime systems and therefor these priorities has to be tuneable for each RT-system. But, currently there is no way within the kernel to adjust this to the needs of the user. Some scripts are floating around to do this from userspace, but for several applications the priorities should already be set properly by the kernel itself before userland is started.
This patch changes this by adding a kernel cmd-line option that can handle a map of priorities.
It is based on the name of the driver that requests an interrupt, it does NOT use the IRQ-ID to prioritize a certain IRQ thread. This is designed this way because across several hardware-boards the IRQ-IDs can change, but not necessarily the drivers (interrupt handlers) name.
Remarks:
* There is a check for conflicts added, for situations where IRQ-sharing is detected with different priorities requested on the kernel cmd-line.
* Priorities are only set at creation time of the IRQ-thread.
* If userland overrules, it is NOT restored by this code.
* if no new kernel cmdline options are given, the kernel works as before, and all IRQ-threads start at 50.
* No wildcards are supported on the cmdline.
See kernel/Documentation/kernel-parameters.txt for usage info.
--- Documentation/kernel-parameters.txt | 6 ++ include/linux/irq.h | 1 kernel/Kconfig.preempt | 17 +++++ kernel/irq/manage.c | 105 ++++++++++++++++++++++++++++++++---- 4 files changed, 118 insertions(+), 11 deletions(-)
Documentation/kernel-parameters.txt +6 -0
@@ -881,6 +881,12 @@ and is between 256 and 4096 characters. ips= [HW,SCSI] Adaptec / IBM ServeRAID controller See header of drivers/scsi/ips.c. + pmap_hirq= [IRQ-threading] List of priorities each interrupt + thread must have. Used to overrule the list provided + by CONFIG_PREEMPT_HARDIRQS_PRIORITIES + Format: pmap_hirq=megasas:90,eth0:40,50 + The first field without ':', is the default prio. + ports= [IP_VS_FTP] IPVS ftp helper module Default is 21. Up to 8 (IP_VS_APP_MAX_PORTS) ports
include/linux/irq.h +1 -0
@@ -170,6 +170,7 @@ struct irq_desc {unsigned int irqs_unhandled;unsigned long last_unhandled;/* Aging timer for unhandled count */ struct task_struct *thread; +int rt_prio;wait_queue_head_t wait_for_handler;cycles_t timestamp;raw_spinlock_t lock;
kernel/irq/manage.c +94 -11
161 lines not on this page · raw message
kernel/Kconfig.preempt +17 -0
@@ -121,6 +121,23 @@ config PREEMPT_HARDIRQS Say N if you are unsure. +config PREEMPT_HARDIRQS_PRIORITIES + string "Thread Hardirqs priorities" + default "50" + depends on PREEMPT_HARDIRQS + help + This option specifies the priority of each interrupt thread. + + Format: megasas:90,eth0:40,50 + The first field without ':', is the default priority to be used. + The string to be used is the name of the interrupt handler, and + can be found in 'cat /proc/interrupts'. + + This line can be overruled on the kernel command line through + the pmap_hirq option. See Documentation/kernel-parameters.txt + + Leave default (50) if you are unsure. + config PREEMPT_RCU bool "Preemptible RCU" depends on PREEMPT
The RT-patch originally creates all its softirq-threads at priority 50. Of course, this is not a usable default for many realtime systems and therefor these priorities has to be tuneable for each RT-system. But, currently there is no way within the kernel to adjust this to the needs of the user. Some scripts are floating around to do this from userspace, but for several applications the priorities should already be set properly by the kernel itself before userland is started.
This patch changes this by adding a kernel cmd-line option that can handle a map of priorities.
Remarks:
* Priorities are only set at creation time of the softirq.
* Priorities has to be set per-cpu.
* If userland overrules, it is NOT restored by this code.
* if no new kernel cmdline options are given, the kernel works as before, and all softirqs start at 50.
* No wildcards are supported on the cmdline.
See kernel/Documentation/kernel-parameters.txt for usage info.
--- Documentation/kernel-parameters.txt | 10 +++ kernel/Kconfig.preempt | 16 +++++ kernel/softirq.c | 109 ++++++++++++++++++++++++++++++------ 3 files changed, 118 insertions(+), 17 deletions(-)
Documentation/kernel-parameters.txt +10 -0
@@ -887,6 +887,16 @@ and is between 256 and 4096 characters. Format: pmap_hirq=megasas:90,eth0:40,50 The first field without ':', is the default prio. + pmap_sirq= [IRQ-threading] List of priorities each softirq + thread must have. Used to overrule the list provided + by CONFIG_PREEMPT_SOFTIRQS_PRIORITIES + Format: pmap_sirq=block/0:90,sched/0:75,50 + The priorities have to be specified per-cpu. + The first field without ':', is the default prio. + The names have to match the softirq_names[] table in + kernel/softirq.c, (thus without 'softirq-' prefix) to + keep the cmd-line short. + ports= [IP_VS_FTP] IPVS ftp helper module Default is 21. Up to 8 (IP_VS_APP_MAX_PORTS) ports
kernel/softirq.c +92 -17
140 lines not on this page · raw message
kernel/Kconfig.preempt +16 -0
@@ -102,6 +102,22 @@ config PREEMPT_SOFTIRQS Say N if you are unsure. +config PREEMPT_SOFTIRQS_PRIORITIES + string "Thread Softirqs priorities" + default "50" + depends on PREEMPT_SOFTIRQS + help + This option specifies the priority of each soft-irq thread. + + Format: "block/0:90,sched/0:75,50" + The priorities have to be specified per-cpu. + The first field without ':', is the default prio. + The names have to match the softirq_names[] table in + kernel/softirq.c, (thus without 'softirq-' prefix) to + keep the cmd-line short. + + Leave default (50) if you are unsure. + config PREEMPT_HARDIRQS bool "Thread Hardirqs" default n