From patchwork Wed Mar 24 16:07:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 12161643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54B92C433C1 for ; Wed, 24 Mar 2021 16:07:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC37761A09 for ; Wed, 24 Mar 2021 16:07:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC37761A09 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 81BE26B02C7; Wed, 24 Mar 2021 12:07:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A4DC6B02D7; Wed, 24 Mar 2021 12:07:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61FD36B02DC; Wed, 24 Mar 2021 12:07:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 44AD46B02C7 for ; Wed, 24 Mar 2021 12:07:48 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F1AE018219363 for ; Wed, 24 Mar 2021 16:07:47 +0000 (UTC) X-FDA: 77955248574.16.2614926 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by imf09.hostedemail.com (Postfix) with ESMTP id BCFA960006C1 for ; Wed, 24 Mar 2021 16:07:44 +0000 (UTC) Received: by mail-wm1-f43.google.com with SMTP id d191so13190851wmd.2 for ; Wed, 24 Mar 2021 09:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F2eqQNnQaTW/PNnGt9t5T4vwku4oA90ao2tJhJGZtFI=; b=HAQORczoTucalytDwswGXDAXkcdld38VvF7BNDmuZcSWktS0OE7md++8dl9QagYDkJ q9oG0x93CIYIIGKujpP2XdBZdaNGh5AnsFraA2FqC1QVpEe80uEHi6B3gPKjdZ0NSsn1 DFQNaenUu0Rngbw0nuwt6sQB3N/DbXitukuvoSoS44ETLH7MEyuwan7qm+4+p/5gqTQB 3vJzJTGSg4weivupcML8hFFDrMT7hDiu0LNXvKJNit7LVtAXt2MTChUGgX64J0I0BV9i b6BLh46tIwO5qrF8/aL1xK3BNGY6Ho/Z/toSlhNAzVmMExFES992s0kO2r8nydv/OTkQ eT5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F2eqQNnQaTW/PNnGt9t5T4vwku4oA90ao2tJhJGZtFI=; b=Qef1o6T7arRLiG0XfeagHHs6lo2qkaVxKyQyEs/cdPToF1OqJrt8Y/j1TBILIANXOV /pqx2WAhJzAo4KSV1pXk7V1I48MGdcHOcTtpqU8OIPfZrTdpcFADsrbsetAGXkQ2HJfF 37/1I5eNGJ+m89SwRsdyk35gzswPuAIsZQPG7GJTqf7O1eXBkwB8UwRgiW8PcBvOXP4N n6Ah33pG7uwvFMWr5+h9xKlXjR6DjeByvXBzmHHB3fkEKQjs7givqKl7mhZjIB0zNpeq VfQZKU/pt8u9TeofwDJ+v9tsHHsjrdfpRTfQUO7aBM+O+x40DYD6gWLHEmOQwWSLLL2W 7H4A== X-Gm-Message-State: AOAM532URPpP3Pyxa3vKVfIcgYhBoT5v2M7PrP1rFYctUenmJURq1Op0 b0Q3C7phu2Xhp/PirdbopOsLuA== X-Google-Smtp-Source: ABdhPJx8ZI9d6RduR34n9l4iaYqCLnlMKGLEHsiZVILBJSM9xXv0/DbPfnkW/rUOoy2qarPbLtTOBw== X-Received: by 2002:a05:600c:4ba2:: with SMTP id e34mr3680336wmp.121.1616602063812; Wed, 24 Mar 2021 09:07:43 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y205sm3463588wmc.18.2021.03.24.09.07.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Mar 2021 09:07:43 -0700 (PDT) From: Georgi Djakov To: rostedt@goodmis.org, akpm@linux-foundation.org Cc: mingo@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org, Liam Mark Subject: [PATCH] mm: cma: add trace events for CMA alloc perf testing Date: Wed, 24 Mar 2021 18:07:40 +0200 Message-Id: <20210324160740.15901-1-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 X-Stat-Signature: ed1bzc9p4cafdtfne4trmcmqnag59cp5 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BCFA960006C1 Received-SPF: none (linaro.org>: No applicable sender policy available) receiver=imf09; identity=mailfrom; envelope-from=""; helo=mail-wm1-f43.google.com; client-ip=209.85.128.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616602064-348901 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Liam Mark Add cma and migrate trace events to enable CMA allocation performance to be measured via ftrace. Signed-off-by: Liam Mark Signed-off-by: Georgi Djakov Reviewed-by: Steven Rostedt (VMware) --- include/trace/events/cma.h | 39 +++++++++++++++++++++++++++++++++- include/trace/events/migrate.h | 22 +++++++++++++++++++ mm/cma.c | 4 ++++ mm/migrate.c | 2 ++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/include/trace/events/cma.h b/include/trace/events/cma.h index 5017a8829270..cdfd06afb39a 100644 --- a/include/trace/events/cma.h +++ b/include/trace/events/cma.h @@ -8,7 +8,7 @@ #include #include -TRACE_EVENT(cma_alloc, +DECLARE_EVENT_CLASS(cma_alloc_class, TP_PROTO(unsigned long pfn, const struct page *page, unsigned int count, unsigned int align), @@ -61,6 +61,43 @@ TRACE_EVENT(cma_release, __entry->count) ); +TRACE_EVENT(cma_alloc_start, + + TP_PROTO(unsigned int count, unsigned int align), + + TP_ARGS(count, align), + + TP_STRUCT__entry( + __field(unsigned int, count) + __field(unsigned int, align) + ), + + TP_fast_assign( + __entry->count = count; + __entry->align = align; + ), + + TP_printk("count=%u align=%u", + __entry->count, + __entry->align) +); + +DEFINE_EVENT(cma_alloc_class, cma_alloc, + + TP_PROTO(unsigned long pfn, const struct page *page, + unsigned int count, unsigned int align), + + TP_ARGS(pfn, page, count, align) +); + +DEFINE_EVENT(cma_alloc_class, cma_alloc_busy_retry, + + TP_PROTO(unsigned long pfn, const struct page *page, + unsigned int count, unsigned int align), + + TP_ARGS(pfn, page, count, align) +); + #endif /* _TRACE_CMA_H */ /* This part must be outside protection */ diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h index 363b54ce104c..9fb2a3bbcdfb 100644 --- a/include/trace/events/migrate.h +++ b/include/trace/events/migrate.h @@ -82,6 +82,28 @@ TRACE_EVENT(mm_migrate_pages, __print_symbolic(__entry->mode, MIGRATE_MODE), __print_symbolic(__entry->reason, MIGRATE_REASON)) ); + +TRACE_EVENT(mm_migrate_pages_start, + + TP_PROTO(enum migrate_mode mode, int reason), + + TP_ARGS(mode, reason), + + TP_STRUCT__entry( + __field(enum migrate_mode, mode) + __field(int, reason) + ), + + TP_fast_assign( + __entry->mode = mode; + __entry->reason = reason; + ), + + TP_printk("mode=%s reason=%s", + __print_symbolic(__entry->mode, MIGRATE_MODE), + __print_symbolic(__entry->reason, MIGRATE_REASON)) +); + #endif /* _TRACE_MIGRATE_H */ /* This part must be outside protection */ diff --git a/mm/cma.c b/mm/cma.c index 90e27458ddb7..984c85fd16ec 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -443,6 +443,8 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, if (!count) goto out; + trace_cma_alloc_start(count, align); + mask = cma_bitmap_aligned_mask(cma, align); offset = cma_bitmap_aligned_offset(cma, align); bitmap_maxno = cma_bitmap_maxno(cma); @@ -483,6 +485,8 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, pr_debug("%s(): memory range at %p is busy, retrying\n", __func__, pfn_to_page(pfn)); + + trace_cma_alloc_busy_retry(pfn, pfn_to_page(pfn), count, align); /* try again with a bit different memory target */ start = bitmap_no + mask + 1; } diff --git a/mm/migrate.c b/mm/migrate.c index 47df0df8f21a..58b1b03e0c98 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1445,6 +1445,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, int rc, nr_subpages; LIST_HEAD(ret_pages); + trace_mm_migrate_pages_start(mode, reason); + if (!swapwrite) current->flags |= PF_SWAPWRITE;