From: Michael Ellerman <michael@ellerman.id.au>
To: Manish Ahuja <ahuja@austin.ibm.com>
Cc: mahuja@us.ibm.com, linuxppc-dev@ozlabs.org,
linasvepstas@gmail.com, paulus@samba.org
Subject: Re: [PATCH 2/8] pseries: phyp dump: reserve-release proof-of-concept
Date: Tue, 11 Mar 2008 12:02:21 +1100 [thread overview]
Message-ID: <1205197341.8656.5.camel@concordia.ozlabs.ibm.com> (raw)
In-Reply-To: <47C750CE.7050202@austin.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 6762 bytes --]
On Thu, 2008-02-28 at 18:24 -0600, Manish Ahuja wrote:
> Initial patch for reserving memory in early boot, and freeing it later.
> If the previous boot had ended with a crash, the reserved memory would contain
> a copy of the crashed kernel data.
>
> Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
> Signed-off-by: Linas Vepstas <linasvepstas@gmail.com>
Hi Manish,
A few comments inline ..
> Index: 2.6.25-rc1/arch/powerpc/platforms/pseries/phyp_dump.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ 2.6.25-rc1/arch/powerpc/platforms/pseries/phyp_dump.c 2008-02-28 21:57:52.000000000 -0600
> @@ -0,0 +1,105 @@
> +/*
> + * Hypervisor-assisted dump
> + *
> + * Linas Vepstas, Manish Ahuja 2008
> + * Copyright 2008 IBM Corp.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + *
> + */
> +
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/pfn.h>
> +#include <linux/swap.h>
> +
> +#include <asm/page.h>
> +#include <asm/phyp_dump.h>
> +#include <asm/machdep.h>
> +#include <asm/prom.h>
> +
> +/* Global, used to communicate data between early boot and late boot */
> +static struct phyp_dump phyp_dump_global;
> +struct phyp_dump *phyp_dump_info = &phyp_dump_global;
I don't see the point of this. You have a static (ie. non-global) struct
called phyp_dump_global, then you create a pointer to it and pass that
around. It could just be:
phyp_dump.h:
extern struct phyp_dump phyp_dump_info;
phyp_dump.c:
struct phyp_dump phyp_dump_info;
phyp_dump_info.foo = bar;
I also think the struct should be called phyp_dump_info, not phyp_dump -
it contains info about phyp_dump, not the dump itself.
> +
> +/**
> + * release_memory_range -- release memory previously lmb_reserved
> + * @start_pfn: starting physical frame number
> + * @nr_pages: number of pages to free.
> + *
> + * This routine will release memory that had been previously
> + * lmb_reserved in early boot. The released memory becomes
> + * available for genreal use.
> + */
> +static void
> +release_memory_range(unsigned long start_pfn, unsigned long nr_pages)
> +{
> + struct page *rpage;
> + unsigned long end_pfn;
> + long i;
> +
> + end_pfn = start_pfn + nr_pages;
> +
> + for (i = start_pfn; i <= end_pfn; i++) {
> + rpage = pfn_to_page(i);
> + if (PageReserved(rpage)) {
> + ClearPageReserved(rpage);
> + init_page_count(rpage);
> + __free_page(rpage);
> + totalram_pages++;
> + }
> + }
> +}
> +
> +static int __init phyp_dump_setup(void)
> +{
> + unsigned long start_pfn, nr_pages;
> +
> + /* If no memory was reserved in early boot, there is nothing to do */
> + if (phyp_dump_info->init_reserve_size == 0)
> + return 0;
> +
> + /* Release memory that was reserved in early boot */
> + start_pfn = PFN_DOWN(phyp_dump_info->init_reserve_start);
> + nr_pages = PFN_DOWN(phyp_dump_info->init_reserve_size);
> + release_memory_range(start_pfn, nr_pages);
> +
> + return 0;
> +}
> +machine_subsys_initcall(pseries, phyp_dump_setup);
> +
> +int __init early_init_dt_scan_phyp_dump(unsigned long node,
> + const char *uname, int depth, void *data)
> +{
> +#ifdef CONFIG_PHYP_DUMP
> + const unsigned int *sizes;
> +
> + phyp_dump_info->phyp_dump_configured = 0;
> + phyp_dump_info->phyp_dump_is_active = 0;
> +
> + if (depth != 1 || strcmp(uname, "rtas") != 0)
> + return 0;
> +
> + if (of_get_flat_dt_prop(node, "ibm,configure-kernel-dump", NULL))
> + phyp_dump_info->phyp_dump_configured++;
> +
> + if (of_get_flat_dt_prop(node, "ibm,dump-kernel", NULL))
> + phyp_dump_info->phyp_dump_is_active++;
> +
> + sizes = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump-sizes",
> + NULL);
> + if (!sizes)
> + return 0;
> +
> + if (sizes[0] == 1)
> + phyp_dump_info->cpu_state_size = *((unsigned long *)&sizes[1]);
> +
> + if (sizes[3] == 2)
> + phyp_dump_info->hpte_region_size =
> + *((unsigned long *)&sizes[4]);
> +#endif
This doesn't need to be inside #ifdef, you have a dummy version already
defined in the header file.
> Index: 2.6.25-rc1/arch/powerpc/kernel/prom.c
> ===================================================================
> --- 2.6.25-rc1.orig/arch/powerpc/kernel/prom.c 2008-02-28 21:54:57.000000000 -0600
> +++ 2.6.25-rc1/arch/powerpc/kernel/prom.c 2008-02-28 21:55:27.000000000 -0600
> @@ -1039,6 +1040,51 @@ static void __init early_reserve_mem(voi
> #endif
> }
>
> +#ifdef CONFIG_PHYP_DUMP
> +/**
> + * reserve_crashed_mem() - reserve all not-yet-dumped mmemory
> + *
> + * This routine may reserve memory regions in the kernel only
> + * if the system is supported and a dump was taken in last
> + * boot instance or if the hardware is supported and the
> + * scratch area needs to be setup. In other instances it returns
> + * without reserving anything. The memory in case of dump being
> + * active is freed when the dump is collected (by userland tools).
> + */
> +static void __init reserve_crashed_mem(void)
This could do with a name change IMO, eg. phyp_dump_reserve_mem() or
something.
> +{
> + unsigned long base, size;
> + if (!phyp_dump_info->phyp_dump_configured) {
> + printk(KERN_ERR "Phyp-dump not supported on this hardware\n");
> + return;
> + }
> +
> + if (phyp_dump_info->phyp_dump_is_active) {
> + /* Reserve *everything* above RMR.Area freed by userland tools*/
> + base = PHYP_DUMP_RMR_END;
> + size = lmb_end_of_DRAM() - base;
> +
> + /* XXX crashed_ram_end is wrong, since it may be beyond
> + * the memory_limit, it will need to be adjusted. */
> + lmb_reserve(base, size);
> +
> + phyp_dump_info->init_reserve_start = base;
> + phyp_dump_info->init_reserve_size = size;
> + } else {
> + size = phyp_dump_info->cpu_state_size +
> + phyp_dump_info->hpte_region_size +
> + PHYP_DUMP_RMR_END;
> + base = lmb_end_of_DRAM() - size;
> + lmb_reserve(base, size);
> + phyp_dump_info->init_reserve_start = base;
> + phyp_dump_info->init_reserve_size = size;
> + }
> +}
> +#else
> +static inline void __init reserve_crashed_mem(void) {}
> +#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2008-03-11 1:02 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-18 4:53 [PATCH 0/8] pseries: phyp dump: hypervisor-assisted dump Manish Ahuja
2008-02-18 5:34 ` [PATCH 1/8] pseries: phyp dump: Documentation Manish Ahuja
2008-02-18 5:36 ` [PATCH 2/8] pseries: phyp dump: reserve-release proof-of-concept Manish Ahuja
2008-02-18 5:38 ` [PATCH 3/8] pseries: phyp dump: use sysfs to release reserved mem Manish Ahuja
2008-02-18 5:40 ` [PATCH 4/8] pseries: phyp dump: register dump area Manish Ahuja
2008-02-18 5:41 ` [PATCH 5/8] pseries: phyp dump: debugging print routines Manish Ahuja
2008-02-18 5:42 ` [PATCH 6/8] pseries: phyp dump: Invalidate and print dump areas Manish Ahuja
2008-02-18 5:44 ` [PATCH 7/8] pseries: phyp dump: Tracking memory range freed Manish Ahuja
2008-02-18 5:45 ` [PATCH 8/8] pseries: phyp dump: config file Manish Ahuja
2008-02-22 0:53 ` [PATCH 0/8] pseries: phyp dump: hypervisor-assisted dump Michael Ellerman
2008-02-28 23:57 ` Manish Ahuja
2008-02-29 0:22 ` [PATCH 1/8] pseries: phyp dump: Docmentation Manish Ahuja
2008-02-29 0:24 ` [PATCH 2/8] pseries: phyp dump: reserve-release proof-of-concept Manish Ahuja
2008-03-11 1:02 ` Michael Ellerman [this message]
2008-03-12 17:52 ` Linas Vepstas
2008-03-13 4:29 ` Manish Ahuja
2008-03-14 4:20 ` Michael Ellerman
2008-03-14 5:19 ` Paul Mackerras
2008-03-11 6:12 ` Paul Mackerras
2008-03-12 0:13 ` Michael Ellerman
2008-03-12 0:53 ` Michael Ellerman
2008-02-29 0:27 ` [PATCH 3/8] pseries: phyp dump: use sysfs to release reserved mem Manish Ahuja
2008-03-11 6:16 ` Paul Mackerras
2008-03-11 16:44 ` Dale Farnsworth
2008-03-12 17:38 ` Linas Vepstas
2008-02-29 0:29 ` [PATCH 4/8] pseries: phyp dump: register dump area Manish Ahuja
2008-03-11 6:17 ` Paul Mackerras
2008-02-29 0:31 ` [PATCH 5/8] pseries: phyp dump: debugging print routines Manish Ahuja
2008-02-29 0:32 ` [PATCH 6/8] pseries: phyp dump: Invalidate and print dump areas Manish Ahuja
2008-03-11 6:19 ` Paul Mackerras
2008-02-29 0:33 ` [PATCH 7/8] pseries: phyp dump: Tracking memory range freed Manish Ahuja
2008-02-29 0:35 ` [PATCH 8/8] pseries: phyp dump: config file Manish Ahuja
2008-03-11 6:21 ` Paul Mackerras
2008-03-12 16:36 ` Manish Ahuja
2008-02-29 2:20 ` [PATCH 0/8] pseries: phyp dump: hypervisor-assisted dump Michael Ellerman
2008-03-03 23:37 ` Joel Schopp
-- strict thread matches above, loose matches on Subject: below --
2008-01-22 19:12 Manish Ahuja
2008-01-22 19:29 ` [PATCH 2/8] pseries: phyp dump: reserve-release proof-of-concept Manish Ahuja
2008-01-22 21:00 ` Manish Ahuja
2008-02-07 0:42 ` Paul Mackerras
2008-02-11 18:29 ` Manish Ahuja
2008-01-22 20:09 ` Manish Ahuja
2008-01-07 23:45 [PATCH 0/8] pseries: phyp dump: hypervisor-assisted dump Manish Ahuja
2008-02-12 6:31 ` Manish Ahuja
2008-02-12 7:08 ` [PATCH 2/8] pseries: phyp dump: reserve-release proof-of-concept Manish Ahuja
2008-02-12 8:48 ` Michael Ellerman
2008-02-12 16:38 ` Manish Ahuja
2008-02-14 3:46 ` Tony Breeds
2008-02-14 23:12 ` Olof Johansson
2008-02-15 7:16 ` Manish Ahuja
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=1205197341.8656.5.camel@concordia.ozlabs.ibm.com \
--to=michael@ellerman.id.au \
--cc=ahuja@austin.ibm.com \
--cc=linasvepstas@gmail.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mahuja@us.ibm.com \
--cc=paulus@samba.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).