Commit efb8ad7e9431a430a75d44288614cf6047ff4baa
Committed by
Tim Shimmin
1 parent
3f89243c5b
Exists in
master
and in
7 other branches
[XFS] Add a debug flag for allocations which are known to be larger than
one page. SGI-PV: 955302 SGI-Modid: xfs-linux-melb:xfs-kern:26800a Signed-off-by: Nathan Scott <nathans@sgi.com> Signed-off-by: Tim Shimmin <tes@sgi.com>
Showing 7 changed files with 18 additions and 9 deletions Side-by-side Diff
fs/xfs/linux-2.6/kmem.c
... | ... | @@ -34,6 +34,14 @@ |
34 | 34 | gfp_t lflags = kmem_flags_convert(flags); |
35 | 35 | void *ptr; |
36 | 36 | |
37 | +#ifdef DEBUG | |
38 | + if (unlikely(!(flags & KM_LARGE) && (size > PAGE_SIZE))) { | |
39 | + printk(KERN_WARNING "Large %s attempt, size=%ld\n", | |
40 | + __FUNCTION__, (long)size); | |
41 | + dump_stack(); | |
42 | + } | |
43 | +#endif | |
44 | + | |
37 | 45 | do { |
38 | 46 | if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS) |
39 | 47 | ptr = kmalloc(size, lflags); |
fs/xfs/linux-2.6/kmem.h
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | #define KM_NOSLEEP 0x0002u |
31 | 31 | #define KM_NOFS 0x0004u |
32 | 32 | #define KM_MAYFAIL 0x0008u |
33 | +#define KM_LARGE 0x0010u | |
33 | 34 | |
34 | 35 | /* |
35 | 36 | * We use a special process flag to avoid recursive callbacks into |
... | ... | @@ -41,7 +42,7 @@ |
41 | 42 | { |
42 | 43 | gfp_t lflags; |
43 | 44 | |
44 | - BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL)); | |
45 | + BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL|KM_LARGE)); | |
45 | 46 | |
46 | 47 | if (flags & KM_NOSLEEP) { |
47 | 48 | lflags = GFP_ATOMIC | __GFP_NOWARN; |
fs/xfs/linux-2.6/xfs_buf.c
... | ... | @@ -768,7 +768,7 @@ |
768 | 768 | _xfs_buf_initialize(bp, target, 0, len, 0); |
769 | 769 | |
770 | 770 | try_again: |
771 | - data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); | |
771 | + data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL | KM_LARGE); | |
772 | 772 | if (unlikely(data == NULL)) |
773 | 773 | goto fail_free_buf; |
774 | 774 |
fs/xfs/quota/xfs_qm.c
... | ... | @@ -112,17 +112,17 @@ |
112 | 112 | { |
113 | 113 | xfs_dqhash_t *udqhash, *gdqhash; |
114 | 114 | xfs_qm_t *xqm; |
115 | - uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL; | |
115 | + uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL | KM_LARGE; | |
116 | 116 | |
117 | 117 | /* |
118 | 118 | * Initialize the dquot hash tables. |
119 | 119 | */ |
120 | 120 | hsize = XFS_QM_HASHSIZE_HIGH; |
121 | - while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) { | |
121 | + while (!(udqhash = kmem_zalloc(hsize * sizeof(*udqhash), flags))) { | |
122 | 122 | if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW) |
123 | 123 | flags = KM_SLEEP; |
124 | 124 | } |
125 | - gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP); | |
125 | + gdqhash = kmem_zalloc(hsize * sizeof(*gdqhash), KM_SLEEP | KM_LARGE); | |
126 | 126 | ndquot = hsize << 8; |
127 | 127 | |
128 | 128 | xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP); |
fs/xfs/support/ktrace.c
fs/xfs/xfs_iget.c
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | xfs_ihash_init(xfs_mount_t *mp) |
51 | 51 | { |
52 | 52 | __uint64_t icount; |
53 | - uint i, flags = KM_SLEEP | KM_MAYFAIL; | |
53 | + uint i, flags = KM_SLEEP | KM_MAYFAIL | KM_LARGE; | |
54 | 54 | |
55 | 55 | if (!mp->m_ihsize) { |
56 | 56 | icount = mp->m_maxicount ? mp->m_maxicount : |
... | ... | @@ -95,7 +95,7 @@ |
95 | 95 | mp->m_chsize = min_t(uint, mp->m_chsize, mp->m_ihsize); |
96 | 96 | mp->m_chash = (xfs_chash_t *)kmem_zalloc(mp->m_chsize |
97 | 97 | * sizeof(xfs_chash_t), |
98 | - KM_SLEEP); | |
98 | + KM_SLEEP | KM_LARGE); | |
99 | 99 | for (i = 0; i < mp->m_chsize; i++) { |
100 | 100 | spinlock_init(&mp->m_chash[i].ch_lock,"xfshash"); |
101 | 101 | } |
fs/xfs/xfs_log.c
... | ... | @@ -1196,7 +1196,7 @@ |
1196 | 1196 | kmem_zalloc(sizeof(xlog_in_core_t), KM_SLEEP); |
1197 | 1197 | iclog = *iclogp; |
1198 | 1198 | iclog->hic_data = (xlog_in_core_2_t *) |
1199 | - kmem_zalloc(iclogsize, KM_SLEEP); | |
1199 | + kmem_zalloc(iclogsize, KM_SLEEP | KM_LARGE); | |
1200 | 1200 | |
1201 | 1201 | iclog->ic_prev = prev_iclog; |
1202 | 1202 | prev_iclog = iclog; |