Skip to contentSkip to conversation

PATCH: Making the VM pressure consistent for dcache and icache

PATCH Juan J. Quintela 1 participant 1 message May 22, 2000

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

Hi
I have made a patch to make the pressure for freeing pages
consistent with the rest of the kernel for the dcache and the icache. In the rest of the kernel we do:

count = number allocated / (priority + 1)

This also removes the need for the if's. It is some reason to have the code this way, or it is better to make the same pressure to all the subsystems?

Comment?

Later, Juan.

PD. I have sent the patch also to Al Viro because I don't know if the
patches about the dcache, icache are sent through Al Viro or directly to Linus.

fs/dcache.c +1 -3
diff -urN --exclude-from=/home/lfcia/quintela/work/kernel/exclude base/fs/dcache.c testing/fs/dcache.c
@@ -494,10 +494,8 @@
  */
 int shrink_dcache_memory(int priority, unsigned int gfp_mask)
 {
-	int count = 0;
+	int count = dentry_stat.nr_unused / (priority + 1);
 	lock_kernel();
-	if (priority)
-		count = dentry_stat.nr_unused / priority;
 	prune_dcache(count);
 	unlock_kernel();
 	/* FIXME: kmem_cache_shrink here should tell us
fs/inode.c +4 -9
diff -urN --exclude-from=/home/lfcia/quintela/work/kernel/exclude base/fs/inode.c testing/fs/inode.c
@@ -411,11 +411,10 @@
 	(((inode)->i_state | (inode)->i_data.nrpages) == 0)
 #define INODE(entry)	(list_entry(entry, struct inode, i_list))
 
-void prune_icache(int goal)
+void prune_icache(int count)
 {
 	LIST_HEAD(list);
 	struct list_head *entry, *freeable = &list;
-	int count = 0;
 	struct inode * inode;
 
 	spin_lock(&inode_lock);
@@ -440,11 +439,10 @@
 		INIT_LIST_HEAD(&inode->i_hash);
 		list_add(tmp, freeable);
 		inode->i_state |= I_FREEING;
-		count++;
-		if (!--goal)
+		inodes_stat.nr_unused--;
+		if (!--count)
 			break;
 	}
-	inodes_stat.nr_unused -= count;
 	spin_unlock(&inode_lock);
 
 	dispose_list(freeable);
@@ -452,10 +450,7 @@
 
 int shrink_icache_memory(int priority, int gfp_mask)
 {
-	int count = 0;
-		
-	if (priority)
-		count = inodes_stat.nr_unused / priority;
+	int count = inodes_stat.nr_unused / (priority + 1);
 	prune_icache(count);
 	/* FIXME: kmem_cache_shrink here should tell us
 	   the number of pages freed, and it should
Signature · 6 lines
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/