From 33db9aff1deaa028f30516e49fdb1e8d6e31bb73 Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Tue, 18 Jul 2017 11:36:19 +0530 Subject: libglusterfs: Name threads on creation Set names to threads on creation for easier debugging. Output of top -H -p Before: 19773 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19774 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19775 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19776 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19777 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19778 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19779 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19780 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19781 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19782 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19783 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19784 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19785 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.01 glusterfsd 19786 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.01 glusterfsd 19787 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.01 glusterfsd 19789 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19790 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 25178 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 5398 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 7881 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd After: 19773 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19774 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glustertimer 19775 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterfsd 19776 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glustermemsweep 19777 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glustersproc0 19778 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glustersproc1 19779 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterepoll0 19780 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusteridxwrker 19781 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusteriotwr0 19782 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterbrssign 19783 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterbrswrker 19784 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterclogecon 19785 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.01 glusterclogd0 19786 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.01 glusterclogd1 19787 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.01 glusterclogd2 19789 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterposixjan 19790 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterposixfsy 25178 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterepoll1 5398 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterepoll2 7881 root 20 0 1301.3m 12.6m 8.4m S 0.0 0.1 0:00.00 glusterposixhc Change-Id: Id5f333755c1ba168a2ffaa4fce6e71c375e10703 BUG: 1254002 Updates: #271 Signed-off-by: Raghavendra Talur Reviewed-on: https://review.gluster.org/11926 Reviewed-by: Prashanth Pai Smoke: Gluster Build System Reviewed-by: Niels de Vos CentOS-regression: Gluster Build System --- xlators/cluster/afr/src/afr-self-heald.c | 2 +- xlators/cluster/dht/src/dht-common.c | 3 ++- xlators/cluster/dht/src/dht-rebalance.c | 19 ++++++++++++------- xlators/cluster/dht/src/tier.c | 20 ++++++++------------ xlators/cluster/ec/src/ec-heald.c | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) (limited to 'xlators/cluster') diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c index 08817202b33..74c9bb67931 100644 --- a/xlators/cluster/afr/src/afr-self-heald.c +++ b/xlators/cluster/afr/src/afr-self-heald.c @@ -685,7 +685,7 @@ afr_shd_healer_spawn (xlator_t *this, struct subvol_healer *healer, pthread_cond_signal (&healer->cond); } else { ret = gf_thread_create (&healer->thread, NULL, - threadfn, healer); + threadfn, healer, "shdheal"); if (ret) goto unlock; healer->running = 1; diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 6aa9b13e37a..253fd71068c 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -9290,7 +9290,8 @@ unlock: run_defrag = 1; ret = gf_thread_create(&conf->defrag->th, NULL, - gf_defrag_start, this); + gf_defrag_start, this, + "dhtdg"); if (ret) { GF_FREE (conf->defrag); conf->defrag = NULL; diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 2e80ada25a3..6a9153f794d 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -3988,8 +3988,9 @@ gf_tier_start_fix_layout (xlator_t *this, /* Spawn the fix layout thread so that its done in the * background */ - ret = pthread_create (&tier_fix_layout_arg->thread_id, NULL, - gf_tier_do_fix_layout, tier_fix_layout_arg); + ret = gf_thread_create (&tier_fix_layout_arg->thread_id, NULL, + gf_tier_do_fix_layout, + tier_fix_layout_arg, "tierfixl"); if (ret) { gf_log ("tier", GF_LOG_ERROR, "Thread creation failed. " "Background fix layout for tiering will not " @@ -4282,6 +4283,7 @@ gf_defrag_start_crawl (void *data) int err = 0; int thread_spawn_count = 0; pthread_t *tid = NULL; + char thread_name[GF_THREAD_NAMEMAX] = {0,}; pthread_t filecnt_thread; gf_boolean_t is_tier_detach = _gf_false; call_frame_t *statfs_frame = NULL; @@ -4447,9 +4449,9 @@ gf_defrag_start_crawl (void *data) "time to complete rebalance."); } - ret = pthread_create (&filecnt_thread, NULL, - &dht_file_counter_thread, - (void *)defrag); + ret = gf_thread_create (&filecnt_thread, NULL, + &dht_file_counter_thread, + (void *)defrag, "dhtfcnt"); if (ret) { gf_msg (this->name, GF_LOG_ERROR, ret, 0, "Failed to " @@ -4491,8 +4493,11 @@ gf_defrag_start_crawl (void *data) /*Spawn Threads Here*/ while (thread_index < thread_spawn_count) { - err = pthread_create(&(tid[thread_index]), NULL, - &gf_defrag_task, (void *)defrag); + snprintf (thread_name, sizeof(thread_name), + "%s%d", "dhtdf", thread_index + 1); + err = gf_thread_create (&(tid[thread_index]), NULL, + &gf_defrag_task, (void *)defrag, + thread_name); if (err != 0) { gf_log ("DHT", GF_LOG_ERROR, "Thread[%d] creation failed. " diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index c8667228c59..db23b9661bb 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -2577,9 +2577,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) demotion_args.is_promotion = _gf_false; demotion_args.is_compaction = _gf_false; - ret = pthread_create (&demote_thread, - NULL, &tier_run, - &demotion_args); + ret = gf_thread_create (&demote_thread, + NULL, &tier_run, &demotion_args, "tierdem"); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, @@ -2596,9 +2595,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) promotion_args.defrag = defrag; promotion_args.is_promotion = _gf_true; - ret = pthread_create (&promote_thread, - NULL, &tier_run, - &promotion_args); + ret = gf_thread_create (&promote_thread, NULL, &tier_run, + &promotion_args, "tierpro"); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, @@ -2614,9 +2612,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) hot_compaction_args.is_compaction = _gf_true; hot_compaction_args.is_hot_tier = _gf_true; - ret = pthread_create (&hot_compact_thread, - NULL, &tier_run, - &hot_compaction_args); + ret = gf_thread_create (&hot_compact_thread, NULL, &tier_run, + &hot_compaction_args, "tierhcom"); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, @@ -2632,9 +2629,8 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag) cold_compaction_args.is_compaction = _gf_true; cold_compaction_args.is_hot_tier = _gf_false; - ret = pthread_create (&cold_compact_thread, - NULL, &tier_run, - &cold_compaction_args); + ret = gf_thread_create (&cold_compact_thread, NULL, &tier_run, + &cold_compaction_args, "tierccom"); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c index 2e8ece8e3f7..b4fa6f87189 100644 --- a/xlators/cluster/ec/src/ec-heald.c +++ b/xlators/cluster/ec/src/ec-heald.c @@ -442,7 +442,7 @@ ec_shd_healer_spawn (xlator_t *this, struct subvol_healer *healer, pthread_cond_signal (&healer->cond); } else { ret = gf_thread_create (&healer->thread, NULL, - threadfn, healer); + threadfn, healer, "ecshd"); if (ret) goto unlock; healer->running = 1; -- cgit