From: Ammar Faizi <[email protected]>
To: Alviro Iskandar Setiawan <[email protected]>
Cc: Ammar Faizi <[email protected]>,
Muhammad Rizki <[email protected]>,
GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH ncns v1 2/2] chnet: Add thread index specifier for chromium thread
Date: Wed, 19 Oct 2022 23:43:09 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Currently, all threads created by the chromium thread pool have task
comm name "chromium_thread". This naming is not helpful when we're
debugging multiple chromium threads. Set the name to "chromium-%u"
where %u is the thread index in the pool. It creates a way to
identify each chromium thread uniquely.
Signed-off-by: Ammar Faizi <[email protected]>
---
chnet/chnet.cc | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/chnet/chnet.cc b/chnet/chnet.cc
index ba3c076..32078cc 100644
--- a/chnet/chnet.cc
+++ b/chnet/chnet.cc
@@ -664,11 +664,20 @@ public:
uint32_t ref_count_;
uint32_t idx_;
- ch_thpool(void);
+ ch_thpool(uint32_t i);
+
+private:
+ inline static std::string gen_thread_name(uint32_t i)
+ {
+ char name[sizeof("chromium-xxxxxxxx")];
+
+ snprintf(name, sizeof(name), "chromium-%u", i);
+ return std::string(name);
+ }
};
-ch_thpool::ch_thpool(void):
- thread_("chromium_thread"),
+ch_thpool::ch_thpool(uint32_t i):
+ thread_(gen_thread_name(i)),
ref_count_(0)
{
CHECK((void *)this == (void *)&thread_);
@@ -698,7 +707,7 @@ static base::Thread *get_thread(void)
tmp = thp[0];
if (!tmp) {
- ret = new struct ch_thpool;
+ ret = new struct ch_thpool(0);
ret->idx_ = 0;
thp[0] = ret;
goto out;
@@ -711,7 +720,7 @@ static base::Thread *get_thread(void)
tmp = thp[i];
if (!tmp) {
- ret = new struct ch_thpool;
+ ret = new struct ch_thpool(i);
ret->idx_ = i;
thp[i] = ret;
goto out;
--
Ammar Faizi
next prev parent reply other threads:[~2022-10-19 16:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 16:43 [PATCH ncns v1 0/2] Small optimization and improve debugging experience Ammar Faizi
2022-10-19 16:43 ` [PATCH ncns v1 1/2] chnet: Optimize `put_thread()` path Ammar Faizi
2022-10-19 16:43 ` Ammar Faizi [this message]
2022-10-19 22:38 ` [PATCH ncns v1 2/2] chnet: Add thread index specifier for chromium thread Alviro Iskandar Setiawan
2022-10-19 22:36 ` [PATCH ncns v1 0/2] Small optimization and improve debugging experience Alviro Iskandar Setiawan
2022-10-19 22:53 ` Ammar Faizi
2022-10-19 22:56 ` Alviro Iskandar Setiawan
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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: link
Be 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