linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* using kmalloc
@ 2002-03-19 16:18 chiranjeevi vaka
  2002-03-19 16:41 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 8+ messages in thread
From: chiranjeevi vaka @ 2002-03-19 16:18 UTC (permalink / raw)
  To: linux-kernel

Hi,

I am getting some problems with kmalloc. If I tried to
allocate more than certain memory then the system is
hanging while booting with the changed kernel. Can you
suggest me how to come out this situation. Can't I
allocate as much I want when I want to allocate in the
kernel. 


Thank you,
Chiranjeevi

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
  2002-03-19 16:18 using kmalloc chiranjeevi vaka
@ 2002-03-19 16:41 ` Arnaldo Carvalho de Melo
  2002-03-19 17:30   ` yodaiken
  0 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2002-03-19 16:41 UTC (permalink / raw)
  To: chiranjeevi vaka; +Cc: linux-kernel

Em Tue, Mar 19, 2002 at 08:18:31AM -0800, chiranjeevi vaka escreveu:

> I am getting some problems with kmalloc. If I tried to allocate more than
> certain memory then the system is hanging while booting with the changed
> kernel. Can you suggest me how to come out this situation. Can't I allocate
> as much I want when I want to allocate in the kernel. 

try vmalloc, kmalloc is limited, AFAIK, to 128 KiB and even that is difficult
to get after some time.

- Arnaldo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
  2002-03-19 16:41 ` Arnaldo Carvalho de Melo
@ 2002-03-19 17:30   ` yodaiken
  0 siblings, 0 replies; 8+ messages in thread
From: yodaiken @ 2002-03-19 17:30 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, chiranjeevi vaka, linux-kernel

On Tue, Mar 19, 2002 at 01:41:36PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Mar 19, 2002 at 08:18:31AM -0800, chiranjeevi vaka escreveu:
> 
> > I am getting some problems with kmalloc. If I tried to allocate more than
> > certain memory then the system is hanging while booting with the changed
> > kernel. Can you suggest me how to come out this situation. Can't I allocate
> > as much I want when I want to allocate in the kernel. 
> 
> try vmalloc, kmalloc is limited, AFAIK, to 128 KiB and even that is difficult
> to get after some time.

Apparently, kmalloc semantics changed at some point
so it does not ever return error.


-- 
---------------------------------------------------------
Victor Yodaiken 
Finite State Machine Labs: The RTLinux Company.
 www.fsmlabs.com  www.rtlinux.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
  2002-03-20  5:53 ` Dan Maas
  2002-03-20 10:27   ` Alan Cox
@ 2002-03-20 11:48   ` Jan Hudec
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Hudec @ 2002-03-20 11:48 UTC (permalink / raw)
  To: linux-kernel

> kmalloc() allocates physically-contiguous pages of memory. Due to
> fragmentation, more than 64KB-128KB of contiguous pages might not be
> available, and hence kmalloc() will fail.

kmalloc allocates from generic slab caches. They come in sizes of powers
of 2 from 32B to 128KiB. The largest has slabs 128KiB large (on i386 at least).
Pages are allocated via __get_free_pages, so they have to be continuous.

However if you allocate namy instances of some structure, it's best to create
a kmem cache and allocate via kmem_cache_alloc (since it does not round the
requested size up to a power of two).

--------------------------------------------------------------------------------
                  				- Jan Hudec `Bulb' <bulb@ucw.cz>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
  2002-03-20  5:53 ` Dan Maas
@ 2002-03-20 10:27   ` Alan Cox
  2002-03-20 11:48   ` Jan Hudec
  1 sibling, 0 replies; 8+ messages in thread
From: Alan Cox @ 2002-03-20 10:27 UTC (permalink / raw)
  To: Dan Maas; +Cc: chiranjeevi vaka, linux-kernel

> To allocate more memory, use vmalloc(), which allocates and maps physically
> disjoint pages into a virtually-contiguous region. Be careful when doing DMA
> to a vmalloc() area, since it is not physically contiguous and exists only
> in the kernel's virtual memory map... Also I believe vmalloc()ed memory is
> only accessible from (the context of) the process in which it was allocated
> (?).

vmalloc memory is accessible everywhere. You can't allocate it during 
interrupts or tasklets, and you will get deadlocks if you allocate it in the
write out path of a file system/disk driver.

Alan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
       [not found] <fa.l19uvvv.1hjmo8t@ifi.uio.no>
@ 2002-03-20  5:53 ` Dan Maas
  2002-03-20 10:27   ` Alan Cox
  2002-03-20 11:48   ` Jan Hudec
  0 siblings, 2 replies; 8+ messages in thread
From: Dan Maas @ 2002-03-20  5:53 UTC (permalink / raw)
  To: chiranjeevi vaka; +Cc: linux-kernel

> I am getting some problems with kmalloc. If I tried to
> allocate more than certain memory then the system is
> hanging while booting with the changed kernel. Can you
> suggest me how to come out this situation. Can't I
> allocate as much I want when I want to allocate in the
> kernel.

kmalloc() allocates physically-contiguous pages of memory. Due to
fragmentation, more than 64KB-128KB of contiguous pages might not be
available, and hence kmalloc() will fail.

To allocate more memory, use vmalloc(), which allocates and maps physically
disjoint pages into a virtually-contiguous region. Be careful when doing DMA
to a vmalloc() area, since it is not physically contiguous and exists only
in the kernel's virtual memory map... Also I believe vmalloc()ed memory is
only accessible from (the context of) the process in which it was allocated
(?).

Regards,
Dan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
  2002-03-19 19:26 ` chiranjeevi vaka
@ 2002-03-19 19:38   ` Tommy Reynolds
  0 siblings, 0 replies; 8+ messages in thread
From: Tommy Reynolds @ 2002-03-19 19:38 UTC (permalink / raw)
  To: chiranjeevi vaka; +Cc: washer, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

Uttered "chiranjeevi vaka" <cvaka_kernel@yahoo.com>, spoke thus:

>  I am trying to get something around 600 to 1000 bytes
>  using kmalloc. This one is for some changes in TCP/IP
>  stack. I am trying to implement a new kernel data
>  structure in tcp layer. So can you suggest me what
>  functionality to use to come out of that hanging.

Be sure to use "kmalloc( 1000, GFP_ATOMIC )" if you don't want to block waiting
for the memory.  Check for a NULL result, because you might not be able to get
the memory.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: using kmalloc
       [not found] <OFD9F443C5.CB1A619A-ON88256B81.005F0AD1@boulder.ibm.com>
@ 2002-03-19 19:26 ` chiranjeevi vaka
  2002-03-19 19:38   ` Tommy Reynolds
  0 siblings, 1 reply; 8+ messages in thread
From: chiranjeevi vaka @ 2002-03-19 19:26 UTC (permalink / raw)
  To: James Washer; +Cc: linux-kernel

Hi jim,
I am trying to get something around 600 to 1000 bytes
using kmalloc. This one is for some changes in TCP/IP
stack. I am trying to implement a new kernel data
structure in tcp layer. So can you suggest me what
functionality to use to come out of that hanging.


thanks. 
--- James Washer <washer@us.ibm.com> wrote:
> 
> How much memory are you trying to get?  Also.. is
> this for a module, or a
> builtin function/driver/whatever?
>  - jim
> 
> chiranjeevi vaka
> <cvaka_kernel@yahoo.com>@vger.kernel.org on
> 03/19/2002
> 08:18:31 AM
> 
> Sent by:    linux-kernel-owner@vger.kernel.org
> 
> 
> To:    linux-kernel@vger.kernel.org
> cc:
> Subject:    using kmalloc
> 
> 
> 
> Hi,
> 
> I am getting some problems with kmalloc. If I tried
> to
> allocate more than certain memory then the system is
> hanging while booting with the changed kernel. Can
> you
> suggest me how to come out this situation. Can't I
> allocate as much I want when I want to allocate in
> the
> kernel.
> 
> 
> Thank you,
> Chiranjeevi
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at 
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-03-20 11:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-19 16:18 using kmalloc chiranjeevi vaka
2002-03-19 16:41 ` Arnaldo Carvalho de Melo
2002-03-19 17:30   ` yodaiken
     [not found] <OFD9F443C5.CB1A619A-ON88256B81.005F0AD1@boulder.ibm.com>
2002-03-19 19:26 ` chiranjeevi vaka
2002-03-19 19:38   ` Tommy Reynolds
     [not found] <fa.l19uvvv.1hjmo8t@ifi.uio.no>
2002-03-20  5:53 ` Dan Maas
2002-03-20 10:27   ` Alan Cox
2002-03-20 11:48   ` Jan Hudec

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).