public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] [Linux] Read vDSO range from /proc/PID/task/PID/maps instead of /proc/PID/maps Date: Tue, 24 May 2016 14:15:00 -0000 [thread overview] Message-ID: <95e94c3f18aaf34fadcd9a2a882ffe6147b9acc3@gdb-build> (raw) *** TEST RESULTS FOR COMMIT 95e94c3f18aaf34fadcd9a2a882ffe6147b9acc3 *** Author: Pedro Alves <palves@redhat.com> Branch: master Commit: 95e94c3f18aaf34fadcd9a2a882ffe6147b9acc3 [Linux] Read vDSO range from /proc/PID/task/PID/maps instead of /proc/PID/maps ... as it's _much_ faster. Hacking the gdb.threads/attach-many-short-lived-threads.exp test to spawn thousands of threads instead of dozens to stress and debug timeout problems with gdb.threads/attach-many-short-lived-threads.exp, I saw that GDB would spend several seconds just reading the /proc/PID/smaps file, to determine the vDSO mapping range. GDB opens and reads the whole file just once, and caches the result, but even that is too slow. For example, with almost 8000 threads: $ ls /proc/3518/task/ | wc -l 7906 reading the /proc/PID/smaps file grepping for "vdso" takes over 15 seconds : $ time cat /proc/3518/smaps | grep vdso 7ffdbafee000-7ffdbaff0000 r-xp 00000000 00:00 0 [vdso] real 0m15.371s user 0m0.008s sys 0m15.017s Looking around the web for hints, I found a nice description of the issue here: http://backtrace.io/blog/blog/2014/11/12/large-thread-counts-and-slow-process-maps/ The problem is that /proc/PID/smaps wants to show the mappings as being thread stack, and that has the kernel iterating over all threads in the thread group, for each mapping. The fix is to use the "map" file under /proc/PID/task/PID/ instead of the /proc/PID/ one, as the former doesn't mark thread stacks for all threads. That alone drops the timing to the millisecond range on my machine: $ time cat /proc/3518/task/3518/smaps | grep vdso 7ffdbafee000-7ffdbaff0000 r-xp 00000000 00:00 0 [vdso] real 0m0.150s user 0m0.009s sys 0m0.084s And since we only need the vdso mapping's address range, we can use "maps" file instead of "smaps", and it's even cheaper: /proc/PID/task/PID/maps : $ time cat /proc/3518/task/3518/maps | grep vdso 7ffdbafee000-7ffdbaff0000 r-xp 00000000 00:00 0 [vdso] real 0m0.027s user 0m0.000s sys 0m0.017s gdb/ChangeLog: 2016-05-24 Pedro Alves <palves@redhat.com> PR gdb/19828 * linux-tdep.c (find_mapping_size): Delete. (linux_vsyscall_range_raw): Rewrite reading from /proc/PID/task/PID/maps directly instead of using gdbarch_find_memory_regions.
next reply other threads:[~2016-05-24 14:15 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-05-24 14:15 sergiodj+buildbot [this message] 2016-05-24 14:15 ` *** COMPILATION FAILED *** Failures on AIX-POWER7-plain, branch master *** BREAKAGE *** sergiodj+buildbot 2016-05-24 14:52 ` Failures on Fedora-i686, branch master sergiodj+buildbot 2016-05-24 14:52 ` Failures on Fedora-x86_64-m32, " sergiodj+buildbot 2016-05-24 14:53 ` Failures on Fedora-x86_64-native-gdbserver-m32, " sergiodj+buildbot 2016-05-24 15:05 ` Failures on Fedora-s390x-m64, " sergiodj+buildbot 2016-05-24 15:06 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " sergiodj+buildbot 2016-05-24 15:21 ` Failures on Debian-i686-native-extended-gdbserver, " sergiodj+buildbot 2016-05-24 15:43 ` Failures on Debian-i686, " sergiodj+buildbot 2016-05-24 20:49 ` Failures on Fedora-ppc64be-native-gdbserver-m64, " sergiodj+buildbot 2016-05-24 21:33 ` Failures on Fedora-ppc64be-native-extended-gdbserver-m64, " sergiodj+buildbot 2016-05-24 23:01 ` Failures on Fedora-ppc64le-native-extended-gdbserver-m64, " sergiodj+buildbot 2016-05-24 23:47 ` Failures on Fedora-ppc64le-cc-with-index, " sergiodj+buildbot 2016-05-25 1:07 ` Failures on Fedora-ppc64le-native-gdbserver-m64, " sergiodj+buildbot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=95e94c3f18aaf34fadcd9a2a882ffe6147b9acc3@gdb-build \ --to=sergiodj+buildbot@sergiodj.net \ --cc=gdb-testers@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).