Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753270AbbDFVcF (ORCPT ); Mon, 6 Apr 2015 17:32:05 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:20834 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751563AbbDFVcD (ORCPT ); Mon, 6 Apr 2015 17:32:03 -0400 X-AuditID: cbfec7f4-b7f106d0000013ec-f4-5522faa23db1 From: Stefan Strogin To: Andrew Morton Cc: Stefan Strogin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Stefan Strogin , Michal Nazarewicz , Marek Szyprowski , Joonsoo Kim , "Aneesh Kumar K . V" , Dmitry Safonov , Pintu Kumar , Sasha Levin , Weijie Yang , Laurent Pinchart , Michal Hocko , Vyacheslav Tyrtov , Aleksei Mateosian Subject: [PATCH] mm-cma-add-functions-to-get-region-pages-counters-fix-2 Date: Tue, 07 Apr 2015 00:31:46 +0300 Message-id: <1428355906-5521-1-git-send-email-stefan.strogin@gmail.com> X-Mailer: git-send-email 2.1.0 In-reply-to: <5522FAEA.4040707@partner.samsung.com> References: <5522FAEA.4040707@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsVy+t/xq7qLfimFGhybaW7xcN4kdos569ew WTx+PY/F4tPKp2wWK7ub2SwmNt1hsbi8aw6bxb01/1kt1h65y27xqvk7q8WC4y2sFn3fD7Nb fDs5h9li8ZHbzBaX3/xnt5g64we7xckNZ1kdBD12zrrL7jG7Yyarx6ZPk9g9ut5eYfI4MeM3 i8eDQ5tZPNb9ecXk8fHpLRaPg+/2MHn0bVnF6HFmwRF2j8+b5AJ4orhsUlJzMstSi/TtErgy Nt+JKzgrXHFh6in2BsZmgS5GTg4JAROJ7WefMUPYYhIX7q1n62Lk4hASWMoosfrVebCEkEAv k0TzQ0cQm01AX6Lr8hQmEFtEQFdi1fNdzCANzAKrWSUm3u9jAUkIC3hIfD2zEmgSBweLgKrE jq/WIGFeAXeJ5un/WSCWyUls2P2fEcTmFDCWeHPzBjvELiOJzWuOsk9g5F3AyLCKUTS1NLmg OCk911CvODG3uDQvXS85P3cTIyT4v+xgXHzM6hCjAAejEg8v50/FUCHWxLLiytxDjBIczEoi vHl3lEKFeFMSK6tSi/Lji0pzUosPMTJxcEo1MM4Tdl5yZeXjjY0qO/6m7GtRPaLz4Paeltxd //i/vN093fdK4smz913mRV4QLHZc/HeWVKNFw513R/Jatyh++Ohq3MEWYKgvGu1fMEM0dtoG 8cUv/0Y+Xnr2YHyyWYe0fIrwwQvpW4TPXXvf5riro8PnVjn/bjE5adb5zJKm3Jd1/l67Kr/e jl+JpTgj0VCLuag4EQAu1pm+XAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2664 Lines: 95 Move the code from cma_get_used() and cma_get_maxchunk() to cma_used_get() and cma_maxchunk_get(), because cma_get_*() aren't used anywhere else, and because of their confusing similar names. Signed-off-by: Stefan Strogin --- mm/cma_debug.c | 51 ++++++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/mm/cma_debug.c b/mm/cma_debug.c index 56c4175..abb9d0b 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c @@ -22,37 +22,6 @@ struct cma_mem { 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; @@ -66,8 +35,13 @@ DEFINE_SIMPLE_ATTRIBUTE(cma_debugfs_fops, cma_debugfs_get, NULL, "%llu\n"); 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; } @@ -76,8 +50,19 @@ DEFINE_SIMPLE_ATTRIBUTE(cma_used_fops, cma_used_get, NULL, "%llu\n"); 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; } -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/