git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into vfs-dev
[lunaix-os.git]
/
lunaix-os
/
kernel
/
mm
/
cake.c
diff --git
a/lunaix-os/kernel/mm/cake.c
b/lunaix-os/kernel/mm/cake.c
index 7e3142b1fbe6579b3d5dc2351cba4e1dae074c87..a64b3ea6acf40f02098c3536076325e3dcfe120d 100644
(file)
--- a/
lunaix-os/kernel/mm/cake.c
+++ b/
lunaix-os/kernel/mm/cake.c
@@
-76,10
+76,10
@@
__init_pile(struct cake_pile* pile,
(piece_size + sizeof(piece_index_t)),
.pg_per_cake = pg_per_cake };
(piece_size + sizeof(piece_index_t)),
.pg_per_cake = pg_per_cake };
- unsigned int overhead_size =
- sizeof(struct cake_s) + pile->pieces_per_cake * sizeof(piece_index_t);
+ unsigned int free_list_size = pile->pieces_per_cake * sizeof(piece_index_t);
- pile->offset = ROUNDUP(overhead_size, offset);
+ pile->offset = ROUNDUP(sizeof(struct cake_s) + free_list_size, offset);
+ pile->pieces_per_cake -= ICEIL((pile->offset - free_list_size), piece_size);
strncpy(&pile->pile_name, name, PILE_NAME_MAXLEN);
strncpy(&pile->pile_name, name, PILE_NAME_MAXLEN);
@@
-120,7
+120,6
@@
cake_grab(struct cake_pile* pile)
pos = list_entry(pile->free.next, typeof(*pos), cakes);
}
pos = list_entry(pile->free.next, typeof(*pos), cakes);
}
-found:
piece_index_t found_index = pos->next_free;
pos->next_free = pos->free_list[found_index];
pos->used_pieces++;
piece_index_t found_index = pos->next_free;
pos->next_free = pos->free_list[found_index];
pos->used_pieces++;
@@
-140,7
+139,7
@@
found:
int
cake_release(struct cake_pile* pile, void* area)
{
int
cake_release(struct cake_pile* pile, void* area)
{
- piece_index_t
area
_index;
+ piece_index_t
piece
_index;
struct cake_s *pos, *n;
struct llist_header* hdrs[2] = { &pile->full, &pile->partial };
struct cake_s *pos, *n;
struct llist_header* hdrs[2] = { &pile->full, &pile->partial };
@@
-150,9
+149,9
@@
cake_release(struct cake_pile* pile, void* area)
if (pos->first_piece > area) {
continue;
}
if (pos->first_piece > area) {
continue;
}
-
area
_index =
+
piece
_index =
(uintptr_t)(area - pos->first_piece) / pile->piece_size;
(uintptr_t)(area - pos->first_piece) / pile->piece_size;
- if (
area
_index < pile->pieces_per_cake) {
+ if (
piece
_index < pile->pieces_per_cake) {
goto found;
}
}
goto found;
}
}
@@
-161,8
+160,8
@@
cake_release(struct cake_pile* pile, void* area)
return 0;
found:
return 0;
found:
- pos->free_list[
area
_index] = pos->next_free;
- pos->next_free =
area
_index;
+ pos->free_list[
piece
_index] = pos->next_free;
+ pos->next_free =
piece
_index;
pos->used_pieces--;
pile->alloced_pieces--;
pos->used_pieces--;
pile->alloced_pieces--;