[PATCH] [16/50] x86: Use macros to modify the PG_arch_1 page flags in change_page_attr

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <patches@...>, <linux-kernel@...>
Date: Friday, September 21, 2007 - 6:32 pm

Instead of open coding the bit accesses uses standard style
*PageDeferred* macros. 

Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/i386/mm/pageattr.c   |   10 +++++++---
 arch/x86_64/mm/pageattr.c |   11 ++++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)

Index: linux/arch/x86_64/mm/pageattr.c
===================================================================
--- linux.orig/arch/x86_64/mm/pageattr.c
+++ linux/arch/x86_64/mm/pageattr.c
@@ -17,6 +17,11 @@
 #define SetPageFlush(p) set_bit(PG_owner_priv_1, &(p)->flags)
 #define TestClearPageFlush(p) test_and_clear_bit(PG_owner_priv_1, &(p)->flags)
 
+#define PageDeferred(p) test_bit(PG_arch_1, &(p)->flags)
+#define SetPageDeferred(p) set_bit(PG_arch_1, &(p)->flags)
+#define ClearPageDeferred(p) clear_bit(PG_arch_1, &(p)->flags)
+#define TestSetPageDeferred(p) test_and_set_bit(PG_arch_1, &(p)->flags)
+
 pte_t *lookup_address(unsigned long address)
 { 
 	pgd_t *pgd = pgd_offset_k(address);
@@ -101,7 +106,7 @@ static inline void save_page(struct page
 {
 	if (data && cpu_has_clflush)
 		SetPageFlush(fpage);
-	if (test_and_set_bit(PG_arch_1, &fpage->flags))
+	if (TestSetPageDeferred(fpage))
 		return;
 	if (cpu_has_clflush || !data) 
 		list_add(&fpage->lru, &deferred_pages);
@@ -137,7 +142,7 @@ static struct page *flush_page(unsigned 
 	if (!(pfn_valid(__pa(address) >> PAGE_SHIFT)))
 		return NULL;
 	p = virt_to_page(address);
-	if ((PageFlush(p) || PageLRU(p)) && !test_bit(PG_arch_1, &p->flags))
+	if ((PageFlush(p) || PageLRU(p)) && !PageDeferred(p))
 		return NULL;
 	return p;
 }
@@ -272,7 +277,7 @@ void global_flush_tlb(void)
 
 	list_for_each_entry_safe(pg, next, &arg.l, lru) {
 		list_del(&pg->lru);
-		clear_bit(PG_arch_1, &pg->flags);
+		ClearPageDeferred(pg);
 		if (TestClearPageFlush(pg))
 			continue;
 		if (page_private(pg) != 0)
Index: linux/arch/i386/mm/pageattr.c
===================================================================
--- linux.orig/arch/i386/mm/pageattr.c
+++ linux/arch/i386/mm/pageattr.c
@@ -17,6 +17,10 @@
 #define PageFlush(p) test_bit(PG_owner_priv_1, &(p)->flags)
 #define SetPageFlush(p) set_bit(PG_owner_priv_1, &(p)->flags)
 #define TestClearPageFlush(p) test_and_clear_bit(PG_owner_priv_1, &(p)->flags)
+#define PageDeferred(p) test_bit(PG_arch_1, &(p)->flags)
+#define SetPageDeferred(p) set_bit(PG_arch_1, &(p)->flags)
+#define ClearPageDeferred(p) clear_bit(PG_arch_1, &(p)->flags)
+#define TestSetPageDeferred(p) test_and_set_bit(PG_arch_1, &(p)->flags)
 
 static DEFINE_SPINLOCK(cpa_lock);
 /* Both protected by cpa_lock */
@@ -152,7 +156,7 @@ static inline void save_page(struct page
 {
 	if (data && cpu_has_clflush)
 		SetPageFlush(fpage);
-	if (test_and_set_bit(PG_arch_1, &fpage->flags))
+	if (TestSetPageDeferred(fpage))
 		return;
 	if (!data || cpu_has_clflush)
 		list_add(&fpage->lru, &df_list);
@@ -164,7 +168,7 @@ static struct page *flush_page(unsigned 
 	if (!(pfn_valid(__pa(address) >> PAGE_SHIFT)))
 		return NULL;
 	p = virt_to_page(address);
-	if ((PageFlush(p) || PageLRU(p)) && !test_bit(PG_arch_1, &p->flags))
+	if ((PageFlush(p) || PageLRU(p)) && !PageDeferred(p))
 		return NULL;
 	return p;
 }
@@ -282,7 +286,7 @@ void global_flush_tlb(void)
 	on_each_cpu(flush_kernel_map, &arg, 1, 1);
 	list_for_each_entry_safe(pg, next, &arg.l, lru) {
 		list_del(&pg->lru);
-		clear_bit(PG_arch_1, &pg->flags);
+		ClearPageDeferred(pg);
 		if (TestClearPageFlush(pg))
 			continue;
 		if (PageReserved(pg) || !cpu_has_pse || page_private(pg) != 0)
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [0/50] x86 2.6.24 patches review II, Andi Kleen, (Fri Sep 21, 6:31 pm)
[PATCH] [50/50] x86_64: Remove fpu io port resource, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [42/50] i386: constify wd_ops, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [40/50] i386: Fix section mismatch, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [36/50] x86: Use raw locks during oopses, Andi Kleen, (Fri Sep 21, 6:32 pm)
Re: [PATCH] [34/50] i386: Fix argument signedness warnings, Jan Engelhardt, (Sat Sep 22, 6:01 am)
[PATCH] [30/50] x86_64: remove some dead code, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [28/50] i386: remove stub early_printk.c, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [22/50] i386: Misc cpuinit annotations, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [21/50] i386: Misc cpuinit annotations, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [16/50] x86: Use macros to modify the PG_arch_1 page..., Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [17/50] x86_64: remove STR() macros, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [6/50] i386: clean up oops/bug reports, Andi Kleen, (Fri Sep 21, 6:32 pm)
Re: [PATCH] [6/50] i386: clean up oops/bug reports, Chuck Ebbert, (Fri Sep 21, 6:41 pm)
Re: [PATCH] [6/50] i386: clean up oops/bug reports, Jan Engelhardt, (Sat Sep 22, 5:47 am)
[PATCH] [8/50] x86_64: remove x86_cpu_to_log_apicid, Andi Kleen, (Fri Sep 21, 6:32 pm)
[PATCH] [5/50] i386: change order in Kconfig.cpu, Andi Kleen, (Fri Sep 21, 6:32 pm)
Re: [PATCH] [4/50] x86: add cpu codenames for Kconfig.cpu, Thomas Gleixner, (Sat Sep 22, 1:50 pm)
Re: [PATCH] [4/50] x86: add cpu codenames for Kconfig.cpu, Jan Engelhardt, (Sat Sep 22, 5:46 am)
[PATCH] [3/50] x86_64: remove never used apic_mapped, Andi Kleen, (Fri Sep 21, 6:32 pm)