static struct dentry *cma_debugfs_root;
-static unsigned long cma_get_used(struct cma *cma)
-{
- unsigned long ret = 0;
-
- mutex_lock(&cma->lock);
- /* pages counter is smaller than sizeof(int) */
- ret = bitmap_weight(cma->bitmap, (int)cma->count);
- mutex_unlock(&cma->lock);
-
- return ret << cma->order_per_bit;
-}
-
-static unsigned long cma_get_maxchunk(struct cma *cma)
-{
- unsigned long maxchunk = 0;
- unsigned long start, end = 0;
-
- mutex_lock(&cma->lock);
- for (;;) {
- start = find_next_zero_bit(cma->bitmap, cma->count, end);
- if (start >= cma->count)
- break;
- end = find_next_bit(cma->bitmap, cma->count, start);
- maxchunk = max(end - start, maxchunk);
- }
- mutex_unlock(&cma->lock);
-
- return maxchunk << cma->order_per_bit;
-}
-
-
static int cma_debugfs_get(void *data, u64 *val)
{
unsigned long *p = data;
static int cma_used_get(void *data, u64 *val)
{
struct cma *cma = data;
+ unsigned long used;
- *val = cma_get_used(cma);
+ mutex_lock(&cma->lock);
+ /* pages counter is smaller than sizeof(int) */
+ used = bitmap_weight(cma->bitmap, (int)cma->count);
+ mutex_unlock(&cma->lock);
+ *val = used << cma->order_per_bit;
return 0;
}
static int cma_maxchunk_get(void *data, u64 *val)
{
struct cma *cma = data;
+ unsigned long maxchunk = 0;
+ unsigned long start, end = 0;
- *val = cma_get_maxchunk(cma);
+ mutex_lock(&cma->lock);
+ for (;;) {
+ start = find_next_zero_bit(cma->bitmap, cma->count, end);
+ if (start >= cma->count)
+ break;
+ end = find_next_bit(cma->bitmap, cma->count, start);
+ maxchunk = max(end - start, maxchunk);
+ }
+ mutex_unlock(&cma->lock);
+ *val = maxchunk << cma->order_per_bit;
return 0;
}