* PATCH: fix slab object alignment
@ 2010-08-06 16:19 Carsten Otte
2010-08-06 19:44 ` Christoph Lameter
0 siblings, 1 reply; 3+ messages in thread
From: Carsten Otte @ 2010-08-06 16:19 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, Matt Mackall, linux-mm
Cc: schwidefsky, heiko.carstens, arnd, ursula.braun
This patch fixes alignment of slab objects in case CONFIG_DEBUG_PAGEALLOC is
active.
Before this spot in kmem_cache_create, we have this situation:
- align contains the required alignment of the object
- cachep->obj_offset is 0 or equals align in case of CONFIG_DEBUG_SLAB
- size equals the size of the object, or object plus trailing redzone in case
of CONFIG_DEBUG_SLAB
This spot tries to fill one page per object if the object is in certain size
limits, however setting obj_offset to PAGE_SIZE - size does break the object
alignment since size may not be aligned with the required alignment.
This patch simply adds an ALIGN(size, align) to the equation and fixes the
object size detection accordingly.
This code in drivers/s390/cio/qdio_setup_init has lead to incorrectly aligned
slab objects (sizeof(struct qdio_q) equals 1792):
qdio_q_cache = kmem_cache_create("qdio_q", sizeof(struct qdio_q),
256, 0, NULL);
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
---
mm/slab.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2331,8 +2331,8 @@ kmem_cache_create (const char *name, siz
}
#if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC)
if (size >= malloc_sizes[INDEX_L3 + 1].cs_size
- && cachep->obj_size > cache_line_size() && size < PAGE_SIZE) {
- cachep->obj_offset += PAGE_SIZE - size;
+ && cachep->obj_size > cache_line_size() && ALIGN(size, align) < PAGE_SIZE) {
+ cachep->obj_offset += PAGE_SIZE - ALIGN(size, align);
size = PAGE_SIZE;
}
#endif
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: fix slab object alignment
2010-08-06 16:19 PATCH: fix slab object alignment Carsten Otte
@ 2010-08-06 19:44 ` Christoph Lameter
2010-08-09 15:51 ` Pekka Enberg
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Lameter @ 2010-08-06 19:44 UTC (permalink / raw)
To: Carsten Otte
Cc: Pekka Enberg, Matt Mackall, linux-mm, schwidefsky, heiko.carstens,
arnd, Ursula Braun
Acked-by: Christoph Lameter <cl@linux.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: fix slab object alignment
2010-08-06 19:44 ` Christoph Lameter
@ 2010-08-09 15:51 ` Pekka Enberg
0 siblings, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2010-08-09 15:51 UTC (permalink / raw)
To: Christoph Lameter
Cc: Carsten Otte, Matt Mackall, linux-mm, schwidefsky, heiko.carstens,
arnd, Ursula Braun, Frank Blaschka, stable
Christoph Lameter wrote:
> Acked-by: Christoph Lameter <cl@linux.com>
Applied, thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-09 15:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06 16:19 PATCH: fix slab object alignment Carsten Otte
2010-08-06 19:44 ` Christoph Lameter
2010-08-09 15:51 ` Pekka Enberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).