ni / linux

Linux kernel source for NI Linux Real-Time
Other
80 stars 77 forks source link

efivarfs: skip efivar_query_variable_info on PREEMPT_RT #152

Closed gratian closed 6 months ago

gratian commented 6 months ago

Commit d86ff3333cb1 ("efivarfs: expose used and total size") introduced the ability to query the efivars file system size with utilities like 'df'.

Unfortunately this introduces large latency spikes in real-time tasks on PREEMPT_RT configured kernels. Skip the EFI run-time services query for EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO if on PREEMPT_RT. The 'df' functionality is lost but the rest of the efivars run-time services continue to work.

Upstream status: Inappropriate (configuration)

[1] https://review-board.natinst.com/r/271066 [2] https://review-board.natinst.com/r/303906

gratian commented 6 months ago

AB#2662085

Testing

chaitu236 commented 6 months ago

fw_printenv continues to work.

Does adding new efivars continue to work?

The 'df' functionality is lost but the rest of the efivars run-time services continue to work.

Is there another method to query efivars file system size?

There was an issue previously due to efivars file system filling up - I know it was fixed but just wondering if we have another way to get the size in case we encounter similar issues in future.

gratian commented 6 months ago

fw_printenv continues to work.

Does adding new efivars continue to work?

Yes:

admin@NI-cRIO-9034-01ACD249:~# efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-TestVar
efivar: show variable: No such file or directory
admin@NI-cRIO-9034-01ACD249:~# efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-TestVar -w -f ./efi.tmp 
admin@NI-cRIO-9034-01ACD249:~# efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-TestVar
GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c
Name: "TestVar"
Attributes:
    Non-Volatile
    Boot Service Access
    Runtime Service Access
Value:
00000000  01                                                |.               |
admin@NI-cRIO-9034-01ACD249:~# uname -a
Linux NI-cRIO-9034-01ACD249 6.6.20-rt25-00074-gb9adaf50f466 #1 SMP PREEMPT_RT Tue Mar 19 09:46:32 CDT 2024 x86_64 x86_64 x86_64 GNU/Linux

The 'df' functionality is lost but the rest of the efivars run-time services continue to work.

Is there another method to query efivars file system size?

There was an issue previously due to efivars file system filling up - I know it was fixed but just wondering if we have another way to get the size in case we encounter similar issues in future.

Yeah, we have a couple of init scripts that try to clean-up efivars:

The information about the vars sizes could probably be reconstructed from /sys/firmware/efi/efivars. It is not going to be as easy as running df on /sys/firmware/efi/efivars.

Regardless, we don't really have a good choice here, at least for the standard RT kernel. The latency impact of querying this information at runtime is large: >60uS on PXI-8880 so we either do away with using EFI variables altogether (like upstream does for PREEMPT_RT) or accept the reduced functionality where we can still read/write EFI vars at runtime but we loose this new 'df' functionality (which we've never shipped to customers, since it was added in 6.5).

gratian commented 6 months ago

@ni/rtos still waiting on an ACK/NACK here.