linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* tiny patch, reduces kernel memory usage (memory_save patch)
@ 1999-01-10 17:00 Max
  1999-01-10 18:11 ` Andrea Arcangeli
  1999-01-10 21:49 ` Stephen C. Tweedie
  0 siblings, 2 replies; 3+ messages in thread
From: Max @ 1999-01-10 17:00 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrea Arcangeli, linux-mm

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3446 bytes --]


I am really sorry to disturb with something that is supposed to be discussed
in linux-kernel, but looks linux-kernel is terribly lagged, and also my
original message (sent on Jan 7) got somehow ignored.

This patch reduces kernel memory usage of 4kb for every 2Mb of physical RAM.
On my 16Mb box this means the kernel uses 32kb less memory, and on a typical
64Mb Intel you save 128kb.

The patch attached is for 2.2.0-pre4, but I couldn't test it yet, sorry.
(I hope it patches 2.2.0-pre5 cleanly too)
I have tested the patch on 2.0.36 and 2.1.119, and it worked for me.
Anyway the patch is so straightforward that it really should give no problems.

Bye,

                        Massimiliano Ghilardi


diff -urN linux-2.2.0-pre4/include/linux/mm.h linux-mine/include/linux/mm.h
--- linux-2.2.0-pre4/include/linux/mm.h	Fri Jan  1 20:56:22 1999
+++ linux-mine/include/linux/mm.h	Thu Jan  7 16:41:35 1999
@@ -118,12 +118,10 @@
 	unsigned long offset;
 	struct page *next_hash;
 	atomic_t count;
-	unsigned int unused;
	unsigned long flags;	/* atomic flags, some possibly updated asynchronously */
 	struct wait_queue *wait;
 	struct page **pprev_hash;
 	struct buffer_head * buffers;
-	unsigned long map_nr;	/* page->map_nr == page - mem_map */
 } mem_map_t;
 
 /* Page flag bit values */
diff -urN linux-2.2.0-pre4/include/linux/pagemap.h linux-mine/include/linux/pagemap.h
--- linux-2.2.0-pre4/include/linux/pagemap.h	Fri Jan  1 20:56:22 1999
+++ linux-mine/include/linux/pagemap.h	Thu Jan  7 16:45:56 1999
@@ -14,7 +14,7 @@
 
 static inline unsigned long page_address(struct page * page)
 {
-	return PAGE_OFFSET + PAGE_SIZE * page->map_nr;
+	return PAGE_OFFSET + PAGE_SIZE * (page - mem_map);
 }
 
 #define PAGE_HASH_BITS 11
diff -urN linux-2.2.0-pre4/include/linux/version.h linux-mine/include/linux/version.h
--- linux-2.2.0-pre4/include/linux/version.h	Thu Jan  1 01:00:00 1970
+++ linux-mine/include/linux/version.h	Thu Jan  7 16:46:58 1999
@@ -0,0 +1,3 @@
+#define UTS_RELEASE "2.2.0-pre4"
+#define LINUX_VERSION_CODE 131584
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff -urN linux-2.2.0-pre4/mm/filemap.c linux-mine/mm/filemap.c
--- linux-2.2.0-pre4/mm/filemap.c	Fri Jan  1 00:15:17 1999
+++ linux-mine/mm/filemap.c	Thu Jan  7 16:46:22 1999
@@ -138,7 +138,7 @@
 		if (PageSkip(page)) {
 			/* next_hash is overloaded for PageSkip */
 			page = page->next_hash;
-			clock = page->map_nr;
+			clock = page - mem_map;
 		}
 		
 		if (test_and_clear_bit(PG_referenced, &page->flags))
diff -urN linux-2.2.0-pre4/mm/page_alloc.c linux-mine/mm/page_alloc.c
--- linux-2.2.0-pre4/mm/page_alloc.c	Sun Jan  3 04:02:16 1999
+++ linux-mine/mm/page_alloc.c	Thu Jan  7 16:44:19 1999
@@ -152,7 +152,7 @@
 		if (PageSwapCache(page))
 			panic ("Freeing swap cache page");
 		page->flags &= ~(1 << PG_referenced);
-		free_pages_ok(page->map_nr, 0);
+		free_pages_ok(page - mem_map, 0);
 		return;
 	}
 #if 0
@@ -201,7 +201,7 @@
 			if (!dma || CAN_DMA(ret)) { \
 				unsigned long map_nr; \
 				(prev->next = ret->next)->prev = prev; \
-				map_nr = ret->map_nr; \
+				map_nr = ret - mem_map; \
 				MARK_USED(map_nr, new_order, area); \
 				nr_free_pages -= 1 << order; \
 				EXPAND(ret, map_nr, order, new_order, area); \
@@ -363,7 +363,6 @@
 		--p;
 		atomic_set(&p->count, 0);
 		p->flags = (1 << PG_DMA) | (1 << PG_reserved);
-		p->map_nr = p - mem_map;
 	} while (p > mem_map);
 
 	for (i = 0 ; i < NR_MEM_LISTS ; i++) {

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

end of thread, other threads:[~1999-01-10 21:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-10 17:00 tiny patch, reduces kernel memory usage (memory_save patch) Max
1999-01-10 18:11 ` Andrea Arcangeli
1999-01-10 21:49 ` Stephen C. Tweedie

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