From patchwork Wed Jun 12 01:11:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13694311 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 795CEC27C7B for ; Wed, 12 Jun 2024 01:10:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F20D6B00AB; Tue, 11 Jun 2024 21:10:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79D1E6B00AC; Tue, 11 Jun 2024 21:10:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 616566B00AD; Tue, 11 Jun 2024 21:10:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4450A6B00AB for ; Tue, 11 Jun 2024 21:10:10 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BA3D8410CA for ; Wed, 12 Jun 2024 01:10:09 +0000 (UTC) X-FDA: 82220455338.05.F67382F Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf19.hostedemail.com (Postfix) with ESMTP id 4E0F21A000C for ; Wed, 12 Jun 2024 01:10:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.189 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=1718154608; 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=Bl4Z8pa52lQKTTWuDL8L1PMN17jJxXExfo0IQByCVGw=; b=unmPyb4ZYqBh/ZFW02fQa/cEdga+qBlmxzPJsDG8lU0y4FPHEJ9BOwnqMpdCIwOqh2MJSE foujQDG2nPYSSv95QqkMfb/5ji7jKhLA5btfVW5rBfgtjUXfhNVkfnJCrxNXapr7AVf4Sv qHEUml5UhsMZqSFnJfEU88dHmHAXrJU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718154608; a=rsa-sha256; cv=none; b=3XqUPTY5/C730XcRUN8W+auIsPQWdLybRrX3Vhy8PiCHSeYhb/ekEib+Fvgrr/gafoJQM7 uIDjm+ka1TFjxYRbL6oY8FpchOhOnXIIfTgPA1dVbZ3yeXC8Yfd9pPEH36axNSTzwGEI0R +A7i/5cmHQ4h0EWchN7q5SUljybcpjs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=lihongbo22@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VzS6l1xWBzPqYx; Wed, 12 Jun 2024 09:06:39 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id DE854140257; Wed, 12 Jun 2024 09:10:03 +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:03 +0800 From: Hongbo Li To: , , CC: , , , , Subject: [PATCH 2/2] hugetlbfs: use tracepoints in hugetlbfs functions. Date: Wed, 12 Jun 2024 09:11:56 +0800 Message-ID: <20240612011156.2891254-3-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-Rspamd-Server: rspam03 X-Stat-Signature: ick8tkykp47idxtxgnjqmksc3e6t7ksd X-Rspamd-Queue-Id: 4E0F21A000C X-Rspam-User: X-HE-Tag: 1718154606-438272 X-HE-Meta: U2FsdGVkX18rT5+SoumV0AEY9vBqIh8lV15i0PQCx0lMo4kIjLArtJ9tMeheXYGrBnZgHJRNE0MoSrQCY0iuAYtL+24o/z9uLv3mr6+ZnT59y0rj6Dl3aAxRAZ4ma8ejwb84/hiHWZ/Cywy/29LMMS9KpirLEgHq2c7x07cwBHngEny0lHGdNJdK4vBtUXb8nZEX2fzgSL4aiP0gGIW2eLpyHlxvhLrzsxRmHY3zRnF04mEwGDv4wS/Q/aNHKDYfk1UV+6KuyPNcIz72c/+spcuvjKsXlJR+ZWEm5g0xfMCiG1DZzy8GwOl1YOjouKeZ6+T6oaTYo7QoKYC/TdSL0egBuug5LM9UL0iY/z/JLFvPbgS44bgLXjIJIsojsGc0NgXQPidvf07fHhTm7ZK6YQ3msK5wErwIQupwzEu9fpHS4zXVA5h5wGoJ6ij9DHhh3bDBYJHwV5v570OTn9hYsW91nTH3sqA8M3h5DX3ti5ZDB381J0J5yZqoOd6Ms9uEt5q952YcxbNJj7WkcX13QEwthP8wiVJ7+YeqWXrkrHyOhfXsA6Py3g0g3LDT6e2rxfdIw4lQkVQRPktKpgqxFJv/lbV4hue464L1AqMK+E9hyWCvZeZB+qw5Km9x03Q2B925ZqCZIpuExKVnzF7lTYz37jiceh7+yNf80xSa4ngaAOO0YcFHnA6eRUUz415nUU2TwhVYbX+UNjVIs5GrIt1/hQ6nxFxfHBa0LTYZ1J13wYTRxZc7wzAiZO9LkQ8jbQiIa5dgPDb2VDH0rbsFZqLYZmdRz+d0lPflKc3A3cSEyCAHd2O/jdlUK1CO9w1P5q5ztktB/vLFPUvXCvZ0nuzSLyWynCd1rmYoHLw7S6JSPwrnSiqa2vve2XaOpv8rF0YayCib/KvgKuEO0vhwXYN73XPReV+sXSAYqsm+JwZtRW/DPyGUiA80eIFY5gJz1JLnUnYRSaYwHgIMaaR 9HAe1/ZF zvxE+cRle/5iP+5av8/ReD7LHfmRtA0AYm9BsF9s4UoJki9+hXUlgaI/BaOxBt5yWic2+fT3gRQFm4RQIF2SnWGvNnIZ09ORnVvA+9bCalPqG+9+DT93T9XhQ75UfKHT4yCzq3MxyGEKDsjjSNYAu8b6bUqK8YLIQXM6h/PdInSrXdqPeO1tXXirkIw== 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: Here we use the hugetlbfs tracepoint to track the call stack. And the output in trace is as follows: ``` touch-5307 [004] ..... 1402.167607: hugetlbfs_alloc_inode: dev = (0,50), ino = 21380, dir = 16921, mode = 0100644 touch-5307 [004] ..... 1402.167638: hugetlbfs_setattr: dev = (0,50), ino = 21380, name = testfile1, ia_valid = 131184, ia_mode = 0132434, ia_uid = 2863018275, ia_gid = 4294967295, old_size = 0, ia_size = 4064 truncate-5328 [003] ..... 1436.031054: hugetlbfs_setattr: dev = (0,50), ino = 21380, name = testfile1, ia_valid = 8296, ia_mode = 0177777, ia_uid = 2862574544, ia_gid = 4294967295, old_size = 0, ia_size = 2097152 rm-5338 [004] ..... 1484.426247: hugetlbfs_evict_inode: dev = (0,50), ino = 21380, i_mode = 0100644, i_size = 2097152, i_nlink = 0, seals = 1, i_blocks = 0 -0 [004] ..s1. 1484.446668: hugetlbfs_free_inode: dev = (0,50), ino = 21380, i_mode = 0100644, i_size = 2097152, i_nlink = 0, seals = 1, i_blocks = 0 ``` Signed-off-by: Hongbo Li --- fs/hugetlbfs/inode.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 412f295acebe..f3399c6a02ca 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -39,6 +39,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + static const struct address_space_operations hugetlbfs_aops; static const struct file_operations hugetlbfs_file_operations; static const struct inode_operations hugetlbfs_dir_inode_operations; @@ -686,6 +689,7 @@ static void hugetlbfs_evict_inode(struct inode *inode) { struct resv_map *resv_map; + trace_hugetlbfs_evict_inode(inode); remove_inode_hugepages(inode, 0, LLONG_MAX); /* @@ -813,8 +817,10 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) return -EOPNOTSUPP; - if (mode & FALLOC_FL_PUNCH_HOLE) - return hugetlbfs_punch_hole(inode, offset, len); + if (mode & FALLOC_FL_PUNCH_HOLE) { + error = hugetlbfs_punch_hole(inode, offset, len); + goto out_nolock; + } /* * Default preallocate case. @@ -918,6 +924,9 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, inode_set_ctime_current(inode); out: inode_unlock(inode); + +out_nolock: + trace_hugetlbfs_fallocate(inode, mode, offset, len, error); return error; } @@ -934,6 +943,12 @@ static int hugetlbfs_setattr(struct mnt_idmap *idmap, if (error) return error; + trace_hugetlbfs_setattr(inode, dentry->d_name.len, dentry->d_name.name, + attr->ia_valid, attr->ia_mode, + from_kuid(&init_user_ns, attr->ia_uid), + from_kgid(&init_user_ns, attr->ia_gid), + inode->i_size, attr->ia_size); + if (ia_valid & ATTR_SIZE) { loff_t oldsize = inode->i_size; loff_t newsize = attr->ia_size; @@ -1032,6 +1047,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, break; } lockdep_annotate_inode_mutex_key(inode); + trace_hugetlbfs_alloc_inode(inode, dir, mode); } else { if (resv_map) kref_put(&resv_map->refs, resv_map_release); @@ -1274,6 +1290,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) static void hugetlbfs_free_inode(struct inode *inode) { + trace_hugetlbfs_free_inode(inode); kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); }