lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 9 Jul 2008 18:30:26 +0800
From:	<KokHow.Teh@...ineon.com>
To:	<penberg@...helsinki.fi>
Cc:	<linux-kernel@...r.kernel.org>, <cl@...ux-foundation.org>
Subject: RE: Kmem_cache handling in linux-2.6.2x kernel

Hi;

>On Wed, Jul 9, 2008 at 8:06 AM,  <KokHow.Teh@...ineon.com> wrote:
>>        I have a question about kmem_cache implemented in Linux-2.6.2x

>> kernel. I have an application that allocates and free 64KByte chunks 
>> of memory (32-byte aligned) quite often. Therefore, I create a 
>> lookaside cache for that purpose and use kmem_cache_alloc(), 
>> kmem_cache_free() to allocate and free the caches. The application 
>> works very well in this model. However, my concern here is if 
>> kmem_cache_free() does return the cache to the system-wide pool so 
>> that it could be used by other applications when need arises; when 
>> system is low in memory resources, for instance. This is a question 
>> about the internal workings of the memory management system of the 
>> Linux-2.6.2x kernel as to how efficient it manages this lookasie 
>> caches. The concern is valid because if this lookaside cache is not 
>> managed well, i.e, it is not returned to the system-wide free memory 
>> pools to be used by other applications, this will penalize the 
>> performace and throughput of the whole system due to the dynamic 
>> behaviour of the utilization of system memory resources. For example,

>> other applications might be swapping in and out of the harddisk and
if 
>> the kmem_cache_free()'ed memory objects could be used by these 
>> applications, it will help in this case to reduce the number of swaps

>> that happen, thereby freeing the CPU and/or DMA from doing the
swapping to do other critical tasks.

>I'm not sure I understand the question. The pages allocated for a
particular cache are given back to the page allocator whenever all
objects of a slab are freed. 

In my applications, only part of total number of objects of the
kmem_cache are freed. So my question is what happen to these "freed"
objects? How are these "freed" objects managed by the linux-MM? Would
they be reused by other kmem_cache_alloc() and/or kmalloc()?

>In addition, SLUB does slab merging so the same cache can be
transparently used by other kmem_cache_alloc() callers. So there really
are no reservation guarantees for a cache in OOM conditions.

(1) SLUB is not available in 2.6.20 kernel which I am using for my
products. In this case, is there similar mechamisms in place to
faciliate "page-sharing" amongst the kmem_cache_alloc() callers?

(2) Does this "page-sharing" happen for kmalloc() callers?

On Wed, Jul 9, 2008 at 8:06 AM,  <KokHow.Teh@...ineon.com> wrote:
>>        On the other hand, if the caches are returned to the 
>> system-wide free memory pool, what are the advantages of using 
>> kmem_cache_t compared to the conventional kmalloc()/kfree()?

>The main advantages for using kmem_cache_create() are that (1) you
control the alignment and (2) you get tighter packing for the objects
(less internal fragmentation).

Thanks.

Regards,
KH
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ