Re: reduce fragmentation: patch for 2.1.108 fs/namei.c

Andi Kleen (ak@muc.de)
15 Jul 1998 17:25:53 +0200


Bill Hawes <whawes@star.net> writes:

> With the recent concern for memory fragmentation I thought it would be
> helpful to reexamine the places where memory is allocated without a
> means of freeing it.
>
> One of these is in the fs/namei.c "quicklist" for getname; pages are
> allocated and cached without even an upper bound on the count. Since the
> getname quicklist is just a performance optimization and the pages in it
> are unused, it's trivial to free them, so I think it makes sense to
> release the whole list when the system starts swapping.

I think it would be better to just remove the quicklist altogether. If
you look at the path in __get_free_page() it doesn't add too much overhead,
and I think preventing L1 icache pollution should always have priority :)

Here is an alternative patch. It survived the compile-boot-run test so far.

--- linux/fs/namei.c-o Wed Jul 15 18:00:13 1998
+++ linux/fs/namei.c Wed Jul 15 18:01:48 1998
@@ -87,50 +87,16 @@
* semantics. See the comments in "open_namei" and "do_link" below.
*/

-char * getname_quicklist = NULL;
-int getname_quickcount = 0;
-spinlock_t getname_quicklock = SPIN_LOCK_UNLOCKED;
-
-/* Tuning: increase locality by reusing same pages again...
- * if getname_quicklist becomes too long on low memory machines, either a limit
- * should be added or after a number of cycles some pages should
- * be released again ...
- */
static inline char * get_page(void)
{
char * res;
- spin_lock(&getname_quicklock);
- res = getname_quicklist;
- if (res) {
-#ifdef DEBUG
- char * tmp = res;
- int i;
- for(i=0; i<getname_quickcount; i++)
- tmp = *(char**)tmp;
- if (tmp)
- printk("bad quicklist %x\n", (int)tmp);
-#endif
- getname_quicklist = *(char**)res;
- getname_quickcount--;
- }
- spin_unlock(&getname_quicklock);
- if (!res)
- res = (char*)__get_free_page(GFP_KERNEL);
+ res = (char*)__get_free_page(GFP_KERNEL);
return res;
}

inline void putname(char * name)
{
- if (name) {
- spin_lock(&getname_quicklock);
- *(char**)name = getname_quicklist;
- getname_quicklist = name;
- getname_quickcount++;
- spin_unlock(&getname_quicklock);
- }
- /* if a getname_quicklist limit is necessary to introduce, call
- * free_page((unsigned long) name);
- */
+ free_page((unsigned long) name);
}

/* In order to reduce some races, while at the same time doing additional

-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html