* [PATCH] efi: replace GFP_KERNEL with GFP_ATOMIC [not found] <saurabh.truth@gmail.com> @ 2015-10-27 18:42 ` Saurabh Sengar 2015-10-28 3:42 ` [PATCH v2] " Saurabh Sengar 1 sibling, 0 replies; 3+ messages in thread From: Saurabh Sengar @ 2015-10-27 18:42 UTC (permalink / raw) To: matt-mF/unelCI9GS6iBeEJttW/XRex20P6io, linux-efi-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Saurabh Sengar replace GFP_KERNEL with GFP_ATOMIC, as code while holding a spinlock should be atomic GFP_KERNEL may sleep and can cause deadlock, where as GFP_ATOMIC may fail but certainly avoids deadlock Signed-off-by: Saurabh Sengar <saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/firmware/efi/vars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 70a0fb1..c07de85 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -334,7 +334,7 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, */ efivar_wq_enabled = false; - str8 = kzalloc(len8, GFP_KERNEL); + str8 = kzalloc(len8, GFP_ATOMIC); if (!str8) return; -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] efi: replace GFP_KERNEL with GFP_ATOMIC @ 2015-10-28 3:42 ` Saurabh Sengar [not found] ` <1446003747-3760-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Saurabh Sengar @ 2015-10-28 3:42 UTC (permalink / raw) To: matt, linux-efi, linux-kernel; +Cc: Saurabh Sengar replace GFP_KERNEL with GFP_ATOMIC, as code while holding a spinlock should be atomic GFP_KERNEL may sleep and can cause deadlock, where as GFP_ATOMIC may fail but certainly avoids deadlock Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com> --- drivers/firmware/efi/vars.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 70a0fb1..d4eeebf 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -322,10 +322,11 @@ static unsigned long var_name_strnsize(efi_char16_t *variable_name, * disable the sysfs workqueue since the firmware is buggy. */ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, - unsigned long len16) + unsigned long len16, bool atomic) { size_t i, len8 = len16 / sizeof(efi_char16_t); char *str8; + int gfp_mask; /* * Disable the workqueue since the algorithm it uses for @@ -334,7 +335,12 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, */ efivar_wq_enabled = false; - str8 = kzalloc(len8, GFP_KERNEL); + if (atomic) + gfp_mask = GFP_ATOMIC; + else + gfp_mask = GFP_KERNEL; + + str8 = kzalloc(len8, gfp_mask); if (!str8) return; @@ -408,7 +414,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), if (duplicates && variable_is_present(variable_name, &vendor_guid, head)) { dup_variable_bug(variable_name, &vendor_guid, - variable_name_size); + variable_name_size, atomic); if (!atomic) spin_lock_irq(&__efivars->lock); -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1446003747-3760-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2] efi: replace GFP_KERNEL with GFP_ATOMIC [not found] ` <1446003747-3760-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-11-03 16:36 ` Matt Fleming 0 siblings, 0 replies; 3+ messages in thread From: Matt Fleming @ 2015-11-03 16:36 UTC (permalink / raw) To: Saurabh Sengar Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Wed, 28 Oct, at 09:12:27AM, Saurabh Sengar wrote: > replace GFP_KERNEL with GFP_ATOMIC, as code while holding a spinlock > should be atomic > GFP_KERNEL may sleep and can cause deadlock, where as GFP_ATOMIC may > fail but certainly avoids deadlock > > Signed-off-by: Saurabh Sengar <saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/firmware/efi/vars.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c > index 70a0fb1..d4eeebf 100644 > --- a/drivers/firmware/efi/vars.c > +++ b/drivers/firmware/efi/vars.c > @@ -322,10 +322,11 @@ static unsigned long var_name_strnsize(efi_char16_t *variable_name, > * disable the sysfs workqueue since the firmware is buggy. > */ > static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, > - unsigned long len16) > + unsigned long len16, bool atomic) > { > size_t i, len8 = len16 / sizeof(efi_char16_t); > char *str8; > + int gfp_mask; > > /* > * Disable the workqueue since the algorithm it uses for > @@ -334,7 +335,12 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, > */ > efivar_wq_enabled = false; > > - str8 = kzalloc(len8, GFP_KERNEL); > + if (atomic) > + gfp_mask = GFP_ATOMIC; > + else > + gfp_mask = GFP_KERNEL; > + > + str8 = kzalloc(len8, gfp_mask); > if (!str8) > return; > > @@ -408,7 +414,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), > if (duplicates && > variable_is_present(variable_name, &vendor_guid, head)) { > dup_variable_bug(variable_name, &vendor_guid, > - variable_name_size); > + variable_name_size, atomic); > if (!atomic) > spin_lock_irq(&__efivars->lock); It's slightly winding code, but if you look at the callers of efivar_init() you'll see that none of them set both 'atomic' and 'duplicates', so dup_variable_bug() will never be called while holding a spinlock. Or am I missing something? ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-03 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <saurabh.truth@gmail.com>
2015-10-27 18:42 ` [PATCH] efi: replace GFP_KERNEL with GFP_ATOMIC Saurabh Sengar
2015-10-28 3:42 ` [PATCH v2] " Saurabh Sengar
[not found] ` <1446003747-3760-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-03 16:36 ` Matt Fleming
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).