From: bill4carson@gmail.com (bill4carson at gmail.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] Store huge page linux pte in mm_struct
Date: Mon, 30 Jan 2012 15:57:15 +0800 [thread overview]
Message-ID: <1327910238-18704-5-git-send-email-bill4carson@gmail.com> (raw)
In-Reply-To: <1327910238-18704-1-git-send-email-bill4carson@gmail.com>
From: Bill Carson <bill4carson@gmail.com>
One easy way to store huge page linux pte is mm_struct instead of thread_info
that's because when parent task with huge page VMA calls fork, parent huge page
pagetable entries are copied into child pagetable. This is done in
int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
struct vm_area_struct *vma)
We cannot derive child's thread_info just using struct mm_struct *dst.
if we have struct mm_struct **dst, then it's easy to find the corresponding
task_struct as well as thread_info, but we only get struct mm_struct *dst.
It's possible to find the desired task_struct by iterating the global task list
by comparing task_struct->mm with dst.
So mm_struct is used for huge page linux pte for faster lookup and efficient.
Signed-off-by: Bill Carson <bill4carson@gmail.com>
---
arch/arm/mm/pgd.c | 28 ++++++++++++++++++++++++++++
include/linux/mm_types.h | 11 +++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c
index a3e78cc..b04a69a 100644
--- a/arch/arm/mm/pgd.c
+++ b/arch/arm/mm/pgd.c
@@ -91,6 +91,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
pte_unmap(new_pte);
}
+#ifdef CONFIG_ARM_HUGETLB_SUPPORT
+ /* reset the hugepage linux pte pointer
+ * for new mm_struct when we do the fork
+ */
+ mm->huge_2m_pte[HUGE_2M_PTE_1ST_ARRAY] = 0;
+ mm->huge_2m_pte[HUGE_2M_PTE_2ND_ARRAY] = 0;
+ mm->huge_16m_pte = 0;
+#endif
return new_pgd;
no_pte:
@@ -103,6 +111,25 @@ no_pgd:
return NULL;
}
+#ifdef CONFIG_ARM_HUGETLB_SUPPORT
+static void free_huge_linuxpte(struct mm_struct *mm)
+{
+ pte_t **huge_linuxpte = &mm->huge_2m_pte[0];
+ int i;
+
+ for (i = 0; i < HUGE_2M_PTE_SIZE; i++)
+ if (huge_linuxpte[i] != 0)
+ free_page((unsigned long)huge_linuxpte[i]);
+
+ if (mm->huge_16m_pte != NULL)
+ kfree(mm->huge_16m_pte);
+}
+#else
+static void free_huge_linuxpte(struct mm_struct *mm)
+{
+}
+#endif
+
void pgd_free(struct mm_struct *mm, pgd_t *pgd_base)
{
pgd_t *pgd;
@@ -135,6 +162,7 @@ no_pud:
pgd_clear(pgd);
pud_free(mm, pud);
no_pgd:
+ free_huge_linuxpte(mm);
#ifdef CONFIG_ARM_LPAE
/*
* Free modules/pkmap or identity pmd tables.
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 3cc3062..88f76e6 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -23,6 +23,11 @@
struct address_space;
#define USE_SPLIT_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)
+#ifdef CONFIG_ARM_HUGETLB_SUPPORT
+#define HUGE_2M_PTE_SIZE 2
+#define HUGE_2M_PTE_1ST_ARRAY 0
+#define HUGE_2M_PTE_2ND_ARRAY 1
+#endif
/*
* Each physical page in the system has a struct page associated with
@@ -388,6 +393,12 @@ struct mm_struct {
#ifdef CONFIG_CPUMASK_OFFSTACK
struct cpumask cpumask_allocation;
#endif
+
+#ifdef CONFIG_ARM_HUGETLB_SUPPORT
+ /* we place hugepage linux pte at mm_struct */
+ pte_t *huge_2m_pte[HUGE_2M_PTE_SIZE];
+ pte_t *huge_16m_pte;
+#endif
};
static inline void mm_init_cpumask(struct mm_struct *mm)
--
1.7.1
next prev parent reply other threads:[~2012-01-30 7:57 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 7:57 [RFC] ARM hugetlb support bill4carson at gmail.com
2012-01-30 7:57 ` [PATCH 1/7] Add various hugetlb arm high level hooks bill4carson at gmail.com
2012-02-06 17:07 ` Catalin Marinas
2012-02-07 2:00 ` bill4carson
2012-02-07 11:54 ` Catalin Marinas
2012-02-07 12:15 ` Catalin Marinas
2012-02-07 12:57 ` carson bill
2012-01-30 7:57 ` [PATCH 2/7] Add various hugetlb page table fix bill4carson at gmail.com
2012-01-31 9:57 ` Catalin Marinas
2012-01-31 9:58 ` Russell King - ARM Linux
2012-01-31 12:25 ` Catalin Marinas
2012-02-01 3:10 ` bill4carson
2012-02-06 16:26 ` Catalin Marinas
2012-02-07 1:42 ` bill4carson
2012-02-07 11:50 ` Catalin Marinas
2012-02-07 13:24 ` carson bill
2012-02-07 14:11 ` Catalin Marinas
2012-02-07 14:46 ` carson bill
2012-02-07 15:09 ` Catalin Marinas
2012-02-07 15:41 ` carson bill
2012-01-30 7:57 ` [PATCH 3/7] Introduce set_hugepte_ext api for huge page hardware page table setup bill4carson at gmail.com
2012-01-30 7:57 ` bill4carson at gmail.com [this message]
2012-01-31 9:37 ` [PATCH 4/7] Store huge page linux pte in mm_struct Catalin Marinas
2012-01-31 10:01 ` Russell King - ARM Linux
2012-02-01 5:45 ` bill4carson
2012-02-06 2:04 ` bill4carson
2012-02-06 10:29 ` Catalin Marinas
2012-02-06 14:40 ` carson bill
2012-01-30 7:57 ` [PATCH 5/7] Using do_page_fault for section fault handling bill4carson at gmail.com
2012-01-30 7:57 ` [PATCH 6/7] Add hugetlb Kconfig option bill4carson at gmail.com
2012-01-30 7:57 ` [PATCH 7/7] Minor compiling fix bill4carson at gmail.com
2012-01-31 9:29 ` [RFC] ARM hugetlb support Catalin Marinas
2012-02-01 1:56 ` bill4carson
2012-02-02 14:38 ` Catalin Marinas
2012-02-03 1:41 ` bill4carson
2012-02-06 16:29 ` Catalin Marinas
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=1327910238-18704-5-git-send-email-bill4carson@gmail.com \
--to=bill4carson@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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 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.