From: Mark Rutland <mark.rutland@arm.com>
To: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Mike Rapoport <rppt@linux.ibm.com>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v14 02/12] powerpc/irq: use memblock functions returning virtual address
Date: Thu, 24 Jan 2019 16:51:53 +0000 [thread overview]
Message-ID: <20190124165153.GB5531@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <1c8e658c094022a15e4b9f5ef5c191caab3c0dff.1548346225.git.christophe.leroy@c-s.fr>
On Thu, Jan 24, 2019 at 04:19:33PM +0000, Christophe Leroy wrote:
> Since only the virtual address of allocated blocks is used,
> lets use functions returning directly virtual address.
>
> Those functions have the advantage of also zeroing the block.
>
> Suggested-by: Mike Rapoport <rppt@linux.ibm.com>
> Acked-by: Mike Rapoport <rppt@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
[...]
> +static void *__init alloc_stack(void)
> +{
> + void *ptr = memblock_alloc(THREAD_SIZE, THREAD_SIZE);
> +
> + if (!ptr)
> + panic("cannot allocate stacks");
> +
> + return ptr;
> +}
I believe memblock_alloc() will panic() if it cannot allocate memory,
since that goes:
memblock_alloc()
-> memblock_alloc_try_nid()
-> panic()
So you can get rid of the panic() here, or if you want a custom panic
message, you can use memblock_alloc_nopanic().
[...]
> static void *__init alloc_stack(unsigned long limit, int cpu)
> {
> - unsigned long pa;
> + void *ptr;
>
> BUILD_BUG_ON(STACK_INT_FRAME_SIZE % 16);
>
> - pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit,
> - early_cpu_to_node(cpu), MEMBLOCK_NONE);
> - if (!pa) {
> - pa = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
> - if (!pa)
> - panic("cannot allocate stacks");
> - }
> + ptr = memblock_alloc_try_nid(THREAD_SIZE, THREAD_SIZE,
> + MEMBLOCK_LOW_LIMIT, limit,
> + early_cpu_to_node(cpu));
> + if (!ptr)
> + panic("cannot allocate stacks");
The same applies here -- memblock_alloc_try_nid() will panic itself
rather than returning NULL.
Otherwise, this looks like a nice cleanup. With the panics removed (or
using the _nopanic() allocators), feel free to add:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Thanks,
Mark.
next prev parent reply other threads:[~2019-01-24 16:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 16:19 [PATCH v14 00/12] powerpc: Switch to CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 01/12] powerpc/32: Fix CONFIG_VIRT_CPU_ACCOUNTING_NATIVE for 40x/booke Christophe Leroy
2019-01-30 8:08 ` Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 02/12] powerpc/irq: use memblock functions returning virtual address Christophe Leroy
2019-01-24 16:51 ` Mark Rutland [this message]
2019-01-24 17:25 ` Mike Rapoport
2019-01-24 17:28 ` Mark Rutland
2019-01-24 16:19 ` [PATCH v14 03/12] book3s/64: avoid circular header inclusion in mmu-hash.h Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 04/12] powerpc: Only use task_struct 'cpu' field on SMP Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 05/12] powerpc: prep stack walkers for THREAD_INFO_IN_TASK Christophe Leroy
2019-01-24 17:04 ` Mark Rutland
2019-01-24 16:19 ` [PATCH v14 06/12] powerpc: Prepare for moving thread_info into task_struct Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 07/12] powerpc: Activate CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2019-01-24 17:18 ` Mark Rutland
2019-01-24 16:19 ` [PATCH v14 08/12] powerpc: regain entire stack space Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 09/12] powerpc: 'current_set' is now a table of task_struct pointers Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 10/12] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 11/12] powerpc/64: Remove CURRENT_THREAD_INFO Christophe Leroy
2019-01-24 16:19 ` [PATCH v14 12/12] powerpc: clean stack pointers naming Christophe Leroy
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=20190124165153.GB5531@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=benh@kernel.crashing.org \
--cc=christophe.leroy@c-s.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=rppt@linux.ibm.com \
/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
all inboxes | Powered by JetHome®