From patchwork Tue Feb 6 12:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 197423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1501987dyb; Tue, 6 Feb 2024 04:28:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEf8XpYuXnVK54x7HlJ+vBRR9TKll+U6Gri0mFttny1MzlGmKVfHeKad06RvyLciez0o/Kz X-Received: by 2002:a17:90b:23cd:b0:295:fe86:ad25 with SMTP id md13-20020a17090b23cd00b00295fe86ad25mr2323132pjb.36.1707222524776; Tue, 06 Feb 2024 04:28:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707222524; cv=pass; d=google.com; s=arc-20160816; b=KAgsBttzn62gi2I64NT3qIBe/9/FuiMNbr5wS7MbpJ35fWeP269mWWcQsUm32Hwlgy MJPq/wB5a6O2vz+Y1zKqf5QAYRBgZ+lr6bwXW9aldwNb7r2SgFeKvgCm1rcw5vaxH4IT Qj1zaJqWJ9RZcefNtNZed7P4zl/PMs0Q5LsFKtD/Wk5m1h7UARWdGmVWQNGuXDqNG0Gq LaXC/cgJyCQukXBMVG62rlmKSAFHM2ZO9D5KTp0+FPwYkfW0GcB7qGzO0+p+9LCYjngm PEI73XOevRykqfAUgvj3NGJK7aTRZ9mNJUI7OEBLu7NXzr3GEB5OiT6e6JC8gW/TsRmM XkJA== 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=sF58LG9B8PoObac1dX0XgZvr2qgINHhZV2zwGtyjWg4=; fh=RBMJg95tT+3N8ktZz4+hkjL/x3AqWkS+nKIYL1N34P8=; b=LNm8rVhU50uJKcEt4Ym+/8wKn20IMVq2NqhJ6NJoArdmM1W6Z+KU1ZmVHy4yPap9h4 K+B1wO5WeQQyZMPtvojyt6nbVyfzXpg1ECBBHrGThGwEaZsDrfAW3GcLsOUmbICmEL/H 5ZfEc4sWvF5tuG93sYbmRj9RH1t4UWRjPH8d52SyP42GZb7nL3o61W4GqudRr7RSe9uc HJuD6TciSzbknuiRmI6IXrCH4om/9ecO5pS5yvW5Oetd71OEULLIwpo+TdvNZttx6Grj TyTXvoPCwpaR440YbwbFOcNttOKTgKnRZRpsBk3bsE/O2mHqQAZxDx2pbZwUNkIbfRdp Y0Vw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54891-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWw92ayXbLPIdMj8Tgr2BAmL8BylnyhJxFGGz7p7y1PayNnFt7mGwmByMrqnx47Dp6PnzKuBYSTm70Q+27ulveF+M0XbA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b4-20020a17090a12c400b0029668a93dc8si1073783pjg.58.2024.02.06.04.28.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:28:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-54891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54891-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E6ADAB2567F for ; Tue, 6 Feb 2024 12:19:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E6CE13BEB6; Tue, 6 Feb 2024 12:09:27 +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 C12BF135A75; 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=1707221360; cv=none; b=V3THxo0kpA6mH3QqlK/T453S/jmW8iK6Tx5r4YhLfvia+D9oQMUHeHqIKnjgGk4D+T7mRTCHUpLseslc4jCMKMCmfkVdmiRGqVFVZ+7bJ9IxaVQuoEAPGChEsUrkl70BLysYCapwKAoaHV+6rId35bWqIzD6c8Jk3bfbIcm9ctQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221360; c=relaxed/simple; bh=RVnqUM31lsQW7+iA50+4o8PZzFkXqjlihPk1b0+w1h0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=dTAZQCGEonNCyJC9GUJTcL5Q4qP0BrjW6IPKM3Af2P7k6PGOPjgbFzuGPPweD915+OHs3yu8mEl9GSU/64+CF4I0RsIHmy5ad7hBXmldu3ft/3IjzwHpZwdXRtkQsCMbys3/AYmH1jPuEIiv8XDo9QSAGfTCP919xJnsr7M86RI= 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 AC917C433B1; Tue, 6 Feb 2024 12:09:20 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rXKGr-00000006b9L-0VCC; Tue, 06 Feb 2024 07:09:49 -0500 Message-ID: <20240206120948.980929088@rostedt.homelinux.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 07:09:21 -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 , Andrew Morton , Ajay Kaher Subject: [v6.6][PATCH 16/57] eventfs: Remove "is_freed" union with rcu head 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: 1790152565944903517 X-GMAIL-MSGID: 1790152565944903517 From: "Steven Rostedt (Google)" The eventfs_inode->is_freed was a union with the rcu_head with the assumption that when it was on the srcu list the head would contain a pointer which would make "is_freed" true. But that was a wrong assumption as the rcu head is a single link list where the last element is NULL. Instead, split the nr_entries integer so that "is_freed" is one bit and the nr_entries is the next 31 bits. As there shouldn't be more than 10 (currently there's at most 5 to 7 depending on the config), this should not be a problem. Link: https://lkml.kernel.org/r/20231101172649.049758712@goodmis.org Cc: stable@vger.kernel.org Cc: Mark Rutland Cc: Andrew Morton Cc: Ajay Kaher Fixes: 63940449555e7 ("eventfs: Implement eventfs lookup, read, open functions") Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) (cherry picked from commit f2f496370afcbc5227d7002da28c74b91fed12ff) --- fs/tracefs/event_inode.c | 2 ++ fs/tracefs/internal.h | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 9f612a8f009d..1ce73acf3df0 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -824,6 +824,8 @@ static void eventfs_remove_rec(struct eventfs_inode *ei, struct list_head *head, eventfs_remove_rec(ei_child, head, level + 1); } + ei->is_freed = 1; + list_del_rcu(&ei->list); list_add_tail(&ei->del_list, head); } diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 64fde9490f52..c7d88aaa949f 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -23,6 +23,7 @@ struct tracefs_inode { * @d_parent: pointer to the parent's dentry * @d_children: The array of dentries to represent the files when created * @data: The private data to pass to the callbacks + * @is_freed: Flag set if the eventfs is on its way to be freed * @nr_entries: The number of items in @entries */ struct eventfs_inode { @@ -38,14 +39,13 @@ struct eventfs_inode { * Union - used for deletion * @del_list: list of eventfs_inode to delete * @rcu: eventfs_inode to delete in RCU - * @is_freed: node is freed if one of the above is set */ union { struct list_head del_list; struct rcu_head rcu; - unsigned long is_freed; }; - int nr_entries; + unsigned int is_freed:1; + unsigned int nr_entries:31; }; static inline struct tracefs_inode *get_tracefs(const struct inode *inode)