Skip to contentSkip to conversation

Fixed kernel stuff

PATCH New Fernando Alencar Maróstica 2 participants 4 messages Oct 15, 2002 – Oct 21, 2002 2 messages not in the archive

Subsystems (7)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1034548634.543.1.camel@nitrogenium

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 Fixed kernel stuff

Hello all, specially David

I think this patch is trivial enough to be accepted, but...

This patch fixed some stuff:
* Fixed warning in script/lxdialog/menubox.c
* Fixed warning in script/lxdialog/textbox.c
* Small VM updates ...

Please apply.

best regards,

Signature · 7 lines
Fernando Alencar Maróstica
Graduate Student, Computer Science
Linux Register User Id #281457

University Methodist of Piracicaba
Departament of Computer Science
home: http://www.unimep.br/~famarost
#3 lore raw

PATCH 1/1 Fixed kernel stuff

In reply to a message not in the archive

Hello all, specially David

I think this patch is trivial enough to be accepted, but...

This patch fixed some stuff:
* Fixed warning in script/lxdialog/menubox.c
* Fixed warning in script/lxdialog/textbox.c
* Small VM updates ...

Please apply.

best regards,

Signature · 7 lines
Fernando Alencar Maróstica
Graduate Student, Computer Science
Linux Register User Id #281457

University Methodist of Piracicaba
Departament of Computer Science
home: http://www.unimep.br/~famarost
CREDITS +10 -0
diff -urN linux-2.0.39/CREDITS linux-2.0.39-patch/CREDITS
@@ -1409,6 +1409,16 @@
 S: Santa Clara, California 95051
 S: USA
 
+N: Fernando Alencar Maróstica
+E: [email protected]
+W: http://www.unimep.br/~famarost
+D: Miscellaneous kernel hacker
+S: UNIMEP University Methodist of Piracicaba
+S: Departament of Computer Science
+S: Rodovia do Açucar, Km 156
+S: 13400-911 - Piracicaba - São Paulo
+S: Brazil
+
 N: Jeff Tranter
 E: [email protected]
 D: Enhancements to Joystick driver
include/asm-i386/page.h +3 -0
diff -urN linux-2.0.39/include/asm-i386/page.h linux-2.0.39-patch/include/asm-i386/page.h
@@ -11,6 +11,9 @@
 
 #define STRICT_MM_TYPECHECKS
 
+#define clear_page(page)	memset((void *)(page), 0, PAGE_SIZE)
+#define copy_page(to,from)	memcpy((void *)(to), (void *)(from), PAGE_SIZE)
+
 #ifdef STRICT_MM_TYPECHECKS
 /*
  * These are used to make use of C type-checking..
include/asm-i386/pgtable.h +2 -2
diff -urN linux-2.0.39/include/asm-i386/pgtable.h linux-2.0.39-patch/include/asm-i386/pgtable.h
@@ -229,7 +229,7 @@
  * area for the same reason. ;)
  */
 #define VMALLOC_OFFSET	(8*1024*1024)
-#define VMALLOC_START ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
+#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
 #define VMALLOC_VMADDR(x) (TASK_SIZE + (unsigned long)(x))
 
 /*
@@ -302,7 +302,7 @@
 
 #define BAD_PAGETABLE __bad_pagetable()
 #define BAD_PAGE __bad_page()
-#define ZERO_PAGE ((unsigned long) empty_zero_page)
+#define ZERO_PAGE(vaddr) ((unsigned long) empty_zero_page)
 
 /* number of bits that fit into a memory pointer */
 #define BITS_PER_PTR			(8*sizeof(unsigned long))
mm/filemap.c +1 -1
diff -urN linux-2.0.39/mm/filemap.c linux-2.0.39-patch/mm/filemap.c
@@ -817,7 +817,7 @@
 	/*
 	 * No sharing ... copy to the new page.
 	 */
-	memcpy((void *) new_page, (void *) old_page, PAGE_SIZE);
+	copy_page(new_page, old_page);
 	flush_page_to_ram(new_page);
 	release_page(page);
 	return new_page;
mm/memory.c +8 -8
diff -urN linux-2.0.39/mm/memory.c linux-2.0.39-patch/mm/memory.c
@@ -57,18 +57,18 @@
  * a common occurrence (no need to read the page to know
  * that it's zero - better for the cache and memory subsystem).
  */
-static inline void copy_page(unsigned long from, unsigned long to)
+static inline void copy_cow_page(unsigned long from, unsigned long to)
 {
-	if (from == ZERO_PAGE) {
-		memset((void *) to, 0, PAGE_SIZE);
+	if (from == ZERO_PAGE(to)) {
+		clear_page(to);
 		return;
 	}
-	memcpy((void *) to, (void *) from, PAGE_SIZE);
+	copy_page(to,from);
 }
 
 #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
 
-mem_map_t * mem_map = NULL;
+mem_map_t *mem_map = NULL;
 
 /*
  * oom() prints a message (so that the user knows why the process died),
@@ -88,7 +88,7 @@
  */
 static inline void free_one_pmd(pmd_t * dir)
 {
-	pte_t * pte;
+	pte_t *pte;
 
 	if (pmd_none(*dir))
 		return;
@@ -632,7 +632,7 @@
 		if (new_page) {
 			if (PageReserved(mem_map + MAP_NR(old_page)))
 				++vma->vm_mm->rss;
-			copy_page(old_page,new_page);
+			copy_cow_page(old_page, new_page);
 			flush_page_to_ram(old_page);
 			flush_page_to_ram(new_page);
 			flush_cache_page(vma, address);
@@ -930,7 +930,7 @@
 		unsigned long page = __get_free_page(GFP_KERNEL);
 		if (!page)
 			goto sigbus;
-		memset((void *) page, 0, PAGE_SIZE);
+		clear_page(page);
 		entry = pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
 		vma->vm_mm->rss++;
 		tsk->min_flt++;
mm/page_alloc.c +1 -1
diff -urN linux-2.0.39/mm/page_alloc.c linux-2.0.39-patch/mm/page_alloc.c
@@ -42,7 +42,7 @@
 struct free_area_struct {
 	struct page *next;
 	struct page *prev;
-	unsigned int * map;
+	unsigned int *map;
 };
 
 #define memory_head(x) ((struct page *)(x))
mm/vmalloc.c +5 -3
diff -urN linux-2.0.39/mm/vmalloc.c linux-2.0.39-patch/mm/vmalloc.c
@@ -97,11 +97,12 @@
 static void free_area_pages(unsigned long address, unsigned long size)
 {
 	pgd_t * dir;
+	unsigned long start = address;
 	unsigned long end = address + size;
 
 	dir = pgd_offset(&init_mm, address);
 	flush_cache_all();
-	while (address < end) {
+	while (address >= start && address < end) {
 		free_area_pmd(dir, address, end - address);
 		address = (address + PGDIR_SIZE) & PGDIR_MASK;
 		dir++;
@@ -154,11 +155,12 @@
 static int alloc_area_pages(unsigned long address, unsigned long size)
 {
 	pgd_t * dir;
+	unsigned long start = address;
 	unsigned long end = address + size;
 
 	dir = pgd_offset(&init_mm, address);
 	flush_cache_all();
-	while (address < end) {
+	while (address >= start && address < end) {
 		pmd_t *pmd = pmd_alloc_kernel(dir, address);
 		if (!pmd)
 			return -ENOMEM;
@@ -250,7 +252,7 @@
 			break;
 		addr = (void *) (tmp->size + (unsigned long) tmp->addr);
 	}
-	area->addr = addr;
+	area->addr = (void *)addr;
 	area->next = *p;
 	*p = area;
 	return area;
mm/vmscan.c +1 -1
diff -urN linux-2.0.39/mm/vmscan.c linux-2.0.39-patch/mm/vmscan.c
@@ -461,7 +461,7 @@
 	
 	current->session = 1;
 	current->pgrp = 1;
-	sprintf(current->comm, "kswapd");
+	strcpy(current->comm, "kswapd");
 	current->blocked = ~0UL;
 	
 	/*
scripts/lxdialog/menubox.c +6 -3
diff -urN linux-2.0.39/scripts/lxdialog/menubox.c linux-2.0.39-patch/scripts/lxdialog/menubox.c
@@ -29,7 +29,7 @@
 static void
 print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey)
 {
-    int i, j;
+    int j;
     char menu_item[menu_width+1];
 
     strncpy(menu_item, item, menu_width);
@@ -40,8 +40,11 @@
     wattrset (win, menubox_attr);
     wmove (win, choice, 0);
 #if OLD_NCURSES
-    for (i = 0; i < menu_width; i++)
-	waddch (win, ' ');
+    {
+    	int i;
+	for (i = 0; i < menu_width; i++)
+		waddch (win, ' ');
+    }
 #else
     wclrtoeol(win);
 #endif
scripts/lxdialog/textbox.c +6 -3
diff -urN linux-2.0.39/scripts/lxdialog/textbox.c linux-2.0.39-patch/scripts/lxdialog/textbox.c
@@ -451,7 +451,7 @@
 static void
 print_line (WINDOW * win, int row, int width)
 {
-    int i, y, x;
+    int y, x;
     char *line;
 
     line = get_line ();
@@ -463,8 +463,11 @@
     getyx (win, y, x);
     /* Clear 'residue' of previous line */
 #if OLD_NCURSES
-    for (i = 0; i < width - x; i++)
-	waddch (win, ' ');
+    {
+	int i;	    
+    	for (i = 0; i < width - x; i++)
+		waddch (win, ' ');
+    }
 #else
     wclrtoeol(win);
 #endif
#4 lore raw
Quoted 8 lines · Fernando Alencar Maróstica

Hello all, specially David

I think this patch is trivial enough to be accepted, but...

This patch fixed some stuff:
* Fixed warning in script/lxdialog/menubox.c
* Fixed warning in script/lxdialog/textbox.c
* Small VM updates ...

Since you are doing changes to the VM, I would like detail descriptions of what each change does, and why it is necessary, stability- or security-wise. I will not accept changes to the VM subsystem unless there is a valid reason; let the early v2.4-series be witness to why this is a good stance.

Speedups are generally not counted as a valid reason, unless we're talking a change in the order of a magnitude or more. Code cleanup might be a good reason, but then I'll merge it into the 2.0.41-tree instead; this will probably be the case for your lxdialog-fixes, since I'm cleaning up that code anyway for 2.0.41.

Regards: David Weinehall

Signature · 3 lines
 /> David Weinehall <[email protected]> /> Northern lights wander      <\
//  Maintainer of the v2.0 kernel   //  Dance across the winter sky //
\>  http://www.acc.umu.se/~tao/    </   Full colour fire           </
#5 lore raw
Quoted 5 lines

Since you are doing changes to the VM, I would like detail descriptions of what each change does, and why it is necessary, stability- or security-wise. I will not accept changes to the VM subsystem unless there is a valid reason; let the early v2.4-series be witness to why this is a good stance.

David,

I've must install Linux on AMD386 DX40, HD Maxtor 160MB, 8MB RAM for this task i used kernel 2.0.39.

When I compiled kernel 2.0.39, I noticed some warnings which I corrected as mentioned previously.

Then I inspected the VM subsystem code, where found any stuff that could be cleanup and improved, such as:

+#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
+#define copy_page(to,from) memcpy((void *)(to), (void *)(from),
PAGE_SIZE)

Quoted 5 lines

Speedups are generally not counted as a valid reason, unless we're talking a change in the order of a magnitude or more. Code cleanup might be a good reason, but then I'll merge it into the 2.0.41-tree instead; this will probably be the case for your lxdialog-fixes, since I'm cleaning up that code anyway for 2.0.41.

LOL!
The main reason this patch is cleanup and better code standartize. I think thats code cleanup is good reason too!

Quoted 6 lines

Regards: David Weinehall

Signature · 3 lines
 /> David Weinehall <[email protected]> /> Northern lights wander      <\
//  Maintainer of the v2.0 kernel   //  Dance across the winter sky //
\>  http://www.acc.umu.se/~tao/    </   Full colour fire           </

Have fun!

Signature · 7 lines
Fernando Alencar Maróstica
Graduate Student, Computer Science
Linux Register User Id #281457

University Methodist of Piracicaba
Departament of Computer Science
home: http://www.unimep.br/~famarost