Regarding the gfp mask "GFP_NOFS"

Regarding the gfp mask "GFP_NOFS"

am 01.08.2006 08:06:19 von Daniel Rodrick

Hi,

As mentioned in Robert Love's book on Linux kernel development:

"The mask GFP_NOFS to kmalloc specifies that the allocation can block
and can initiate disk I/O, if it must, but will not initiate a
filesystem operation. This is the flag to use in filesystem code when
you cannot start another filesystem operation."

When it came to GFP_NOIO mask that says that no Disk IO should be
initiated to free memory; I could digest that very well since Disk IO
could be initiated to swap a process to disk to free memory.

But I could not understand why and how could a filesystem request be
initiated in order to free memory (the case avoided by GFP_NOFS)?

What am I missing here?

Thanks,

Dan

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/

Re: Regarding the gfp mask "GFP_NOFS"

am 02.08.2006 08:15:37 von Daniel Rodrick

> > But I could not understand why and how could a filesystem request be
> > initiated in order to free memory (the case avoided by GFP_NOFS)?
>
> Not really sure, but I have an idea. What if the memory block you want
> to free is currently swapped out? Thus at least, you need to mark the
> related swap slot(s) as "free", right? In other word, it will generate
> some I/Os, although not too much.

Thank for replying ... but sorry, I could not get you. The flag
GFP_NOFS is sent to kmalloc() to indicate that if no memory is
available, it should not initiate any filesystem IO, however it is
allowed to initiate Disk IO.

So if some memory needs to be swapped out to disk (in order to free
memory that can be returned to the process calling kmalloc), I
understand Disk IO should suffice. But my doubt is how can a
filesystem IO help to free memory (so that it can be returned to the
process calling kmalloc)?

Thanks,

Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs

Re: Re: Regarding the gfp mask "GFP_NOFS"

am 02.08.2006 13:37:40 von Mulyadi Santosa

Hi...
> So if some memory needs to be swapped out to disk (in order to free
> memory that can be returned to the process calling kmalloc), I
> understand Disk IO should suffice. But my doubt is how can a
> filesystem IO help to free memory (so that it can be returned to the
> process calling kmalloc)?

I hope I also got your point...

Think about a scenario where the swap area is actually a file stored
inside formatted partition (let's say ext2). Thus, it will first
generate filesystem operation, right?

regards,

Mulyadi.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs

Re: Re: Regarding the gfp mask "GFP_NOFS"

am 02.08.2006 14:24:37 von Rajat Jain

> Think about a scenario where the swap area is actually a file stored
> inside formatted partition (let's say ext2). Thus, it will first
> generate filesystem operation, right?

Do linux systems have swap files?? Isn't swap space provided (only) by
the swap partition?

I am assuming that swap partition doesn't have any filesystem. I may be wrong.

Thanks,

Rajat

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/

Re: Regarding the gfp mask "GFP_NOFS"

am 03.08.2006 07:36:49 von Rajat Jain

>
> So if some memory needs to be swapped out to disk (in order to free
> memory that can be returned to the process calling kmalloc), I
> understand Disk IO should suffice. But my doubt is how can a
> filesystem IO help to free memory (so that it can be returned to the
> process calling kmalloc)?
>

Ummm ... not sure ... but just a direction to think upon. There memory
occupied by VFS / filesystems may be holding some buffers (of certain
files). So a file system request may be used to flush these buffers to
the disk, and thus free memory to be returned.

Thanks,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs

Re: Re: Re: Regarding the gfp mask "GFP_NOFS"

am 04.08.2006 08:59:49 von Mulyadi Santosa

Hi Rajat...

> Do linux systems have swap files?? Isn't swap space provided (only) by
> the swap partition?

Yes, you can format a blank file and format it as swap. Later, you
mount it (mkswap). In the end, you get another swap area,
only this time it is not a partition.

>Ummm ... not sure ... but just a direction to think upon. There memory
>occupied by VFS / filesystems may be holding some buffers (of certain
>files). So a file system request may be used to flush these buffers to
>the disk, and thus free memory to be returned.

Hm, I agree with the idea above. Page cache can be simply dropped to
provide more space, but first it needs to be sync'ed. That's where filesystem
operation comes from..

regards,

Mulyadi

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs