Re: can a malloc be *both* GFP_KERNEL and GFP_ATOMIC?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 3/25/07, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:

  from everything i'd ever read, i was under the impression that a
memory allocation might be GFP_KERNEL or GFP_ATOMIC, but not both.
however, there are at least a couple calls in the kernel where both of
those flags are used simultaneously.  does that make sense?

If it's in the kernel, then it makes sense. The right question is,
what sense it makes?

http://lxr.linux.no/source/include/linux/gfp.h#L61
"/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use
emergency pool */"

The GFP_ATOMIC | GFP_KERNEL results in
__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_FS.

But I understand the above comment that the use of __GFP_HIGH
implies to the memory allocation code that it must ignore the
__GFP_WAIT flag. Therefore I think the GFP_ATOMIC | GFP_KERNEL
is equal to __GFP_HIGH |  __GFP_IO | __GFP_FS. That reads: the memory
allocation code is not allowed to sleep (__GFP_HIGH) (probably use
emergency memory pools), is allowed to perform file system operation
(__GFP_FS)[*], or is allowed to perform some input/output operation
(__GFP_IO)[**].

[*] One example I can imagine is that when the system is low on memory,
then the memory subsystem can try to free some dirty pages. In this case
it would most probably call some file system specific function, that will be
responsible for writing the page contents to the disk (or otherwise
synchronize the page contents with the storage area [***]).

[**]
I don't have any example for this one.

[***]
Network file system (like NFS) would probably have to send the page through
the network to the server.

BlackHole

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux