public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "liyu@WAN" <liyu@ccoss.com.cn>
To: LKML <linux-kernel@vger.kernel.org>
Subject: one question about pgd allocation
Date: Fri, 01 Jul 2005 21:00:45 +0800	[thread overview]
Message-ID: <42C53E7D.7090404@ccoss.com.cn> (raw)

hi LKML:

    I am reading kernel code about memory management.

    on i386 platform, the function pgd_alloc() alloc one page table 
directory,
every directory entry is one PMD address. that is OK.

pgd_t *pgd_alloc(struct mm_struct *mm)
{
    int i;
    pgd_t *pgd = kmem_cache_alloc(pgd_cache, GFP_KERNEL);

    if (PTRS_PER_PMD == 1 || !pgd)
        return pgd;

    for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
        pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
        if (!pmd)
            goto out_oom;
        set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
    }
    return pgd;

out_oom:
    for (i--; i >= 0; i--)
        kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
    kmem_cache_free(pgd_cache, pgd);
    return NULL;
}

    My question is the statement:

        set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));

    why here is not :

        set_pgd(&pgd[i], __pgd(__pa(pmd)));

    I can not understand this. I search intel developer mannal. but 
nothing to help.
Who can tell me why?


    thank in advanced.

                                                          liyu
                                                                2005/7/1



             reply	other threads:[~2005-07-01 12:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-01 13:00 liyu@WAN [this message]
     [not found] <42C53E7D.7090404@ccoss.com.cn.suse.lists.linux.kernel>
2005-07-01 13:15 ` one question about pgd allocation Andi Kleen

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=42C53E7D.7090404@ccoss.com.cn \
    --to=liyu@ccoss.com.cn \
    --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