From nobody Thu Apr 2 15:38:02 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 093C831B80D for ; Tue, 10 Feb 2026 11:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770723298; cv=none; b=gWvBJqrkmVL6/ebMLBb5gMox2rsAM1mN9ZtvchkA+E55RJMswKLpL/ONl0VqwOjTAt39euvCcdy8mg1uXZjaQOpwih/WIIe4F5YouBmlLHrpNnqHfVqNjXvtQAmB0CbUdm4KYF4rUCrFsuxx8Rnf95vknBPbkMbE3Lh5LIJ94j8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770723298; c=relaxed/simple; bh=AZbPmQspnfdPD1dkBj8q9VPDlES/gdctt4sqkPbmfJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fv0Ou9qvyiYBbxFV8qY3ErF8gKGqCVkEJrW/q3LBdfoHfXQ9Mztk+dryEOcp+KojK4F4PfMcCvFQfgXmGERCDwp0uQZCNS2psMSmZyxkt4yW7l1i08pgVPfniDy4klp/PrS++rLkNUOPD3oEJl8+V8CmBIR7FigismOvs9Gcg4E= 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=CbzLe7XG; arc=none smtp.client-ip=209.85.128.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="CbzLe7XG" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4806ce0f97bso6389145e9.0 for ; Tue, 10 Feb 2026 03:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770723291; x=1771328091; 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=8xzTbvx4j2WGhpm6B/fN7XDTTbeiE+41Vj6geLDrtfc=; b=CbzLe7XGv4OoSFfaG1y1qI8DN0Vql96lv/kEtcDfFfFafD7L9qo0b+SHT8tJLmTnsi OKEVBjRgSMwqiCXxn35uuhjczofjEssNTc6aiEqhpNSh2rjjBGynoAuQjX5jESTBIxDK CtRJcoUSQA7KVhJyBnFr82BWZQG/pG2RPJhvxKpB5iYKr5Dwz6Njwjb8gLqwooTqj6PR KeIEAZaboD1wu9wiMWorK4r7MYd02s2okZpJROLeYl08/9JmWp/JsnqLGz+ph0Una50i e4xqIdi8PW9QmKh8NIqvfw65tBtThg28b2bOTRFETyGhKdbyFvUgvM0e00yIj+4yJZI9 Qkaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770723291; x=1771328091; 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=8xzTbvx4j2WGhpm6B/fN7XDTTbeiE+41Vj6geLDrtfc=; b=N/C52zj9+rKhZ3LSuxGvYcaXKM1lM6EN3ht4QJJ00FBTtHhmHumB2ts+hwJbnfcHnz O7YCRyNlZ68NIax8whbGxcWb/uR3wOHIszzc12Q3AtH782tcvdSuI6r4Iz9RdYv7QfEc sSLziJDDa0B1vFEcgaT0BQ2g+aIEG7fZYFnDlA0PJ1HAAmymC6bxemzVyPmgMnnkAIrD EXiD0+yb9uAc0a+TOtvCpkVcU3tnzEjpNHLiKQaKEgW5ceHlbJM9XSTXNsicoKAwZ22/ fJ9zHe7Dy0fJPtRZUcwvIXU5XDhUR9Tao+gowcISl6UKQZMhafXkRH/B4U2+JtSOh4oq yjpQ== X-Forwarded-Encrypted: i=1; AJvYcCUFLnOoHQqg0vGNTrhRdn5RU3sOFI9gp+8hMiZqP5rrBulSWDEQNg00IuvxkKpxo32pQH6hAeq8A+GZBYI=@vger.kernel.org X-Gm-Message-State: AOJu0YzTLxzzJ1kwW88jUDO82iczyzmIADL8/U84dXazdK/hIpARExz5 hUpWFu3H6OnkaWdjrtWOERQK6xnQnteDCV169ReLZ/QVBLmrMw2wpxjd9qz/g54d1+w= X-Gm-Gg: AZuq6aJOrclhrra2CVxdna/xyxkPSbg7L2dcfE5gi7a1sgr/8nJ2E6LYkdMXdDCV14E CTJS26VLfDZRbmRlgSUDzYNZHBYb6GvYDABh6xELoXEhY2coIZqBQLBx6esu9sE2M47/iC9wzxX fZ7iVkMUMZUVqMlDkcxHAb10beRYPE9B/m/8mxR49mqBPs/5e20gsKKRdYxvcMTrLYP4bLIWXiw FLkCDJFe8cAEBn2JzBm4WzzbWFXZfuzyaS8cUFKWZoMxXZbLfri5j20cKYlx9mqjKTIZpiMrtXS zT1L235Zs888cE+gWZ6SkYs19qPoC2BZ6hPf/7wjvrVrkf9JCYuv8oUfhR2uX+yaN8Xs/HcgtmB t2tMD3OmgWhMbXyr3ISbiPYJNJi+9VZfLJdwC9KmDkCOFaOxrhN8m+vHIJZLA75JJfqVYG6TZWZ ClhsxFBJ4QON9vYOA7G7DbVnKD3PhzPBRHspjZnkAbs+Zb984PjZ+CtwCEPhQ3dwRxtB3Iy2L5A YQqJXn8kT2LVP93lAoQzpGK X-Received: by 2002:a7b:cdf0:0:b0:483:2c98:435e with SMTP id 5b1f17b1804b1-4832c984526mr130383165e9.34.1770723291435; Tue, 10 Feb 2026 03:34:51 -0800 (PST) Received: from zovi.suse.cz (dynamic-2a00-1028-838d-271e-8e3b-4aff-fe4c-a100.ipv6.o2.cz. [2a00:1028:838d:271e:8e3b:4aff:fe4c:a100]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483209cfd77sm120182275e9.14.2026.02.10.03.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 03:34:51 -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 4/5] tracing: Clean up access to trace_event_file from a file pointer Date: Tue, 10 Feb 2026 12:28:19 +0100 Message-ID: <20260210113427.1068932-5-petr.pavlu@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260210113427.1068932-1-petr.pavlu@suse.com> References: <20260210113427.1068932-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. A previous fix also modified event_id_read() to read i_private while holding the event_mutex. Remove the now unnecessary READ_ONCE() access to i_private in both event_file_file() and event_file_data(). 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 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index c11edec5d8f5..c6b450de93bc 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1739,11 +1739,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 @@ -1764,12 +1759,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; --=20 2.52.0