Message ID | 20221018181053.434508-2-urezki@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2096332wrs; Tue, 18 Oct 2022 11:16:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67xKeSM9ltr71iSqpaYXtqZ1TY875QRhwiTN2mApjJukUf4il7k92PakhEChTiVFeRntuT X-Received: by 2002:a17:906:5dac:b0:78d:fc53:7db1 with SMTP id n12-20020a1709065dac00b0078dfc537db1mr3391790ejv.99.1666116963559; Tue, 18 Oct 2022 11:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666116963; cv=none; d=google.com; s=arc-20160816; b=aVrbR27rnDs97T/Mwiv1UR9F7f3q4CyGhBAOBvgKrXyrqUqM3VcDq7S3U1xgVASjz2 dgQDJaQ3o1DSn7GXOCGHn7daJE2KnU3nk7oIKhGjC3/FSQqVycMn/wGf7UAsfwKN7zZy iWFkHUeL/5SVFl9KadxdrsGvj7XcZC+VwVE+FzJEu8909zeQJzI7oov57mWfvlB0QrQD q5QX/s3IS9mD7jS58WmZMdXv0q60MpxGTz6LRwzMvoo5Dhwkba/gitZ8EZioTiCAhUXq M2byoEzVXNVKlRp5Nh23OdsCddBq0ocomWixNnb5eOIoCDWq4tdlWf++Waci7fCzp4EV h8WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=se3AV6vebDZ5YP2shntPND551GMkzS6L+QPXNqXiQ7o=; b=KbEIj0PsXs7M4/6xUDAPpSbPjY+DORZU6H0tS2w4Tj8aoXWDdTOuzIpFnQNC1r/qYf LC9p6/GjbkPFzObeTxGXShJG2UJaX0XkrpltSlmkPgQYBU1S4Vqg6Qa4R0OcrheDZNDL MyY5CA7n2STOrZu6JTFsj0BkBiRY+jSDVKopBRNnfpXHi5zNZJcJZSKdrrCvpUB9gmwl myQb8dPnazNkSeLREXzmyGmhlfbw9wSzle2HZvhpVk3B65/fQzEsXrjnOb5wyxKlYK2e EtBk+a1IsB0PAm6vj7AaNqo0nbBWlV4cpnpF0xgA7W1TeiG7wIPlyBtkKY5WZKOZvDYu kafg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EiH1XPct; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go37-20020a1709070da500b0078356aaeb61si13028136ejc.286.2022.10.18.11.15.36; Tue, 18 Oct 2022 11:16:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EiH1XPct; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbiJRSLD (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 18 Oct 2022 14:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbiJRSLA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Oct 2022 14:11:00 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 076212A402 for <linux-kernel@vger.kernel.org>; Tue, 18 Oct 2022 11:10:59 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id r14so21722458edc.7 for <linux-kernel@vger.kernel.org>; Tue, 18 Oct 2022 11:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=se3AV6vebDZ5YP2shntPND551GMkzS6L+QPXNqXiQ7o=; b=EiH1XPctTsH40jJoCVZZQ2IWCv/qUknaMjZUF6TgNR1NyiiSgP1FKDRwgS3YgvgusO KAuH+P3qhGPDvn9cHgJYQ3UTGZGWiJlnO/BPHA/hsY8Ri9HPyj/YX5Tr7/BV7dnuoHlQ AtOfDu0kXX/3QfwsV1hlmwVz9X+MeAL0TpbJIQ2awoBkxBa+iQkwbt4U+XoHEetoQ3J5 SnhRrjXJuyZiyawCxpUsB/X1SVmr2DP4dlXgGt39dKrXXpQnovJNwgHhtrEYxPAF9Yp5 zigl8L0Dn6HAeQDpPGtOBDWQmEvL6nC2ySfy50CgtLQmONHTErp3JDAE9H2hq5yQ3prC 3mvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=se3AV6vebDZ5YP2shntPND551GMkzS6L+QPXNqXiQ7o=; b=OX1IU61dl/YpJSFrq5FQOwPupjrFA3CjPb9hSpmlpcAYhzOZ3QU73Byg8F65BVkwa6 w73GdIOmVjra30r/EVr95wWpbs2WkTMl4J8PhSylGe5ritKahZTzXKn74bx7s4aMVOTy iACTXSNXE8Q3/Z4TZcDNR1vvLQWy4WFgmbWQEF1Tf+ehm+K5h66BFRY8DKWuzKKqfsOc XCLJtX0mVXq8ZNkKGVeLNYswBdbimtNrDHqqbIwbxiQTVwzKVrzwYwnILwivXXRv8roc E3tNE8h8LvzmmmIVDPK/NxuZ/LcCG5nJpscIjeDsZaqnl8LwMakz6k/dNSlbDFmHFlzo Fkmw== X-Gm-Message-State: ACrzQf2IE7Be8Htm1vqm1/LwLdME0iGzzL8/pOLhkhmZbT7fJV8Exz3m zke7y5mTlglSpzEzVFaIUTE= X-Received: by 2002:a05:6402:5193:b0:45c:e2c6:6f0e with SMTP id q19-20020a056402519300b0045ce2c66f0emr3820266edd.29.1666116657449; Tue, 18 Oct 2022 11:10:57 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id c1-20020a17090618a100b007877ad05b32sm7739302ejf.208.2022.10.18.11.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 11:10:56 -0700 (PDT) From: "Uladzislau Rezki (Sony)" <urezki@gmail.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>, Christoph Hellwig <hch@infradead.org>, Matthew Wilcox <willy@infradead.org>, Nicholas Piggin <npiggin@gmail.com>, Steven Rostedt <rostedt@goodmis.org>, Uladzislau Rezki <urezki@gmail.com>, Oleksiy Avramchenko <oleksiy.avramchenko@sony.com> Subject: [PATCH v2 1/7] mm: vmalloc: Add alloc_vmap_area trace event Date: Tue, 18 Oct 2022 20:10:47 +0200 Message-Id: <20221018181053.434508-2-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018181053.434508-1-urezki@gmail.com> References: <20221018181053.434508-1-urezki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747050261255966821?= X-GMAIL-MSGID: =?utf-8?q?1747050261255966821?= |
Series |
Add basic trace events for vmap/vmalloc (v2)
|
|
Commit Message
Uladzislau Rezki
Oct. 18, 2022, 6:10 p.m. UTC
It is for a debug purpose and for validation of passed parameters.
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
include/trace/events/vmalloc.h | 56 ++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 include/trace/events/vmalloc.h
Comments
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
On Tue, 18 Oct 2022 20:10:47 +0200 "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote: > It is for a debug purpose and for validation of passed parameters. > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > --- > include/trace/events/vmalloc.h | 56 ++++++++++++++++++++++++++++++++++ > 1 file changed, 56 insertions(+) > create mode 100644 include/trace/events/vmalloc.h > > diff --git a/include/trace/events/vmalloc.h b/include/trace/events/vmalloc.h > new file mode 100644 > index 000000000000..39fbd77c91e7 > --- /dev/null > +++ b/include/trace/events/vmalloc.h > @@ -0,0 +1,56 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM vmalloc > + > +#if !defined(_TRACE_VMALLOC_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_VMALLOC_H > + > +#include <linux/tracepoint.h> > + > +/** > + * alloc_vmap_area - called when a new vmap allocation occurs > + * @addr: an allocated address > + * @size: a requested size > + * @align: a requested alignment > + * @vstart: a requested start range > + * @vend: a requested end range > + * @failed: an allocation failed or not > + * > + * This event is used for a debug purpose, it can give an extra > + * information for a developer about how often it occurs and which > + * parameters are passed for further validation. > + */ > +TRACE_EVENT(alloc_vmap_area, > + > + TP_PROTO(unsigned long addr, unsigned long size, unsigned long align, > + unsigned long vstart, unsigned long vend, int failed), > + > + TP_ARGS(addr, size, align, vstart, vend, failed), The above is passed in via (from patch 4): @@ -1621,6 +1624,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, size, align, vstart, vend); spin_unlock(&free_vmap_area_lock); + trace_alloc_vmap_area(addr, size, align, vstart, vend, addr == vend); + /* * If an allocation fails, the "vend" address is * returned. Therefore trigger the overflow path. > + > + TP_STRUCT__entry( > + __field(unsigned long, addr) > + __field(unsigned long, size) > + __field(unsigned long, align) > + __field(unsigned long, vstart) > + __field(unsigned long, vend) > + __field(int, failed) I would drop the failed field... > + ), > + > + TP_fast_assign( > + __entry->addr = addr; > + __entry->size = size; > + __entry->align = align; > + __entry->vstart = vstart; > + __entry->vend = vend; And instead have: __entry->failed = addr == vend; Why pass in a parameter that can be calculated in the trace event logic? Other than that, from a tracing perspective: Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> for the series. -- Steve > + __entry->failed = failed; > + ), > + > + TP_printk("va_start: %lu size=%lu align=%lu vstart=0x%lx vend=0x%lx failed=%d", > + __entry->addr, __entry->size, __entry->align, > + __entry->vstart, __entry->vend, __entry->failed) > +); > + > +#endif /* _TRACE_VMALLOC_H */ > + > +/* This part must be outside protection */ > +#include <trace/define_trace.h>
> On Tue, 18 Oct 2022 20:10:47 +0200 > "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote: > > > It is for a debug purpose and for validation of passed parameters. > > > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > > --- > > include/trace/events/vmalloc.h | 56 ++++++++++++++++++++++++++++++++++ > > 1 file changed, 56 insertions(+) > > create mode 100644 include/trace/events/vmalloc.h > > > > diff --git a/include/trace/events/vmalloc.h b/include/trace/events/vmalloc.h > > new file mode 100644 > > index 000000000000..39fbd77c91e7 > > --- /dev/null > > +++ b/include/trace/events/vmalloc.h > > @@ -0,0 +1,56 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +#undef TRACE_SYSTEM > > +#define TRACE_SYSTEM vmalloc > > + > > +#if !defined(_TRACE_VMALLOC_H) || defined(TRACE_HEADER_MULTI_READ) > > +#define _TRACE_VMALLOC_H > > + > > +#include <linux/tracepoint.h> > > + > > +/** > > + * alloc_vmap_area - called when a new vmap allocation occurs > > + * @addr: an allocated address > > + * @size: a requested size > > + * @align: a requested alignment > > + * @vstart: a requested start range > > + * @vend: a requested end range > > + * @failed: an allocation failed or not > > + * > > + * This event is used for a debug purpose, it can give an extra > > + * information for a developer about how often it occurs and which > > + * parameters are passed for further validation. > > + */ > > +TRACE_EVENT(alloc_vmap_area, > > + > > + TP_PROTO(unsigned long addr, unsigned long size, unsigned long align, > > + unsigned long vstart, unsigned long vend, int failed), > > + > > + TP_ARGS(addr, size, align, vstart, vend, failed), > > The above is passed in via (from patch 4): > > > @@ -1621,6 +1624,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, > size, align, vstart, vend); > spin_unlock(&free_vmap_area_lock); > > + trace_alloc_vmap_area(addr, size, align, vstart, vend, addr == vend); > + > /* > * If an allocation fails, the "vend" address is > * returned. Therefore trigger the overflow path. > > > + > > + TP_STRUCT__entry( > > + __field(unsigned long, addr) > > + __field(unsigned long, size) > > + __field(unsigned long, align) > > + __field(unsigned long, vstart) > > + __field(unsigned long, vend) > > > + __field(int, failed) > > I would drop the failed field... > > > + ), > > + > > + TP_fast_assign( > > + __entry->addr = addr; > > + __entry->size = size; > > + __entry->align = align; > > + __entry->vstart = vstart; > > + __entry->vend = vend; > > And instead have: > > __entry->failed = addr == vend; > > Why pass in a parameter that can be calculated in the trace event logic? > It can be. A condition about when it is failed or not is taken on upper level because it might be changed afterwards. So a trace event is not aware about it thus no need in adaptation. But i do not have a strong opinion here. I can prepare a patch to eliminate it. What is your preference? -- Uladzislau Rezki
diff --git a/include/trace/events/vmalloc.h b/include/trace/events/vmalloc.h new file mode 100644 index 000000000000..39fbd77c91e7 --- /dev/null +++ b/include/trace/events/vmalloc.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM vmalloc + +#if !defined(_TRACE_VMALLOC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_VMALLOC_H + +#include <linux/tracepoint.h> + +/** + * alloc_vmap_area - called when a new vmap allocation occurs + * @addr: an allocated address + * @size: a requested size + * @align: a requested alignment + * @vstart: a requested start range + * @vend: a requested end range + * @failed: an allocation failed or not + * + * This event is used for a debug purpose, it can give an extra + * information for a developer about how often it occurs and which + * parameters are passed for further validation. + */ +TRACE_EVENT(alloc_vmap_area, + + TP_PROTO(unsigned long addr, unsigned long size, unsigned long align, + unsigned long vstart, unsigned long vend, int failed), + + TP_ARGS(addr, size, align, vstart, vend, failed), + + TP_STRUCT__entry( + __field(unsigned long, addr) + __field(unsigned long, size) + __field(unsigned long, align) + __field(unsigned long, vstart) + __field(unsigned long, vend) + __field(int, failed) + ), + + TP_fast_assign( + __entry->addr = addr; + __entry->size = size; + __entry->align = align; + __entry->vstart = vstart; + __entry->vend = vend; + __entry->failed = failed; + ), + + TP_printk("va_start: %lu size=%lu align=%lu vstart=0x%lx vend=0x%lx failed=%d", + __entry->addr, __entry->size, __entry->align, + __entry->vstart, __entry->vend, __entry->failed) +); + +#endif /* _TRACE_VMALLOC_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>