WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Mini-OS: Fix alignment in maybe_split()

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Mini-OS: Fix alignment in maybe_split()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Feb 2008 06:00:07 -0800
Delivery-date: Mon, 18 Feb 2008 06:00:04 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1202980953 0
# Node ID b9b6caf06f8c355fcc79a1cd9bfff883167751b8
# Parent  e1dde6f8bc873b74786feb603289c502c9a43ed9
Mini-OS: Fix alignment in maybe_split()
Needed on ia64, speeds up on x86.
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
 extras/mini-os/lib/xmalloc.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff -r e1dde6f8bc87 -r b9b6caf06f8c extras/mini-os/lib/xmalloc.c
--- a/extras/mini-os/lib/xmalloc.c      Wed Feb 13 18:30:12 2008 +0000
+++ b/extras/mini-os/lib/xmalloc.c      Thu Feb 14 09:22:33 2008 +0000
@@ -62,10 +62,19 @@ struct xmalloc_pad
     size_t hdr_size;
 };
 
+/* Return size, increased to alignment with align. */
+static inline size_t align_up(size_t size, size_t align)
+{
+    return (size + align - 1) & ~(align - 1);
+}
+
 static void maybe_split(struct xmalloc_hdr *hdr, size_t size, size_t block)
 {
     struct xmalloc_hdr *extra;
-    size_t leftover = block - size;
+    size_t leftover;
+    size = align_up(size, __alignof__(struct xmalloc_hdr));
+    size = align_up(size, __alignof__(struct xmalloc_pad));
+    leftover = block - size;
 
     /* If enough is left to make a block, put it on free list. */
     if ( leftover >= (2 * (sizeof(struct xmalloc_hdr) + sizeof(struct 
xmalloc_pad))) )
@@ -98,12 +107,6 @@ static struct xmalloc_hdr *xmalloc_new_p
     maybe_split(hdr, size, PAGE_SIZE);
 
     return hdr;
-}
-
-/* Return size, increased to alignment with align. */
-static inline size_t align_up(size_t size, size_t align)
-{
-    return (size + align - 1) & ~(align - 1);
 }
 
 /* Big object?  Just use the page allocator. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Mini-OS: Fix alignment in maybe_split(), Xen patchbot-unstable <=