linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: page->offset
@ 2000-04-12 13:04 pnilesh
  2000-04-12 14:45 ` page->offset Stephen C. Tweedie
  2000-04-12 15:29 ` page->offset Eric W. Biederman
  0 siblings, 2 replies; 10+ messages in thread
From: pnilesh @ 2000-04-12 13:04 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: linux-mm



To have your views,

If a file is opened and from an offset which is not page aligned say from
offset 10.
When we read this file into the memory page ,where the first byte will be
loaded into the memory ?
In 2.2 the first byte of the page will be the 10th byte of the file.
In 2.3 the first byte will be first byte in the file and 10th byte is the
10th in the file.

This is what I feel.

Nilesh

Correct.  There are some very old binary formats in which the pages
of the executable are not page-aligned.  2.2 still supports them
and allows such binaries to be non-aligned in cache, but there is
no guarantee of cache coherency on such mappings and they are no
longer supported in 2.3.

--Stephen



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: page->offset
@ 2000-04-13 11:19 pnilesh
  0 siblings, 0 replies; 10+ messages in thread
From: pnilesh @ 2000-04-13 11:19 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: linux-mm

Odd, it should't.  Which kernel is this?
cat /proc/version shows  2.2.5-15

>         char *p = mmap (NULL,10,PROT_READ,MAP_SHARED,fd,1024);
>         char *s = mmap (NULL,10,PROT_READ,MAP_SHARED,fd,1024);

strace shows:

  old_mmap(NULL, 10, PROT_READ, MAP_SHARED, 3, 0x400) = -1 EINVAL (Invalid
argument)
  old_mmap(NULL, 10, PROT_READ, MAP_SHARED, 3, 0x400) = -1 EINVAL (Invalid
argument)

on a 1k blocksize filesystem.

> Does these virtual addresses point to only one physical page ?
> This page is in the page cache if I am not wrong with page->count = 3 ?
> (2.2.x)

Correct.

> If I do read () from 1024 offset the data I will get will be from the
above
> phyiscal page or from .... ?

read() _always_ invokes the page cache with pagesize-aligned
page offsets.  If a correctly aligned page is not present, a new one
will be created.


Nilesh


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: page->offset
@ 2000-04-13  4:53 pnilesh
  2000-04-13  6:07 ` page->offset Matti Aarnio
  2000-04-13  9:59 ` page->offset Stephen C. Tweedie
  0 siblings, 2 replies; 10+ messages in thread
From: pnilesh @ 2000-04-13  4:53 UTC (permalink / raw)
  To: linux-mm

I think I had put up the question in a wrong way.

If I mmap a file from/at a particular offset.
char *p;
fd = open("anyfile");
p = mmap (NULL,100,PROT_READ|PROT_WRITE, MAP_SHARED,fd,10);

Here the call fails .
I tried to map at / from offset 512 that also failed.
however with the offset of 1024 it succeded.

So I can not mmap anything which is not fs block size aligned .

#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
main (int argc, char **argv)
{
        int i = 0;
        int fd = open("./anyfile",O_RDWR);
        char *p = mmap (NULL,10,PROT_READ,MAP_SHARED,fd,1024);
        char *s = mmap (NULL,10,PROT_READ,MAP_SHARED,fd,1024);
        char *q = 0;

        q = (char*)((int)p & 0xfffff000);
        printf ("p %x masked p %x\n",p,q);
        q = (char*)((int)s & 0xfffff000);
        printf ("s %x masked s %x\n",s,q);
}
The output of this was
p 40014000 masked p 40014000
s 40015000 masked s 40015000

Does these virtual addresses point to only one physical page ?
This page is in the page cache if I am not wrong with page->count = 3 ?
(2.2.x)


If I do read () from 1024 offset the data I will get will be from the above

phyiscal page or from .... ?

Nilesh




--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* page->offset
@ 2000-04-12 10:07 pnilesh
  2000-04-12 11:06 ` page->offset Stephen C. Tweedie
  0 siblings, 1 reply; 10+ messages in thread
From: pnilesh @ 2000-04-12 10:07 UTC (permalink / raw)
  To: linux-mm

This is related to 2.2.x


One of the comment in mm.h says that we can have more than one copy of some
page of an executable or shared lib (not normally).

Does it have to do something with offet field in page structure ?
Does it mean that it may happen becoz offset field is not guarenteed to be
PAGE_SIZE aligned  ?

Nilesh Patel


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-04-13 19:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-12 13:04 page->offset pnilesh
2000-04-12 14:45 ` page->offset Stephen C. Tweedie
2000-04-12 15:29 ` page->offset Eric W. Biederman
  -- strict thread matches above, loose matches on Subject: below --
2000-04-13 11:19 page->offset pnilesh
2000-04-13  4:53 page->offset pnilesh
2000-04-13  6:07 ` page->offset Matti Aarnio
2000-04-13 19:34   ` page->offset Andrea Arcangeli
2000-04-13  9:59 ` page->offset Stephen C. Tweedie
2000-04-12 10:07 page->offset pnilesh
2000-04-12 11:06 ` page->offset Stephen C. Tweedie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox