From: Andrew Donnellan <ajd@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
Daniel Axtens <dja@axtens.net>,
linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk
Cc: akash.goel@intel.com,
syzbot+1e925b4b836afe85a1c6@syzkaller-ppc64.appspotmail.com,
syzbot+587b2421926808309d21@syzkaller-ppc64.appspotmail.com,
syzbot+58320b7171734bf79d26@syzkaller.appspotmail.com,
syzbot+d6074fb08bdb2e010520@syzkaller.appspotmail.com
Subject: Re: [PATCH] relay: handle alloc_percpu returning NULL in relay_open
Date: Fri, 29 Nov 2019 23:42:33 +1100 [thread overview]
Message-ID: <4415adee-5c12-3d65-d44a-34ee4eb00fed@linux.ibm.com> (raw)
In-Reply-To: <87d0dbffbk.fsf@mpe.ellerman.id.au>
On 29/11/19 3:59 pm, Michael Ellerman wrote:
>> diff --git a/kernel/relay.c b/kernel/relay.c
>> index ade14fb7ce2e..a376cc6b54ec 100644
>> --- a/kernel/relay.c
>> +++ b/kernel/relay.c
>> @@ -580,7 +580,13 @@ struct rchan *relay_open(const char *base_filename,
>> if (!chan)
>> return NULL;
>>
>> - chan->buf = alloc_percpu(struct rchan_buf *);
>> + chan->buf = alloc_percpu_gfp(struct rchan_buf *,
>> + GFP_KERNEL | __GFP_NOWARN);
>> + if (!chan->buf) {
>> + kfree(chan);
>> + return NULL;
>> + }
>> +
>> chan->version = RELAYFS_CHANNEL_VERSION;
>> chan->n_subbufs = n_subbufs;
>> chan->subbuf_size = subbuf_size;
>
> This looks right to me. The kfree + direct return is correct, there's
> nothing else that needs tear down in this function.
>
> I think I'm 50/50 on the __GFP_NOWARN. We're only asking for 8 bytes per
> cpu, and if that fails the system is pretty sick, so a warning could be
> helpful. There's also logic in the percpu allocator to limit the number
> of warnings printed. But see what others think.
mpe was wondering why we didn't see a message printed from the percpu
allocator - the answer appears to be that we hit this case when the
process is killed while the percpu allocator is waiting for
pcpu_alloc_mutex, in which case it bails out without printing a warning.
It looks to me like that case doesn't warrant a warning message, while a
failing allocation for other reasons should probably get a warning.
But whatever, otherwise this patch looks good to me. I've told our
powerpc syzbot to test it.
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
next prev parent reply other threads:[~2019-11-29 12:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-29 1:37 [PATCH] relay: handle alloc_percpu returning NULL in relay_open Daniel Axtens
2019-11-29 4:59 ` Michael Ellerman
2019-11-29 12:42 ` Andrew Donnellan [this message]
2019-11-30 6:04 ` Daniel Axtens
2019-12-23 16:36 ` Guenter Roeck
2019-12-24 0:26 ` Daniel Axtens
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=4415adee-5c12-3d65-d44a-34ee4eb00fed@linux.ibm.com \
--to=ajd@linux.ibm.com \
--cc=akash.goel@intel.com \
--cc=dja@axtens.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mpe@ellerman.id.au \
--cc=syzbot+1e925b4b836afe85a1c6@syzkaller-ppc64.appspotmail.com \
--cc=syzbot+58320b7171734bf79d26@syzkaller.appspotmail.com \
--cc=syzbot+587b2421926808309d21@syzkaller-ppc64.appspotmail.com \
--cc=syzbot+d6074fb08bdb2e010520@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/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