linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Pegasus11 <aijazbaig1.new@gmail.com>
To: linuxppc-dev@ozlabs.org
Subject: Understanding how kernel updates MMU hash table
Date: Tue, 4 Dec 2012 21:56:36 -0800 (PST)	[thread overview]
Message-ID: <34760537.post@talk.nabble.com> (raw)


Hello.

Ive been trying to understand how an hash PTE is updated. Im on a PPC970MP
machine which using the IBM PowerPC 604e core. My Linux version is 2.6.10 (I
am sorry I cannot migrate at the moment. Management issues and I can't help
:-(( )

Now onto the problem:
hpte_update is invoked to sync the on-chip MMU cache which Linux uses as its
TLB. So whenever a change is made to the PTE, it has to be propagated to the
corresponding TLB entry. And this uses hpte_update for the same. Am I right
here?

Now  http://lxr.linux.no/linux-bk+*/+code=hpte_update hpte_update  is
declared as
 
' void hpte_update(pte_t *ptep, unsigned long pte, int wrprot) '. 
The arguments to this function is a POINTER to the PTE entry (needed to make
a change persistent across function call right?), the PTE entry (as in the
value) as well the wrprot flag.

Now the code snippet thats bothering me is this:
'
  86        ptepage = virt_to_page(ptep);
  87        mm = (struct mm_struct *) ptepage->mapping;
  88        addr = ptepage->index +
  89                (((unsigned long)ptep & ~PAGE_MASK) * PTRS_PER_PTE);
'

On line 86, we get the page structure for a given PTE but we pass the
pointer to PTE not the PTE itself whereas virt_to_page is a macro defined
as:

#define virt_to_page(kaddr)   pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)

Why are passing the POINTER to pte here? I mean are we looking for the PAGE
that is described by the PTE or are we looking for the PAGE which contains
the pointer to PTE? Me things it is the later since the former is given by
the VALUE of the PTE not its POINTER. Right?

So if it indeed the later, what trickery are we here after? Perhaps
following the snippet will make us understand? As I see from above, after
that we get the 'address space object' associated with this page. 

What I don't understand is the following line:
 addr = ptepage->index + (((unsigned long)ptep & ~PAGE_MASK) *
PTRS_PER_PTE);

First we get the index of the page in the file i.e. the number of pages
preceding the page which holds the address of PTEP. Then we get the lower 12
bits of this page. Then we shift that these bits to the left by 12 again and
to it we add the above index. What is this doing?

There are other things in this function that I do not understand. I'd be
glad if someone could give me a heads up on this.
-- 
View this message in context: http://old.nabble.com/Understanding-how-kernel-updates-MMU-hash-table-tp34760537p34760537.html
Sent from the linuxppc-dev mailing list archive at Nabble.com.

             reply	other threads:[~2012-12-05  6:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05  5:56 Pegasus11 [this message]
2012-12-05  8:20 ` Understanding how kernel updates MMU hash table Benjamin Herrenschmidt
2012-12-05 17:14   ` Pegasus11
2012-12-06  3:58     ` Benjamin Herrenschmidt
2012-12-06  7:57       ` Pegasus11
2012-12-06 11:56         ` Benjamin Herrenschmidt
2012-12-09  7:18           ` Pegasus11
2012-12-09 21:10             ` Benjamin Herrenschmidt
2012-12-11  7:27               ` Pegasus11
2012-12-13  8:48               ` pegasus
2012-12-13 21:48                 ` Benjamin Herrenschmidt
2012-12-12  5:10 ` Pegasus11

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=34760537.post@talk.nabble.com \
    --to=aijazbaig1.new@gmail.com \
    --cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).