Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp506333rdb; Tue, 23 Jan 2024 06:24:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdoJ3nO7PiyTREIlfBAM4gjvYYgRaJWioSxebfPj7Pnf/3lMpTlWmz9lhNFSmO8I/547an X-Received: by 2002:a05:622a:1390:b0:42a:3ce2:7bbd with SMTP id o16-20020a05622a139000b0042a3ce27bbdmr1018688qtk.3.1706019875346; Tue, 23 Jan 2024 06:24:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706019875; cv=pass; d=google.com; s=arc-20160816; b=q6ZQcsoE33IJKieZOcte0GulVhc2cMOK5fvfYtJAM5BPBYgAW38XD+/SWWZpBBgmmT UPbQoVYmIyypTRNxP2VuCudqFIJ4cGlkB7t97eApuC2KNc9aSX4byOJSqfEmOC8EcV0X p02x2JwlNlNxh2LORUKecmAM4wZj1MCy416rbUolVe25/pKVfhy79WbDmy+2HNoxfSt9 kvBtW/ZCcTXkAAoFYloOnm0Wfxk4cWC7pnyAUV02p14vJrjqjPSubVehOBSV8UyzuxNC 0K0J51v+/+FuMtA3osQLxpQoNZucfnkvZLITl8oghlq7J0nxMOoF683jHRJG7//8/gkY 1AxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=ebMst8VqAh3PXk3lYXeBl+GBxS+jUYubu64ErhFVYFM=; fh=5gr3sruEhFDdQe9pEyEitRst57Yk9kqtueYAeNpJU84=; b=etL41+Z2A0Lqh7IglwpsZR5S7KULzZqGd3CvZ3T0N5ldfQtMC/wqlH3bjU4r9SI9ZB hHj72Fc7hBIicA0ocnLLsWO9+q+PTvK6Ou3tgcm06zCXuMRGP6De7tuIS4y9AY6k2xIQ 8rkPZ17NY36BcUZvsCl0PJcZ9sxTo83KOVI/GdrCfsnHXb8nnQp3YuuQp+9aqXZUX2Kf tSRgK/aAf3NwXLVtFySsxc/feJDWZkXCORaQ17IudrqfOcX8DDomHTOuflhqIlsFJaVY 5XXPUOu6FTgp9FdunKKo4omeqtYO533E8I6L6hyQlFJRlk7xiK3XpAOX5fWpcp3x2yyZ Pbog== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-35446-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35446-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g6-20020ac85d46000000b0042a1fc49eb0si7988130qtx.396.2024.01.23.06.24.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 06:24:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35446-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-35446-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35446-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C89281C243CA for ; Tue, 23 Jan 2024 14:24:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40F8E5FB83; Tue, 23 Jan 2024 14:24:31 +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 BEB9A5EE8E for ; Tue, 23 Jan 2024 14:24:30 +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=1706019870; cv=none; b=maHt6uanfFDzCUZLpw1nk6fN5Gzu//NpTzLI4eULPAtWh6q6+LDB+36r3cnPWgLTs2fHQQg60dif7i4wGUnjc4K3I2AKkLNipueoCVbD5HTRwEfrOOme9vXsvuVIGNFIJPQcJFYZrn3/MsJpuLXdn5gkEEBL+GHkOquUcdjwib4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706019870; c=relaxed/simple; bh=OqwBKZG+HAM9Z/m1JbNtARLUkXeFQAw6q0XphWXmSYE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=fvpnw2t/0EKholZblnVujYGA3R3NS400gGnucBMNaCC3IE7+cLFyK8SYAGcwSoniHoghzvLKWMXM+bZWUSx4vMUSoBdiQKGLTrD9NOb+I9D4fYJFZPCoHbyg6VzMqyD4nEkUKSVwC7MO1Prs9tIW7PahuK219ZQTiKXX6TcZ3VI= 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 AB9F5C433C7; Tue, 23 Jan 2024 14:24:29 +0000 (UTC) Date: Tue, 23 Jan 2024 09:26:00 -0500 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers , Petr Pavlu , Geert Uytterhoeven Subject: [GIT PULL] tracing: Fixes for eventfs and histograms Message-ID: <20240123092600.39d78909@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Linus, Tracing and eventfs fixes for 6.8: - Fix histogram tracing_map insertion. The tracing_map_insert copies the value into the elt variable and then assigns the elt to the entry value. But it is possible that the entry value becomes visible on other CPUs before the elt is fully initialized. This is fixed by adding a wmb() between the initialization of the elt variable and assigning it. - Have eventfs directory have unique inode numbers. Having them be all the same proved to be a failure as the find application will think that the directories are causing loops, as it checks for directory loops via their inodes. Have the evenfs dir entries get their inodes assigned when they are referenced and then save them in the eventfs_inode structure. Please pull the latest trace-v6.8-rc1 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-v6.8-rc1 Tag SHA1: 729afc0bff83ae580a1151b1de10618ce04cb6dd Head SHA1: 834bf76add3e6168038150f162cbccf1fd492a67 Petr Pavlu (1): tracing: Ensure visibility when inserting an element into tracing_map Steven Rostedt (Google) (1): eventfs: Save directory inodes in the eventfs_inode structure ---- fs/tracefs/event_inode.c | 14 +++++++++++--- fs/tracefs/internal.h | 7 ++++--- kernel/trace/tracing_map.c | 7 ++++++- 3 files changed, 21 insertions(+), 7 deletions(-) --------------------------- diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 6795fda2af19..6b211522a13e 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -34,7 +34,15 @@ static DEFINE_MUTEX(eventfs_mutex); /* Choose something "unique" ;-) */ #define EVENTFS_FILE_INODE_INO 0x12c4e37 -#define EVENTFS_DIR_INODE_INO 0x134b2f5 + +/* Just try to make something consistent and unique */ +static int eventfs_dir_ino(struct eventfs_inode *ei) +{ + if (!ei->ino) + ei->ino = get_next_ino(); + + return ei->ino; +} /* * The eventfs_inode (ei) itself is protected by SRCU. It is released from @@ -396,7 +404,7 @@ static struct dentry *create_dir(struct eventfs_inode *ei, struct dentry *parent inode->i_fop = &eventfs_file_operations; /* All directories will have the same inode number */ - inode->i_ino = EVENTFS_DIR_INODE_INO; + inode->i_ino = eventfs_dir_ino(ei); ti = get_tracefs(inode); ti->flags |= TRACEFS_EVENT_INODE; @@ -802,7 +810,7 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx) name = ei_child->name; - ino = EVENTFS_DIR_INODE_INO; + ino = eventfs_dir_ino(ei_child); if (!dir_emit(ctx, name, strlen(name), ino, DT_DIR)) goto out_dec; diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 12b7d0150ae9..45397df9bb65 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -55,6 +55,10 @@ struct eventfs_inode { struct eventfs_attr *entry_attrs; struct eventfs_attr attr; void *data; + unsigned int is_freed:1; + unsigned int is_events:1; + unsigned int nr_entries:30; + unsigned int ino; /* * Union - used for deletion * @llist: for calling dput() if needed after RCU @@ -64,9 +68,6 @@ struct eventfs_inode { struct llist_node llist; struct rcu_head rcu; }; - unsigned int is_freed:1; - unsigned int is_events:1; - unsigned int nr_entries:30; }; static inline struct tracefs_inode *get_tracefs(const struct inode *inode) diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c index c774e560f2f9..a4dcf0f24352 100644 --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c @@ -574,7 +574,12 @@ __tracing_map_insert(struct tracing_map *map, void *key, bool lookup_only) } memcpy(elt->key, key, map->key_size); - entry->val = elt; + /* + * Ensure the initialization is visible and + * publish the elt. + */ + smp_wmb(); + WRITE_ONCE(entry->val, elt); atomic64_inc(&map->hits); return entry->val;