linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Max <max@Linuz.sns.it>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Andrea Arcangeli <andrea@e-mind.com>, linux-mm@kvack.org
Subject: tiny patch, reduces kernel memory usage (memory_save patch)
Date: Sun, 10 Jan 1999 18:00:52 +0100 (MET)	[thread overview]
Message-ID: <Pine.LNX.3.96.990110174423.15469A-100000@Linuz.sns.it> (raw)

[-- 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++) {

             reply	other threads:[~1999-01-10 17:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-10 17:00 Max [this message]
1999-01-10 18:11 ` Andrea Arcangeli
1999-01-10 21:49 ` Stephen C. Tweedie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.3.96.990110174423.15469A-100000@Linuz.sns.it \
    --to=max@linuz.sns.it \
    --cc=andrea@e-mind.com \
    --cc=linux-mm@kvack.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox