From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 334543858D39; Wed, 12 Jun 2024 09:53:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 334543858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1718185994; bh=JlViRZ4uBS2+fn49f9wVPTVIMshngy6jkkH7bvq+rtY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Iuqta/iMly3kCf9NyV2Isbm23fadMu0ScBdcY0dEOYu94KT5ZJn3fRoAPoU/tvKP4 scX1HehiMG039aNIEPFUmI5HCeiW2zteL9dsSAQSgvSXK2Yu0K2ffZIc/EEDFbf8ir tyIghsxLcDM36EAmPdziABeIJg7fpmqsLSK1a3mk= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/31832] [gdb] FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 3: attach (timeout) Date: Wed, 12 Jun 2024 09:53:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31832 --- Comment #6 from Tom de Vries --- Created attachment 15582 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15582&action=3Ded= it gdb.log (with statistics-gathering patch) I applied the following statistics-gathering patch: ... diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c index 5efc86cca1f..f6847257b85 100644 --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -22,6 +22,7 @@ #include #include #include +#include "gdbsupport/scope-exit.h" /* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not found. */ @@ -377,17 +378,42 @@ linux_proc_attach_tgid_threads (pid_t pid, threads, new threads may be spawned. Cycle through the list of threads until we have done two iterations without finding new threads. */ + + unsigned long long total_iterations =3D 0; + unsigned long long dir_entries =3D 0; + unsigned long long no_lwp =3D 0; + unsigned long long lookup =3D 0; + unsigned long long skipped =3D 0; + unsigned long long insert =3D 0; + unsigned long long attach =3D 0; + unsigned long long start_over =3D 0; + SCOPE_EXIT + { + printf ("total_iterations: %llu\n", total_iterations); + printf ("dir_entries: %llu\n", dir_entries); + printf ("no_lwp: %llu\n", no_lwp); + printf ("lookup: %llu\n", lookup); + printf ("skipped: %llu\n", skipped); + printf ("insert: %llu\n", insert); + printf ("attach: %llu\n", attach); + printf ("start_over: %llu\n", start_over); + }; + for (iterations =3D 0; iterations < 2; iterations++) { + total_iterations++; struct dirent *dp; new_threads_found =3D 0; while ((dp =3D readdir (dir.get ())) !=3D NULL) { + dir_entries++; unsigned long lwp; /* Fetch one lwp. */ lwp =3D strtoul (dp->d_name, NULL, 10); + if (lwp =3D=3D 0) + no_lwp++; if (lwp !=3D 0) { ptid_t ptid =3D ptid_t (pid, lwp); @@ -399,12 +425,18 @@ linux_proc_attach_tgid_threads (pid_t pid, std::pair key (lwp, *starttime); /* If we already visited this LWP, skip it this time. */ + lookup++; if (visited_lwps.find (key) !=3D visited_lwps.cend ()) - continue; + { + skipped++; + continue; + } + insert++; visited_lwps.insert (key); } + attach++; if (attach_lwp (ptid)) new_threads_found =3D 1; } @@ -414,6 +446,7 @@ linux_proc_attach_tgid_threads (pid_t pid, { /* Start over. */ iterations =3D -1; + start_over++; } rewinddir (dir.get ()); ... and ran the test-case. The first iteration gives us: ... (gdb) builtin_spawn /home/vries/gdb/build/gdb/testsuite/outputs/gdb.threads/attach-many-short-l= ived-threads/attach-many-short-lived-threads^M attach 1301317^M Attaching to program: /home/vries/gdb/build/gdb/testsuite/outputs/gdb.threads/attach-many-short-l= ived-threads/attach-many-short-lived-threads, process 1301317^M FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach (time= out) total_iterations: 2092^M dir_entries: 594518^M no_lwp: 4412^M lookup: 119037^M skipped: 118355^M insert: 682^M attach: 471751^M start_over: 2091^M Cannot attach to lwp 2340832: Operation not permitted (1)^M ... I'm not sure what this means, but I do notice the big difference between dir_entries and lookup. So only 20% of the time we find the starttime and = can use the cache. --=20 You are receiving this mail because: You are on the CC list for the bug.=