From patchwork Wed Jun 12 01:11:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13694312 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 EB934C27C78 for ; Wed, 12 Jun 2024 01:10:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4B556B00AC; Tue, 11 Jun 2024 21:10:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAC526B00AD; Tue, 11 Jun 2024 21:10:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D58E6B00B0; Tue, 11 Jun 2024 21:10:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6D7226B00AC for ; Tue, 11 Jun 2024 21:10:11 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0E201C0736 for ; Wed, 12 Jun 2024 01:10:11 +0000 (UTC) X-FDA: 82220455422.28.B9A7A44 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf12.hostedemail.com (Postfix) with ESMTP id 9369A40009 for ; Wed, 12 Jun 2024 01:10:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.255 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=1718154609; a=rsa-sha256; cv=none; b=3sSNjGWFBTp6tRR0yjSaOwgv9UoEgSJpP+IQSibmFzNwk0ryljipCqja4Pu8IzQ0b/Ngup u1XQIu4QPdQsK8sYlzWqi6rqD8amJ7G674y9WuP/nzzb8ukPDYgBcFPo1F+xDywcPK2D5d 1+rYnDzrukyXlFEMDHSjothjDwUn7FU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.255 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=1718154609; 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=tSTvCddZRP9YB4qmEFlAU8yY8aT+4u7AMmayidftKD4=; b=LTk95phQHl2nzvz5peuM7EiUbDgyghlpLbASVmBeeHYhbReZr3GZyfNeDv5r46CC6mN6uH 8jZ28mtayL7Y261ZBL3gG9ZM8LDEmE6qDouRIOXUN/OcyOMBRLp6+7SBkuwuGORr9UAvoE vIfUwLOscVzOojVoEinavGUnOd+LJhs= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VzS5x64cgz1SBrq; Wed, 12 Jun 2024 09:05:57 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id EFDA8180069; Wed, 12 Jun 2024 09:10:02 +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; Wed, 12 Jun 2024 09:10:02 +0800 From: Hongbo Li To: , , CC: , , , , Subject: [PATCH 1/2] hugetlbfs: support tracepoint Date: Wed, 12 Jun 2024 09:11:55 +0800 Message-ID: <20240612011156.2891254-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240612011156.2891254-1-lihongbo22@huawei.com> References: <20240612011156.2891254-1-lihongbo22@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-Stat-Signature: uihh35erb7tp6dgsh1fqeb9nir73pbzd X-Rspamd-Queue-Id: 9369A40009 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1718154608-384284 X-HE-Meta: U2FsdGVkX194Q1MCaEH0+9oL8ZYrf/T3lijmeUDDimogGzO71mYHoqDfNxnA9bzr8FIGSyoKXhHrWbu5XRwXlsQ4JG0XqgSYrMjf8drkntnLZID4KVzmHCH57JugMmhQtOAJyL5MGduGdznqQqPjzbkQ/luWJp+YJ0CbepWqCMx69RlPZbsq5pXJzPo/UGWBqDtmc7MptWcOGR5N6DBzXFpiWR2Hwluc6+bytdtigqD3+DJz1fO+8fBnUDdcbspysEZDDrmLl/qTGgEzuHfKwWDGGmIslwpNL4MrE3WvjK9FrXikiN4rbKqFkTxP+3DYMao5Vtf+tsqU5PZSfWttJnkdvU1xsO580cnydgYNf35q0q4r/oV7LVlzAWtuunKhq+9ZvxR6WCEF9Ltk/QdI6tVkt69Oje2BuNY2uPj/kVmXM2Cn03R3SMbCxE00jks6ZxmgTb2fKPfKJpB31emFMPEx4yw/DJ3MXiU/v2kjQHMS4WGy8Mz1tgDCMYzcepJvupXHNJVMeZ6ynXHUbHjvLLnuLNbGnK/5UTaJicH9WFy5jVsd3BV5Lcjre6YpzHNBVZyflq4bHs5EwOyWbo+AKxS0E5q9Tonzuz4txzfAnnJxnOOKZ67zmV4iYGIuxSTBn6ULX7oBpNxo/dRTknBQRYdp4a5fotKX2cjx5BNS0nPMqxL6WqmqDNEG8/whvGZLZD/GQY/BlGlQNJD1yp/delJfa59M0RZZ4BOrx47V/T8axfv3EOfH080t4DJhx18mFTc2vTUHmOi3aYjWmOAm5i9zEbNAyDo/NV8Aj0+C+aurbSBeja8w8iACFO6G6+p/cTwrfUObG6DBUIKGBGqm4RDNtncSSUDD4rzuLRp3kvX7r6TqWizkm/GcQ0coBx2ESI7RvCxfZTVvpCGbBO+gyHnDmZNCfBp9p1eiNOYG6W3uk2wMvkO2UC6c7xk+oRzOgglGbeyeTJ/ZZ+91oc1 bYUTOb8C goA3x4ivsM2SFnZmyemoQIo0Zd5MhApAJ9kIafq6H3QNxHb0jxbKTXD+UDoU6Ll7Z8yi6SrgbKuCQNR+4QfjLaQLIe3ipa917jpX1hjlEl09KnJESb93jX9r44QqJBjWD4KolsF164GVX0UQ= 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 | 164 +++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 include/trace/events/hugetlbfs.h diff --git a/MAINTAINERS b/MAINTAINERS index aacccb376c28..df6fe4aa0f50 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10187,6 +10187,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..a4d785c87155 --- /dev/null +++ b/include/trace/events/hugetlbfs.h @@ -0,0 +1,164 @@ +/* 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, i_mode = 0%o, i_size = %lld, i_nlink = %u, seals = %u, i_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, + unsigned int d_len, const unsigned char *d_name, + unsigned int ia_valid, unsigned int ia_mode, + unsigned int ia_uid, unsigned int ia_gid, + loff_t old_size, loff_t ia_size), + + TP_ARGS(inode, d_len, d_name, + ia_valid, ia_mode, ia_uid, ia_gid, old_size, ia_size), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(unsigned int, d_len) + __string(d_name, d_name) + __field(unsigned int, ia_valid) + __field(unsigned int, ia_mode) + __field(unsigned int, ia_uid) + __field(unsigned int, ia_gid) + __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 = d_len; + __assign_str(d_name); + __entry->ia_valid = ia_valid; + __entry->ia_mode = ia_mode; + __entry->ia_uid = ia_uid; + __entry->ia_gid = ia_gid; + __entry->old_size = old_size; + __entry->ia_size = ia_size; + ), + + TP_printk("dev = (%d,%d), ino = %lu, name = %.*s, ia_valid = %u, ia_mode = 0%o, ia_uid = %u, ia_gid = %u, old_size = %lld, ia_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->ia_uid, __entry->ia_gid, __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 = %x, offset = %lld, len = %lld, i_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