why does mlockall appear to make memcpy slower ?

From: Paul Barton-Davis (pbd@Op.Net)
Date: Sun Apr 02 2000 - 17:29:26 EST


The following program prints:

  Average msecs per MB 4.914158; Average copy rate: 0.000005 msecs/byte

if run without root permission (i.e. mlockall() fails), and

  Average msecs per MB 7.417227; Average copy rate: 0.000007 msecs/byte

if run with root permission.

Is there a simple explanation ?

--p

--------------------------------------------------------------------
#include <stdlib.h>
#include <sys/mman.h>
#include <asm/msr.h>

main ()

{
        char buf[1048576];
        char obuf[1048576];
        int i;
        float total;
        unsigned long now, then;

#define N 1000
#define CYCLES_PER_MSEC 450000.0f

        total = 0;

        mlockall (MCL_CURRENT);

        for (i = 0; i < N; i++) {
                rdtscl (then);
                memcpy (buf, obuf, sizeof (obuf));
                rdtscl (now);
                total += now - then;
        }

        printf ("Average msecs per MB %.6f; "
                "Average copy rate: %.6f msecs/byte\n",
                total / (N * CYCLES_PER_MSEC),
                total / (N * 1048576.0 * CYCLES_PER_MSEC));
}
--------------------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:09 EST