[Top] [All Lists]

Re: VCEI/VCED handling

Subject: Re: VCEI/VCED handling
From: Thomas Bogendoerfer <>
Date: Tue, 29 Sep 1998 23:24:55 +0200
In-reply-to: <>; from on Tue, Sep 29, 1998 at 01:50:03AM +0200
References: <> <>
On Tue, Sep 29, 1998 at 01:50:03AM +0200, wrote:
> We've got code of which we're shure that it is correct.  Nevertheless
> Linux ist still fragile on SC machines.  I've been tracking this in
> private emails with Ulf but so far only with limited success.  Aside of
> the missing VCED / VCEI handlers there must be something else that is
> broken.

As I understand the problem now, I wrote the little test program below.
If I'll try it on a R4600PC Indy or a R4000PC Olivetti with Linux, I don't
get what I would expect. On IRIX, Linux/Alpha (I have to change the offset
between the two mapping to 0x2000, because of the bigger page size on Alphas)
and Linux/x86 the program works. IMHO this is a showstopper as we don't handle 
cache aliases right.  

How does IRIX solve this problem ? Does it disable caching for shared 
writeable pages ?


#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <stdio.h>
#include <unistd.h>

unsigned char buf[1024];

int main (int argc, char *argv[])
        int fd;
        unsigned char *mem1,*mem2;

        if ((fd = open ("mmap_file",O_RDWR|O_CREAT,0644)) < 0) {
                perror ("open");
                exit (1);
        write (fd, buf, sizeof(buf));

        if ((mem1 = mmap (NULL, 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) 
== (unsigned char *)-1) {
                perror ("mmap mem1");
                exit (2);
        if ((mem2 = mmap (mem1+0x1000, 1024, 
PROT_READ|PROT_WRITE,MAP_SHARED|MAP_FIXED, fd, 0)) == (unsigned char *)-1) {
                perror ("mmap mem2");
                exit (3);
        printf ("mem1 %p, mem2 %p\n",mem1,mem2);

        *mem1 = 0x55;
        printf ("*mem1 = %x, *mem2 = %x\n",*mem1,*mem2);

        *mem1 = 0xaa;
        printf ("*mem1 = %x, *mem2 = %x\n",*mem1,*mem2);

        *mem2 = 0x33;
        printf ("*mem2 = %x, *mem1 = %x\n",*mem2,*mem1);

        *mem2 = 0xcc;
        printf ("*mem2 = %x, *mem1 = %x\n",*mem2,*mem1);

        return 0;

See, you not only have to be a good coder to create a system like Linux,
you have to be a sneaky bastard too ;-)
                   [Linus Torvalds in <4rikft$7g5@linux.cs.Helsinki.FI>]

<Prev in Thread] Current Thread [Next in Thread>