Re: kmalloc before kmem_cache_init

2012-01-28 Thread Sukanto Ghosh
Hi Dave,

If you look into start_kernel() the call to parse_early_param()
precedes mm_init().
parse_early_param() eventually calls do_early_param().
do_early_param() parses for "earlycon" in kernel commandline and then calls the
setup_function associated with earlycon.

I have in my commandline: earlycon=uart8250,mmio32,0x1000,9600

Call flow starting from drivers/tty/serial/8250_early.c will lead to kmalloc

early_param("early_con", setup_early_serial8250_console)
   setup_early_serial8250_console()
   early_serial8250_setup()
   parse_options()
   ioremap_nocache()
  ... arch-specific-ioremap
-- some form of arch specific __ioremap_caller
--- get_vm_area_caller()
  __get_vm_area_node
   kzalloc_node
   kmalloc_node
kmalloc


Regards,
Sukanto


On Jan 29, 2012 12:28 PM, "Dave Hylands"  wrote:
>
> Hi Sukanto
>
> On Sat, Jan 28, 2012 at 10:02 PM, Sukanto Ghosh
>  wrote:
> > I am kind of lost trying to figure out how can kmallocs work if they
> > are called before kmem_cache_init
> >
> > (e.g. such a case occurs when in start_kernel() we call
> > parse_early_param() (which in turn might call
> > early_serial8250_setup() if earlycon= is used in kernel command-line)
> > before mm_init()  (which later calls
> > kmem_cache_init() )
>
> I don't think that you're allowed to call kmalloc during early_setup.
> I don't see where early_serial8250_setup calls kmalloc.
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kmalloc before kmem_cache_init

2012-01-28 Thread Dave Hylands
Hi Sukanto

On Sat, Jan 28, 2012 at 10:02 PM, Sukanto Ghosh
 wrote:
> I am kind of lost trying to figure out how can kmallocs work if they
> are called before kmem_cache_init
>
> (e.g. such a case occurs when in start_kernel() we call
> parse_early_param() (which in turn might call
> early_serial8250_setup() if earlycon= is used in kernel command-line)
> before mm_init()  (which later calls
> kmem_cache_init() )

I don't think that you're allowed to call kmalloc during early_setup.
I don't see where early_serial8250_setup calls kmalloc.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


kmalloc before kmem_cache_init

2012-01-28 Thread Sukanto Ghosh
I am kind of lost trying to figure out how can kmallocs work if they
are called before kmem_cache_init

(e.g. such a case occurs when in start_kernel() we call
parse_early_param() (which in turn might call
early_serial8250_setup() if earlycon= is used in kernel command-line)
before mm_init()  (which later calls
kmem_cache_init() )

>From what I understood, kmalloc() (SLUB implementation) first tries to
find out the slab fit for the size
being kmalloced and slabs are nothing but kmalloc_caches[]. Now these
kmalloc_caches get initialized in
kmem_cache_init().

What am I missing here ?

Regards,
Sukanto Ghosh


-- 
Regards,
Sukanto Ghosh

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Tool for automatic style of coding guidelines

2012-01-28 Thread Adil Mujeeb
On Fri, Jan 27, 2012 at 11:45 PM, Greg KH  wrote:
> On Fri, Jan 27, 2012 at 05:50:30PM +0530, Prajosh Premdas wrote:
>> Hi
>>
>> I have developed some kernel drivers and would like to send the patches for
>> review. But i find that I have not followed the coding guideline for tabs and
>> spaces properly, which can be easily corrected by using some tools like
>> astyle.
>>
>> Can any body please help me with the proper commands string for the astyle
>> tool? Or could any body please suggest me with any new tool like indent etc
>> which you are using
>
> scripts/Lindent will give you a good start, but odds are you really want
> to do this by hand, it will be easier in the end as indent can do some
> strange things at times.
>
> good luck,
>
> greg k-h

You can see this excellent video [1] where Greg has explained how to
submit your first patch.

[1] http://www.youtube.com/watch?v=LLBrBBImJt4

Regards,
Adil

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Tool for automatic style of coding guidelines

2012-01-28 Thread Bernd Petrovitsch
On Fre, 2012-01-27 at 13:55 -0500, Greg Freemyer wrote:
[...]
> BUT, can checkpatch actually modify the files?  I think I've only used
> it to identify issues, not resolve them.

Yup, and one wants actually no automatic repair in general because the
main goal of (the) coding style guide(s) is to keep a common "layout" so
that the code is easily readable and understandable and *not* to follow
some hard-coded rules.
Yes, for "spaces to tabs" one can do that (and actually emacsens can do
it with "indent-region" etc. without much hassle and it shouldn't be
that hard with global-find-and-replace in any decent editor).

So it's OK to "break" rules if the source gets obscured by following it.
The prime example is probably the line length where it doesn't get
better in any way (au contraire IMHO - it gets much worse) if
printk("this is a very long format string and it is here for good 
reason");
is split on 2 lines.

And
if (some_condition)
x = 1;
else {
x = 4711;
y = 45;
}
also hurts my eyes.

Bernd
-- 
Bernd Petrovitsch  Email : be...@petrovitsch.priv.at
 LUGA : http://www.luga.at


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Recursive Makefile howto

2012-01-28 Thread Bernd Petrovitsch
On Fre, 2012-01-27 at 10:02 +0100, Kristof Provost wrote:
[...]
> Try something like this instead:
> 
> build:
> for d in $(DIRS) ; \
> do \
> $(MAKE) -C $$d $@ || exit $? ; \
> done

Or 

build:
set -e; for d in $(DIRS); \
do \
$(MAKE) -C $$d $@; \
done

Read bash' manual page for what "set -e" does.

Bernd
-- 
Bernd Petrovitsch  Email : be...@petrovitsch.priv.at
 LUGA : http://www.luga.at


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Recursive Makefile howto

2012-01-28 Thread Manavendra Nath Manav
On Fri, Jan 27, 2012 at 9:28 PM, Dave Hylands  wrote:
> Hi Manavendra,
>
> On Thu, Jan 26, 2012 at 10:13 PM, Manavendra Nath Manav
>  wrote:
>> Hi All,
>>
>> I have developed a Makefile which recursively builds the code spread
>> across multiple directories, each having it's own Makefile.
>
> You may want to reconsider your approach:
> http://aegis.sourceforge.net/auug97.pdf
> http://evbergen.home.xs4all.nl/nonrecursive-make.html
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com

Thanks Dave, I went through both the links provided by you and the
make process is pretty much clear to me now. The following two points
I would want elaborate from the paper:
1. As a rule of thumb: always use immediate evaluation assignment
unless you knowingly want deferred evaluation.
2. You will get more accurate builds of your project if you use
whole-project make rather than recursive make.

-- 
Manavendra Nath Manav

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies