kmalloc



Liczniki odwiedzin | Księgi gości | Metal Lyrics | Znaczenie imion | Konwerter | Wolne domeny | Informacje o samochodach | Zakupy w UK | | | | | | | wyposażenie warsztatów | Wypoczynek nad jeziorami




NAME

       __get_free_pages,      get_free_page,     __get_free_page,
       __get_dma_pages, free_pages,  free_page,  kmalloc,  kfree,
       kfree_s, vmalloc, vfree - Allocate and free dynamic kernel
       memory


SYNOPSIS

       #include <linux/malloc.h>
       #include <linux/mm.h>

       unsigned long __get_free_pages(int priority, unsigned long gfporder);
       unsigned long __get_free_page(int priority);
       unsigned long get_free_page(int priority);
       void free_pages(unsigned long addr, unsigned long order);
       void free_page(addr);
       void *kmalloc (size_t size, int priority)
       void kfree_s(void * obj, int size);
       void kfree(void *obj);
       void * vmalloc(unsigned long size);
       void vfree(void * addr);


DESCRIPTION

       __get_free_pages()
              allocates 2^gfporder consecutive  pages  in  kernel
              space.

              priority is one of GFP_BUFFER, GFP_ATOMIC, GFP_KER-
              NEL, GFP_USER, GFP_NOBUFFER, GFP_NFS or GFP_DMA.

       GFP_BUFFER
              has the lowest priority, and doesn't  try  to  free
              other  pages  if  the requested memory isn't avail-
              able.

       GFP_ATOMIC
              tries to allocate the memory immediately.  The task
              will  not  sleep  if  the  memory  isn't available.
              There is a number of reserved pages for GFP_ATOMIC.
              For  allocating  memory on interrupt this has to be
              used.

       GFP_KERNEL
              is the normal way to allocate memory in the  kernel
              space.  The reserved pages will not be used, and if
              the   memory   is   not   available    immediately,
              try_to_free_page() will be called.

       GFP_USER
              is currently the same as GFP_KERNEL.

       GFP_NOBUFFER
              doesn't  try  to shrink the buffer cache for memory
              allocation. This is used  in kernel for  allocating
              pages for the buffer cache.

       GFP_NFS
              is  the  same  as GFP_KERNEL, but the number of the
              reserved pages  is  lower,  so  this  will  succeed
              faster.

       GFP_DMA
              Has  no  effect in __get_free_pages(). This flag is
              only for use with kmalloc().  For DMA memory  kmal-
              loc or __get_dma_pages should be used.  Description
              of effect see __get_dma_pages().

       __get_dma_pages()
              calls repeatedly  __get_free_pages()  until   pages
              suitable for dma are found.  After success the mis-
              takenly allocated pages will be freed.  This  func-
              tion  is  necessary  because  PC DMA controlles are
              limited to 16MB.   DMA  Pages  may  not  cross  64k
              boundaries.  This  is  guaranteed by the allocation
              algorithm of __get_free_pages(). This function

       __get_free_page()
              allocates one  page.  It's  a   macro  which  calls
              __get_free_pages() with gfporder 0.

       get_free_page()
              Same  as  __get_free_page(),  except  the allocated
              memory is set to zero.

       free_pages()
              frees  the  memory space starting  at  addr,  which
              must  have  been  returned  by a previous  call  to
              __get_free_pages().   order  has  to  be  the  same
              __get_free_pages() was called with.  Note that addr
              is unsigned long.

       free_page()
              frees the memory page starting at addr, which  must
              have   been   returned   by   a  previous  call  to
              __get_free_page() or  get_free_page().   Note  that
              addr is unsigned long.

       kmalloc()
              allocates  size bytes, and returns a pointer to the
              allocated memory.  On  i386  the  following  bucket
              sizes  are  possible:  24, 56, 120, 244, 500, 1012,
              2032, 4072, 8168, 16360, 32744,  65512  and  131048
              bytes.  ( See linux/mm/kmalloc.c ) If an other size
              is kmalloc'ed  the the next  bigger  one  is  allo-
              cated. For priority see __get_free_pages.

       kfree_s()
              frees  the  memory  object pointed to by obj.  size
              should be the size of the memory  object  or  zero.
              kfree_s()  determines  the  size of the object from
              the block header. If size is not zero  it  will  be
              checked for being correct.

       kfree()
              frees the memory object pointed to by obj.  It is a
              macro which calls kfree_s() with size zero.

       vmalloc()
              allocates size bytes, and returns a pointer to  the
              allocated  memory.  size  becomes  page  aligned by
              vmalloc(), so the smallest allocated amount is 4kB.
              The  allocated pages are mapped to the virtual mem-
              ory space behind the 1:1 mapped physical memory  in
              the  kernel  space.  Behind  every  vmalloc'ed area
              there is at least one  unmapped  page.  So  writing
              behind the end of a vmalloc'ed area will not result
              in a system crash, but in a segmentation  violation
              in  the kernel space.  Because memory fragmentation
              isn't a big problem for vmalloc(), vmalloc() should
              be used for huge amounts of memory.

       vfree()
              frees  the  virtual memory area pointed to by addr,
              which must have been allocated by a  previous  call
              to vmalloc().



RETURN VALUES

       __get_free_pages(),  __get_free_page()  and  get_free_page
       return on success an unsigned long which is the address of
       the start of the allocated memory, and  should normally be
       cast to a pointer. On failure zero is returned.

       kmalloc and vmalloc return a pointer to the allocated mem-
       ory on success and NULL on failure.



ERRORS

       If    one    of    the    functions    __get_free_pages(),
       __get_free_page(), get_free_page(), or kmalloc() is called
       from  interrupt,  and  priority  is not GFP_ATOMIC, syslog
       will give a warning.



SOURCES

       linux/mm/kmalloc.c
       linux/mm/vmalloc.c
       linux/mm/swap.c
       linux/include/linux/mm.h
       linux/include/linux/malloc.h


BUGS/LIMITAIONS

       Because of memory fragmentation  it's  still  insecure  to
       allocate  areas  of many pages with kmalloc. So for  areas
       bigger than one page vmalloc() should be  used.  Only  for
       DMA kmalloc or __get_dma_pages() has to be used.



AUTHOR

       Linus Torvalds

  Księgarnia

- Oferta księgarni Mentis
- Oferta księgarni Onepress
- Linux Manual (english)
- Konstytucje
- Kręgosłup, bóle karku
- Elektroniczne książki
- Prasa elektroniczna
- Gry RPG, figurki
- darmowy słownik on-line
- jubiler - biżuteria
- polityka prywatności





Linux - Welsh Matt, Dalheimer Matthias Kalle, Kaufman Lar Linux
Autor: Welsh Matt, Dalheimer Matthias Kalle, Kaufman Lar
Cena: 85.44
Rok wydania: 2000
Wydawnictwo: Read Me
Ilość stron: 700
Linux - bezpieczeństwo serwerów - Michael D.Bauer Linux - bezpieczeństwo serwerów
Autor: Michael D.Bauer
Cena: 58.88
Rok wydania: 2003
Wydawnictwo: Read Me
Ilość stron: 488
Linux kernel - Daniel P. Bovet, Marco Cesati Linux kernel
Autor: Daniel P. Bovet, Marco Cesati
Cena: 85.44
Rok wydania: 2001
Wydawnictwo: Read Me
Ilość stron: 634
Linux. Programowanie dla zaawansowanych - Mark Mitchell. Jeffrey Oldham, Alex Samuel Linux. Programowanie dla zaawansowanych
Autor: Mark Mitchell. Jeffrey Oldham, Alex Samuel
Cena: 42.32
Rok wydania: 2002
Wydawnictwo: Read Me
Ilość stron: 300
Linux: Systemy plików - Moshe Bar Linux: Systemy plików
Autor: Moshe Bar
Cena: 51.52
Rok wydania: 2002
Wydawnictwo: Read Me
Ilość stron: 332
Linux. Archiwizacja danych - Leszek Madeja Linux. Archiwizacja danych
Autor: Leszek Madeja
Cena: 17.60
Rok wydania: 2003
Wydawnictwo: Mikom
Ilość stron:
Linux i galanteria SCSI - Leszek Madeja Linux i galanteria SCSI
Autor: Leszek Madeja
Cena: 10.80
Rok wydania: 2003
Wydawnictwo: Mikom
Ilość stron: 88
Bezpieczeństwo systemu Linux - Ramón J. Honta&ntilde;ón Bezpieczeństwo systemu Linux
Autor: Ramón J. Honta&ntilde;ón
Cena: 44.62
Rok wydania: 2002
Wydawnictwo: Mikom
Ilość stron: 464
Korzystanie z drukarki. Ćwiczenia z systemu Linux - Leszek Madeja Korzystanie z drukarki. Ćwiczenia z systemu Linux
Autor: Leszek Madeja
Cena: 16.80
Rok wydania: 2000
Wydawnictwo: Mikom
Ilość stron: 192
Korzystanie z pomocy. Ćwiczenia z systemu Linux - Leszek Madeja Korzystanie z pomocy. Ćwiczenia z systemu Linux
Autor: Leszek Madeja
Cena: 15.40
Rok wydania: 2000
Wydawnictwo: Mikom
Ilość stron: 152
Linux - książka kucharska - Michael Stutz Linux - książka kucharska
Autor: Michael Stutz
Cena: 47.84
Rok wydania: 2002
Wydawnictwo: Mikom
Ilość stron: 488
Linux. Gniazda w programowaniu - Woren W. Gay Linux. Gniazda w programowaniu
Autor: Woren W. Gay
Cena: 47.29
Rok wydania: 2001
Wydawnictwo: Mikom
Ilość stron: 552
LINUX. Rozwiązywanie problemów - Brian Ward LINUX. Rozwiązywanie problemów
Autor: Brian Ward
Cena: 33.92
Rok wydania: 2001
Wydawnictwo: Mikom
Ilość stron: 312
Midnight Commander. Ćwiczenia z systemu Linux - Leszek Madeja Midnight Commander. Ćwiczenia z systemu Linux
Autor: Leszek Madeja
Cena: 23.80
Rok wydania: 2000
Wydawnictwo: Mikom
Ilość stron: 272
Red Hat Linux 6.2 same konkrety - Bob Rankin Red Hat Linux 6.2 same konkrety
Autor: Bob Rankin
Cena: 39.74
Rok wydania: 2000
Wydawnictwo: Mikom
Ilość stron: 372
Caldera Linux 2.3 dla każdego - Bill Ball Caldera Linux 2.3 dla każdego
Autor: Bill Ball
Cena: 49.00
Rok wydania: 2000
Wydawnictwo: Helion
Ilość stron: 400
Linux. Praktyczne rozwiązania - Adam Podstawczyński Linux. Praktyczne rozwiązania
Autor: Adam Podstawczyński
Cena: 35.00
Rok wydania: 2000
Wydawnictwo: Helion
Ilość stron: 248
Red Hat Linux 7.3. Księga eksperta - Bill Ball Red Hat Linux 7.3. Księga eksperta
Autor: Bill Ball
Cena: 110.00
Rok wydania: 2002
Wydawnictwo: Helion
Ilość stron: 752
Linux w sieci - Adam Podstawczyński Linux w sieci
Autor: Adam Podstawczyński
Cena: 39.00
Rok wydania: 2002
Wydawnictwo: Helion
Ilość stron: 224
Red Hat Linux 7.2. Ćwiczenia praktyczne - Jerzy Marczyński Red Hat Linux 7.2. Ćwiczenia praktyczne
Autor: Jerzy Marczyński
Cena: 18.00
Rok wydania: 2002
Wydawnictwo: Helion
Ilość stron: 176






ksiegarnia.pila.pl exists since 2005 year.
Provided by: Przemysław Krajniak, PHP Scripts