Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760156AbYCCJfG (ORCPT ); Mon, 3 Mar 2008 04:35:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752918AbYCCJex (ORCPT ); Mon, 3 Mar 2008 04:34:53 -0500 Received: from mail.suse.de ([195.135.220.2]:49965 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752477AbYCCJew (ORCPT ); Mon, 3 Mar 2008 04:34:52 -0500 Date: Mon, 3 Mar 2008 10:34:49 +0100 From: Nick Piggin To: netdev@vger.kernel.org, Linux Kernel Mailing List , yanmin_zhang@linux.intel.com, David Miller , Christoph Lameter , Eric Dumazet Subject: [rfc][patch 1/3] slub: fix small HWCACHE_ALIGN alignment Message-ID: <20080303093449.GA15091@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1155 Lines: 35 SLUB should pack even small objects nicely into cachelines if that is what has been asked for. Use the same algorithm as SLAB for this. Signed-off-by: Nick Piggin --- Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c +++ linux-2.6/mm/slub.c @@ -1896,12 +1896,15 @@ static unsigned long calculate_alignment * specified alignment though. If that is greater * then use it. */ - if ((flags & SLAB_HWCACHE_ALIGN) && - size > cache_line_size() / 2) - return max_t(unsigned long, align, cache_line_size()); + if (flags & SLAB_HWCACHE_ALIGN) { + unsigned long ralign = cache_line_size(); + while (size <= ralign / 2) + ralign /= 2; + align = max(align, ralign); + } if (align < ARCH_SLAB_MINALIGN) - return ARCH_SLAB_MINALIGN; + align = ARCH_SLAB_MINALIGN; return ALIGN(align, sizeof(void *)); } -- 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/