Messages in this thread Patch in this message | | | From | "Rafael J. Wysocki" <> | Subject | [RFC][PATCH -mm 1/2] mm: make shrink_all_memory overflow-resistant | Date | Mon, 27 Feb 2006 19:28:22 +0100 |
| |
Make shrink_all_memory() overflow-resistant.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> --- include/linux/swap.h | 2 +- mm/vmscan.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
Index: linux-2.6.16-rc4-mm2/mm/vmscan.c =================================================================== --- linux-2.6.16-rc4-mm2.orig/mm/vmscan.c +++ linux-2.6.16-rc4-mm2/mm/vmscan.c @@ -1785,18 +1785,19 @@ void wakeup_kswapd(struct zone *zone, in * Try to free `nr_pages' of memory, system-wide. Returns the number of freed * pages. */ -int shrink_all_memory(unsigned long nr_pages) +unsigned long shrink_all_memory(unsigned int nr_pages) { pg_data_t *pgdat; - unsigned long nr_to_free = nr_pages; - int ret = 0; + long long nr_to_free = nr_pages; + unsigned long ret = 0; struct reclaim_state reclaim_state = { .reclaimed_slab = 0, }; current->reclaim_state = &reclaim_state; for_each_pgdat(pgdat) { - int freed; + unsigned long freed; + freed = balance_pgdat(pgdat, nr_to_free, 0); ret += freed; nr_to_free -= freed; Index: linux-2.6.16-rc4-mm2/include/linux/swap.h =================================================================== --- linux-2.6.16-rc4-mm2.orig/include/linux/swap.h +++ linux-2.6.16-rc4-mm2/include/linux/swap.h @@ -173,7 +173,7 @@ extern void swap_setup(void); /* linux/mm/vmscan.c */ extern unsigned long try_to_free_pages(struct zone **, gfp_t); -extern int shrink_all_memory(unsigned long nr_pages); +extern unsigned long shrink_all_memory(unsigned int nr_pages); extern int vm_swappiness; #ifdef CONFIG_NUMA - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |