mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Matvejchikov Ilya" <matvejchikov@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: A question about page caching
Date: Tue, 4 Mar 2008 19:57:06 +0300	[thread overview]
Message-ID: <8496f91a0803040857y78d70ca4o70704fa03e208823@mail.gmail.com> (raw)

Hi folks,

I have a little question about such thing as a page caching while file
reading. As I know there is mechanism that optimise system performance
when file read occurs repeatedly. But I can't simulate it. The test
program that I wrote doesn't show acceptable results.
Here is it.

--- [main.c] ---
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <asm/msr.h>

#define RSIZE	(4096*1024*128)

int main()
{
    int fd;
    char * data;
    unsigned long long counter0;
    unsigned long long counter1;

    fd = open("junkfile", O_RDONLY);
    if (fd == -1) {
	printf("ERROR: open() = %d\n", fd);
	exit(1);
    }

    data = (char *)malloc(RSIZE);
    if (data == NULL) {
	printf("ERROR: malloc() fails\n");
	exit(1);
    }

    rdtscll(counter0);
    read(fd, (void *)data, RSIZE);
    rdtscll(counter1);

    printf("D = %lu\n", counter1 - counter0);

    fgetc(stdin);

    close(fd);

    return 0;
}
--- [main.c] ---

When I run first copy of program I have such result:
(1) D = 191860948
When I run second copy of program (i.e. when first copy waits on
fgetc()) I have the similar result:
(2) D = 192320613

Where I be wrong?

Thanks!

                 reply	other threads:[~2008-03-04 16:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8496f91a0803040857y78d70ca4o70704fa03e208823@mail.gmail.com \
    --to=matvejchikov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®