Re: shm bug introduced with pagecache in 2.3.11

Christoph Rohland (hans-christoph.rohland@sap.com)
09 Nov 1999 18:09:39 +0100


--Multipart_Tue_Nov__9_18:09:39_1999-1
Content-Type: text/plain; charset=US-ASCII

andrea@suse.de (Andrea Arcangeli) writes:

> On 9 Nov 1999, Christoph Rohland wrote:
>
> > swap_duplicate
> > read_swap_cache_async
> > swapin_readahead
> > shm_nopage
> > handle_mm_fault
> > ...
>
> Hmm, are you sure you reproduced it in UP as you stated in the previous
> email? The above trace seems the effect of this SMP race condition:
>
> --- 2.3.26/mm/memory.c Sun Nov 7 17:33:38 1999
> +++ /tmp/memory.c Tue Nov 9 16:46:02 1999
> @@ -282,7 +282,9 @@
> free_page_and_swap_cache(mem_map+nr);
> return 1;
> }
> + lock_kernel();
> swap_free(pte_to_swp_entry(page));
> + unlock_kernel();
> return 0;
> }

Yes it is definitely on UP.

I append my test program. I normally run it with 32 Megs of RAM and
'./shmtst 15 4444000 5 31 0'

Christoph

--Multipart_Tue_Nov__9_18:09:39_1999-1
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: attachment; filename="shmtst.c"
Content-Transfer-Encoding: 7bit

#include <stdlib.h>
#include <stdio.h>

#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>

int main (int ac, char **av) {
int segs, size, proc, rmpr;
unsigned long long iter;
pid_t pid;

if (ac < 5) {
printf ("usage: shmtst segs size proc iter rm%%\n");
exit (1);
}
segs = atoi (av[1]);
size = atoi (av[2]);
proc = atoi (av[3]);
iter = atoi (av[4]);
rmpr = atoi (av[5]);

iter = 1 << iter;
printf ("using %d segs of size %d (%llu iterations)\n",
segs, size, iter);
while (-- proc) {
if ((pid = fork()) > 0) {
printf ("started process %d\n", (int) pid);
} else {
break;
}
}
srandom (getpid());
while (iter--) {
key_t key;
int seg, i;
char *ptr, *p;

key = random() % segs +1;
if ((seg = shmget (key, size, IPC_CREAT| 0600)) == -1) {
perror("shmget");
if (errno != EIDRM)
exit (1);
continue;
}
if ((ptr = shmat (seg, 0, 0)) == NULL) {
perror ("shmat");
continue;
}
for (i = 0 ; i < size; i += 4097)
ptr[i] = (char) i;

for (i = 0 ; i < size; i += 4097){
if (ptr[i] != (char)i)
printf ("ptr[%i] != %i\n", (int)ptr[i], (int)i);
}

if (shmdt (ptr) != 0) {
perror("shmdt");
exit (1);
}
if (random () % 100 < rmpr &&
shmctl (seg, IPC_RMID, NULL) == -1)
perror("shmctl IPC_RMID");
}
}

--Multipart_Tue_Nov__9_18:09:39_1999-1--

-
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/