Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 60732
b: refs/heads/master
c: 6300ea7
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jul 17, 2007
1 parent 4504304 commit 2124693
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 68dff6a9af9f27df5aeee6d0339818b0e36c1b51
refs/heads/master: 6300ea75031e7aebfe3331245b7f750d82621223
21 changes: 19 additions & 2 deletions trunk/mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ static inline void ClearSlabDebug(struct page *page)
#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
#endif

/*
* The page->inuse field is 16 bit thus we have this limitation
*/
#define MAX_OBJECTS_PER_SLAB 65535

/* Internal SLUB flags */
#define __OBJECT_POISON 0x80000000 /* Poison object */

Expand Down Expand Up @@ -1736,8 +1741,17 @@ static inline int slab_order(int size, int min_objects,
{
int order;
int rem;
int min_order = slub_min_order;

for (order = max(slub_min_order,
/*
* If we would create too many object per slab then reduce
* the slab order even if it goes below slub_min_order.
*/
while (min_order > 0 &&
(PAGE_SIZE << min_order) >= MAX_OBJECTS_PER_SLAB * size)
min_order--;

for (order = max(min_order,
fls(min_objects * size - 1) - PAGE_SHIFT);
order <= max_order; order++) {

Expand All @@ -1751,6 +1765,9 @@ static inline int slab_order(int size, int min_objects,
if (rem <= slab_size / fract_leftover)
break;

/* If the next size is too high then exit now */
if (slab_size * 2 >= MAX_OBJECTS_PER_SLAB * size)
break;
}

return order;
Expand Down Expand Up @@ -2037,7 +2054,7 @@ static int calculate_sizes(struct kmem_cache *s)
* The page->inuse field is only 16 bit wide! So we cannot have
* more than 64k objects per slab.
*/
if (!s->objects || s->objects > 65535)
if (!s->objects || s->objects > MAX_OBJECTS_PER_SLAB)
return 0;
return 1;

Expand Down

0 comments on commit 2124693

Please sign in to comment.