All of lore.kernel.org
 help / color / mirror / Atom feed
* Replacing a page in page_cache
@ 2012-02-27 13:41 Jack David
  2012-02-27 21:20 ` Mulyadi Santosa
  0 siblings, 1 reply; 3+ messages in thread
From: Jack David @ 2012-02-27 13:41 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

I am trying to replace a page which is already present in page_cache.
Is there any direct way to do so (via some kernel API)?  My experiment
is something like, I have a file opened and read completely in user
space app (just to make sure that all the file is present in page
cache). From kernel, I am allocating a new page, filling some data
into it, and want to store this data by replacing some existing page
from page_cache.

Initially I was thinking of removing a page (at a particular index)
from page_cache and then add my new page at the same index. But by
doing so, that page will be treated as containing invalid data, hence
again the data will be fetched from the disk and it will overwrite
whatever I had initially written into that page. Is there any way I
can add the page into page_cache (by add_to_page_cache_lru) and still
mark it Uptodate (SetPageUptodate or something) without any bad
consequences?

Regards,
Jack

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

* Replacing a page in page_cache
  2012-02-27 13:41 Replacing a page in page_cache Jack David
@ 2012-02-27 21:20 ` Mulyadi Santosa
  2012-02-28  6:17   ` Jack David
  0 siblings, 1 reply; 3+ messages in thread
From: Mulyadi Santosa @ 2012-02-27 21:20 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Feb 27, 2012 at 20:41, Jack David <jd6589@gmail.com> wrote:
> Hi All,
>
> I am trying to replace a page which is already present in page_cache.
> Is there any direct way to do so (via some kernel API)? ?My experiment
> is something like, I have a file opened and read completely in user
> space app (just to make sure that all the file is present in page
> cache). From kernel, I am allocating a new page, filling some data
> into it, and want to store this data by replacing some existing page
> from page_cache.

sounds like what you want to do is like normal mmap in user space and
then write new data into it?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

* Replacing a page in page_cache
  2012-02-27 21:20 ` Mulyadi Santosa
@ 2012-02-28  6:17   ` Jack David
  0 siblings, 0 replies; 3+ messages in thread
From: Jack David @ 2012-02-28  6:17 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Feb 28, 2012 at 2:50 AM, Mulyadi Santosa
<mulyadi.santosa@gmail.com> wrote:
> On Mon, Feb 27, 2012 at 20:41, Jack David <jd6589@gmail.com> wrote:
>> Hi All,
>>
>> I am trying to replace a page which is already present in page_cache.
>> Is there any direct way to do so (via some kernel API)? ?My experiment
>> is something like, I have a file opened and read completely in user
>> space app (just to make sure that all the file is present in page
>> cache). From kernel, I am allocating a new page, filling some data
>> into it, and want to store this data by replacing some existing page
>> from page_cache.
>
> sounds like what you want to do is like normal mmap in user space and
> then write new data into it?
>

Actually I want to share the pages (present in page cache) between two
files. I want to avoid memcopy in kernel as much as possible. I am
going through the mmap implementation in kernel but not able to
understand how it can help me in my scenario.

J

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

end of thread, other threads:[~2012-02-28  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27 13:41 Replacing a page in page_cache Jack David
2012-02-27 21:20 ` Mulyadi Santosa
2012-02-28  6:17   ` Jack David

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.