Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2501561rdb; Mon, 20 Nov 2023 12:36:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMblnUzqS2QBnMZ18odekVfbt0BX1ISl4riG1T+XSf3TdUSUZaesg1KyyR6sPepMKLLZxY X-Received: by 2002:a17:90b:4b4e:b0:27d:166b:40f6 with SMTP id mi14-20020a17090b4b4e00b0027d166b40f6mr6709678pjb.41.1700512591314; Mon, 20 Nov 2023 12:36:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700512591; cv=none; d=google.com; s=arc-20160816; b=mVu2oQcNs/C9urQ4tWHFZiW1HB66qS9mSgcSNxe7NhtgCktcLS9ZrPyXHb0nxmkhGh JP8tkgjpPxDso9dX5Uj9PIaBRsUMTg//Y+nbDG01bT16B3Dt8T0Y4PA0XR/JzwV5aKvZ XleQ+QWQ3W7jURjlBfjj477iZvQceefx8qSm8+fZNA0yZSo2AG1vGytn5UYJAffkurGE gPH+Y770DXBOZCF4sT12mMzP8wHAkZLcXv7nMXdtLfZXC9zUOXpHqymX+p/3q59+RB8C mRUimBqOA8TDhR4z+dSd6tQQW99bjlY7Cc4e2rJUngOsUb/mSC8+TuE8Klbi2TzHprbK EOVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=sx3FNcDhKHwMvdOYIC5n8OOWTx3JQdr7eVUIybWdbl4=; fh=vdGPEc86BAcUASrXCk1CgPMBwlQ+N66I+M0dnXsn/LA=; b=Ra7QNcqaghtM2G4Uyyi6XT2turFGpTnsGKOqeCHSdDRhB6CXrXzI5EVUKUgKDyBzze xWjPyq3QtJ3pfxRBFO0yGzoP2UJxg8ul1VyCL0UZeutD1NhfRuJ9LHlOm5XUqA/YRFxF PI66nh90kiaXuZBYfvSQr5708bvq0iYD77yT/oR85az3/GFuY2GB7jDQWS5LB/0p20ES Q4weJXelPDo8k2EgH6T2Mw/mmicdQJMFn5wMKBiP7HpOIjUMZxurOkqyDveJLJPBto5B Iad4p8A7rcBbMSGImrf9KBmlK6q5HjFDJr9tOO0unDYQFJgq6Xnss1dTk/t0TFw3G+8B tDHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s4-20020a17090aad8400b002774ecb2ecdsi8873679pjq.19.2023.11.20.12.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 12:36:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 8DD9C80764B4; Mon, 20 Nov 2023 12:36:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbjKTUgR (ORCPT + 99 others); Mon, 20 Nov 2023 15:36:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjKTUgP (ORCPT ); Mon, 20 Nov 2023 15:36:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4211ACD for ; Mon, 20 Nov 2023 12:36:11 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2022BC433C8; Mon, 20 Nov 2023 20:36:10 +0000 (UTC) Date: Mon, 20 Nov 2023 15:36:23 -0500 From: Steven Rostedt To: Naresh Kamboju Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, mark.rutland@arm.com, lkft@linaro.org Subject: Re: selftests: ftrace: WARNING: __list_del_entry_valid_or_report (lib/list_debug.c:62 (discriminator 1)) Message-ID: <20231120153623.49c5119b@gandalf.local.home> In-Reply-To: <20231116123016.140576-1-naresh.kamboju@linaro.org> References: <20231116123016.140576-1-naresh.kamboju@linaro.org> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 12:36:27 -0800 (PST) On Thu, 16 Nov 2023 18:00:16 +0530 Naresh Kamboju wrote: > Following kernel crash noticed while running selftests: ftrace on arm64 Juno-r2 > device running stable-rc linux-6.6.y kernel. > > This kernel crash is hard to reproduce. > Can you test this patch. Note, there's a similar bug on 6.7-rc1 which I'll fix first. And when that's accepted, I'll push this one for v6.6. This may be two patches as one if the d_invalidate() issue, and another is a memory leak fix. -- Steve diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 5fcfb634fec2..b60048469df1 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -289,6 +289,8 @@ void eventfs_set_ef_status_free(struct tracefs_inode *ti, struct dentry *dentry) ef = dentry->d_fsdata; if (ef) free_ef(ef); + else + kfree(ei); return; } @@ -342,7 +344,6 @@ static void eventfs_post_create_dir(struct eventfs_file *ef) static struct dentry * create_dentry(struct eventfs_file *ef, struct dentry *parent, bool lookup) { - bool invalidate = false; struct dentry *dentry; mutex_lock(&eventfs_mutex); @@ -387,23 +388,24 @@ create_dentry(struct eventfs_file *ef, struct dentry *parent, bool lookup) eventfs_post_create_dir(ef); dentry->d_fsdata = ef; } else { - /* A race here, should try again (unless freed) */ - invalidate = true; - /* + * If we are here then the directory is being freed. + * The simple_recursive_removal() will get rid of the dentry + * here. + */ + dentry = NULL; + /* * Should never happen unless we get here due to being freed. * Otherwise it means two dentries exist with the same name. */ WARN_ON_ONCE(!ef->is_freed); } mutex_unlock(&eventfs_mutex); - if (invalidate) - d_invalidate(dentry); - if (lookup || invalidate) + if (lookup) dput(dentry); - return invalidate ? NULL : dentry; + return dentry; } static bool match_event_file(struct eventfs_file *ef, const char *name) -- 2.42.0