From patchwork Tue Jul 23 03:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13739289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E33D1C3DA70 for ; Tue, 23 Jul 2024 03:03:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB8C36B0088; Mon, 22 Jul 2024 23:03:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF2F56B0089; Mon, 22 Jul 2024 23:03:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1F3A6B008A; Mon, 22 Jul 2024 23:03:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 82F506B0088 for ; Mon, 22 Jul 2024 23:03:34 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2270CA1B7F for ; Tue, 23 Jul 2024 03:03:34 +0000 (UTC) X-FDA: 82369521948.22.38F36F4 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf30.hostedemail.com (Postfix) with ESMTP id 76B9A8000E for ; Tue, 23 Jul 2024 03:03:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=lihongbo22@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721703789; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YHcViOhs66YKTs24XG3I6Lct2/SrqlKDxlXZqgWhLmc=; b=vfSWfYsY4wM7F7SRbA02kKt5N5+HxHc0AlrtESIofWII2evC5zTkQkNzqo7mOh6JW11m3A 1enj09U1klUImCLAiYkmM+aUyYVjoQRm2+kS9xzbGpE61awgJxZAIiTG51J+UytB5NZCLK N0sYr4R4veJD4Jxd4ptRZ2Qkaau7FcA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=lihongbo22@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721703789; a=rsa-sha256; cv=none; b=BGbQEzdjvqjTLV9RnlrrmCnLFV2R1tiihnITSTEb4cRa5E4K3tWeWqKoGxgeV8kn3Of8oc UiFOJXtNM0Drub5Px1BDI1ThI68f08f3TJoPZBTRbxWaDS2cGAuFOKUsnvmsmOt2PAKtPX Rv7SmygaWsihnTf2RSJvLcie1oiKC/I= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WShkf2XHwz20lW3; Tue, 23 Jul 2024 11:01:46 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id C42331A0188; Tue, 23 Jul 2024 11:03:27 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 23 Jul 2024 11:03:27 +0800 From: Hongbo Li To: , , , CC: , , , , Subject: [PATCH v3 1/2] hugetlbfs: support tracepoint Date: Tue, 23 Jul 2024 11:08:33 +0800 Message-ID: <20240723030834.213012-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723030834.213012-1-lihongbo22@huawei.com> References: <20240723030834.213012-1-lihongbo22@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500022.china.huawei.com (7.185.36.66) X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 76B9A8000E X-Stat-Signature: wxya8ahykptumdc7azrynp5eh64as8wr X-Rspam-User: X-HE-Tag: 1721703811-59256 X-HE-Meta: U2FsdGVkX19TzVOxedKyBRjH4EXOUAoMqrWGpn2aCQb6+MMvfct0mAc4zUO6vy87Vs5gyy3GyOlt/VQpxfpg7TaNfHNfvXdsMhVhoGhLSruzs7vWmfkXo+oODW+PGXtp30Bmy2LuZysvTv6qczJU1MCIoItnKjHtpjh+QtDFHasmhVYAQQtmTja/rd3dB086KCKPw/kGBCLVE0cibTs6APLIKA5Vw51/RVArQIPnOeJqoSFaRTvEYlLfmNLQ2TlfdLXmgKb1KbrAJm2CeWuMCUVShex2zl63h75s6fuzrmsQnvIvi5uoAqlxhjwDiD9DfVXAroHENW+yJTuSxIqGAEb2lfYUPH8Es2iDNcl4tuzCsuv2DDGF3r9NfBBLDQvgZT5loARO+CrXFR9R9XijE/Pbp3mauvwJtyaq03ypCg95xTzMjvrz/3eGRoJVrWpgFY8/ik/99A8fzwP5OtTnti1t1Jyk5c4esgzy8t1uKP5Bb7Yf5rSR9sWxch3ABz+ZeYMmN8c/XtMZtZ6x5PX+4GQVSD3xG/pJ055JJ1AxqA/yFBYoCgQPvRNyLO/QG1hMGbKw5367t7k5Ic5ZhzO2h5rwyQfMsujRwJsxZgXwOTLjqionMbMK8Z0MNS6kgtRtIuSoM/7wBdr04y6xQQb3J6OddtkTyzMkKu34uqsYqozQzBQA4MLAYMZAr0slrtNEP/dGwOweaon9BoyDX7DnZf/cxrtI0ajAiGHE5OVitYI7s6WKU3qrnqTGUbbOvBWolVqKpgmGghqvcCm05slgSC4PNbSxafpoGs7W3ZA71yBNoTVc4M54ymXkJzqyQAQAMGo8lRNxRQZAhWsWIsQgYDnqft2L6Fi97c+0fdRMSsposHMfNSFP+NbYjxvvTbXnwqfypkUnNCcQ919O2F/rDyIUfrMjMLR4/M3+5Jfzq06QUxyHSBpDfxaGTWMv4H5snahaBoAauQsDF0g8cL/ fhqHLGoS r6qL3WAkGye5r6a/VUh4pE099oslnQ2CKjv+qRnfpwv3y0EOUOTYscWB2wHHxwxNWwXQM+BYS1koBVA0g6yQ4HFN1G76N79j5CPd3ObAn80qKDMViK6Jqe6sOp98aW5eSFMQR4IAuPg56kj8= 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: List-Subscribe: List-Unsubscribe: Add basic tracepoints for {alloc, evict, free}_inode, setattr and fallocate. These can help users to debug hugetlbfs more conveniently. Signed-off-by: Hongbo Li --- MAINTAINERS | 1 + include/trace/events/hugetlbfs.h | 156 +++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 include/trace/events/hugetlbfs.h diff --git a/MAINTAINERS b/MAINTAINERS index a0baccca11de..362e846e1294 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10351,6 +10351,7 @@ F: Documentation/mm/hugetlbfs_reserv.rst F: Documentation/mm/vmemmap_dedup.rst F: fs/hugetlbfs/ F: include/linux/hugetlb.h +F: include/trace/events/hugetlbfs.h F: mm/hugetlb.c F: mm/hugetlb_vmemmap.c F: mm/hugetlb_vmemmap.h diff --git a/include/trace/events/hugetlbfs.h b/include/trace/events/hugetlbfs.h new file mode 100644 index 000000000000..8331c904a9ba --- /dev/null +++ b/include/trace/events/hugetlbfs.h @@ -0,0 +1,156 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM hugetlbfs + +#if !defined(_TRACE_HUGETLBFS_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HUGETLBFS_H + +#include + +TRACE_EVENT(hugetlbfs_alloc_inode, + + TP_PROTO(struct inode *inode, struct inode *dir, int mode), + + TP_ARGS(inode, dir, mode), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(ino_t, dir) + __field(__u16, mode) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->dir = dir->i_ino; + __entry->mode = mode; + ), + + TP_printk("dev %d,%d ino %lu dir %lu mode 0%o", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long) __entry->ino, + (unsigned long) __entry->dir, __entry->mode) +); + +DECLARE_EVENT_CLASS(hugetlbfs__inode, + + TP_PROTO(struct inode *inode), + + TP_ARGS(inode), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(__u16, mode) + __field(loff_t, size) + __field(unsigned int, nlink) + __field(unsigned int, seals) + __field(blkcnt_t, blocks) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->mode = inode->i_mode; + __entry->size = inode->i_size; + __entry->nlink = inode->i_nlink; + __entry->seals = HUGETLBFS_I(inode)->seals; + __entry->blocks = inode->i_blocks; + ), + + TP_printk("dev %d,%d ino %lu mode 0%o size %lld nlink %u seals %u blocks %llu", + MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, + __entry->mode, __entry->size, __entry->nlink, __entry->seals, + (unsigned long long)__entry->blocks) +); + +DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_evict_inode, + + TP_PROTO(struct inode *inode), + + TP_ARGS(inode) +); + +DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_free_inode, + + TP_PROTO(struct inode *inode), + + TP_ARGS(inode) +); + +TRACE_EVENT(hugetlbfs_setattr, + + TP_PROTO(struct inode *inode, struct dentry *dentry, + struct iattr *attr), + + TP_ARGS(inode, dentry, attr), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(unsigned int, d_len) + __string(d_name, dentry->d_name.name) + __field(unsigned int, ia_valid) + __field(unsigned int, ia_mode) + __field(loff_t, old_size) + __field(loff_t, ia_size) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->d_len = dentry->d_name.len; + __assign_str(d_name); + __entry->ia_valid = attr->ia_valid; + __entry->ia_mode = attr->ia_mode; + __entry->old_size = inode->i_size; + __entry->ia_size = attr->ia_size; + ), + + TP_printk("dev %d,%d ino %lu name %.*s valid %#x mode 0%o old_size %lld size %lld", + MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long)__entry->ino, + __entry->d_len, __get_str(d_name), __entry->ia_valid, __entry->ia_mode, + __entry->old_size, __entry->ia_size) +); + +TRACE_EVENT(hugetlbfs_fallocate, + + TP_PROTO(struct inode *inode, int mode, + loff_t offset, loff_t len, int ret), + + TP_ARGS(inode, mode, offset, len, ret), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(int, mode) + __field(loff_t, offset) + __field(loff_t, len) + __field(loff_t, size) + __field(int, ret) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->mode = mode; + __entry->offset = offset; + __entry->len = len; + __entry->size = inode->i_size; + __entry->ret = ret; + ), + + TP_printk("dev %d,%d ino %lu mode 0%o offset %lld len %lld size %lld ret %d", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long)__entry->ino, __entry->mode, + (unsigned long long)__entry->offset, + (unsigned long long)__entry->len, + (unsigned long long)__entry->size, + __entry->ret) +); + +#endif /* _TRACE_HUGETLBFS_H */ + + /* This part must be outside protection */ +#include