From patchwork Tue Feb 6 12:09:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 197390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1496991dyb; Tue, 6 Feb 2024 04:19:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdixT3JnxVlyQDOb9P1ugNPubq4urCAv+AA2Wu9iOn1RvUMwrZAATOmtq5fZsbE2wADF6S X-Received: by 2002:ac8:5513:0:b0:42b:e9e3:283 with SMTP id j19-20020ac85513000000b0042be9e30283mr1634555qtq.17.1707221956471; Tue, 06 Feb 2024 04:19:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707221956; cv=pass; d=google.com; s=arc-20160816; b=uZDOtm8bu0v0pEk2mOqKYVaHewzCuXDnlfaYNg+DAEO7iZLnW45+IK7t4FDOgN66b/ Js71B4ZJ8kmw8iQjsf+Y91HoUq9OPuii+BYet0ECQyuxzRiAniDL5xdppKG30XNLBKb5 LyeQFPsIcdX73d20NsK2E2Syx5uTxtOPtAgD3a7luUHSEBml9D10acIGBaa23rGywetm uJ7bP4zoRcB+izcAs45sS4j01pECZa5pcn4QLyJVzPHqqtFpfzg8Xv/AqxjhaBNtsmpz 3bzpmy+G1zJxLVDmjTeDZgjIHrQz1Wf3SAIfDYRTV5zoDVVF8QikMZNyEL2YYM52Qwxu 9Deg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=edC2pGSjdH2oZhjemhrbSG+9sQgH5UdRKVYhheylhw0=; fh=AQ7Wl1RH5XYQsAqygPFWxNxHGtn0zZvAvZgLRlndXU4=; b=Eq8uDvxxe+UPmpLmhhq6pGXvlXoYE5G2r2+Ea9YbyTUvEwQWNpiTn3pyAvPR2cnZmZ Lv3/b550tbnwhgwRNfZed0nwdEueBtvfhhVYTrHAUal+J4MKfQncevS/77gYH2JTxscu mJhdPCH0mTXL2N5QsjK6acJxABr1UXp6jYuNGlfrBM26cBsYv7J4tTSGCzWfFmGtd5z6 oG0HpV5HB3djRHeRMoF5JksLMC6ekJbgUVVMsubjQY9fZElI6FIQUjiu//UJBp0LOhU1 7B5PVMORcZM4RYYxhWwq0T0h6YE4oKR2mVE5LFGbi+ThwptpjhHUWatsN/fCpvOdBcrK 5pnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54892-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54892-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUNU8Jwvd9KBIsn6qNAcNFi4kjCc/LxuFGgd66y6UgPd/tnVmfWZdMrczluI/D3XEClrEbxFUQwKNIWGN31bYmcjv4PLg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n11-20020a05622a11cb00b0042a2aef2a52si2233133qtk.439.2024.02.06.04.19.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:19:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54892-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54892-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54892-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 40DF11C23FA6 for ; Tue, 6 Feb 2024 12:19:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B931613B79B; Tue, 6 Feb 2024 12:09:26 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E0FC136669; Tue, 6 Feb 2024 12:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221361; cv=none; b=EzYI1zSwvavP5r09nnQ2i9N8faT4tDSG2oiqcWtUJ7LSgmsqfB/iTPXlLfWYmtPqBDRz9dxxqgswvhc6UIgT0RUTNDGGzpSp0VZF2CmTyvr8c+wqAA5cWHa3lcmOSeoXgs9yu3L4Z/t/DhumAWzhIH6WtclZRg978hUWQEWrskg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221361; c=relaxed/simple; bh=WpYoW8hnMOujdkzLe1GcecRgFI7u2M+2UE6LWIzx05Y=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Zb4KLVO+nJkcxtoJzbKbrBrUoYXYLFlp95Nu+HfLj1RsCPr243N7SRSn3XJjmjLw9oAUTv5xmUUqzM5CLioedac9BwU9hp+NGPR9/7HcU2nnsEzOmDpuWoBSlO4QHJBqcNCD74c/mwLpbiiCZNui4noJkRzG/6gG1dWeDcu4L+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0121C433C7; Tue, 6 Feb 2024 12:09:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rXKGr-00000006b9q-1B0s; Tue, 06 Feb 2024 07:09:49 -0500 Message-ID: <20240206120949.141151788@rostedt.homelinux.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 07:09:22 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Torvalds , Greg Kroah-Hartman , Sasha Levin , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Ajay Kaher , Andrew Morton Subject: [v6.6][PATCH 17/57] eventfs: Have a free_ei() that just frees the eventfs_inode References: <20240206120905.570408983@rostedt.homelinux.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790151970302879143 X-GMAIL-MSGID: 1790151970302879143 From: "Steven Rostedt (Google)" As the eventfs_inode is freed in two different locations, make a helper function free_ei() to make sure all the allocated fields of the eventfs_inode is freed. This requires renaming the existing free_ei() which is called by the srcu handler to free_rcu_ei() and have free_ei() just do the freeing, where free_rcu_ei() will call it. Link: https://lkml.kernel.org/r/20231101172649.265214087@goodmis.org Cc: Ajay Kaher Cc: Mark Rutland Cc: Andrew Morton Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) (cherry picked from commit db3a397209b00d2e4e0a068608e5c546fc064b82) --- fs/tracefs/event_inode.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 1ce73acf3df0..dd5971855732 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -129,6 +129,13 @@ static struct dentry *create_dir(const char *name, struct dentry *parent) return eventfs_end_creating(dentry); } +static void free_ei(struct eventfs_inode *ei) +{ + kfree_const(ei->name); + kfree(ei->d_children); + kfree(ei); +} + /** * eventfs_set_ei_status_free - remove the dentry reference from an eventfs_inode * @ti: the tracefs_inode of the dentry @@ -168,9 +175,7 @@ void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry) eventfs_remove_dir(ei_child); } - kfree_const(ei->name); - kfree(ei->d_children); - kfree(ei); + free_ei(ei); return; } @@ -784,13 +789,11 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry return ERR_PTR(-ENOMEM); } -static void free_ei(struct rcu_head *head) +static void free_rcu_ei(struct rcu_head *head) { struct eventfs_inode *ei = container_of(head, struct eventfs_inode, rcu); - kfree_const(ei->name); - kfree(ei->d_children); - kfree(ei); + free_ei(ei); } /** @@ -881,7 +884,7 @@ void eventfs_remove_dir(struct eventfs_inode *ei) for (i = 0; i < ei->nr_entries; i++) unhook_dentry(&ei->d_children[i], &dentry_list); unhook_dentry(&ei->dentry, &dentry_list); - call_srcu(&eventfs_srcu, &ei->rcu, free_ei); + call_srcu(&eventfs_srcu, &ei->rcu, free_rcu_ei); } mutex_unlock(&eventfs_mutex);