[dovecot-cvs] dovecot/src/lib file-cache.c,1.1,1.2

cras at dovecot.org cras at dovecot.org
Mon Nov 8 03:02:55 EET 2004


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv19145/lib

Modified Files:
	file-cache.c 
Log Message:
Use madvise(MADV_DONTNEED) for invalidated pages to free memory.



Index: file-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/file-cache.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- file-cache.c	8 Nov 2004 00:40:36 -0000	1.1
+++ file-cache.c	8 Nov 2004 01:02:52 -0000	1.2
@@ -171,6 +171,15 @@
 	offset /= page_size;
 	size -= offset;
 
+	if (size != 1) {
+		/* tell operating system that we don't need the memory anymore
+		   and it may free it. don't bother to do it for single pages,
+		   there's a good chance that they get re-read back
+		   immediately. */
+		(void)madvise(PTR_OFFSET(cache->mmap_base, offset * page_size),
+			      size * page_size, MADV_DONTNEED);
+	}
+
 	bits = buffer_get_space_unsafe(cache->page_bitmask, offset / CHAR_BIT,
 				       (size + CHAR_BIT - 1) / CHAR_BIT);
 



More information about the dovecot-cvs mailing list