tiny MM performance and typo patches for 2.4.2
Subsystems (2)
PATCH 1/1 tiny MM performance and typo patches for 2.4.2
Hi folks,
this is a list of patches I collected while looking at the memory management sources. Two patches might improve the performance of your box. The others are more or less cosmetic.
This mail is sent with a kernel using these patches. Here is a list sorted with decreasing importance:
patch-uk2 makes use of the pgd, pmd and pte quicklists for x86 too;
risky: there might be a reason that 2.4.x doesn't use the quicklists.
patch-uk6 In 2.4.x _page_hashfn divides struct address_space pointer
with a parameter derived from the size of struct inode. Deriving this parameter from the size of struct address_space makes more sense -- at least for me.
patch-uk5 cleans the bd_flush_param union.
patch-uk1 fixes a comment typo in asm-i386/highmem.h.
patch-uk3 fixes a comment typo in asm-i386/pgtable-3level.h.
Ciao,
Uli Kunitz
Signature · 1 line
Ulrich Kunitz ([email protected])
include/asm-i386/pgalloc.h +4 -4
@@ -92,9 +92,9 @@free_page ((unsigned long )pte); } -#define pte_free_kernel (pte) free_pte_slow(pte) -#define pte_free (pte) free_pte_slow(pte) -#define pgd_free (pgd) free_pgd_slow(pgd) +#define pte_free_kernel (pte) free_pte_fast(pte) +#define pte_free (pte) free_pte_fast(pte) +#define pgd_free (pgd) free_pgd_fast(pgd)#define pgd_alloc () get_pgd_fast()extern inline pte_t *pte_alloc_kernel (pmd_t * pmd,unsigned long address)
@@ -145,7 +145,7 @@* inside the pgd, so has no extra memory associated with it. * (In the PAE case we free the page.) */ -#define pmd_free (pmd) free_pmd_slow(pmd) +#define pmd_free (pmd) free_pmd_fast(pmd)#define pmd_free_kernel pmd_free#define pmd_alloc_kernel pmd_alloc
include/linux/pagemap.h +2 -1
@@ -58,7 +58,8 @@*/ extern inline unsigned long _page_hashfn (struct address_space * mapping,unsigned long index) { -#define i (((unsigned long) mapping)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1))) +#define i (((unsigned long) mapping) / \ + (sizeof(struct address_space) & ~ (sizeof(struct address_space) - 1)))#define s (x) ((x)+((x)>>PAGE_HASH_BITS))return s (i+index) & (PAGE_HASH_SIZE -1 );#undef i
fs/buffer.c +6 -7
@@ -112,19 +112,18 @@*/ union bdflush_param {struct { -int nfract;/* Percentage of buffer cache dirty to -activate bdflush */ -int ndirty;/* Maximum number of dirty blocks to write out per +int nfract;/* Percentage of buffer cache dirty to +activate bdflush */ +int ndirty;/* Maximum number of dirty blocks to write out per wake-cycle */ -int nrefill;/* Number of clean buffers to try to obtain -each time we call refill */ int dummy1;/* unused */ +int dummy2;/* unused */ int interval;/* jiffies delay between kupdate flushes */ int age_buffer;/* Time for normal buffer to age before we flush it */ int nfract_sync;/* Percentage of buffer cache dirty to activate bdflush synchronously */ -int dummy2;/* unused */ -int dummy3;/* unused */ +int dummy3;/* unused */ +int dummy4;/* unused */ } b_un;unsigned int data[N_PARAM ]; } bdf_prm = {{30 ,64 ,64 ,256 ,5 *HZ ,30 *HZ ,60 ,0 ,0 }};
include/asm-i386/highmem.h +1 -1
@@ -9,7 +9,7 @@* * * Redesigned the x86 32-bit VM architecture to deal with -* up to 16 Terrabyte physical memory. With current x86 CPUs +* up to 16 Terabyte physical memory. With current x86 CPUs * we now support up to 64 Gigabytes physical RAM. * * Copyright (C) 1999 Ingo Molnar <[email protected]>
include/asm-i386/pgtable-3level.h +1 -1
@@ -48,7 +48,7 @@/* Rules for using set_pte: the pte being assigned *must* be * either not present or in a state where the hardware will * not attempt to update the pte. In places where this is -* not possible, use pte_get_and_clear to obtain the old pte +* not possible, use ptep_get_and_clear to obtain the old pte * value and then use set_pte to update it. -ben */ static inline void set_pte (pte_t *ptep,pte_t pte)
Quoted 4 lines · Ulrich Kunitz
patch-uk6 In 2.4.x
_page_hashfndivides structaddress_spacepointer
with a parameter derived from the size of struct inode. Deriving this parameter from the size of structaddress_spacemakes more sense -- at least for me.
The address_space is %99 of the time (unless swapping, and in that case the address is constant :-)) inside of an inode struct so this change actually makes the hash worse. I looked at this one time myself...
Later,
David S. Miller
[email protected]
Quoted 10 lines · David S. Miller
Quoted 4 lines · Ulrich Kunitz
patch-uk6 In 2.4.x
_page_hashfndivides structaddress_spacepointer
with a parameter derived from the size of struct inode. Deriving this parameter from the size of structaddress_spacemakes more sense -- at least for me.The
address_spaceis %99 of the time (unless swapping, and in that case the address is constant :-)) inside of an inode struct so this change actually makes the hash worse. I looked at this one time myself...
The other patches look fine to me. Alan, Linus, could you please include Ulrich's other patches in the next pre-kernel ?
thanks,
Rik
--
Virtual memory is like a game you can't win; However, without VM there's truly nothing to lose...
http://www.surriel.com/
Quoted 3 lines · Ulrich Kunitz
patch-uk2 makes use of the pgd, pmd and pte quicklists for x86 too;
risky: there might be a reason that 2.4.x doesn't use the quicklists.
I remember these being taken out (long ago), but not why. Anyone?
-Mike
Quoted 7 lines · Mike Galbraith
Quoted 3 lines · Ulrich Kunitz
patch-uk2 makes use of the pgd, pmd and pte quicklists for x86 too;
risky: there might be a reason that 2.4.x doesn't use the quicklists.I remember these being taken out (long ago), but not why. Anyone?
They probably wasted too much memory ...
Having _2_ quicklists per CPU (on SMP) is probably the way to go: one with zeroed pages and one with non-zeroed pages.
This should avoid cache contention in __alloc_pages() and also avoid unneeded zeroing of pages (when we put away a zeroed page, eg. an freed pagetable page).
On UP we probably want a (smaller) freelist with zeroed pages only, since that means we can keep more pages on the inactive_clean list.
regards,
Rik
--
Virtual memory is like a game you can't win; However, without VM there's truly nothing to lose...
http://www.surriel.com/