Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1440281 > unrolled thread

[PATCH 1/2] kexec: remove unnecessary unusable_pages

Started byzhongjiang <zhongjiang@huawei.com>
First post2016-07-11 08:50 +0200
Last post2016-07-12 04:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] kexec: remove unnecessary unusable_pages zhongjiang <zhongjiang@huawei.com> - 2016-07-11 08:50 +0200
    [PATCH 2/2] kexec: add a pmd huge entry condition during the page table zhongjiang <zhongjiang@huawei.com> - 2016-07-11 08:50 +0200
      Re: [PATCH 2/2] kexec: add a pmd huge entry condition during the  page table Andrew Morton <akpm@linux-foundation.org> - 2016-07-11 22:30 +0200
        Re: [PATCH 2/2] kexec: add a pmd huge entry condition during the  page table zhong jiang <zhongjiang@huawei.com> - 2016-07-12 04:30 +0200

#1440281 — [PATCH 1/2] kexec: remove unnecessary unusable_pages

Fromzhongjiang <zhongjiang@huawei.com>
Date2016-07-11 08:50 +0200
Subject[PATCH 1/2] kexec: remove unnecessary unusable_pages
Message-ID<rTDct-3r7-1@gated-at.bofh.it>
From: zhong jiang <zhongjiang@huawei.com>

In general, kexec alloc pages from buddy system, it cannot exceed
the physical address in the system.

The patch just remove this code, no functional change.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 include/linux/kexec.h |  1 -
 kernel/kexec_core.c   | 13 -------------
 2 files changed, 14 deletions(-)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index e8acb2b..26e4917 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -162,7 +162,6 @@ struct kimage {
 
 	struct list_head control_pages;
 	struct list_head dest_pages;
-	struct list_head unusable_pages;
 
 	/* Address of next control page to allocate for crash kernels. */
 	unsigned long control_page;
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 56b3ed0..448127d 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -257,9 +257,6 @@ struct kimage *do_kimage_alloc_init(void)
 	/* Initialize the list of destination pages */
 	INIT_LIST_HEAD(&image->dest_pages);
 
-	/* Initialize the list of unusable pages */
-	INIT_LIST_HEAD(&image->unusable_pages);
-
 	return image;
 }
 
@@ -517,10 +514,6 @@ static void kimage_free_extra_pages(struct kimage *image)
 {
 	/* Walk through and free any extra destination pages I may have */
 	kimage_free_page_list(&image->dest_pages);
-
-	/* Walk through and free any unusable pages I have cached */
-	kimage_free_page_list(&image->unusable_pages);
-
 }
 void kimage_terminate(struct kimage *image)
 {
@@ -647,12 +640,6 @@ static struct page *kimage_alloc_page(struct kimage *image,
 		page = kimage_alloc_pages(gfp_mask, 0);
 		if (!page)
 			return NULL;
-		/* If the page cannot be used file it away */
-		if (page_to_pfn(page) >
-				(KEXEC_SOURCE_MEMORY_LIMIT >> PAGE_SHIFT)) {
-			list_add(&page->lru, &image->unusable_pages);
-			continue;
-		}
 		addr = page_to_pfn(page) << PAGE_SHIFT;
 
 		/* If it is the destination page we want use it */
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1440282 — [PATCH 2/2] kexec: add a pmd huge entry condition during the page table

Fromzhongjiang <zhongjiang@huawei.com>
Date2016-07-11 08:50 +0200
Subject[PATCH 2/2] kexec: add a pmd huge entry condition during the page table
Message-ID<rTDcu-3r7-17@gated-at.bofh.it>
In reply to#1440281
From: zhong jiang <zhongjiang@huawei.com>

when image is loaded into kernel, we need set up page table for it.
and all valid pfn also set up new mapping. it will set up a pmd huge
entry if pud_present is true.  relocate_kernel points to code segment
can locate in the pmd huge entry in init_transtion_pgtable. therefore,
we need to take the situation into account.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 arch/x86/kernel/machine_kexec_64.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 5a294e4..c33e344 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -14,6 +14,7 @@
 #include <linux/gfp.h>
 #include <linux/reboot.h>
 #include <linux/numa.h>
+#include <linux/hugetlb.h>
 #include <linux/ftrace.h>
 #include <linux/io.h>
 #include <linux/suspend.h>
@@ -34,6 +35,17 @@ static struct kexec_file_ops *kexec_file_loaders[] = {
 };
 #endif
 
+static void split_pmd(pmd_t *pmd, pte_t *pte)
+{
+	unsigned long pfn = pmd_pfn(*pmd);
+	int i = 0;
+
+	do {
+		set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
+		pfn++;
+	} while (pte++, i++, i < PTRS_PER_PTE);
+}
+
 static void free_transition_pgtable(struct kimage *image)
 {
 	free_page((unsigned long)image->arch.pud);
@@ -68,15 +80,19 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd)
 		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE));
 	}
 	pmd = pmd_offset(pud, vaddr);
-	if (!pmd_present(*pmd)) {
+	if (!pmd_present(*pmd) || pmd_huge(*pmd)) {
 		pte = (pte_t *)get_zeroed_page(GFP_KERNEL);
 		if (!pte)
 			goto err;
 		image->arch.pte = pte;
-		set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
+		if (pmd_huge(*pmd))
+			split_pmd(pmd, pte);
+		else
+			set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
 	}
 	pte = pte_offset_kernel(pmd, vaddr);
 	set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
+
 	return 0;
 err:
 	free_transition_pgtable(image);
-- 
1.8.3.1

[toc] | [prev] | [next] | [standalone]


#1440860 — Re: [PATCH 2/2] kexec: add a pmd huge entry condition during the page table

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-07-11 22:30 +0200
SubjectRe: [PATCH 2/2] kexec: add a pmd huge entry condition during the page table
Message-ID<rTQ01-3tm-15@gated-at.bofh.it>
In reply to#1440282
On Mon, 11 Jul 2016 14:36:01 +0800 zhongjiang <zhongjiang@huawei.com> wrote:

> From: zhong jiang <zhongjiang@huawei.com>
> 
> when image is loaded into kernel, we need set up page table for it.
> and all valid pfn also set up new mapping. it will set up a pmd huge
> entry if pud_present is true.  relocate_kernel points to code segment
> can locate in the pmd huge entry in init_transtion_pgtable. therefore,
> we need to take the situation into account.

Sorry, I just don't understand this changelog.  The second sentence is
particularly hard.

So can you please have another attempt at preparing the changelog text?
The resend the patches and this time be sure to Cc the kexec
maintainers.  I suggest this list:

Cc: kexec@lists.infradead.org
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Simon Horman <horms@verge.net.au>

[toc] | [prev] | [next] | [standalone]


#1441030 — Re: [PATCH 2/2] kexec: add a pmd huge entry condition during the page table

Fromzhong jiang <zhongjiang@huawei.com>
Date2016-07-12 04:30 +0200
SubjectRe: [PATCH 2/2] kexec: add a pmd huge entry condition during the page table
Message-ID<rTVCq-79h-9@gated-at.bofh.it>
In reply to#1440860
On 2016/7/12 4:25, Andrew Morton wrote:
> On Mon, 11 Jul 2016 14:36:01 +0800 zhongjiang <zhongjiang@huawei.com> wrote:
>
>> From: zhong jiang <zhongjiang@huawei.com>
>>
>> when image is loaded into kernel, we need set up page table for it.
>> and all valid pfn also set up new mapping. it will set up a pmd huge
>> entry if pud_present is true.  relocate_kernel points to code segment
>> can locate in the pmd huge entry in init_transtion_pgtable. therefore,
>> we need to take the situation into account.
> Sorry, I just don't understand this changelog.  The second sentence is
> particularly hard.
>
> So can you please have another attempt at preparing the changelog text?
> The resend the patches and this time be sure to Cc the kexec
> maintainers.  I suggest this list:
>
> Cc: kexec@lists.infradead.org
> Cc: Eric Biederman <ebiederm@xmission.com>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Cc: Simon Horman <horms@verge.net.au>
>
>
> .
>
 ok ,  I will modify the changelog and resend to this list. thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web