diff mbox series

ss: Tone down cgroup path resolution

Message ID 20250210141103.44270-1-mkoutny@suse.com (mailing list archive)
State New
Delegated to: Stephen Hemminger
Headers show
Series ss: Tone down cgroup path resolution | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Michal Koutný Feb. 10, 2025, 2:11 p.m. UTC
Sockets and cgroups have different lifetimes (e.g. fd passing between
cgroups) so obtaining a cgroup id to a removed cgroup dir is not an
error. Furthermore, the message is printed for each such a socket.
Improve user experience by silencing these specific errors.
---
 lib/fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Davide Benini Feb. 18, 2025, 1:11 p.m. UTC | #1
On 10/02/25 15:11, Michal Koutný wrote:
> Sockets and cgroups have different lifetimes (e.g. fd passing between
> cgroups) so obtaining a cgroup id to a removed cgroup dir is not an
> error. Furthermore, the message is printed for each such a socket.
> Improve user experience by silencing these specific errors.

Note that if ss has been called with -e (to show detailed socket information) or with --cgroup (to show cgroup information), even if the message "Failed to open cgroup2 by ID" will no longer appear, however the cg_id_to_path() will return a string "unreachable:%llx" and the output will still be similar to

tcp	LISTEN	0	4096	[::]:2049	[::]:*	ino:710321	sk:10da	cgroup:unreachable:8ed7	v6only:1 <->

But I agree that removing the specific error message would be enough to prevent customer concern.

Davide Benini
Michal Koutný Feb. 18, 2025, 1:40 p.m. UTC | #2
On Tue, Feb 18, 2025 at 02:11:06PM +0100, Davide Benini <davide.benini@suse.com> wrote:
> however the cg_id_to_path() will return a string "unreachable:%llx"
> and the output will still be similar to

And I think that is good -- it captures the situation with the socket
like its "property" and not a global error.

> But I agree that removing the specific error message would be enough
> to prevent customer concern.

One can do only so much with sockets of rmdir'd cgroups.

Thanks,
Michal
diff mbox series

Patch

diff --git a/lib/fs.c b/lib/fs.c
index 622f28b3..6fe1d6db 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -223,7 +223,8 @@  char *get_cgroup2_path(__u64 id, bool full)
 
 	fd = open_by_handle_at(mnt_fd, fhp, 0);
 	if (fd < 0) {
-		fprintf(stderr, "Failed to open cgroup2 by ID\n");
+		if (errno != ESTALE)
+			fprintf(stderr, "Failed to open cgroup2 by ID\n");
 		goto out;
 	}