Re: Regarding Page alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks guys. For me it looks more like to ease the job of memory management rather than performance or if I am wrong, it depends on the scenario.

Sanjay

eliad lubovsky wrote:

One example is extracting the process descriptor from the Stack Pointer.

__asm__("andl %%esp,%0; ":"=r" (ti) : "" (~(THREAD_SIZE - 1)));

The address of the process descriptor is aligned to THREAD_SIZE (which may be 4 or 8KB).


On 1/5/06, *Kirk True* <ktrue@xxxxxxxxxxx <mailto:ktrue@xxxxxxxxxxx>> wrote:

    Hi Sanjay,

    > - What is meant by aligning to page boudaries?

    It means that an address is an integer multiple of the page size. For
    instance, a common page size (on x86 at least) is 4k. So any address
    must be a multiple of 4,096 bytes (0x1000).

    Aligned:

        0xc3564000
        0xdeadb000

    Unaligned:

        0xc3564080
        0xdeadbeae

    It's kinda easy for 4k pages because an address must end with three
    zeros (in hex).

    If the modulo isn't 0, it's not aligned:

        if (address % PAGE_SIZE)
            printk(KERN_DEBUG "address %p isn't page aligned!\n",
    address);

    > - When do you need to need to make use of it?

    When it's required ;) Some system calls require page-aligned
    addresses,
    some don't.

    > - What are the advantages of it, if any?

    Performance is one, though the exact reasoning/explanation is better
    left to someone else. It makes the code cleaner in some of the mm/
    stuff
    too.

    Kirk

    --
    Kernelnewbies: Help each other learn about the Linux kernel.
    Archive:       http://mail.nl.linux.org/kernelnewbies/
    FAQ:           http://kernelnewbies.org/faq/





--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux