* [Linux-ia64] Re: Pagesize is different between IA32 and IA64
@ 2001-11-12 8:29 Hideki Yamamoto
2001-11-12 8:59 ` nomura
0 siblings, 1 reply; 2+ messages in thread
From: Hideki Yamamoto @ 2001-11-12 8:29 UTC (permalink / raw)
To: linux-ia64
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
I am sorry I forgot to say my opinion and attach sample
program.
I think the solution of this problem is which
following them
- __getpagesize function should returns the real pagesize
- It needs to prepare the another function that
returns real pagesize for malloc instead.
I have confirmed this problem, the Kernel version is
2.4.7 and the libc version is 2.2.4.
This is a sample program.
[-- Attachment #2: d.c --]
[-- Type: application/octet-stream, Size: 2114 bytes --]
#include <unistd.h>
#define SIZE4K (0x1000)
#define SIZE16K (0x4000)
//#define MORECORE (MORECORE)
#define MORECORE (sbrk)
main() {
char *brk, *curbrk, *p, *adjust;
int i, j;
if((brk = (char *)MORECORE(0)) == (char *)-1) {
printf("Morecore failed.\n");
exit(1);
}
adjust = (char*)((((long)(char *)brk /SIZE16K)+1) *SIZE16K) ;
if( (brk = (char *)MORECORE((char *)adjust - (char *)brk)) == (char *)-1 ) {
printf("Morecore failed.\n");
exit(1);
}
if( (curbrk = (char*)MORECORE(SIZE4K)) == (char*)-1 ) {
printf("Morecore failed.\n");
exit(1);
}
p = curbrk;
printf("First MORECORE(It must be cleared) curbrk=0x%x\n", curbrk);
for(i = 0; i < SIZE4K; i++ ) {
if( *p != 0 ) { printf("It is dirty\n"); break; }
*p++;
}
p = curbrk;
for(i = 0; i < SIZE4K; i++ ) {
*p = (char)0xff;
p++;
}
if( (curbrk = (char*)MORECORE(SIZE4K)) == (char*)-1 ) {
printf("Morecore failed.\n");
exit(1);
}
p = curbrk;
printf("Second MORECORE(It also must be cleared) curbrk=0x%x\n", curbrk);
for(i = 0; i < SIZE4K; i++ ) {
if( *p != 0 ) { printf("It is dirty\n"); break; }
*p++;
}
p = curbrk;
for(i = 0; i < SIZE4K; i++ ) {
*p = (char)0xff;
p++;
}
if( (curbrk = (char*)MORECORE(-SIZE4K)) == (char*)-1 ) {
printf("Morecore failed.\n");
exit(1);
}
/*
printf("Aftere MORECORE(-SIZE4K)\n");
p = curbrk;
for(i = 0; i < SIZE4K; i++ ) {
if( *p != 0 ) { printf("It is dirty\n"); break; }
p++;
}
*/
if( (curbrk = (char*)MORECORE(SIZE4K)) == (char*)-1 ) {
printf("Morecore failed.\n");
exit(1);
}
p = curbrk;
printf("Third MORECORE curbrk = 0x%x\n", curbrk);
for(i = 0; i < SIZE4K; i++ ) {
if( *p != 0 ) { printf("It is dirty\n"); break; }
p++;
}
if( (curbrk = (char*)MORECORE(-SIZE4K)) == (char*)-1 ) {
printf("Morecore failed.\n");
exit(1);
}
}
[-- Attachment #3: Type: text/plain, Size: 918 bytes --]
>
>
> Hello all.
>
> If this problem has already known, I am sorry.
>
> I am investigating the problem that calloc returns no
> cleared area.
> It was made on IA32 system and executes on IA64.
> I think calloc expects to clear the memories sbrk
> returned. But When the program made on IA32 is
> executing on IA64 system, sbrk sometimes returns no
> cleared area.
> Because the Kernel on IA64 alignes the memories 16K
> bytes. However, when the progmam made on IA32 is
> executing on IA64, the function __getpagesize returns
> 4Kbytes. At this case, if the memories that calloc
> requests to return sbrk(-xxx) is smaller than
> 16Kbytes, the kernel do not unmap this memory.
> (I think that the time that the memories clears 0 by
> the kernel is when the kernel maps memories by the signal)
>
> How do you think?
>
> --
> Regards,
> Hideki Yamamoto (V).v.(V) # Empowered by Innovation
>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [Linux-ia64] Re: Pagesize is different between IA32 and IA64
2001-11-12 8:29 [Linux-ia64] Re: Pagesize is different between IA32 and IA64 Hideki Yamamoto
@ 2001-11-12 8:59 ` nomura
0 siblings, 0 replies; 2+ messages in thread
From: nomura @ 2001-11-12 8:59 UTC (permalink / raw)
To: linux-ia64
As a supplement to his report,
it seems that sys_brk() in mm/mmap.c uses PAGE_ALIGN and brk syscall in
ia32 emulation uses the sys_brk as it is.
Does this result in the situation that ia32 brk() behaves as if the page
size is 16KB, though in reality 4KB?
From: "Hideki Yamamoto" <hideki@hpc.bs1.fc.nec.co.jp>
Subject: [Linux-ia64] Re: Pagesize is different between IA32 and IA64
Date: Mon, 12 Nov 2001 17:29:53 +0900
> I think the solution of this problem is which
> following them
> - __getpagesize function should returns the real pagesize
> - It needs to prepare the another function that
> returns real pagesize for malloc instead.
>
> I have confirmed this problem, the Kernel version is
> 2.4.7 and the libc version is 2.2.4.
>
> This is a sample program.
Best regards.
--
NOMURA, Jun'ichi <j-nomura@ce.jp.nec.com, nomura@hpc.bs1.fc.nec.co.jp>
HPC Operating System Group, 1st Computers Software Division,
Computers Software Operations Unit, NEC Solutions.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-11-12 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-12 8:29 [Linux-ia64] Re: Pagesize is different between IA32 and IA64 Hideki Yamamoto
2001-11-12 8:59 ` nomura
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox