Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753423AbbBXSo4 (ORCPT ); Tue, 24 Feb 2015 13:44:56 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:55115 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753160AbbBXSoy (ORCPT ); Tue, 24 Feb 2015 13:44:54 -0500 X-AuditID: cbfec7f4-b7f126d000001e9a-99-54ecc6118d2d From: Stefan Strogin To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Stefan Strogin , Joonsoo Kim , Andrew Morton , Marek Szyprowski , Michal Nazarewicz , aneesh.kumar@linux.vnet.ibm.com, Laurent Pinchart , Dmitry Safonov , Pintu Kumar , Weijie Yang , Laura Abbott , SeongJae Park , Hui Zhu , Minchan Kim , Dyasly Sergey , Vyacheslav Tyrtov , Aleksei Mateosian , gregory.0xf0@gmail.com, sasha.levin@oracle.com, gioh.kim@lge.com, pavel@ucw.cz, stefan.strogin@gmail.com Subject: [PATCH v3 0/4] mm: cma: add some debug information for CMA Date: Tue, 24 Feb 2015 21:44:31 +0300 Message-id: X-Mailer: git-send-email 2.1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRmVeSWpSXmKPExsVy+t/xa7qCx96EGFx5rWfxcN4kdos569ew WTx+PY/F4tPKp2wWz5q+MFpMm76B1WJldzObxfbOGewWnROXsFtc3jWHzeLemv+sFmuP3GW3 WHC8hdVi2df37BZ3Tx1ls+j7fpjdYvJsKYtvJ+cwWyw+cpvZ4tqOfiaLy2/+s1tMnfGD3eLk hrOsFhuauRwkPC739TJ57Jx1l91jdsdMVo9NqzrZPDZ9msTu0fX2CpPHiRm/WTweHNrM4rHu zysmj49Pb7F4HHy3h8mjb8sqRo8Vq7+ze3zeJOfRtfEXawB/FJdNSmpOZllqkb5dAlfGnSdd 7AWLdCruHZ3J1sD4XaWLkZNDQsBEonnmTBYIW0ziwr31bF2MXBxCAksZJc7fncAEkhAS6GWS WNHBAWKzATUcuzCdEcQWAbJ3N89lBGlgFtjKJtFw8gfYJGEBZ4l3q3rBilgEVCVWLZ7CCmLz CjhIvLy2ihFim5zEht3/GScwci9gZFjFKJpamlxQnJSea6hXnJhbXJqXrpecn7uJERIxX3Yw Lj5mdYhRgINRiYf3QdmrECHWxLLiytxDjBIczEoivBs2vwkR4k1JrKxKLcqPLyrNSS0+xMjE wSnVwKiVM7nStLKoZ3fOtTahj4xvJE4f5D+l/HpR07/3HUsqlz1mNNZZuGVF56EK1m+VnlGJ HkKzLRjWLUs8ZXZQUufBHCeGya5fr0RnHFcXWJEyjyX4+OTF139+PcMedP9L8lHnoyLnXjCa WZR/2bSiMsLyc7XCMZufzZ4W2eH7eZY21f9u6g6WDFdiKc5INNRiLipOBACx8s8gdgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5780 Lines: 136 Hi all. Here is the third version of a patch set that adds some debugging facility for CMA. This patch set is based on v4.0-rc1 and Sasha Levin's patch set "mm: cma: debugfs access to CMA" v5 [1]. It is also available on git: git://github.com/stefanstrogin/linux -b cmainfo-v3 We want an interface to see a list of currently allocated CMA buffers and some useful information about them (like /proc/vmallocinfo but for physically contiguous buffers allocated with CMA). For example. We want a big (megabytes) CMA buffer to be allocated in runtime in default CMA region. If someone already uses CMA then the big allocation could fail. If it happened then with such an interface we could find who used CMA at the moment of failure, who caused fragmentation and so on. Ftrace also would be helpful here, but with ftrace we can see the whole history of allocations and releases, whereas with this patch set we can see a snapshot of CMA region with actual information about its allocations. These patches add some files to debugfs when CONFIG_CMA_DEBUGFS is enbled. /sys/kernel/debug/cma/cma-/used and cma/cma-/maxchunk are added to show used size in pages and the biggest free chunk in each CMA region. When CONFIG_CMA_BUFFER_LIST is enabled (depended on CONFIG_CMA_DEBUGFS) /sys/kernel/debug/cma/cma-/buffers is added. It contains a list of currently allocated contiguous buffers for each CMA region (N stands for region number). Format is: - ( kB), allocated by () Another added option is CONFIG_CMA_ALLOC_STACKTRACE. When it's enabled then stack traces are also saved when the allocations are made. The stack traces are added to each entry in cma/cma-/buffers (see an example [3]). This can be used to see who and whence allocated each buffer. Also added trace events for cma_alloc() and cma_release(). Changes from v2 (https://lkml.org/lkml/2015/2/12/647): - Rebased on v4.0-rc1 and Sasha Levin's patch set v5 [1]. - Changed kmalloc() to vmalloc() in cma_buffer_list_read(). - Added CONFIG_CMA_BUFFER_LIST and CONFIG_CMA_ALLOC_STACKTRACE. - Considered order_per_bit for returning page number in cma_get_used() and cma_get_maxchunk(). - Reordered the patches to make the one with trace events indepentent of others. - Moved the prototypes of cma_buffer_list_add() and cma_buffer_list_del() from include/linux/cma.h to mm/cma.h. - Various small changes. Changes from v1 (aka "mm: cma: add /proc/cmainfo") (https://lkml.org/lkml/2014/12/26/95): - Rebased on v3.19 and Sasha Levin's patch set v4 [2]. - Moved debug code from cma.c to cma_debug.c. - Moved cmainfo to debugfs and splited it by CMA region. - Splited 'cmainfo' into 'buffers', 'used' and 'maxchunk'. - Used CONFIG_CMA_DEBUGFS instead of CONFIG_CMA_DEBUG. - Added trace events for cma_alloc() and cma_release(). - Don't use seq_files. - A small change of debug output in cma_release(). - cma_buffer_list_del() now supports releasing chunks which ranges don't match allocations. E.g. we have buffer1: [0x0, 0x1], buffer2: [0x2, 0x3], then cma_buffer_list_del(cma, 0x1 /*or 0x0*/, 1 /*(or 2 or 3)*/) should work. - Various small changes. [1] https://lkml.org/lkml/2015/2/12/657 [2] https://lkml.org/lkml/2015/1/28/755 [3] root@debian:/sys/kernel/debug/cma# cat cma-0/buffers 0x2f400000 - 0x2f417000 (92 kB), allocated by pid 1 (swapper/0) [] cma_alloc+0x1bb/0x200 [] dma_alloc_from_contiguous+0x3a/0x40 [] dma_generic_alloc_coherent+0x89/0x160 [] dmam_alloc_coherent+0xbe/0x100 [] ahci_port_start+0xe2/0x210 [] ata_host_start.part.28+0xc0/0x1a0 [] ata_host_activate+0xd0/0x110 [] ahci_host_activate+0x3f/0x170 [] ahci_init_one+0x764/0xab0 [] pci_device_probe+0x6f/0xd0 [] driver_probe_device+0x68/0x210 [] __driver_attach+0x79/0x80 [] bus_for_each_dev+0x4f/0x80 [] driver_attach+0x1e/0x20 [] bus_add_driver+0x157/0x200 [] driver_register+0x5d/0xf0 <...> 0x2f41b000 - 0x2f41c000 (4 kB), allocated by pid 1264 (NetworkManager) [] cma_alloc+0x1bb/0x200 [] dma_alloc_from_contiguous+0x3a/0x40 [] dma_generic_alloc_coherent+0x89/0x160 [] e1000_setup_all_tx_resources+0x93/0x540 [] e1000_open+0x31/0x120 [] __dev_open+0x9f/0x130 [] __dev_change_flags+0x8e/0x150 [] dev_change_flags+0x28/0x60 [] do_setlink+0x2a0/0x760 [] rtnl_newlink+0x60b/0x7b0 [] rtnetlink_rcv_msg+0x84/0x1f0 [] netlink_rcv_skb+0x8e/0xb0 [] rtnetlink_rcv+0x21/0x30 [] netlink_unicast+0x13a/0x1d0 [] netlink_sendmsg+0x240/0x3e0 [] do_sock_sendmsg+0xbd/0xe0 <...> Dmitry Safonov (1): mm: cma: add functions to get region pages counters Stefan Strogin (3): mm: cma: add trace events to debug physically-contiguous memory allocations mm: cma: add number of pages to debug message in cma_release() mm: cma: add list of currently allocated CMA buffers to debugfs include/linux/cma.h | 2 + include/trace/events/cma.h | 57 ++++++++++++++ mm/Kconfig | 17 +++++ mm/cma.c | 45 +++++++++++- mm/cma.h | 26 +++++++ mm/cma_debug.c | 180 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 include/trace/events/cma.h -- 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/