mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zlatko Calusic <zlatko.calusic@iskon.hr>
To: akpm@zip.com.au, hugh@veritas.com
Cc: linux-kernel@vger.kernel.org
Subject: Shared memory shmat/dt not working well in 2.5.x
Date: Tue, 01 Oct 2002 11:52:59 +0200	[thread overview]
Message-ID: <dny99icwp0.fsf@magla.zg.iskon.hr> (raw)

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

Hi, Andrew, Hugh & others.

Still having problems with Oracle on 2.5.x (it can't even be started),
I devoted some time trying to pinpoint where the problem is. Reading
many traces of Oracle, and rebooting a dozen times, I finally found
that the culprit is weird behaviour of shmat/shmdt functions in 2.5,
when combined with mprotect() calls. I wrote a simple test app
(attached) and I'm also appending output of it below (running on
2.4.19 & 2.5.39 kernels, see the difference).

Hopefully, somebody will know how to help resolve that issue, so I can
finally benchmark Oracle on 2.4 vs Oracle on 2.5. ;)

Best regards,


{2.4.19} % shm-bug
First shmat & protects done: 50000000
50000000-51000000 rw-s 00000000 00:04 327974932  /SYSV01478e7f (deleted)
51000000-51001000 r--s 01000000 00:04 327974932  /SYSV01478e7f (deleted)
51001000-51081000 rw-s 01001000 00:04 327974932  /SYSV01478e7f (deleted)
51081000-51082000 r--s 01081000 00:04 327974932  /SYSV01478e7f (deleted)
51082000-51083000 rw-s 01082000 00:04 327974932  /SYSV01478e7f (deleted)
Second shmat done: 50000000
50000000-51083000 rw-s 00000000 00:04 327974932  /SYSV01478e7f (deleted)

{2.5.39} % shm-bug
First shmat & protects done: 50000000
50000000-51000000 rw-s 00000000 00:06 2457614    /SYSV01478e7f (deleted)
51000000-51001000 r--s 00000000 00:06 2457614    /SYSV01478e7f (deleted)
51001000-51081000 rw-s 00001000 00:06 2457614    /SYSV01478e7f (deleted)
51081000-51082000 r--s 00001000 00:06 2457614    /SYSV01478e7f (deleted)
51082000-51083000 rw-s 00002000 00:06 2457614    /SYSV01478e7f (deleted)
shmat 2: Invalid argument


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: shm-bug.c --]
[-- Type: text/x-csrc, Size: 1190 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/mman.h>

#define SIZE 17313792

void xperror(char *error_string)
{
	perror(error_string);
	exit(EXIT_FAILURE);
}

int main(int argc, char **argv)
{
	int shmid, *addr;
	char buffer[64];

	if ((shmid = shmget(21466751, SIZE, IPC_CREAT | IPC_EXCL | 0640)) < 0)
		xperror("shmget");
	addr = (int *) shmat(shmid, (char *) 0x50000000, 0);
	if (addr == (int *) -1)
		xperror("shmat 1");
	if (mprotect((char *) 0x51000000, 4096, PROT_READ) < 0)
		xperror("mprotect 1");
	if (mprotect((char *) 0x51081000, 4096, PROT_READ) < 0)
		xperror("mprotect 2");
	printf("First shmat & protects done: %08lx\n", (unsigned long) addr);
	sprintf(buffer, "cat /proc/%d/maps | grep /SYSV", getpid());
	system(buffer);
	if (shmdt(addr) < 0)
		xperror("shmdt 1");
	addr = (int *) shmat(shmid, (char *) 0x50000000, 0);
	if (addr == (int *) -1) {
		perror("shmat 2");
		shmctl(shmid, IPC_RMID, NULL);
		exit(EXIT_FAILURE);
	}
	printf("Second shmat done: %08lx\n", (unsigned long) addr);
	system(buffer);
	if (shmdt(addr) < 0)
		xperror("shmdt 2");
	shmctl(shmid, IPC_RMID, NULL);
	exit(EXIT_SUCCESS);
}

[-- Attachment #3: Type: text/plain, Size: 12 bytes --]


-- 
Zlatko

             reply	other threads:[~2002-10-01  9:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-01  9:52 Zlatko Calusic [this message]
2002-10-01 13:07 ` Alessandro Suardi
2002-10-01 13:09 ` [PATCH] " Hugh Dickins
2002-10-01 13:28   ` Alessandro Suardi
2002-10-01 13:46     ` Zlatko Calusic
2002-10-01 14:51       ` Alessandro Suardi
2002-10-01 14:59         ` Zlatko Calusic
2002-10-02 18:45         ` Zlatko Calusic
2002-10-08 11:22           ` Zlatko Calusic
2002-10-08 11:38             ` Duncan Sands
2002-10-08 15:10               ` Zlatko Calusic
2002-10-08 15:25                 ` Duncan Sands
2002-10-01 13:37   ` Zlatko Calusic
2002-10-01 15:32 ` [PATCH] Oracle startup split_vma fix Hugh Dickins

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=dny99icwp0.fsf@magla.zg.iskon.hr \
    --to=zlatko.calusic@iskon.hr \
    --cc=akpm@zip.com.au \
    --cc=hugh@veritas.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®