Re: [PATCH] drivers/base: export gpl (un)register_memory_notifier

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dave Hansen
Date: Wednesday, February 13, 2008 - 10:05 am

On Wed, 2008-02-13 at 16:17 +0100, Jan-Bernd Themann wrote:

Are there enough to have one per 16MB section?


You're wrong ;).  In mainline, this is true.  There was a version of the
SUSE kernel that did otherwise.  But you can not and should not depend
on this never changing.  But, someone is perfectly free to go out an
implement something better than sparsemem for memory hotplug.  If they
go and do this, your driver may get left behind. 


True, and true. (There might be exceptions to the whole sections one,
but that's blatant abuse and should be fixed. :)


You can export and use (un)register_memory_notifier.  You just need to
do it in a reasonable way that compiles for randconfig on your
architecture.  Believe me, we don't want to start teaching drivers about
sparsemem.  


Look at kernel/resource.c

But, I'm really not convinced that you can actually keep this map
yourselves.  It's not as simple as you think.  What happens if you get
on an LPAR with two sections, one 256MB@0x0 and another
16MB@0x1000000000000000.  That's quite possible.  I think your vmalloc'd
array will eat all of memory.  

That's why we have SPARSEMEM_EXTREME and SPARSEMEM_VMEMMAP implemented
in the core, so that we can deal with these kinds of problems, once and
*NOT* in every single little driver out there.  


Basically, you can't use anything related to sections outside of the
core code.  You can use things like pfn_valid(), or you can create new
interfaces that are properly abstracted.  


It isn't the act of exporting that's the problem.  It's making sure that
the exports won't be prone to abuse and that people are using them
properly.  You should assume that you can export and use
walk_memory_resource().

Do you know what other operating systems do with this hardware?

In the future, please make an effort to get review from knowledgeable
people about these kinds of things before using them in your driver.
Your company has many, many resources available, and all you need to do
is ask.  All that you have to do is look to the tops of the files of the
functions you are calling.

-- Dave

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] drivers/base: export gpl (un)register_memory_notifier, Jan-Bernd Themann, (Mon Feb 11, 9:24 am)
Re: [PATCH] drivers/base: export gpl (un)register_memory_n ..., Jan-Bernd Themann, (Wed Feb 13, 8:17 am)
Re: [PATCH] drivers/base: export gpl (un)register_memory_n ..., Dave Hansen, (Wed Feb 13, 10:05 am)
Re: [PATCH] drivers/base: export gpl (un)register_memory_n ..., Badari Pulavarty, (Thu Feb 14, 10:36 am)
Re: [PATCH] drivers/base: export gpl (un)register_memory_n ..., Jan-Bernd Themann, (Mon Feb 18, 3:00 am)