From: Pavel Machek <pavel@ucw.cz>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: shrikant.maurya@techveda.org,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>,
Greg KH <gregkh@linuxfoundation.org>,
Linux PM list <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Suniel Mahesh <sunil.m@techveda.org>,
Karthik Tummala <karthik@techveda.org>,
raghu@techveda.org
Subject: Re: [PATCH] drivers: base: power: Fix GFP_KERNEL in spinlock context
Date: Fri, 15 Dec 2017 09:45:15 +0100 [thread overview]
Message-ID: <20171215084515.GB8221@amd> (raw)
In-Reply-To: <CAMuHMdUrhV9RkUnXkTbSWaRY33iQrANwbKBE5KAPQseNgxOofg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1889 bytes --]
On Tue 2017-12-12 15:58:00, Geert Uytterhoeven wrote:
> Hi Shrikant,
>
> On Tue, Dec 12, 2017 at 2:45 PM, <shrikant.maurya@techveda.org> wrote:
> > From: Shrikant Maurya <shrikant.maurya@techveda.org>
> >
> > As reported by Jia-Ju Bai (https://lkml.org/lkml/2017/12/11/872):
> > API's are using GFP_KERNEL to allocate memory which may sleep.
> >
> > To ensure atomicity such allocations must be avoided in critical
> > sections under spinlock.
> > Fixed by replacing GFP_KERNEL to GFP_ATOMIC.
> >
> > Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> > Signed-off-by: Shrikant Maurya <shrikant.maurya@techveda.org>
> > Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
> > Signed-off-by: Raghu Bharadwaj <raghu@techveda.org>
> > Signed-off-by: Karthik Tummala <karthik@techveda.org>
>
> Can't the call to device_init_wakeup() in isp116x_start() just be moved
> below the spinlock release?
>
> > --- a/drivers/base/power/wakeup.c
> > +++ b/drivers/base/power/wakeup.c
> > @@ -92,11 +92,11 @@ struct wakeup_source *wakeup_source_create(const char *name)
> > {
> > struct wakeup_source *ws;
> >
> > - ws = kmalloc(sizeof(*ws), GFP_KERNEL);
> > + ws = kmalloc(sizeof(*ws), GFP_ATOMIC);
>
> With GFP_ATOMIC, allocation failure is much more likely to occur.
> So IMHO it's better to fix the isp116x, than to impose this burden on
> every user.
>
> > if (!ws)
> > return NULL;
> >
> > - wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_KERNEL) : NULL);
> > + wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_ATOMIC) : NULL);
> > return ws;
NAK. This will silently replace name with NULL if memory is low.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2017-12-15 8:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 13:45 [PATCH] drivers: base: power: Fix GFP_KERNEL in spinlock context shrikant.maurya
2017-12-12 14:58 ` Geert Uytterhoeven
2017-12-15 8:45 ` Pavel Machek [this message]
2017-12-16 8:15 ` shrikant
2017-12-16 8:14 ` shrikant
2017-12-12 16:55 ` Rafael J. Wysocki
2017-12-16 8:21 ` shrikant
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=20171215084515.GB8221@amd \
--to=pavel@ucw.cz \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=karthik@techveda.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=raghu@techveda.org \
--cc=rjw@rjwysocki.net \
--cc=shrikant.maurya@techveda.org \
--cc=sunil.m@techveda.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 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).