]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mm: Fix signal SIGFPE in slabinfo.c.
authormajianpeng <majianpeng@gmail.com>
Tue, 26 Jun 2012 01:30:31 +0000 (09:30 +0800)
committerPekka Enberg <penberg@kernel.org>
Mon, 2 Jul 2012 20:11:14 +0000 (23:11 +0300)
In function slab_stats(), if total_free is equal zero, it will error.
So fix it.

Acked-by: Christoph Lameter <cl@linux.com>
Signed-off-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/vm/slabinfo.c

index 164cbcf61106f5d65412961c46f548383e8263ab..808d5a9d5dcfb062a5dc9d9fc10246cb6e7e00d2 100644 (file)
@@ -437,34 +437,34 @@ static void slab_stats(struct slabinfo *s)
        printf("Fastpath             %8lu %8lu %3lu %3lu\n",
                s->alloc_fastpath, s->free_fastpath,
                s->alloc_fastpath * 100 / total_alloc,
-               s->free_fastpath * 100 / total_free);
+               total_free ? s->free_fastpath * 100 / total_free : 0);
        printf("Slowpath             %8lu %8lu %3lu %3lu\n",
                total_alloc - s->alloc_fastpath, s->free_slowpath,
                (total_alloc - s->alloc_fastpath) * 100 / total_alloc,
-               s->free_slowpath * 100 / total_free);
+               total_free ? s->free_slowpath * 100 / total_free : 0);
        printf("Page Alloc           %8lu %8lu %3lu %3lu\n",
                s->alloc_slab, s->free_slab,
                s->alloc_slab * 100 / total_alloc,
-               s->free_slab * 100 / total_free);
+               total_free ? s->free_slab * 100 / total_free : 0);
        printf("Add partial          %8lu %8lu %3lu %3lu\n",
                s->deactivate_to_head + s->deactivate_to_tail,
                s->free_add_partial,
                (s->deactivate_to_head + s->deactivate_to_tail) * 100 / total_alloc,
-               s->free_add_partial * 100 / total_free);
+               total_free ? s->free_add_partial * 100 / total_free : 0);
        printf("Remove partial       %8lu %8lu %3lu %3lu\n",
                s->alloc_from_partial, s->free_remove_partial,
                s->alloc_from_partial * 100 / total_alloc,
-               s->free_remove_partial * 100 / total_free);
+               total_free ? s->free_remove_partial * 100 / total_free : 0);
 
        printf("Cpu partial list     %8lu %8lu %3lu %3lu\n",
                s->cpu_partial_alloc, s->cpu_partial_free,
                s->cpu_partial_alloc * 100 / total_alloc,
-               s->cpu_partial_free * 100 / total_free);
+               total_free ? s->cpu_partial_free * 100 / total_free : 0);
 
        printf("RemoteObj/SlabFrozen %8lu %8lu %3lu %3lu\n",
                s->deactivate_remote_frees, s->free_frozen,
                s->deactivate_remote_frees * 100 / total_alloc,
-               s->free_frozen * 100 / total_free);
+               total_free ? s->free_frozen * 100 / total_free : 0);
 
        printf("Total                %8lu %8lu\n\n", total_alloc, total_free);