diff options
Diffstat (limited to 'mm/zsmalloc.c')
-rw-r--r-- | mm/zsmalloc.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a8ff24a29693..2858b20dce76 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c | |||
@@ -167,9 +167,14 @@ enum zs_stat_type { | |||
167 | OBJ_USED, | 167 | OBJ_USED, |
168 | CLASS_ALMOST_FULL, | 168 | CLASS_ALMOST_FULL, |
169 | CLASS_ALMOST_EMPTY, | 169 | CLASS_ALMOST_EMPTY, |
170 | NR_ZS_STAT_TYPE, | ||
171 | }; | 170 | }; |
172 | 171 | ||
172 | #ifdef CONFIG_ZSMALLOC_STAT | ||
173 | #define NR_ZS_STAT_TYPE (CLASS_ALMOST_EMPTY + 1) | ||
174 | #else | ||
175 | #define NR_ZS_STAT_TYPE (OBJ_USED + 1) | ||
176 | #endif | ||
177 | |||
173 | struct zs_size_stat { | 178 | struct zs_size_stat { |
174 | unsigned long objs[NR_ZS_STAT_TYPE]; | 179 | unsigned long objs[NR_ZS_STAT_TYPE]; |
175 | }; | 180 | }; |
@@ -448,19 +453,23 @@ static int get_size_class_index(int size) | |||
448 | static inline void zs_stat_inc(struct size_class *class, | 453 | static inline void zs_stat_inc(struct size_class *class, |
449 | enum zs_stat_type type, unsigned long cnt) | 454 | enum zs_stat_type type, unsigned long cnt) |
450 | { | 455 | { |
451 | class->stats.objs[type] += cnt; | 456 | if (type < NR_ZS_STAT_TYPE) |
457 | class->stats.objs[type] += cnt; | ||
452 | } | 458 | } |
453 | 459 | ||
454 | static inline void zs_stat_dec(struct size_class *class, | 460 | static inline void zs_stat_dec(struct size_class *class, |
455 | enum zs_stat_type type, unsigned long cnt) | 461 | enum zs_stat_type type, unsigned long cnt) |
456 | { | 462 | { |
457 | class->stats.objs[type] -= cnt; | 463 | if (type < NR_ZS_STAT_TYPE) |
464 | class->stats.objs[type] -= cnt; | ||
458 | } | 465 | } |
459 | 466 | ||
460 | static inline unsigned long zs_stat_get(struct size_class *class, | 467 | static inline unsigned long zs_stat_get(struct size_class *class, |
461 | enum zs_stat_type type) | 468 | enum zs_stat_type type) |
462 | { | 469 | { |
463 | return class->stats.objs[type]; | 470 | if (type < NR_ZS_STAT_TYPE) |
471 | return class->stats.objs[type]; | ||
472 | return 0; | ||
464 | } | 473 | } |
465 | 474 | ||
466 | #ifdef CONFIG_ZSMALLOC_STAT | 475 | #ifdef CONFIG_ZSMALLOC_STAT |