linux-mips
[Top] [All Lists]

Re: kmalloc issue on MIPS target

To: naveen yadav <yad.naveen@gmail.com>
Subject: Re: kmalloc issue on MIPS target
From: Ralf Baechle <ralf@linux-mips.org>
Date: Wed, 18 Aug 2010 14:33:36 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <AANLkTiniH42L=-DdJ_XHOm1Uo_=YoAqE-j9Jrm45imtG@mail.gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <AANLkTiniH42L=-DdJ_XHOm1Uo_=YoAqE-j9Jrm45imtG@mail.gmail.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.20 (2009-12-10)
On Wed, Aug 18, 2010 at 06:07:12PM +0530, naveen yadav wrote:

> To: majordomo@kvack.org, linux-mips@linux-mips.org

Your sentences are to complex for majordomo to understand.  Also its
area of expertise is generally limited to mailing list related issues.

> We are using MIPS(mips32r2) target. when I alloc memory using kmalloc
> suppose  28 bytes, the kernel still consume 128 bytes.
> 
> So when I check File on kernel source  mach-ip32/kmalloc.h
> 
> Since it is allign to 128 bytes so i understand that even if  I
> consume 1 byte it will waste 128 bytes.
> 
> #ifndef __ASM_MACH_IP32_KMALLOC_H
> #define __ASM_MACH_IP32_KMALLOC_H

Eh...  That's an IP32-specific header.  I have no idea why you're looking
at it.  It's not being used for your platform.

> So I could not understand why it is allign to 128 bytes. Is there any
> specific reason for it. ?

Each allocation needs some memory for kmalloc's internal bookkeeping,
the memory you actually asked for and for cacheline alignment.  For very
small allocations the later is likely to be larger than the other two
so will be the deciding factor in actual memory allocation.

The cacheline aligment results in better performance and on non-coherent
platforms such as probably yours it is necessary to get get DMA transfers
to work right.

It would appear that in your case CONFIG_MIPS_L1_CACHE_SHIFT is set to 7.
For a MIPS32-based platform (you didn' say what actual processor core!)
that appears to be an excessively large number.  32 bytes would be a more
typical figure.  Just check the kernel bootup messages for the cacheline
size if you don't know.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>