public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* forget_pte()
@ 2002-06-01 16:40 William Lee Irwin III
  2002-06-03  3:04 ` forget_pte() Rusty Russell
  2002-06-03  5:38 ` forget_pte() William Lee Irwin III
  0 siblings, 2 replies; 4+ messages in thread
From: William Lee Irwin III @ 2002-06-01 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: trivial, kernel-janitor-discuss

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.656   -> 1.657  
#	         mm/memory.c	1.70    -> 1.71   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/06/01	wli@holomorphy.com	1.657
# memory.c:
#   Fix stale comment around forget_pte() and change to a #define in order to get accurate line numbers for BUG(), also using BUG_ON().
# --------------------------------------------
#
diff -Nru a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c	Sat Jun  1 09:35:40 2002
+++ b/mm/memory.c	Sat Jun  1 09:35:40 2002
@@ -309,15 +309,12 @@
 }
 
 /*
- * Return indicates whether a page was freed so caller can adjust rss
+ * bug check to be sure pte's are unmapped when no longer used
  */
-static inline void forget_pte(pte_t page)
-{
-	if (!pte_none(page)) {
-		printk("forget_pte: old mapping existed!\n");
-		BUG();
-	}
-}
+#define forget_pte(pte)			\
+	do {				\
+		BUG_ON(!pte_none(pte));	\
+	} while (0)
 
 static void zap_pte_range(mmu_gather_t *tlb, pmd_t * pmd, unsigned long address, unsigned long size)
 {

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

* Re: forget_pte()
  2002-06-01 16:40 forget_pte() William Lee Irwin III
@ 2002-06-03  3:04 ` Rusty Russell
  2002-06-03  5:35   ` forget_pte() William Lee Irwin III
  2002-06-03  5:38 ` forget_pte() William Lee Irwin III
  1 sibling, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2002-06-03  3:04 UTC (permalink / raw)
  To: William Lee Irwin III; +Cc: linux-kernel, kernel-janitor-discuss

In message <20020601164002.GC10243@holomorphy.com> you write:
> diff -Nru a/mm/memory.c b/mm/memory.c
> --- a/mm/memory.c	Sat Jun  1 09:35:40 2002
> +++ b/mm/memory.c	Sat Jun  1 09:35:40 2002
> @@ -309,15 +309,12 @@
>  }
>  
>  /*
> - * Return indicates whether a page was freed so caller can adjust rss
> + * bug check to be sure pte's are unmapped when no longer used
>   */
> -static inline void forget_pte(pte_t page)
> -{
> -	if (!pte_none(page)) {
> -		printk("forget_pte: old mapping existed!\n");
> -		BUG();
> -	}
> -}
> +#define forget_pte(pte)			\
> +	do {				\
> +		BUG_ON(!pte_none(pte));	\
> +	} while (0)

Hmm... it's only used in two places, and the name is entirely
misleading.  I think it might be neater to replace those two
occurances with:

	/* PTEs must be unmapped */
	BUG_ON(!pte_none(pte));

Cheers,
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

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

* Re: forget_pte()
  2002-06-03  3:04 ` forget_pte() Rusty Russell
@ 2002-06-03  5:35   ` William Lee Irwin III
  0 siblings, 0 replies; 4+ messages in thread
From: William Lee Irwin III @ 2002-06-03  5:35 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel, kernel-janitor-discuss

On Mon, Jun 03, 2002 at 01:04:03PM +1000, Rusty Russell wrote:
> Hmm... it's only used in two places, and the name is entirely
> misleading.  I think it might be neater to replace those two
> occurances with:
> 
> 	/* PTEs must be unmapped */
> 	BUG_ON(!pte_none(pte));
> Cheers,
> Rusty.

I'll send a patch replacing it with that open-coded at the call sites
in short order, then.

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

* Re: forget_pte()
  2002-06-01 16:40 forget_pte() William Lee Irwin III
  2002-06-03  3:04 ` forget_pte() Rusty Russell
@ 2002-06-03  5:38 ` William Lee Irwin III
  1 sibling, 0 replies; 4+ messages in thread
From: William Lee Irwin III @ 2002-06-03  5:38 UTC (permalink / raw)
  To: linux-kernel, trivial, kernel-janitor-discuss

On Sat, Jun 01, 2002 at 09:40:02AM -0700, William Lee Irwin III wrote:
...

patch updated to incorporate rusty's suggestion:


===== mm/memory.c 1.70 vs edited =====
--- 1.70/mm/memory.c	Fri May 31 18:18:07 2002
+++ edited/mm/memory.c	Sun Jun  2 22:37:17 2002
@@ -310,17 +310,6 @@
 	return -ENOMEM;
 }
 
-/*
- * Return indicates whether a page was freed so caller can adjust rss
- */
-static inline void forget_pte(pte_t page)
-{
-	if (!pte_none(page)) {
-		printk("forget_pte: old mapping existed!\n");
-		BUG();
-	}
-}
-
 static void zap_pte_range(mmu_gather_t *tlb, pmd_t * pmd, unsigned long address, unsigned long size)
 {
 	unsigned long offset;
@@ -779,7 +768,8 @@
 		pte_t zero_pte = pte_wrprotect(mk_pte(ZERO_PAGE(address), prot));
 		pte_t oldpage = ptep_get_and_clear(pte);
 		set_pte(pte, zero_pte);
-		forget_pte(oldpage);
+		/* PTE's must be unmapped */
+		BUG_ON(!pte_none(oldpage));
 		address += PAGE_SIZE;
 		pte++;
 	} while (address && (address < end));
@@ -857,7 +847,8 @@
 
 		if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
  			set_pte(pte, pfn_pte(pfn, prot));
-		forget_pte(oldpage);
+		/* PTE's must be unmapped */
+		BUG_ON(!pte_none(oldpage));
 		address += PAGE_SIZE;
 		pfn++;
 		pte++;

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

end of thread, other threads:[~2002-06-03  5:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-01 16:40 forget_pte() William Lee Irwin III
2002-06-03  3:04 ` forget_pte() Rusty Russell
2002-06-03  5:35   ` forget_pte() William Lee Irwin III
2002-06-03  5:38 ` forget_pte() William Lee Irwin III

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