aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/slab.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/mm/slab.c b/mm/slab.c
index d31a06bfbea5..f1b644eb39d8 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -207,11 +207,6 @@ typedef unsigned int kmem_bufctl_t;
207#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2) 207#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2)
208#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3) 208#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3)
209 209
210/* Max number of objs-per-slab for caches which use off-slab slabs.
211 * Needed to avoid a possible looping condition in cache_grow().
212 */
213static unsigned long offslab_limit;
214
215/* 210/*
216 * struct slab 211 * struct slab
217 * 212 *
@@ -1356,12 +1351,6 @@ void __init kmem_cache_init(void)
1356 NULL, NULL); 1351 NULL, NULL);
1357 } 1352 }
1358 1353
1359 /* Inc off-slab bufctl limit until the ceiling is hit. */
1360 if (!(OFF_SLAB(sizes->cs_cachep))) {
1361 offslab_limit = sizes->cs_size - sizeof(struct slab);
1362 offslab_limit /= sizeof(kmem_bufctl_t);
1363 }
1364
1365 sizes->cs_dmacachep = kmem_cache_create(names->name_dma, 1354 sizes->cs_dmacachep = kmem_cache_create(names->name_dma,
1366 sizes->cs_size, 1355 sizes->cs_size,
1367 ARCH_KMALLOC_MINALIGN, 1356 ARCH_KMALLOC_MINALIGN,
@@ -1780,6 +1769,7 @@ static void set_up_list3s(struct kmem_cache *cachep, int index)
1780static size_t calculate_slab_order(struct kmem_cache *cachep, 1769static size_t calculate_slab_order(struct kmem_cache *cachep,
1781 size_t size, size_t align, unsigned long flags) 1770 size_t size, size_t align, unsigned long flags)
1782{ 1771{
1772 unsigned long offslab_limit;
1783 size_t left_over = 0; 1773 size_t left_over = 0;
1784 int gfporder; 1774 int gfporder;
1785 1775
@@ -1791,9 +1781,18 @@ static size_t calculate_slab_order(struct kmem_cache *cachep,
1791 if (!num) 1781 if (!num)
1792 continue; 1782 continue;
1793 1783
1794 /* More than offslab_limit objects will cause problems */ 1784 if (flags & CFLGS_OFF_SLAB) {
1795 if ((flags & CFLGS_OFF_SLAB) && num > offslab_limit) 1785 /*
1796 break; 1786 * Max number of objs-per-slab for caches which
1787 * use off-slab slabs. Needed to avoid a possible
1788 * looping condition in cache_grow().
1789 */
1790 offslab_limit = size - sizeof(struct slab);
1791 offslab_limit /= sizeof(kmem_bufctl_t);
1792
1793 if (num > offslab_limit)
1794 break;
1795 }
1797 1796
1798 /* Found something acceptable - save it away */ 1797 /* Found something acceptable - save it away */
1799 cachep->num = num; 1798 cachep->num = num;