IRQ Affinity setup

More
13 Oct 2024 12:55 - 13 Oct 2024 12:58 #311964 by rajsekhar
IRQ Affinity setup was created by rajsekhar
Please refer the below message
Last edit: 13 Oct 2024 12:58 by rajsekhar.

Please Log in or Create an account to join the conversation.

More
13 Oct 2024 12:56 #311965 by rajsekhar
Replied by rajsekhar on topic IRQ Affinity setup
RQ Affinity setup  was created by  rajsekhar
Hi..I am doing a machine using MESA boards.

Over last few weeks, I have overcome the computer latency issue, Many thanks to this forum. Now, max jitter comes within 40,000ns for both base thread and servo thread.

But network latency continues unless I use IRQ affinity.

I had run tests and result as follows:

with enp4s0(my network hardware) interrupt in CPU0:
===========================================
raycnc1@debian:~/Desktop$ sudo chrt 99 ping -i .001 -q 10.10.10.10
[sudo] password for raycnc1: 
PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data.

--- 10.10.10.10 ping statistics ---
966462 packets transmitted, 966461 received, 0.00010347% packet loss, time 967436ms
rtt min/avg/max/mdev = 0.096/0.100/7.930/0.009 ms
^Craycnc1@debian:~/Desktop$ 
===============================================


And with interrupts in CPU1 (i.e last CPU)
===================================================
raycnc1@debian:~/Desktop$ sudo chrt 99 ping -i .001 -q 10.10.10.10
[sudo] password for raycnc1: 
PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data.

--- 10.10.10.10 ping statistics ---
7762711 packets transmitted, 7762710 received, 1.28821e-05% packet loss, time 7770480ms
rtt min/avg/max/mdev = 0.048/0.095/0.267/0.027 ms
^Craycnc1@debian:~/Desktop$ 
===========================================================

Note 1) In CPU0 result, max time is 8ms almost compared to 0.3ms in other case. So IRQ affinity setting is essential.
Note 2) The affinity setup is done for test using a script from PCW, but that require manual command run after every boot, not run automatically.

So, I have failed to do the IRQ setup.

I did follow the Mozmck post. 
forum.linuxcnc.org/38-general-linuxcnc-q...ead-and-irq-affinity

The network interface file is attached. I assume it is not as per the requirement. I have attached IPV4 setup page photo for ip setting values.

Need help.
Attachments:

Please Log in or Create an account to join the conversation.

More
13 Oct 2024 16:50 - 13 Oct 2024 16:53 #311989 by PCW
Replied by PCW on topic IRQ Affinity setup
Mozmck's script requires your interfaces file to setup the interface and that the host IP address
in parts of his script are changed to match that IP address in the interfaces file.

Alternatively, maybe adding my little script to the Linuxcnc startup script would be a simple solution

(the command "linuxcnc" is a script)
Last edit: 13 Oct 2024 16:53 by PCW.
The following user(s) said Thank You: rajsekhar

Please Log in or Create an account to join the conversation.

More
14 Oct 2024 01:35 #312020 by rajsekhar
Replied by rajsekhar on topic IRQ Affinity setup
How to add to kinuxcnc startup script? Please guide, it is new thing for me.

Please Log in or Create an account to join the conversation.

More
14 Oct 2024 03:09 #312026 by PCW
Replied by PCW on topic IRQ Affinity setup
Well it ends up being a bit awkward because it needs root privleges
probably the easiest is to add it to the startup using systemd

 

Please Log in or Create an account to join the conversation.

More
14 Oct 2024 12:33 #312054 by rajsekhar
Replied by rajsekhar on topic IRQ Affinity setup
Well, I followed some youtube videos..made two files attached.

irq32affinitty.sh put in /usr/local/sbin
irq32affinitty.service in /etc/systemd/system

My enp4s0 irq number is 32. It does not change normally, hardware change might do so, I have not checked that.

My target is : echo 2 > /proc/irq/32/smp_affinity

the irq32affinity.service works fine when started with systemctl command i.e after login.

But it fails to execute during booting.

I think service shall be started after login, but how to set that.

Request for suggestion.


 
Attachments:

Please Log in or Create an account to join the conversation.

More
14 Oct 2024 13:30 #312058 by PCW
Replied by PCW on topic IRQ Affinity setup
Here's a fair description of whats needed:

www.howtogeek.com/687970/how-to-run-a-li...tartup-with-systemd/
 

Please Log in or Create an account to join the conversation.

More
14 Oct 2024 14:46 #312064 by royka
Replied by royka on topic IRQ Affinity setup
Otherwise in /etc/rc.local above "exit 0": sleep 10 && echo .....

Or "sudo crontab -e": @reboot sleep 10 && echo ......

The sleep is necessary with the orange pi at least.

Please Log in or Create an account to join the conversation.

More
14 Oct 2024 14:51 #312066 by tommylight
Replied by tommylight on topic IRQ Affinity setup
rc.local would work, but not sure it is usable still on Debian, i know Mint stopped using it a while back, but it can still be made to work with a bit of fiddling.
The following user(s) said Thank You: royka

Please Log in or Create an account to join the conversation.

More
15 Oct 2024 07:07 #312128 by rajsekhar
Replied by rajsekhar on topic IRQ Affinity setup
rc.local is absent.

However, I somehow managed it.

In case someone need to do the same, steps are given below.
  1. Find out Interrupt number for network device by 'watch -n1 -d cat /proc/interrupts'. in my case it is 32.
  2. Check your last CPU number. In my case it is CPU1, so 'echo 2' to be set. This link may be helpful: bitsum.com/tools/cpu-affinity-calculator/
  3. create two file as attached in my post above dated 14 Oct 2024 12.33. Put them to respective directory as mentioned. chmod a+x for both files.
  4. go to 'Setting', then 'Session and Startup', then under 'Application Autostart' tab, click 'Add'
  5. under command, type "sudo systemctl start irq32affinity.service", Trigger 'on login', save.
  6. go to '/etc' directory, open terminal, type 'sudo geany sudoers'
  7. add '<user name> ALL=(ALL) NOPASSWD: /usr/bin/systemctl' at the bottom. putting in middle may not work.
  8. save and close geany.
  9. restart and check IRQ affinity.
Note1: Basically sudo password is deactivated for 'systemctl' command.
Note2: It is done on LCNC2.9.3/ Debian
Note3: Any change in last CPU number/ network hardware Interrupt number will require reconfiguration of .sh file.
Note4: No need to enable irq32affinity.service by 'systemctl enable' command.
 
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum