All of lore.kernel.org
 help / color / mirror / Atom feed
From: Izik Eidus <ieidus@redhat.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kvm@vger.kernel.org, avi@redhat.com, aarcange@redhat.com,
	chrisw@redhat.com, mtosatti@redhat.com, hugh@veritas.com,
	Izik Eidus <ieidus@redhat.com>
Subject: [PATCH 2/5] add get_pte(): helper function: fetching pte for va
Date: Mon, 20 Apr 2009 04:36:03 +0300	[thread overview]
Message-ID: <1240191366-10029-3-git-send-email-ieidus@redhat.com> (raw)
In-Reply-To: <1240191366-10029-2-git-send-email-ieidus@redhat.com>

get_pte() receive mm_struct of a task, and a virtual address and return
the pte corresponding to it.

this function return NULL in case it couldnt fetch the pte.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
---
 include/linux/mm.h |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index bff1f0d..9a34109 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -894,6 +894,30 @@ int vma_wants_writenotify(struct vm_area_struct *vma);
 
 extern pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl);
 
+static inline pte_t *get_pte(struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t *pgd;
+	pud_t *pud;
+	pmd_t *pmd;
+	pte_t *ptep = NULL;
+
+	pgd = pgd_offset(mm, addr);
+	if (!pgd_present(*pgd))
+		goto out;
+
+	pud = pud_offset(pgd, addr);
+	if (!pud_present(*pud))
+		goto out;
+
+	pmd = pmd_offset(pud, addr);
+	if (!pmd_present(*pmd))
+		goto out;
+
+	ptep = pte_offset_map(pmd, addr);
+out:
+	return ptep;
+}
+
 #ifdef __PAGETABLE_PUD_FOLDED
 static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
 						unsigned long address)
-- 
1.5.6.5


WARNING: multiple messages have this Message-ID (diff)
From: Izik Eidus <ieidus@redhat.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kvm@vger.kernel.org, avi@redhat.com, aarcange@redhat.com,
	chrisw@redhat.com, mtosatti@redhat.com, hugh@veritas.com,
	Izik Eidus <ieidus@redhat.com>
Subject: [PATCH 2/5] add get_pte(): helper function: fetching pte for va
Date: Mon, 20 Apr 2009 04:36:03 +0300	[thread overview]
Message-ID: <1240191366-10029-3-git-send-email-ieidus@redhat.com> (raw)
In-Reply-To: <1240191366-10029-2-git-send-email-ieidus@redhat.com>

get_pte() receive mm_struct of a task, and a virtual address and return
the pte corresponding to it.

this function return NULL in case it couldnt fetch the pte.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
---
 include/linux/mm.h |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index bff1f0d..9a34109 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -894,6 +894,30 @@ int vma_wants_writenotify(struct vm_area_struct *vma);
 
 extern pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl);
 
+static inline pte_t *get_pte(struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t *pgd;
+	pud_t *pud;
+	pmd_t *pmd;
+	pte_t *ptep = NULL;
+
+	pgd = pgd_offset(mm, addr);
+	if (!pgd_present(*pgd))
+		goto out;
+
+	pud = pud_offset(pgd, addr);
+	if (!pud_present(*pud))
+		goto out;
+
+	pmd = pmd_offset(pud, addr);
+	if (!pmd_present(*pmd))
+		goto out;
+
+	ptep = pte_offset_map(pmd, addr);
+out:
+	return ptep;
+}
+
 #ifdef __PAGETABLE_PUD_FOLDED
 static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
 						unsigned long address)
-- 
1.5.6.5

--
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-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-04-20  1:39 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-20  1:36 [PATCH 0/5] ksm - dynamic page sharing driver for linux v4 Izik Eidus
2009-04-20  1:36 ` Izik Eidus
2009-04-20  1:36 ` [PATCH 1/5] MMU_NOTIFIERS: add set_pte_at_notify() Izik Eidus
2009-04-20  1:36   ` Izik Eidus
2009-04-20  1:36   ` Izik Eidus [this message]
2009-04-20  1:36     ` [PATCH 2/5] add get_pte(): helper function: fetching pte for va Izik Eidus
2009-04-20  1:36     ` [PATCH 3/5] add page_wrprotect(): write protecting page Izik Eidus
2009-04-20  1:36       ` Izik Eidus
2009-04-20  1:36       ` [PATCH 4/5] add replace_page(): change the page pte is pointing to Izik Eidus
2009-04-20  1:36         ` Izik Eidus
2009-04-20  1:36         ` [PATCH 5/5] add ksm kernel shared memory driver Izik Eidus
2009-04-20  1:36           ` Izik Eidus
2009-04-20 10:02           ` Alan Cox
2009-04-20 10:02             ` Alan Cox
2009-04-20 10:02             ` Alan Cox
2009-04-20 11:11             ` Avi Kivity
2009-04-20 11:11               ` Avi Kivity
2009-04-20 12:52               ` Izik Eidus
2009-04-20 12:52                 ` Izik Eidus
2009-04-27 22:34           ` Andrew Morton
2009-04-27 22:34             ` Andrew Morton
2009-04-27 22:34             ` Andrew Morton
2009-04-27 23:12             ` Izik Eidus
2009-04-27 23:12               ` Izik Eidus
2009-04-30 17:46               ` Izik Eidus
2009-04-30 17:46                 ` Izik Eidus
2009-04-30 17:58                 ` Andrew Morton
2009-04-30 17:58                   ` Andrew Morton
2009-05-13 23:17           ` Andrew Morton
2009-05-13 23:17             ` Andrew Morton
2009-05-13 23:17             ` Andrew Morton
2009-05-13 23:25             ` Chris Wright
2009-05-13 23:25               ` Chris Wright
2009-05-14  0:14               ` Anthony Liguori
2009-05-14  0:14                 ` Anthony Liguori
2009-05-14  0:11                 ` Izik Eidus
2009-05-14  0:11                   ` Izik Eidus
2009-05-14  0:15             ` Izik Eidus
2009-05-14  0:15               ` Izik Eidus
2009-05-14  1:40               ` Tony Breeds
2009-05-14  1:40                 ` Tony Breeds

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=1240191366-10029-3-git-send-email-ieidus@redhat.com \
    --to=ieidus@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=hugh@veritas.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mtosatti@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.