public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: xue yong <ultraice.kernel@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: mm: dirty page problem
Date: Tue, 23 Jun 2009 16:17:06 +0800	[thread overview]
Message-ID: <fc71709d0906230117h2bee4d7en9f3aadeae3cb9545@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 734 bytes --]

I wrote a test program. It  mmap  a file and do some write, so some
pages become dirty.
and then I do "cat /proc/meminfo", so I get dirty pages that I have
written. this happened in my home
computer with debian, self compiled kernel 2.6.18-5 installed.


but in my company, on the servers (suse kernel 2.6.16.54), after the
test program have written the data, there was no change in
dirty pages column of "cat /proc/meminfo" 's output. after I killed
the test program, the dirty pages changed immediately.


I dont know why such different behavior, can you help me?


becauce we want a program mmap some files, and after the files'
contents were changed, the OS can write out these dirty
data back to disk periodly.




Best regards!

[-- Attachment #2: mmaptest.c --]
[-- Type: application/octet-stream, Size: 1480 bytes --]

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <time.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
    int fd;
    char *pm;
    struct stat st;
    pid_t p;
//    p = fork();
    fd = open("/home/ice/mmap.dat", O_RDWR);
    if( fd < 0 ){
        perror("open mmap.dat error");
        exit(1);
    }
    if ( fstat(fd, &st) != 0 ){
        perror("stat error");
        exit(1);
    }
    pm = (char*) mmap( NULL, st.st_size, PROT_WRITE | PROT_READ , MAP_SHARED , fd, 0);
//    pm = (char*) mmap( NULL, st.st_size,  PROT_READ , MAP_SHARED , fd, 0);
    if ( pm < 0 || pm == MAP_FAILED ){
        perror("mmap failed");
        exit(1);
    }
    
    struct timeval tBegin, tEnd;
    bzero( &tBegin, sizeof(tBegin) );
    bzero( &tEnd, sizeof(tEnd) );

    gettimeofday( &tBegin, NULL);
    int i;
    char buffer[4096];
//    read( fd, buffer, 4096);
    while(1){
    for( i = 0; i < 1024*100; ++i )
    {
        memcpy( pm + 4096*i,buffer, 4096 );
//        pwrite( fd, buffer, 4096, i * 4096 );

    }
    sleep(300);
    }
//    mlockall(MCL_CURRENT);
//
    gettimeofday( &tEnd, NULL);
    int liTimeDiff = ((tEnd.tv_sec - tBegin.tv_sec) * 1000000 + tEnd.tv_usec - tBegin.tv_usec ) / 1000;
    printf("%d ms\n", liTimeDiff );
    printf("msync\n");
    msync( pm, st.st_size, MS_SYNC );
    munmap( pm, st.st_size );
//    sleep(600);
}

             reply	other threads:[~2009-06-23  8:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23  8:17 xue yong [this message]
2009-06-23  9:02 ` mm: dirty page problem xue yong
2009-06-23 10:33   ` Peter Zijlstra
     [not found]     ` <fc71709d0906230443pf8c4b34pcd4b7fa798fbf1ed@mail.gmail.com>
     [not found]       ` <1245757970.19816.1675.camel@twins>
2009-06-23 13:32         ` xue yong
2009-06-23 13:38           ` Peter Zijlstra

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=fc71709d0906230117h2bee4d7en9f3aadeae3cb9545@mail.gmail.com \
    --to=ultraice.kernel@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