Hi,
I'm sending an email to discuss how to remove spinlock from a whole process of open/read/close of efi_pstore.
[Problem]
Current efi_pstore calls kmalloc() in a read callback while holding a spinlock, efivar->lock, in an open callback.
This means efi_pstore may deadlock if it sleeps in kmalloc().
Also, there is a comment that an efivar->lock shouldn't be held when calling kmalloc().
[Idea]
In a process of open/read/close, pstore creates some files in the directory of /dev/pstore.
So, memory allocations like kmalloc() are not avoidable.
My idea fixing this issue is removing spinlock from a whole process of open/read/close of efi_pstore.
Currently, efivar->lock protects two things, efivar->list and ops.[gs]et_variable().
But if we can revise locks of efivar as follows, we can fix this issue.
- Introduce a new efivar->list_lock to protect efivar->list and RCU is used while searching it.
- An existing efivar>lock protects just ops.[gs]et_variable() calls.
Any comments are welcome.
Seiji