From nobody Thu Mar 19 03:44:48 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DFF4348469 for ; Thu, 19 Feb 2026 16:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518466; cv=none; b=pKW1Q1IYsDnlD7aDf47DFwwrItASk4paOhtBqh3UUEUYtPD6BQcOLmUZ60goKo+fAxUW9nrjtVRm5cpWtVtf3BUnp0764cIizoaNgrzSKHb79K18m2e9K7QGEyo1ORF/SgdeBlv7LYrqR+o2OMgEfydzhfcsdpKSMr3Vqm4NvC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518466; c=relaxed/simple; bh=qGEgzEowAKOYqoLetjY4uyHAcod3FdEe26Azz1HZSBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CZiZnTA1L45kUftRVLbaFS4rnVUIDV0HiAURqA/IxW+ncyWpi8w8ZElDi+lDW7oivlcLOeHqfXMceL/Rjrbh3z6sasZlQgzaRS899z287mpM1u8Ocr5JI/cms1/2FrL9jXPdrw0ZcG8NAb+k7gJYcKW0svHQ3qnvgCK0oubk7w8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ZxQ2VCEz; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ZxQ2VCEz" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4834826e5a0so12414765e9.2 for ; Thu, 19 Feb 2026 08:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771518463; x=1772123263; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AFctbIz6tiPHsqiezPeCZfcnyQYkHL5Q+XsVl6eb4Bs=; b=ZxQ2VCEzPl+eIbryTLnHFQq6GocvmnTLQFcPF4jCHzW0T7USx6z7fVuPiftsUId1y7 sLf8KpVfJMUIFIY37TlJD+sfZ3mPfpBDRwAuBayc6JEEJ3Mz8hW1sLFXjfQRonLBUTwm /fOzf36UdUWBTrb9G7Cg4Y0q0qul5Rr8/ELjt800Rwz7EgPSVp/RV60MWqb7x08sr2Xo 0R87vWYTkBvi1hr/diWtgztpwKznMnRw5oP7bNQk9AoYQeWuNwFkgNGTaeJYGOhUNbiQ aq3aA0nfD2kWr9S6NBpbJyjzViSas7w5vb0JeNgHv3aLDNpbNPWxFUt+ZiFKeY7Xrluh R4nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771518463; x=1772123263; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AFctbIz6tiPHsqiezPeCZfcnyQYkHL5Q+XsVl6eb4Bs=; b=AAKwjUnJ3LVleqi/vNrB8Pd62dZGOpU6kBnR3DdMemWgSHlLwKWdmoA0ZMW+Qrakow CFsmF8gn1UwJ9E8AhX6YfpKXYU7t3s/YVS2WjLm9bgz8cdTEsC4pJq061Y1NtRtwJItH huWN+lzZx5PKymzsRnpjnxyDgXOiSDNUGfsVx43iGR0aO0SVIT8tMIl78XKWcovUxZd8 Szw/CB1hrCYnQ66k7v7MUel2rFH3N6yjZA4nXFg8ouDOi7ektNT3oo0l1iNxQSlr0wzO Z55X+GYW1masu9m3odarCpRa/NeRUTy+NkQ7I8hYKr+ajC05DFnyuaeChHGrzDoyWPeW T9+A== X-Forwarded-Encrypted: i=1; AJvYcCWyXwwZlH4t3oxkaepT/xXzsMblXRksW6lpK/I0GnNbblg7adKgvfnSIP2g202YGy3KNNJrzE57JP6J5Ww=@vger.kernel.org X-Gm-Message-State: AOJu0YwcJN9E9+vuQ5zonDDPdMpbrZL9KFcCxn6D3r2io3IdVOywIO8k Tny1HxwJghH4Kf45lWpGym48Tek0rrjl/ZOw6wMelZYWDIR4qfjytrrd7VpmfoBrwoI= X-Gm-Gg: AZuq6aIBIOHsuJy/W5GGXJKyfZ/E8/3C0VQSRHElNEdy4tmhE5pwOOhRCASehv3bMqT oPBh71bzVykxgAg5YzP6gbRhrw5xQadUDWgKEWKLWNK/G5BYUTA2FW7j37S9a0CyKkbmXzmeamP TglWYKb3yx3z0iKLE8vEHZ7LnatnzIySmKlYoSK8t8ZeWFliQYj8+QI7vWw3FUnYGa55BSR9fqW nq6ptD+vVsFWlO9+YayOqd91XpIJbgNarQJapirQhrQB2qIUygOq3eaDYrs68/LAkznDyXehDov y16W78lMzNDUxGMmAjxNerSO+NgTIEVYp+W7CyaqCfQ3/yEKmqlO7vighxLhExFvbd9vtk/aENt cu1xn9NeJKLI0/lEjL8reTV65aHXnzysXcspH/y6/n94d1EmWmly53f4A4bqH8qBaAYEh2YHPkT cff/mmTI7+2gqN+aKaofBtE6uXUo9+35AVv7cbNWwQ X-Received: by 2002:a05:600c:4f92:b0:482:eec4:76d with SMTP id 5b1f17b1804b1-48398b5e0d0mr103863385e9.17.1771518463404; Thu, 19 Feb 2026 08:27:43 -0800 (PST) Received: from zovi.suse.cz (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac8075sm47324631f8f.29.2026.02.19.08.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 08:27:43 -0800 (PST) From: Petr Pavlu To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Tom Zanussi , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH v3 1/5] tracing: Fix checking of freed trace_event_file for hist files Date: Thu, 19 Feb 2026 17:27:01 +0100 Message-ID: <20260219162737.314231-2-petr.pavlu@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260219162737.314231-1-petr.pavlu@suse.com> References: <20260219162737.314231-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The event_hist_open() and event_hist_poll() functions currently retrieve a trace_event_file pointer from a file struct by invoking event_file_data(), which simply returns file->f_inode->i_private. The functions then check if the pointer is NULL to determine whether the event is still valid. This approach is flawed because i_private is assigned when an eventfs inode is allocated and remains set throughout its lifetime. Instead, the code should call event_file_file(), which checks for EVENT_FILE_FL_FREED. Using the incorrect access function may result in the code potentially opening a hist file for an event that is being removed or becoming stuck while polling on this file. Correct the access method to event_file_file() in both functions. Fixes: 1bd13edbbed6 ("tracing/hist: Add poll(POLLIN) support on hist file") Signed-off-by: Petr Pavlu Acked-by: Masami Hiramatsu (Google) --- kernel/trace/trace_events_hist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_h= ist.c index e6f449f53afc..768df987419e 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5784,7 +5784,7 @@ static __poll_t event_hist_poll(struct file *file, st= ruct poll_table_struct *wai =20 guard(mutex)(&event_mutex); =20 - event_file =3D event_file_data(file); + event_file =3D event_file_file(file); if (!event_file) return EPOLLERR; =20 @@ -5822,7 +5822,7 @@ static int event_hist_open(struct inode *inode, struc= t file *file) =20 guard(mutex)(&event_mutex); =20 - event_file =3D event_file_data(file); + event_file =3D event_file_file(file); if (!event_file) { ret =3D -ENODEV; goto err; --=20 2.53.0 From nobody Thu Mar 19 03:44:48 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C41EC34AB0D for ; Thu, 19 Feb 2026 16:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518467; cv=none; b=Mcv5VokAxVpTAZihNKhtl9mjjiOJrHKNHQYV/dDhb0M6kqep0gAwHuVQ72hWlxHVVt85mswVIgGYksmAsxn3dYx5mmdhO+NHu7maiRKiNHvho4Ryf18b8oGh+Ecf0pC8Rl1S7tUwnIwY7v7pVsBOHFeVoa/qYffqFlgL1eOCr5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518467; c=relaxed/simple; bh=oz+04hEQM4d1rwxHpRDrO4zzKJ7Z7kOfi68mc4rkKH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XZsN8TgBiH9zmibxTaskF4Tt0VBsTBXXifGCD5SqnGI6lR0DE1F5XNxFznOZyV0cd5Nq9lxEOHpwmxT3KiiIR2cImj6Y4VFhU8xXwL8CSCqjYSeCWxAzNqMpQpRtjSpl6X6/cgnO9Ypkmym5VY7HZCB3UlDAmJrwBlhdibyKk/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=B/Jv8VL/; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="B/Jv8VL/" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-43638a3330dso977217f8f.0 for ; Thu, 19 Feb 2026 08:27:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771518464; x=1772123264; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D3kvNkKdoYfEDJexUIfvxiiZkFHsP2vDeB3pQYKUtGQ=; b=B/Jv8VL/HRvLxYIh43pm/Rt3euxp/y2j7Xatvd8U2OKcwAg9RKBasONpq+8Vc/FK6s ZPDCu1KAho46njkvU6zc2D6xHR5+fFhSonoeP3MmFbVd1OGKbPVQMxmgKA2oEOmu48ZH 48VDh1nIDYW1EEcroEYtIFH38dB/SpulkLWG77+oJJw48LGy5Kl7SLtfgB0d59CnqnKR z/9rRwoWcsKPjs8YV7yeIFiQLuEGZtJSbrBrYeV8mWGd98Zmjzpw854mteUGchWosPz8 2SwtYxq3Mfi7wwfpavKxXZYiiNxqim9WGOFRWlaIK1uX7+j/bRaNyFeCt0R+vLwUEUCM QiLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771518464; x=1772123264; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=D3kvNkKdoYfEDJexUIfvxiiZkFHsP2vDeB3pQYKUtGQ=; b=L61DHvgP4uyZLsVGGkAcZNuHrMen+TQD0UekHb6V4tcnj4GP0/O9DCeNsS/HayxS1Y jWvLHCTn+WqeUqWbR31ZmFqBlXuziiw8EJo5cJBBYMV+zAR1v9kbx/PQmRFZ217IPWMH oc9oqB6xVxrt1Eev2G6Gu67Y8lSIQCnbbvD6T+UxBiN0e/PFlk3TSDtlpYX9/4m2R9F5 dFpCKBWqB0OboDQ5YKDPvEf2n7PJCFIkSutQZZGD+fLSLJf57yqaUgAqG2HruuXqHg5A 9p67jrlvZbiiVxFWUpyz5DtD0+kjRgTzzx52wmTe2qJwsoEGN59jIhlYYzPQatu9qzpp mm9Q== X-Forwarded-Encrypted: i=1; AJvYcCWwRmLL1gtVn01AOxWlv2VZEZFnTp42aY865lmdFDlqRBERdVrK2YO/tCK2BJJVrHJiztr2dnWZFGsR3Sw=@vger.kernel.org X-Gm-Message-State: AOJu0YzbddzVRcK4DSyLNKW59Pybbrm/TiNi/njwcqr4s0FOgtO2rw84 zmsCgjA/nBDKogt6wk25Fb12qStejhaiD8s4mnjeCu7U83fCa4wkdeiRBey1CAM0rvBcZYJo2Zo SZbEN X-Gm-Gg: AZuq6aJ+91flKSTcwwuWhNYiQ7n4jSq4fzn5T03Dq4VjF+nWr9CXgRK9YxlVd5E25wF 5LluOL7nMrOoXwy17gqnBegwuqA4WbK2n5C0PCOiu79mbeHYqFU9R3k65uknJ9kwreF+eZaP0QG 1PmrvpqryDP+HxhM79+NJZTRSPL9/1V7cdPL/PgZE2OFeIF8ISZ/7ePYAddkJ9n2B63DbjEbpZG w2BI3b1ANvtZQzOwTi3ccG4yRa65U1AewahhChei5Y0pte1Mg2diSOrOLq68jsf+bC8+WNcQ+WQ Y0VpHt7syh0otIKtHbGAWs3pjcwXzcdMnov10u+qO5GfW3aNYWilWGlr50rLQL6s5fCtiUtR9h7 A0l1mwU+rDeJZmim8YylNnFc5B1/5lIfiBn6jSNJbDd7aI2OaedLf1z4qpT9SCgfrDRJc9Bie/9 +SO353MwDOJ55dUdMuHXahVZVfjV/SQJvDwsDzyY/I2w35RrrRUX8= X-Received: by 2002:a05:6000:2f87:b0:435:a136:b8a2 with SMTP id ffacd0b85a97d-4379db7017cmr35432454f8f.28.1771518464029; Thu, 19 Feb 2026 08:27:44 -0800 (PST) Received: from zovi.suse.cz (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac8075sm47324631f8f.29.2026.02.19.08.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 08:27:43 -0800 (PST) From: Petr Pavlu To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Tom Zanussi , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH v3 2/5] tracing: Wake up poll waiters for hist files when removing an event Date: Thu, 19 Feb 2026 17:27:02 +0100 Message-ID: <20260219162737.314231-3-petr.pavlu@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260219162737.314231-1-petr.pavlu@suse.com> References: <20260219162737.314231-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The event_hist_poll() function attempts to verify whether an event file is being removed, but this check may not occur or could be unnecessarily delayed. This happens because hist_poll_wakeup() is currently invoked only from event_hist_trigger() when a hist command is triggered. If the event file is being removed, no associated hist command will be triggered and a waiter will be woken up only after an unrelated hist command is triggered. Fix the issue by adding a call to hist_poll_wakeup() in remove_event_file_dir() after setting the EVENT_FILE_FL_FREED flag. This ensures that a task polling on a hist file is woken up and receives EPOLLERR. Fixes: 1bd13edbbed6 ("tracing/hist: Add poll(POLLIN) support on hist file") Signed-off-by: Petr Pavlu Acked-by: Masami Hiramatsu (Google) --- include/linux/trace_events.h | 5 +++++ kernel/trace/trace_events.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 0a2b8229b999..37eb2f0f3dd8 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -683,6 +683,11 @@ static inline void hist_poll_wakeup(void) =20 #define hist_poll_wait(file, wait) \ poll_wait(file, &hist_poll_wq, wait) + +#else +static inline void hist_poll_wakeup(void) +{ +} #endif =20 #define __TRACE_EVENT_FLAGS(name, value) \ diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 61fe01dce7a6..b659653dc03a 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1311,6 +1311,9 @@ static void remove_event_file_dir(struct trace_event_= file *file) free_event_filter(file->filter); file->flags |=3D EVENT_FILE_FL_FREED; event_file_put(file); + + /* Wake up hist poll waiters to notice the EVENT_FILE_FL_FREED flag. */ + hist_poll_wakeup(); } =20 /* --=20 2.53.0 From nobody Thu Mar 19 03:44:48 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47BB834CFA8 for ; Thu, 19 Feb 2026 16:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518467; cv=none; b=V3bIWoi4mHHltESgM+K2SEEj3CvDXXPsId1p7sF3NNml93rggaJlsX6q2irLCiyphywrmUg7ElOIKf/V5mFW7XmdREjCKS3ndgJiDmSDIdUMzQwr039MoweTDKOkWTZ+oY8ODzUV/JNn8v3xscFhK6AatRFKcc2fO/6LJDoqFyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518467; c=relaxed/simple; bh=KgrBTXu77Iye3UmYdwe000SXgI76QMvrcd1NFmgU4Jc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EOQlb6fp5UWrc9nwpy+nOtzcGKFmk0mPS1E/Gvq92RW1ZbPb5syBzvdaaeNg6sP8uWZzYa15f5oYY+A8PbEukc7DbEmqhzbQ/2UJWrbMp+CkYpjAnWPowmyJ9EHjUlTYFY0dYTY4+DRXi2dBxG1ASGB5Ph73v2dwoBgFPjflJDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ZbsMiIu/; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ZbsMiIu/" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-43591b55727so1142703f8f.3 for ; Thu, 19 Feb 2026 08:27:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771518465; x=1772123265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BI5owf5Lg6dz1A8TLbDN4r7HFJ4qL66b0FlE66FGWHI=; b=ZbsMiIu/8IYCOmc2ulT3xxkzJlFnzbhPm/HeYo89WUtmAnYKmhDwUs8PVpfc1vLlNX /MLbDcg/vh36GcuPUtE89+og3gRYwhpvBWT+oRaqKShBnC33lvWStP/MFOmEm2c9DZ0Z N+rBZmk4MWC2Rq10aDKIHZJGf4bpgdkcFkkOuCUy4exOqyi8+8O1aSNpjANrIyKZZxKa tF4c7CZ/8aIzLGqV1Fre5mBkVTDsmy4p/Yj13O0ud4FIepaU8PjoenqTEuUg9pOk2omd 9Pa0vNdXJ3LgwHd3segq5PAxl4Wd7wjPg9pS+8vqUtcMzmHKT18i/b02XWMyGccCuscw HPxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771518465; x=1772123265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BI5owf5Lg6dz1A8TLbDN4r7HFJ4qL66b0FlE66FGWHI=; b=Sl+GxOWL2F0l6w6ibJlqpyAUl/bgG+WUfqDDoyPmGpr1RuwveTAff5DgXVdewEmz8E cxzDb/5Vjoq9wIiwKn8QILsdTQ6JwV5ZM9IYFA2BWSpFjyTtn3mhaqItMTAWlKYCPPcr juwB8+NrDJiQPPzEeWzeTaqfzezTO+U2HB3wbLf//uQxyfi4b1vD0v9mWqrWHvajEmha Cm3BJvzeCiswjxkoUEt9T+V5D+gMHV8/LSjsDjl6TLZK1htyMSpjc8kZA8hDrF502ONp dMN5zCHqylh9t1U+ZQJPch/q2YM9ns8Fu8pqoWXIzTxGh2eXk0eg+shkMv6vugfFdaCj mErw== X-Forwarded-Encrypted: i=1; AJvYcCXDTc5EF1JoxXokMpEZKnHJz08mKeiOb1hWuu045SwKomsZ+iM6aOBAHquR3sRRF6bfdyNoe9iQaiQ4UZk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3tqhk+ks1vNv81LY6nz8lV8DyKDhn3KfG4MvYrHfGdoLFytu4 zKDeHNHUCcADPtsfq63O1u0QjJijgaN/syrTVRkbT/BjM/lXMNhi3O3Nme/x421eDRM= X-Gm-Gg: AZuq6aJpg4pzJYXx9Q83MFyGL7G4fjtrCJadlIV8kD34BNr8GDju2X4nnEFBDa+aRVv hasG9HmH8gqovW/0KAZg2T6O/WDvTlnhBKa9Rhhpda/U6OJ3ZIH4hnXg1q2uZVgpbDXJVnjs0AL qzdo47WTaZJLealuc/MilT6FVHOy4KJwJdwSnx2PSiHnrM5FoEM5zCGSOt5Elyq+hzHAhTiTfiz cUh5JKjOmYIsMAbg0BMbHyJ3uyyNIwmKTXDXZ+3vrzlHaMzR+zUS/4deoO+UCkhOAN73Rlx63+M 9I+0/kD1xhDb+AcKetUjnNdtFB3nIqbyuDwAhW5BES5c1Cz6vu9ouIuk+IhusMHSIBCHS4axcaq JyeJ3JwP/2Fd/wiT8PGPVTLL/j/LIHDNdTlS4K4m3soTaYGAr0kLqFIQbp/wcySrddaI1tR0BUK w6wvzBA1oXxGLh2CJ/IrsJpmsTRTVBVwUfWi9XhXSj X-Received: by 2002:a05:6000:2001:b0:435:96ec:679e with SMTP id ffacd0b85a97d-4379db61cccmr34207692f8f.23.1771518464634; Thu, 19 Feb 2026 08:27:44 -0800 (PST) Received: from zovi.suse.cz (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac8075sm47324631f8f.29.2026.02.19.08.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 08:27:44 -0800 (PST) From: Petr Pavlu To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Tom Zanussi , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH v3 3/5] tracing: Remove unnecessary check for EVENT_FILE_FL_FREED Date: Thu, 19 Feb 2026 17:27:03 +0100 Message-ID: <20260219162737.314231-4-petr.pavlu@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260219162737.314231-1-petr.pavlu@suse.com> References: <20260219162737.314231-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The event_filter_write() function calls event_file_file() to retrieve a trace_event_file associated with a given file struct. If a non-NULL pointer is returned, the function then checks whether the trace_event_file instance has the EVENT_FILE_FL_FREED flag set. This check is redundant because event_file_file() already performs this validation and returns NULL if the flag is set. The err value is also already initialized to -ENODEV. Remove the unnecessary check for EVENT_FILE_FL_FREED in event_filter_write(). Signed-off-by: Petr Pavlu --- kernel/trace/trace_events.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index b659653dc03a..90915e1286da 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2245,12 +2245,8 @@ event_filter_write(struct file *filp, const char __u= ser *ubuf, size_t cnt, =20 mutex_lock(&event_mutex); file =3D event_file_file(filp); - if (file) { - if (file->flags & EVENT_FILE_FL_FREED) - err =3D -ENODEV; - else - err =3D apply_event_filter(file, buf); - } + if (file) + err =3D apply_event_filter(file, buf); mutex_unlock(&event_mutex); =20 kfree(buf); --=20 2.53.0 From nobody Thu Mar 19 03:44:48 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C2FE34CFBD for ; Thu, 19 Feb 2026 16:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518469; cv=none; b=uWr+x+cTLXPt4RHnAgosTLWqWqtqXcrE4ZG2PUxHfbACIzBTyUUeoYQ+tLyo+xP0921ZvgYFoem0gn0rlLYSK0EDAhWRagPJ9dxRIGTj4PskVBiKjpltHkzDUHDGqr3aaLSnj0b5aO52Fgd+JT0ZbGCGIUV4BpO11v/3NH+V5iU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518469; c=relaxed/simple; bh=3aIPneSbFeQu4MdSA2qZGQY/yDCy+AZLupTPmFmOaUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E8wD3J6V6lBHRSrJBtu52pVFABkGu8Z8efi3kgMIO+t/ytWll6lIfF/+7IvRIupFaoJi9VQSUTk4hjrhSNlomVKTreh2ZFQbfRsT96zL4hA1X95lda093erlndPQcM7c25kQxgyOeU5dfyOiiJJaFrI02WqMnBYhMX5qcn/UHFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=D6SzTEh9; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="D6SzTEh9" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-4362507f396so1210371f8f.0 for ; Thu, 19 Feb 2026 08:27:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771518465; x=1772123265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t8pmqafAMo/XejBQW7PotvCqT3/aAFA10KU7IAZ4oDE=; b=D6SzTEh9p337AcddKGb2SDqBg+OyuMU95ATEYHUSIX6x7tzZ9tUKLf6jaSx1Y68LJi db4FdChaPPyw7VHggEJvySO/qGyfhlCMEYjNLnUvf9R4EIjhuXARqI4GeYF9N5IRqspP vfYwp3AW42yEIUnYx33CLEbrDpu3OFnmR996ZchSsxn0J4TohHIbW/2AbMySzDDrAF6F iuevlurSivuH1kU0GphtcBLkVGYxKxjFeJmG/1HrK8v/dDj597ZRHY1te3Q4nHI5FAFd oYgUQ7VJYtED9u+v1Rh/bG+8ttlpNaErgsQW7Nms3MsMiNJcc0PnVCb+plpQVoNa4/EG ckkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771518465; x=1772123265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=t8pmqafAMo/XejBQW7PotvCqT3/aAFA10KU7IAZ4oDE=; b=thGfYEuBo6WLgOtqwRwz9JpoU39tjTGlyfqfQUQNMbtaBJOEBP6iRnottoIEkS8qBp UAnQNc6JV0UvDhAILYDQiYb6fH8jSgkm/ZP7PArEqMZ9HUPjYKSs9k95IT3Mk0va7MjW dfA6fHOsfeBx2F58TlwgtY+SLGF2R5B0nOy1/v3rNqqBuRPpgz7bELzzExcvBAoxms3C yqKXOHOht+S/U5mgmAXlCr7nZKRRGfEejPo6LWYgs/Q1U803a8ERYK0QMa6ih1kFN4fq 9FbROubBojpLFoxYFgHlSX3ukUDbRK7GQq3jvhgpbIJTWy0OnGHomk3bGfUxNkVnDaWO Jyww== X-Forwarded-Encrypted: i=1; AJvYcCWAdYUKzJOpdqPcio0vNHoxfv0fnpeJWwkgcM6slCiIJ9EkC3ysj6NFjksp1NSVzaIC+Cr28hc7R97X4ds=@vger.kernel.org X-Gm-Message-State: AOJu0YxDaHCV71yHlmonuDvswZ7fBB49McX87pF/hrx2vd13hq1YxIFy JjeKlwOVIXqfBYOFu0U8y+6nNCqJgIInSsSauESoRT6BH7ZIQbTH9A9sheGI2MN3d4k= X-Gm-Gg: AZuq6aIMNf+ko1JCR58KoQ+K4hjXpoc1AdF9qR+1vR0Se0rfJ4IIBDR+G/p2ASQwSyZ 6V3ADEa3pSzg7WyL9flduLngWYyX3plLKdJpmeVpUFPWm5onXX0jUkTcZIeJUWfkibDcBTvW34W +moqSsXtZJCw3SIglHP4AW4cUuNXMfkq6DG4YFjqo8VkeT8PcXsMFEof53sd53NgDm9t98mxvGD PMuqNq5yCYAT//GlP1HSnIpRkXrya/zS8YWbZErUWtEAOia4kCwMtdu7CskmNG7mob73owJRory 0paIaVGry+YeGhIyj3S5JPvG02IowlAXlAA84Oin/W31aLUbat4VKhPtQMhJul+KTItXmokYysR +Js4+ixbFdMIjwagIRX2YI+vEJLi3KpUvKcHhdmz57ozVUoytLL0MAtLXJ3zH4CF8f6Y74ByD+o krPPIC3hGU+H31JACsjymQbhUsQR8UFlRVXVkrby7YGFExUniUJjU= X-Received: by 2002:a5d:588c:0:b0:436:3536:f698 with SMTP id ffacd0b85a97d-43958e4052fmr10504746f8f.30.1771518465266; Thu, 19 Feb 2026 08:27:45 -0800 (PST) Received: from zovi.suse.cz (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac8075sm47324631f8f.29.2026.02.19.08.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 08:27:44 -0800 (PST) From: Petr Pavlu To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Tom Zanussi , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH v3 4/5] tracing: Clean up access to trace_event_file from a file pointer Date: Thu, 19 Feb 2026 17:27:04 +0100 Message-ID: <20260219162737.314231-5-petr.pavlu@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260219162737.314231-1-petr.pavlu@suse.com> References: <20260219162737.314231-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The tracing code provides two functions event_file_file() and event_file_data() to obtain a trace_event_file pointer from a file struct. The primary method to use is event_file_file(), as it checks for the EVENT_FILE_FL_FREED flag to determine whether the event is being removed. The second function event_file_data() is an optimization for retrieving the same data when the event_mutex is still held. In the past, when removing an event directory in remove_event_file_dir(), the code set i_private to NULL for all event files and readers were expected to check for this state to recognize that the event is being removed. In the case of event_id_read(), the value was read using event_file_data() without acquiring the event_mutex. This required event_file_data() to use READ_ONCE() when retrieving the i_private data. With the introduction of eventfs, i_private is assigned when an eventfs inode is allocated and remains set throughout its lifetime. Remove the now unnecessary READ_ONCE() access to i_private in both event_file_file() and event_file_data(). Inline the access to i_private in remove_event_file_dir(), which allows event_file_data() to handle i_private solely as a trace_event_file pointer. Add a check in event_file_data() to ensure that the event_mutex is held and that file->flags doesn't have the EVENT_FILE_FL_FREED flag set. Finally, move event_file_data() immediately after event_file_code() since the latter provides a comment explaining how both functions should be used together. Signed-off-by: Petr Pavlu --- kernel/trace/trace.h | 17 +++++++++++------ kernel/trace/trace_events.c | 6 +++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index b8f3804586a0..7db78a62f786 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1802,11 +1802,6 @@ extern struct trace_event_file *find_event_file(stru= ct trace_array *tr, const char *system, const char *event); =20 -static inline void *event_file_data(struct file *filp) -{ - return READ_ONCE(file_inode(filp)->i_private); -} - extern struct mutex event_mutex; extern struct list_head ftrace_events; =20 @@ -1827,12 +1822,22 @@ static inline struct trace_event_file *event_file_f= ile(struct file *filp) struct trace_event_file *file; =20 lockdep_assert_held(&event_mutex); - file =3D READ_ONCE(file_inode(filp)->i_private); + file =3D file_inode(filp)->i_private; if (!file || file->flags & EVENT_FILE_FL_FREED) return NULL; return file; } =20 +static inline void *event_file_data(struct file *filp) +{ + struct trace_event_file *file; + + lockdep_assert_held(&event_mutex); + file =3D file_inode(filp)->i_private; + WARN_ON(!file || file->flags & EVENT_FILE_FL_FREED); + return file; +} + extern const struct file_operations event_trigger_fops; extern const struct file_operations event_hist_fops; extern const struct file_operations event_hist_debug_fops; diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 90915e1286da..c52135cd9265 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2182,12 +2182,12 @@ static int trace_format_open(struct inode *inode, s= truct file *file) static ssize_t event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *pp= os) { - int id =3D (long)event_file_data(filp); + /* id is directly in i_private and available for inode's lifetime. */ + int id =3D (long)file_inode(filp)->i_private; char buf[32]; int len; =20 - if (unlikely(!id)) - return -ENODEV; + WARN_ON(!id); =20 len =3D sprintf(buf, "%d\n", id); =20 --=20 2.53.0 From nobody Thu Mar 19 03:44:48 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A14EF34CFD7 for ; Thu, 19 Feb 2026 16:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518469; cv=none; b=VhQ5Az3tH1t0sEM2j4HGzHdF2i6+lK8zwGRRS3G5N+Q+x5y893L2rg4goSHCdsjfuhhLzlOHmHhK/roPjrsbE2pJIJq6U9Rq2fGBovYZdw91i4wK7muFpOv01GreLEREMpjD2gJcWFj1pxunnNmu+SDTMlUpGKUkyLKSAKfiImA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771518469; c=relaxed/simple; bh=nQP7wK+Ye6wYmIxmU3SiJET+QmuNicuHrwudrViWMD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OQ+NieJksB/xcd5mq805TuA/tyd7+rFrYvBlapNcSJKgRfNuiIC2rHqSowC21Ea8iDIoNsTbvtDABbPhoeZoyP4lUFbdgX1gZpJ49g2imnuwnazlstin3TXKyftbpJh2wC6mByCjveTzlnaggu47JkC7Y8w8rOue4EewM9J8/Qo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=VwGrrmnR; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="VwGrrmnR" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4376acce52eso739954f8f.1 for ; Thu, 19 Feb 2026 08:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771518466; x=1772123266; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lFC9HlnT6aCliYljADQFst4QAf50G/C+x6kbmjPwxh0=; b=VwGrrmnRcCIhe7JT8CL6K7mSwlQclA4l6F6qYq23cI3yjTmjYt0Bng+a4RVvgugXGI /J585sVZT9X2TgTl3iWXM1iwYUpvQHedP8gj/gmuujGSHbW8r5ch5P+nho3tekXAVSTB i2V1xra+a+j3ZTD7wvBpZDAivGk7nwOI9abg7yny1G6cMyrH9yUKnfv6lO40yxF/OFVD O3qAfeO8mXFaY4zpj2cqDuVaq0mU1kZTKX1MY77UqnZ/bxxeHW4EQO8UK/08qyo06joj 3yhBUrmiKOGujlLjxietkt4WzdGvV6HzLJwoIAp3AJVmWVKrkUgAhPwJWuYSthOgcniq GK4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771518466; x=1772123266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lFC9HlnT6aCliYljADQFst4QAf50G/C+x6kbmjPwxh0=; b=Zl3jxDRTOyZ/U0wUmThSnlMC4srHA9ksf/UwsRzx30loO3oj5W0XHY6aKm0iGIhCW4 5SsGZ/seoDL6tN0GZn9teM16+tPRWF9XsBtlzuM1g3A7RrcdYTud4/0R6yLmMkutvKJ/ cq3vK9dOdaJpHLyydNvBgw5c04mkPmNXvILKZ5ugGLXVYkMeczUYPN3Q2O/0jehFzi5u iIO6/Yk0svEIC7lr1B9l971t+oUQSdZN4TpdJ5ugEzfj53xXqARtmBUgpC4S+DSyIiYm 55+9O8XRrAlI4/Vl1pYb5La/Z6TPZX6Av4PBCS2bNWNflPIZkptYdqgpqyjQhITHEdEb kFgw== X-Forwarded-Encrypted: i=1; AJvYcCWEa3XC6s2fQQo08PkvOJWFCR9X6cP0J3VIT8mG33+eVx5xDYUdBYDMZw1gSUZ9h4lUpVgwsoxojfbVt2s=@vger.kernel.org X-Gm-Message-State: AOJu0YzBkgEqJVDbBI7QEf7RbW4mm2RYp3b6MIR6Nt9V/NE9h+y5+HJn Mm8Z115frlYx+VdvLO1JU1eQ6upBrQUJgb8I1t2HkhXPqXdbDnzpCJ1QJEQeJjBU5QI= X-Gm-Gg: AZuq6aK44Za0B+28psHnT8kzfgaEGjN5YbZws1uLA3At9VTtoGw8jsXCzWFgqfVSndP QsN4AqoHssu4ADorVTUb9iH+gimOrt2RPOB8cTowVoU+zfy3Fa0Ll3cIV5jvlwju+kL+ye+Ax3v wPXPwOfJxeVL56mCdQNTFnx69IijKH7GxOffIc4FTdI9kVNvKgcxFbjY2SpOzDMboUyp+gUHVDW j+6nONbtxfiLR+/IC8n2m5v2kIurTJf6w/WH1yM/nPYQ1dcaAiBlfgSTTellpqE2urnFMWHSrIo dkp7TMJvdAwv/13mnHRexeE89FRXCompWoppF85j6pMIt63GmilcjA6fVvTadXJ29E2vEuCalrW Vl3Vr1f9qBsv3zVl0aSopz8jWr5+jUXJvrKJl6RbXKMUc14SaNUckmovHYmDsizeYP1+Jkrd12E 7DY6Xjl9iTLRIOrYnqCat235XmyuXcl3wD4ZCMyAGemFWgWMrZUwg= X-Received: by 2002:a05:6000:2486:b0:436:10bc:d718 with SMTP id ffacd0b85a97d-43958e53837mr11362724f8f.57.1771518465892; Thu, 19 Feb 2026 08:27:45 -0800 (PST) Received: from zovi.suse.cz (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ac8075sm47324631f8f.29.2026.02.19.08.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 08:27:45 -0800 (PST) From: Petr Pavlu To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Tom Zanussi , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH v3 5/5] tracing: Free up file->private_data for use by individual events Date: Thu, 19 Feb 2026 17:27:05 +0100 Message-ID: <20260219162737.314231-6-petr.pavlu@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260219162737.314231-1-petr.pavlu@suse.com> References: <20260219162737.314231-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The tracing_open_file_tr() function currently copies the trace_event_file pointer from inode->i_private to file->private_data when the file is successfully opened. This duplication is not particularly useful, as all event code should utilize event_file_file() or event_file_data() to retrieve a trace_event_file pointer from a file struct and these access functions read file->f_inode->i_private. Moreover, this setup requires the code for opening hist files to explicitly clear file->private_data before calling single_open(), since this function expects the private_data member to be set to NULL and uses it to store a pointer to a seq_file. Remove the unnecessary setting of file->private_data in tracing_open_file_tr() and simplify the hist code. Signed-off-by: Petr Pavlu --- kernel/trace/trace.c | 2 -- kernel/trace/trace_events_hist.c | 4 ---- 2 files changed, 6 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2f6fbf9e7caf..a51c675be0f4 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4051,8 +4051,6 @@ int tracing_open_file_tr(struct inode *inode, struct = file *filp) event_file_get(file); } =20 - filp->private_data =3D inode->i_private; - return 0; } =20 diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_h= ist.c index 768df987419e..57c76d40be2d 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5837,8 +5837,6 @@ static int event_hist_open(struct inode *inode, struc= t file *file) hist_file->file =3D file; hist_file->last_act =3D get_hist_hit_count(event_file); =20 - /* Clear private_data to avoid warning in single_open() */ - file->private_data =3D NULL; ret =3D single_open(file, hist_show, hist_file); if (ret) { kfree(hist_file); @@ -6127,8 +6125,6 @@ static int event_hist_debug_open(struct inode *inode,= struct file *file) if (ret) return ret; =20 - /* Clear private_data to avoid warning in single_open() */ - file->private_data =3D NULL; ret =3D single_open(file, hist_debug_show, file); if (ret) tracing_release_file_tr(inode, file); --=20 2.53.0