From: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
To: Saurabh Sengar <saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2] efi: replace GFP_KERNEL with GFP_ATOMIC
Date: Tue, 3 Nov 2015 16:36:56 +0000 [thread overview]
Message-ID: <20151103163650.GE2653@codeblueprint.co.uk> (raw)
In-Reply-To: <1446003747-3760-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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?
WARNING: multiple messages have this Message-ID (diff)
From: Matt Fleming <matt@codeblueprint.co.uk>
To: Saurabh Sengar <saurabh.truth@gmail.com>
Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] efi: replace GFP_KERNEL with GFP_ATOMIC
Date: Tue, 3 Nov 2015 16:36:56 +0000 [thread overview]
Message-ID: <20151103163650.GE2653@codeblueprint.co.uk> (raw)
In-Reply-To: <1446003747-3760-1-git-send-email-saurabh.truth@gmail.com>
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@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);
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?
next prev parent reply other threads:[~2015-11-03 16:36 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <saurabh.truth@gmail.com>
2015-10-27 3:42 ` [PATCH] drivers: of: removing assignment of 0 to static variable Saurabh Sengar
2015-10-27 3:42 ` Saurabh Sengar
2015-10-30 18:30 ` Rob Herring
2015-10-27 15:47 ` [PATCH] IB/sa: replace GFP_KERNEL with GFP_ATOMIC Saurabh Sengar
2015-10-27 15:47 ` Saurabh Sengar
[not found] ` <1445960860-3396-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-27 18:12 ` ira.weiny
2015-10-27 18:12 ` ira.weiny
[not found] ` <20151027181235.GA27038-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2015-10-27 18:16 ` Jason Gunthorpe
2015-10-27 18:16 ` Jason Gunthorpe
[not found] ` <20151027181652.GA6879-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-10-27 18:20 ` ira.weiny
2015-10-27 18:20 ` ira.weiny
2015-10-27 18:56 ` Wan, Kaike
2015-10-27 18:56 ` Wan, Kaike
[not found] ` <3F128C9216C9B84BB6ED23EF16290AFB18571E3F-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-10-27 20:00 ` Jason Gunthorpe
2015-10-27 20:00 ` Jason Gunthorpe
2015-10-28 4:30 ` Weiny, Ira
[not found] ` <2807E5FD2F6FDA4886F6618EAC48510E1CBD4369-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-11-13 7:42 ` Saurabh Sengar
2015-11-13 7:42 ` Saurabh Sengar
[not found] ` <1447400547-11490-1-git-send-email-saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-13 10:47 ` Wan, Kaike
2015-11-13 10:47 ` Wan, Kaike
[not found] ` <3F128C9216C9B84BB6ED23EF16290AFB1857D86D-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-11-13 12:37 ` Saurabh Sengar
2015-11-13 12:37 ` Saurabh Sengar
2015-10-27 18:42 ` [PATCH] efi: " Saurabh Sengar
2015-10-27 18:42 ` 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 message]
2015-11-03 16:36 ` Matt Fleming
2015-11-03 17:38 ` [PATCH] " Saurabh Sengar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151103163650.GE2653@codeblueprint.co.uk \
--to=matt-mf/unelci9gs6ibeejttw/xrex20p6io@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=saurabh.truth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.