From: Li Yang <leoli@freescale.com>
To: Chuck Meade <chuck@ThePTRGroup.com>
Cc: linuxppc-dev Development <linuxppc-dev@ozlabs.org>,
Liu Dave-r63238 <DaveLiu@freescale.com>
Subject: Re: ucc_geth DPRAM alloc error, 2.6.22-rc3
Date: Thu, 14 Jun 2007 21:42:20 +0800 [thread overview]
Message-ID: <467145BC.1020800@freescale.com> (raw)
In-Reply-To: <4671321E.9000204@ThePTRGroup.com>
Here is the patch to remove internal fragment when doing
aligned allocation.
The patch change to add the fragments back into the free list,
instead of allocate the whole trunk of space with internal
fragment.
---
arch/powerpc/lib/rheap.c | 45 +++++++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index 180ee29..f8b3f1a 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -437,16 +437,12 @@ unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, const ch
struct list_head *l;
rh_block_t *blk;
rh_block_t *newblk;
- unsigned long start;
+ unsigned long start, sp_size;
/* Validate size, and alignment must be power of two */
if (size <= 0 || (alignment & (alignment - 1)) != 0)
return (unsigned long) -EINVAL;
- /* given alignment larger that default rheap alignment */
- if (alignment > info->alignment)
- size += alignment - 1;
-
/* Align to configured alignment */
size = (size + (info->alignment - 1)) & ~(info->alignment - 1);
@@ -456,8 +452,11 @@ unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, const ch
blk = NULL;
list_for_each(l, &info->free_list) {
blk = list_entry(l, rh_block_t, list);
- if (size <= blk->size)
- break;
+ if (size <= blk->size) {
+ start = (blk->start + alignment - 1) & ~(alignment - 1);
+ if (start + size <= blk->start + blk->size)
+ break;
+ }
blk = NULL;
}
@@ -470,25 +469,35 @@ unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, const ch
list_del(&blk->list);
newblk = blk;
} else {
+ /* Fragment caused, split if needed */
+ /* Create block for fragment in the beginning, insert to free list */
+ sp_size = start - blk->start;
+ if (sp_size) {
+ rh_block_t *spblk;
+
+ spblk = get_slot(info);
+ spblk->start = blk->start;
+ spblk->size = sp_size;
+ list_add(&spblk->list, &blk->list);
+ }
newblk = get_slot(info);
- newblk->start = blk->start;
+ newblk->start = start;
newblk->size = size;
- /* blk still in free list, with updated start, size */
- blk->start += size;
- blk->size -= size;
+ /* blk still in free list, with updated start, size
+ * for fragment in the end */
+ blk->start = start + size;
+ blk->size -= sp_size + size;
+ /* No fragment in the end, remove blk */
+ if (blk->size == 0) {
+ list_del(&blk->list);
+ release_slot(info, blk);
+ }
}
newblk->owner = owner;
- start = newblk->start;
attach_taken_block(info, newblk);
- /* for larger alignment return fixed up pointer */
- /* this is no problem with the deallocator since */
- /* we scan for pointers that lie in the blocks */
- if (alignment > info->alignment)
- start = (start + alignment - 1) & ~(alignment - 1);
-
return start;
}
next prev parent reply other threads:[~2007-06-14 13:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-13 14:22 ucc_geth DPRAM alloc error, 2.6.22-rc3 Joakim Tjernlund
2007-06-13 22:00 ` Timur Tabi
2007-06-13 22:47 ` Joakim Tjernlund
2007-06-14 2:31 ` Dave Liu
2007-06-14 7:03 ` Joakim Tjernlund
2007-06-14 7:17 ` Joakim Tjernlund
2007-06-14 7:26 ` Li Yang-r58472
2007-06-14 7:57 ` Joakim Tjernlund
2007-06-14 7:37 ` Li Yang-r58472
2007-06-14 7:54 ` Joakim Tjernlund
2007-06-14 12:18 ` Chuck Meade
2007-06-14 12:48 ` Li Yang-r58472
2007-06-14 13:42 ` Li Yang [this message]
2007-06-15 13:03 ` Joakim Tjernlund
2007-06-15 14:35 ` Joakim Tjernlund
2007-06-14 22:50 ` Rune Torgersen
2007-06-15 2:44 ` Li Yang-r58472
2007-06-15 3:47 ` Rune Torgersen
2007-06-14 22:46 ` Rune Torgersen
2007-06-14 3:14 ` Li Yang-r58472
-- strict thread matches above, loose matches on Subject: below --
2007-06-14 3:37 Li Yang-r58472
2007-06-14 7:04 ` Joakim Tjernlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=467145BC.1020800@freescale.com \
--to=leoli@freescale.com \
--cc=DaveLiu@freescale.com \
--cc=chuck@ThePTRGroup.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox