From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [182.253.183.71]) by gnuweeb.org (Postfix) with ESMTPSA id 6AAAA81151; Wed, 19 Oct 2022 16:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666197801; bh=ebJiToeHCw9Yy/kBQR7n3fxm9+MEFvcm/nH9z7+u5I0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLGxHGZcQVtGWpL/uBPKW5oaO6NzzmYVNxzuQtxa1TjnguYw8+SGLcOloDzcCocWP +34H6QUgw/KNoVPuMZ99p+xIU7Xud2SVxhgOMhuzYhWzYDRmjx89NeAWxrJKrF/kFj oZUKE2+NlN/2zLWKpm/RmoME1FoU8ayYO1xX7AzrWHaVcLKbC8E1aYKBte1wKIfxDr w7N9s8Rcs410y2+XeyZQz9/jF9ht2+/MtpO8XN8SfKdor+m2UVd9rVmmH9do50QUCC MEqwXCDhexIyw//Y5ZRJmE1Ih15chVmxfila+Sj3Jv58+KN83PpzAgPLvSv2+NsC+v e7oaU2lY/uoeg== From: Ammar Faizi To: Alviro Iskandar Setiawan Cc: Ammar Faizi , Muhammad Rizki , GNU/Weeb Mailing List Subject: [PATCH ncns v1 2/2] chnet: Add thread index specifier for chromium thread Date: Wed, 19 Oct 2022 23:43:09 +0700 Message-Id: <20221019164309.1709541-3-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019164309.1709541-1-ammarfaizi2@gnuweeb.org> References: <20221019164309.1709541-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 --- 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