public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/2] x86_64: pageattr cleanups
@ 2006-01-18 15:03 Nick Piggin
  2006-01-18 15:03 ` [patch 1/2] x86_64: pageattr use single list Nick Piggin
  2006-01-18 15:03 ` [patch 2/2] x86_64: pageattr remove __put_page Nick Piggin
  0 siblings, 2 replies; 5+ messages in thread
From: Nick Piggin @ 2006-01-18 15:03 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Nick Piggin, Andrew Morton

The following patches remove __put_page from x86-64 pageattr.c and tidies
it up a bit. They've had some testing.

Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch 1/2] x86_64: pageattr use single list
  2006-01-18 15:03 [patch 0/2] x86_64: pageattr cleanups Nick Piggin
@ 2006-01-18 15:03 ` Nick Piggin
  2006-01-18 19:38   ` Jason Baron
  2006-01-18 15:03 ` [patch 2/2] x86_64: pageattr remove __put_page Nick Piggin
  1 sibling, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2006-01-18 15:03 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Nick Piggin, Andrew Morton

Use page->lru.next to implement the singly linked list of pages rather
than the struct deferred_page which needs to be allocated and freed for
each page.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Acked-by: Andi Kleen <ak@suse.de>

Index: linux-2.6/arch/x86_64/mm/pageattr.c
===================================================================
--- linux-2.6.orig/arch/x86_64/mm/pageattr.c
+++ linux-2.6/arch/x86_64/mm/pageattr.c
@@ -77,26 +77,12 @@ static inline void flush_map(unsigned lo
 	on_each_cpu(flush_kernel_map, (void *)address, 1, 1);
 }
 
-struct deferred_page { 
-	struct deferred_page *next; 
-	struct page *fpage;
-	unsigned long address;
-}; 
-static struct deferred_page *df_list; /* protected by init_mm.mmap_sem */
+static struct page *deferred_pages; /* protected by init_mm.mmap_sem */
 
-static inline void save_page(unsigned long address, struct page *fpage)
+static inline void save_page(struct page *fpage)
 {
-	struct deferred_page *df;
-	df = kmalloc(sizeof(struct deferred_page), GFP_KERNEL); 
-	if (!df) {
-		flush_map(address);
-		__free_page(fpage);
-	} else { 
-		df->next = df_list;
-		df->fpage = fpage;
-		df->address = address;
-		df_list = df;
-	} 			
+	fpage->lru.next = (struct list_head *)deferred_pages;
+	deferred_pages = fpage;
 }
 
 /* 
@@ -163,7 +149,7 @@ __change_page_attr(unsigned long address
 
 	switch (page_count(kpte_page)) {
  	case 1:
-		save_page(address, kpte_page); 		     
+		save_page(kpte_page);
 		revert_page(address, ref_prot);
 		break;
  	case 0:
@@ -220,17 +206,16 @@ int change_page_attr(struct page *page, 
 
 void global_flush_tlb(void)
 { 
-	struct deferred_page *df, *next_df;
+	struct page *dpage;
 
 	down_read(&init_mm.mmap_sem);
-	df = xchg(&df_list, NULL);
+	dpage = xchg(&deferred_pages, NULL);
 	up_read(&init_mm.mmap_sem);
-	flush_map((df && !df->next) ? df->address : 0);
-	for (; df; df = next_df) { 
-		next_df = df->next;
-		if (df->fpage) 
-			__free_page(df->fpage);
-		kfree(df);
+
+	flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0);
+	while (dpage) {
+		__free_page(dpage);
+		dpage = (struct page *)dpage->lru.next;
 	} 
 } 
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch 2/2] x86_64: pageattr remove __put_page
  2006-01-18 15:03 [patch 0/2] x86_64: pageattr cleanups Nick Piggin
  2006-01-18 15:03 ` [patch 1/2] x86_64: pageattr use single list Nick Piggin
@ 2006-01-18 15:03 ` Nick Piggin
  1 sibling, 0 replies; 5+ messages in thread
From: Nick Piggin @ 2006-01-18 15:03 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Nick Piggin, Andrew Morton

Remove page_count and __put_page from x86-64 pageattr

Signed-off-by: Nick Piggin <npiggin@suse.de>
Acked-by: Andi Kleen <ak@suse.de>

Index: linux-2.6/arch/x86_64/mm/pageattr.c
===================================================================
--- linux-2.6.orig/arch/x86_64/mm/pageattr.c
+++ linux-2.6/arch/x86_64/mm/pageattr.c
@@ -45,6 +45,9 @@ static struct page *split_large_page(uns
 	pte_t *pbase;
 	if (!base) 
 		return NULL;
+	SetPagePrivate(base);
+	page_private(base) = 0;
+
 	address = __pa(address);
 	addr = address & LARGE_PAGE_MASK; 
 	pbase = (pte_t *)page_address(base);
@@ -137,23 +140,20 @@ __change_page_attr(unsigned long address
 			set_pte(kpte,mk_pte(split, ref_prot2));
 			kpte_page = split;
 		}	
-		get_page(kpte_page);
+		page_private(kpte_page)++;
 	} else if ((kpte_flags & _PAGE_PSE) == 0) { 
 		set_pte(kpte, pfn_pte(pfn, ref_prot));
-		__put_page(kpte_page);
+		BUG_ON(page_private(kpte_page) == 0);
+		page_private(kpte_page)--;
 	} else
 		BUG();
 
 	/* on x86-64 the direct mapping set at boot is not using 4k pages */
  	BUG_ON(PageReserved(kpte_page));
 
-	switch (page_count(kpte_page)) {
- 	case 1:
+	if (page_private(kpte_page) == 0) {
 		save_page(kpte_page);
 		revert_page(address, ref_prot);
-		break;
- 	case 0:
- 		BUG(); /* memleak and failed 2M page regeneration */
  	}
 	return 0;
 } 
@@ -214,6 +214,7 @@ void global_flush_tlb(void)
 
 	flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0);
 	while (dpage) {
+		ClearPagePrivate(dpage);
 		__free_page(dpage);
 		dpage = (struct page *)dpage->lru.next;
 	} 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch 1/2] x86_64: pageattr use single list
  2006-01-18 15:03 ` [patch 1/2] x86_64: pageattr use single list Nick Piggin
@ 2006-01-18 19:38   ` Jason Baron
  2006-01-19 14:01     ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Baron @ 2006-01-18 19:38 UTC (permalink / raw)
  To: Nick Piggin; +Cc: Linux Kernel Mailing List, Andrew Morton


On Wed, 18 Jan 2006, Nick Piggin wrote:

> Use page->lru.next to implement the singly linked list of pages rather
> than the struct deferred_page which needs to be allocated and freed for
> each page.
> 
> Signed-off-by: Nick Piggin <npiggin@suse.de>
> Acked-by: Andi Kleen <ak@suse.de>
> 
> Index: linux-2.6/arch/x86_64/mm/pageattr.c
> ===================================================================

...

> +
> +	flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0);
> +	while (dpage) {
> +		__free_page(dpage);
> +		dpage = (struct page *)dpage->lru.next;
>  	} 
>  } 
>  

do you want to be touching a struct page that was just freed?

-Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch 1/2] x86_64: pageattr use single list
  2006-01-18 19:38   ` Jason Baron
@ 2006-01-19 14:01     ` Nick Piggin
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Piggin @ 2006-01-19 14:01 UTC (permalink / raw)
  To: Jason Baron; +Cc: Nick Piggin, Linux Kernel Mailing List, Andrew Morton

On Wed, Jan 18, 2006 at 02:38:11PM -0500, Jason Baron wrote:
> 
> On Wed, 18 Jan 2006, Nick Piggin wrote:
> 
> > Use page->lru.next to implement the singly linked list of pages rather
> > than the struct deferred_page which needs to be allocated and freed for
> > each page.
> > 
> > Signed-off-by: Nick Piggin <npiggin@suse.de>
> > Acked-by: Andi Kleen <ak@suse.de>
> > 
> > Index: linux-2.6/arch/x86_64/mm/pageattr.c
> > ===================================================================
> 
> ...
> 
> > +
> > +	flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0);
> > +	while (dpage) {
> > +		__free_page(dpage);
> > +		dpage = (struct page *)dpage->lru.next;
> >  	} 
> >  } 
> >  
> 
> do you want to be touching a struct page that was just freed?
> 

No, thanks. Good catch.

Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-01-19 14:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-18 15:03 [patch 0/2] x86_64: pageattr cleanups Nick Piggin
2006-01-18 15:03 ` [patch 1/2] x86_64: pageattr use single list Nick Piggin
2006-01-18 19:38   ` Jason Baron
2006-01-19 14:01     ` Nick Piggin
2006-01-18 15:03 ` [patch 2/2] x86_64: pageattr remove __put_page Nick Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox