Skip to contentSkip to conversation

Use names, not numbers for pagefault types

PATCH In review Andrew Morton 1 participant 1 message Jul 4, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 27/27 Use names, not numbers for pagefault types

This is Bill Irwin's cleanup patch which gives symbolic names to the fault types:

	#define VM_FAULT_OOM	(-1)
	#define VM_FAULT_SIGBUS	0
	#define VM_FAULT_MINOR	1
	#define VM_FAULT_MAJOR	2

Only arch/i386 has been updated - other architectures can do this too.

 arch/i386/mm/fault.c |   34 +++++++++++++++------------
 include/linux/mm.h   |   10 +++++++
 mm/memory.c          |   64 ++++++++++++++++++++++++++++-----------------------
 3 files changed, 66 insertions(+), 42 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~fault-type-cleanup +10 -0
@@ -305,6 +305,16 @@ static inline void set_page_zone(struct 
 #define NOPAGE_SIGBUS	(NULL)
 #define NOPAGE_OOM	((struct page *) (-1))
 
+/*
+ * Different kinds of faults, as returned by handle_mm_fault().
+ * Used to decide whether a process gets delivered SIGBUS or
+ * just gets major/minor fault counters bumped up.
+ */
+#define VM_FAULT_OOM	(-1)
+#define VM_FAULT_SIGBUS	0
+#define VM_FAULT_MINOR	1
+#define VM_FAULT_MAJOR	2
+
 /* The array of struct pages */
 extern struct page *mem_map;
 
mm/memory.c renamed from mm/memory.c~fault-type-cleanup +36 -28

169 lines not on this page · raw message

arch/i386/mm/fault.c renamed from arch/i386/mm/fault.c~fault-type-cleanup +20 -14
@@ -56,12 +56,16 @@ good_area:
 
 	for (;;) {
 	survive:
-		{
-			int fault = handle_mm_fault(current->mm, vma, start, 1);
-			if (!fault)
+		switch (handle_mm_fault(current->mm, vma, start, 1)) {
+			case VM_FAULT_SIGBUS:
 				goto bad_area;
-			if (fault < 0)
+			case VM_FAULT_OOM:
 				goto out_of_memory;
+			case VM_FAULT_MINOR:
+			case VM_FAULT_MAJOR:
+				break;
+			default:
+				BUG();
 		}
 		if (!size)
 			break;
@@ -239,16 +243,18 @@ good_area:
 	 * the fault.
 	 */
 	switch (handle_mm_fault(mm, vma, address, write)) {
-	case 1:
-		tsk->min_flt++;
-		break;
-	case 2:
-		tsk->maj_flt++;
-		break;
-	case 0:
-		goto do_sigbus;
-	default:
-		goto out_of_memory;
+		case VM_FAULT_MINOR:
+			tsk->min_flt++;
+			break;
+		case VM_FAULT_MAJOR:
+			tsk->maj_flt++;
+			break;
+		case VM_FAULT_SIGBUS:
+			goto do_sigbus;
+		case VM_FAULT_OOM:
+			goto out_of_memory;
+		default:
+			BUG();
 	}
 
 	/*

-