From patchwork Tue Oct 31 22:33:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 160368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp61580vqx; Tue, 31 Oct 2023 15:34:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOyB/9duVflWlHDc8Eok7kViztbduDwcieGa9UKU5Y31a9m/7ikTFmE2uDmW4/JB/kayX4 X-Received: by 2002:a05:6a20:3d8f:b0:172:913c:ba36 with SMTP id s15-20020a056a203d8f00b00172913cba36mr13018418pzi.24.1698791679683; Tue, 31 Oct 2023 15:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698791679; cv=none; d=google.com; s=arc-20160816; b=bGHq0AhadMcBevGLEcOKckGiR+0k+lnLXY/BMGWCG9G0hkn8A1tSuH+lef7Mmc+5ii vHn+R7AdoeeRHoBv3ZAmh/hhHm4lAHxvCC5FjHBZtX67ydpXFLUnqOpw56wu1xRoNYeJ kk3tBvtF8AVKPcRR57OvEAWpETawDwSTlZobNOLto2KXkUoHNuQTX94qm5Yo3Vycjg3q UP0dzn9UBnENp6fZs2FOPw8wqEHwg8y3zbuMGq8Xqp+nNcr0+uJjYV0laV3JsKrU+gh6 oJLorGC1hDhOllL3DpF0s8jds08JAlLuVMGZ3O9GagvxprAjGECEYP2Us/xcY+Ks2qCl +B6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=2r+zcUBhbJPU/j00U4FUrgYvXYoxcqBWrEqYgiZewyc=; fh=MiH27HHdX4MWqZXs92F3hQX1wt9YgEr4ABTH3w82nJ0=; b=Iw7f/XxLhBAS622moX9nYWdzcl+vwHQYdeNSR/r8sNzaSxu3gayQTnsANdN0BbbIO4 93CWU1iEvK1gNLKxOdiKhJLb2YLfuAeOpeZ0JxxQ+41nyQUEEhyY+U0b6xR90QvogcVm jU4roGOLNyjyE6JGDYe29msu4LshVwE/jmEMM8NajecV9qtJ03IMiMitJgAXqtV1eThB 3VVIORQZTc+uMWDmbF3te2JGAAvluaqTLbYz0AZ9KOuQcVbjRy9YOaKP4gHshGgPwli0 Hxj+25bF7CaRCpoqlC3kmhsPe8+PwnH1yHic11CA14zuvUNcLRxKqfErlAy+2S/7ZWfz Qq4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p67-20020a625b46000000b00690fc88e4acsi274272pfb.228.2023.10.31.15.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 15:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 54CB28027F76; Tue, 31 Oct 2023 15:34:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346821AbjJaWe1 (ORCPT + 33 others); Tue, 31 Oct 2023 18:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346777AbjJaWeY (ORCPT ); Tue, 31 Oct 2023 18:34:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 851F1F4; Tue, 31 Oct 2023 15:34:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26CF0C433C7; Tue, 31 Oct 2023 22:34:21 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1qxxJU-00EPgt-0O; Tue, 31 Oct 2023 18:34:20 -0400 Message-ID: <20231031223419.935276916@goodmis.org> User-Agent: quilt/0.66 Date: Tue, 31 Oct 2023 18:33:27 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Ajay Kaher , Andrew Morton , stable@vger.kernel.org Subject: [PATCH v5 1/7] eventfs: Remove "is_freed" union with rcu head References: <20231031223326.794680978@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 15:34:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781312184532089660 X-GMAIL-MSGID: 1781312184532089660 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. Cc: stable@vger.kernel.org Fixes: 63940449555e7 ("eventfs: Implement eventfs lookup, read, open functions") Signed-off-by: Steven Rostedt (Google) Reviewed-by: Masami Hiramatsu (Google) --- 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 754885dfe71c..2c2c75b2ad73 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)