From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, linuxppc-dev@lists.ozlabs.org
Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>,
Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
Reza Arbab <arbab@linux.vnet.ibm.com>,
Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH 3/5] powerpc/perf: fix imc allocation failure handling
Date: Wed, 24 Jul 2019 15:28:02 +0530 [thread overview]
Message-ID: <87d0hzn49h.fsf@linux.ibm.com> (raw)
In-Reply-To: <20190724084638.24982-3-npiggin@gmail.com>
Nicholas Piggin <npiggin@gmail.com> writes:
> The alloc_pages_node return value should be tested for failure
> before being passed to page_address.
>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
This need Fixes: tag? It fix a real crash unlike the other patch in this
series?
> Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> Tested-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/perf/imc-pmu.c | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
> index dea243185ea4..cb50a9e1fd2d 100644
> --- a/arch/powerpc/perf/imc-pmu.c
> +++ b/arch/powerpc/perf/imc-pmu.c
> @@ -577,6 +577,7 @@ static int core_imc_mem_init(int cpu, int size)
> {
> int nid, rc = 0, core_id = (cpu / threads_per_core);
> struct imc_mem_info *mem_info;
> + struct page *page;
>
> /*
> * alloc_pages_node() will allocate memory for core in the
> @@ -587,11 +588,12 @@ static int core_imc_mem_init(int cpu, int size)
> mem_info->id = core_id;
>
> /* We need only vbase for core counters */
> - mem_info->vbase = page_address(alloc_pages_node(nid,
> - GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
> - __GFP_NOWARN, get_order(size)));
> - if (!mem_info->vbase)
> + page = alloc_pages_node(nid,
> + GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
> + __GFP_NOWARN, get_order(size));
> + if (!page)
> return -ENOMEM;
> + mem_info->vbase = page_address(page);
>
> /* Init the mutex */
> core_imc_refc[core_id].id = core_id;
> @@ -849,15 +851,17 @@ static int thread_imc_mem_alloc(int cpu_id, int size)
> int nid = cpu_to_node(cpu_id);
>
> if (!local_mem) {
> + struct page *page;
> /*
> * This case could happen only once at start, since we dont
> * free the memory in cpu offline path.
> */
> - local_mem = page_address(alloc_pages_node(nid,
> + page = alloc_pages_node(nid,
> GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
> - __GFP_NOWARN, get_order(size)));
> - if (!local_mem)
> + __GFP_NOWARN, get_order(size));
> + if (!page)
> return -ENOMEM;
> + local_mem = page_address(page);
>
> per_cpu(thread_imc_mem, cpu_id) = local_mem;
> }
> @@ -1095,11 +1099,14 @@ static int trace_imc_mem_alloc(int cpu_id, int size)
> int core_id = (cpu_id / threads_per_core);
>
> if (!local_mem) {
> - local_mem = page_address(alloc_pages_node(phys_id,
> - GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
> - __GFP_NOWARN, get_order(size)));
> - if (!local_mem)
> + struct page *page;
> +
> + page = alloc_pages_node(phys_id,
> + GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
> + __GFP_NOWARN, get_order(size));
> + if (!page)
> return -ENOMEM;
> + local_mem = page_address(page);
> per_cpu(trace_imc_mem, cpu_id) = local_mem;
>
> /* Initialise the counters for trace mode */
> --
> 2.22.0
next prev parent reply other threads:[~2019-07-24 10:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-24 8:46 [PATCH 1/5] powerpc/64s/radix: Fix memory hotplug section page table creation Nicholas Piggin
2019-07-24 8:46 ` [PATCH 2/5] powerpc/64s/radix: Fix memory hot-unplug page table split Nicholas Piggin
2019-07-24 9:55 ` Aneesh Kumar K.V
2019-07-24 8:46 ` [PATCH 3/5] powerpc/perf: fix imc allocation failure handling Nicholas Piggin
2019-07-24 9:58 ` Aneesh Kumar K.V [this message]
2019-07-24 8:46 ` [PATCH 4/5] powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses Nicholas Piggin
2019-07-24 9:59 ` Aneesh Kumar K.V
2019-07-29 11:57 ` Christophe Leroy
2021-12-24 13:24 ` Christophe Leroy
2021-12-25 10:10 ` Nicholas Piggin
2021-12-26 17:20 ` Christophe Leroy
2019-07-24 8:46 ` [PATCH 5/5] powerpc/64s/radix: Remove redundant pfn_pte bitop, add VM_BUG_ON Nicholas Piggin
2019-07-24 9:59 ` Aneesh Kumar K.V
2019-07-24 9:54 ` [PATCH 1/5] powerpc/64s/radix: Fix memory hotplug section page table creation Aneesh Kumar K.V
2019-08-22 13:08 ` Michael Ellerman
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=87d0hzn49h.fsf@linux.ibm.com \
--to=aneesh.kumar@linux.ibm.com \
--cc=anju@linux.vnet.ibm.com \
--cc=arbab@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.vnet.ibm.com \
--cc=npiggin@gmail.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;
as well as URLs for NNTP newsgroup(s).