Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753558AbbDANb5 (ORCPT ); Wed, 1 Apr 2015 09:31:57 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:64673 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753155AbbDANbz (ORCPT ); Wed, 1 Apr 2015 09:31:55 -0400 X-AuditID: cbfec7f4-b7f126d000001e9a-05-551bf2984986 From: Stefan Strogin To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Stefan Strogin , Steven Rostedt , Ingo Molnar , Joonsoo Kim , Andrew Morton , Marek Szyprowski , Michal Nazarewicz , aneesh.kumar@linux.vnet.ibm.com, Laurent Pinchart , Sasha Levin , Dmitry Safonov , Pintu Kumar , Laura Abbott , Dyasly Sergey , Vyacheslav Tyrtov , Aleksei Mateosian , gioh.kim@lge.com, stefan.strogin@gmail.com Subject: [PATCH] mm: cma: add trace events for CMA allocations and freeings Date: Wed, 01 Apr 2015 16:31:43 +0300 Message-id: <1427895103-9431-1-git-send-email-s.strogin@partner.samsung.com> X-Mailer: git-send-email 2.1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsVy+t/xq7ozPkmHGlx8LW3xcN4kdos569ew WTx+PY/F4tPKp2wWz5q+MFqs7G5ms9jeOYPdonPiEnaLy7vmsFncW/Of1WLtkbvsFguOt7Ba XDqwgMmi7/thdot9HQ+YLCbPlrL4dnIOs8XiI7eZLS6/+c9uMXXGD3YHEY/Lfb1MHjtn3WX3 aNl3i91jdsdMVo9Nnyaxe3S9vcLkcWLGbxaPB4c2s3is+/OKyePj01ssHgff7WHyeL/vKptH 35ZVjB6fN8kF8EVx2aSk5mSWpRbp2yVwZbzvfctc8E+qYs/y44wNjHdFuxg5OSQETCQmTuxn hLDFJC7cW8/WxcjFISSwlFFiY+9FFginl0liRtdiJpAqNqCOYxemg3WIANm7m+eC2cwC11gl 3j8N7GLk4BAW8JbYuyUIxGQRUJVYs0kWpIJXwEfi29/trBC75CQ27P7POIGRewEjwypG0dTS 5ILipPRcQ73ixNzi0rx0veT83E2MkOD/soNx8TGrQ4wCHIxKPLyc0VKhQqyJZcWVuYcYJTiY lUR42Z9KhwrxpiRWVqUW5ccXleakFh9iZOLglGpg3Gqvqr705U/Rf4LmUhPesryKFs27u9Gr 0OZ0xcpckX2/Ll3nqOb4syxLr3Kfa87jiVtztESemim9/3Nu4vJVyX6Bt5Xalj7QfSdTmLH4 8ZX9K66uPsRienWLjkElQ81vrfa+VarTgjdvi2j+7XF8+203foXL7i6v2kJ95tvlRtbq3G23 +lDQp8RSnJFoqMVcVJwIAPZyH7BcAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3566 Lines: 138 Add trace events for cma_alloc() and cma_release(). The cma_alloc tracepoint is used both for successful and failed allocations, in case of allocation failure pfn=-1UL is stored and printed. Signed-off-by: Stefan Strogin --- Took out from the patch set "mm: cma: add some debug information for CMA" v4 (http://thread.gmane.org/gmane.linux.kernel.mm/129903) because of probable uselessness of the rest of the patches. Changes from the version from the patch set: - Constify the struct page * parameter passed to the tracepoints. - Pass both pfn and struct page * to the tracepoints to decrease unnecessary pfn_to_page() and page_to_pfn() calls and avoid using them in TP_printk. - Store and print pfn=-1UL instead of pfn=0, because 0th pfn can truly exist on some architectures. include/trace/events/cma.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++ mm/cma.c | 5 ++++ 2 files changed, 68 insertions(+) create mode 100644 include/trace/events/cma.h diff --git a/include/trace/events/cma.h b/include/trace/events/cma.h new file mode 100644 index 0000000..e01b35d --- /dev/null +++ b/include/trace/events/cma.h @@ -0,0 +1,63 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM cma + +#if !defined(_TRACE_CMA_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_CMA_H + +#include +#include + +TRACE_EVENT(cma_alloc, + + TP_PROTO(unsigned long pfn, const struct page *page, + unsigned int count), + + TP_ARGS(pfn, page, count), + + TP_STRUCT__entry( + __field(unsigned long, pfn) + __field(const struct page *, page) + __field(unsigned int, count) + ), + + TP_fast_assign( + __entry->pfn = pfn; + __entry->page = page; + __entry->count = count; + ), + + TP_printk("pfn=%lx page=%p count=%u", + __entry->pfn, + __entry->page, + __entry->count) +); + +TRACE_EVENT(cma_release, + + TP_PROTO(unsigned long pfn, const struct page *page, + unsigned int count), + + TP_ARGS(pfn, page, count), + + TP_STRUCT__entry( + __field(unsigned long, pfn) + __field(const struct page *, page) + __field(unsigned int, count) + ), + + TP_fast_assign( + __entry->pfn = pfn; + __entry->page = page; + __entry->count = count; + ), + + TP_printk("pfn=%lx page=%p count=%u", + __entry->pfn, + __entry->page, + __entry->count) +); + +#endif /* _TRACE_CMA_H */ + +/* This part must be outside protection */ +#include diff --git a/mm/cma.c b/mm/cma.c index 47203fa..e9410b7c 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -23,6 +23,7 @@ # define DEBUG #endif #endif +#define CREATE_TRACE_POINTS #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include "cma.h" @@ -414,6 +416,8 @@ struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align) start = bitmap_no + mask + 1; } + trace_cma_alloc(page ? pfn : -1UL, page, count); + pr_debug("%s(): returned %p\n", __func__, page); return page; } @@ -446,6 +450,7 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count) free_contig_range(pfn, count); cma_clear_bitmap(cma, pfn, count); + trace_cma_release(pfn, pages, count); return true; } -- 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/