All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	yinghai@kernel.org, tglx@linutronix.de, hpa@zytor.com,
	penberg@cs.helsinki.fi, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: introduce bootmem_state -v2
Date: Fri, 06 Mar 2009 14:06:31 -0800	[thread overview]
Message-ID: <49B19E67.9050003@goop.org> (raw)
In-Reply-To: <20090306193611.GA4278@elte.hu>

Ingo Molnar wrote:
> * Andrew Morton <akpm@linux-foundation.org> wrote:
>
>   
>> On Fri, 6 Mar 2009 20:12:49 +0100
>> Ingo Molnar <mingo@elte.hu> wrote:
>>
>>     
>>> * Yinghai Lu <yinghai@kernel.org> wrote:
>>>
>>>       
>>>> Impact: cleanup
>>>>
>>>> extend after_bootmem and after_init_bootmem to bootmem_state
>>>> and will have BEFORE_BOOTMEM, DURING_BOOTMEM, AFTER_BOOTMEM
>>>>
>>>> v2: style changes according to ingo
>>>>
>>>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>>>>
>>>> ---
>>>>  arch/x86/kernel/setup.c |    1 +
>>>>  arch/x86/mm/init.c      |   13 +++++++------
>>>>  arch/x86/mm/init_32.c   |   28 ++++++++++++++++++++--------
>>>>  arch/x86/mm/init_64.c   |   33 +++++++++++++++++++--------------
>>>>  include/linux/mm.h      |    9 +++++++++
>>>>  5 files changed, 56 insertions(+), 28 deletions(-)
>>>>         
>>>> Index: linux-2.6/include/linux/mm.h
>>>> ===================================================================
>>>> --- linux-2.6.orig/include/linux/mm.h
>>>> +++ linux-2.6/include/linux/mm.h
>>>> @@ -1067,6 +1067,15 @@ extern void __init mmap_init(void);
>>>>  extern void show_mem(void);
>>>>  extern void si_meminfo(struct sysinfo * val);
>>>>  extern void si_meminfo_node(struct sysinfo *val, int nid);
>>>> +
>>>> +enum bootmem_state {
>>>> +	BEFORE_BOOTMEM,
>>>> +	DURING_BOOTMEM,
>>>> +	AFTER_BOOTMEM
>>>> +};
>>>> +
>>>> +extern enum bootmem_state bootmem_state;
>>>> +
>>>>  extern int after_bootmem;
>>>>         
>>> Btw., the after_bootmem variable itself should either move to 
>>> x86 (and arch/sh), or should be defined in mm/bootmem.c.
>>>
>>> Right now we have this weird mm.h construct that is not actually 
>>> useful to generic code.
>>>
>>> Andrew, what would be your preference?
>>>
>>>       
>> If two architectures are using it then it should be provided 
>> by core kernel?
>>
>> This is obvious if the state transitions are occurring in 
>> core-kernel code, but if the transitions are happening in arch 
>> code then making it a core concept assumes consistency between 
>> different architectures which might not exist.
>>
>> IOW: dunno.
>>     
>
> Core kernel could provide a wrapper allocator which calls the 
> right method depending on which state we are in. It will call 
> bootmem_alloc() if called early, and kmalloc() if called later. 
> Or something like that. Would there be any utility in that?
>   

Yes, so long as you're never intending to free the memory (since you 
won't know which free function to use for a given pointer - assuming one 
even exists).  And code which does:

    p = use_anytime_alloctor();

...
    kfree(p);        /* I know it was really allocated by kmalloc */


should be shot.

    J

  reply	other threads:[~2009-03-06 22:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-05 12:54 [PATCH 07/17] x86: rename after_init_bootmem to after_bootmem in mm/init_32.c Pekka Enberg
2009-03-05 13:37 ` [tip:x86/mm] " Pekka Enberg
2009-03-05 19:14 ` [PATCH 07/17] " Yinghai Lu
     [not found]   ` <49B02C68.1030203@cs.helsinki.fi>
2009-03-05 23:45     ` [PATCH] x86: introduce bootmem_state Yinghai Lu
2009-03-06  6:14       ` H. Peter Anvin
2009-03-06  6:38         ` Yinghai Lu
2009-03-06 22:12         ` Jeremy Fitzhardinge
2009-03-06 23:34           ` H. Peter Anvin
2009-03-07  0:01             ` Andrew Morton
2009-03-07  0:10             ` Jeremy Fitzhardinge
2009-03-07  0:11               ` H. Peter Anvin
2009-03-06 14:59       ` Ingo Molnar
2009-03-06 18:20         ` Yinghai Lu
2009-03-06 18:38         ` [PATCH] x86: introduce bootmem_state -v2 Yinghai Lu
2009-03-06 19:12           ` Ingo Molnar
2009-03-06 19:30             ` Andrew Morton
2009-03-06 19:36               ` Ingo Molnar
2009-03-06 22:06                 ` Jeremy Fitzhardinge [this message]
2009-03-06 19:50             ` Yinghai Lu
2009-03-06 20:15               ` Ingo Molnar
2009-03-06 20:40                 ` Yinghai Lu
2009-03-06 21:35                   ` Ingo Molnar
2009-03-07  0:49                     ` [PATCH] x86: introduce bootmem_state -v3 Yinghai Lu
2009-03-08 18:54                       ` [tip:kmemcheck] x86: introduce bootmem_state Yinghai Lu
2009-03-08 18:58                         ` Ingo Molnar
2009-03-08 19:30                           ` Yinghai Lu
2009-03-08 20:32                             ` Ingo Molnar

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=49B19E67.9050003@goop.org \
    --to=jeremy@goop.org \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=tglx@linutronix.de \
    --cc=yinghai@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.