[sheepdog] [PATCH 1/4] work: rename nr_workers -> nr_queued_work
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Tue Oct 22 09:13:10 CEST 2013
The previous name is clearly confusing.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
lib/work.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/work.c b/lib/work.c
index 6933e1a..25cf964 100644
--- a/lib/work.c
+++ b/lib/work.c
@@ -65,7 +65,7 @@ struct worker_info {
size_t nr_threads;
/* protected by uatomic primitives */
- size_t nr_workers;
+ size_t nr_queued_work;
/* we cannot shrink work queue till this time */
uint64_t tm_end_of_protection;
@@ -109,7 +109,7 @@ static inline uint64_t wq_get_roof(struct worker_info *wi)
static bool wq_need_grow(struct worker_info *wi)
{
- if (wi->nr_threads < uatomic_read(&wi->nr_workers) &&
+ if (wi->nr_threads < uatomic_read(&wi->nr_queued_work) &&
wi->nr_threads * 2 <= wq_get_roof(wi)) {
wi->tm_end_of_protection = get_msec_time() +
WQ_PROTECTION_PERIOD;
@@ -125,7 +125,7 @@ static bool wq_need_grow(struct worker_info *wi)
*/
static bool wq_need_shrink(struct worker_info *wi)
{
- if (uatomic_read(&wi->nr_workers) < wi->nr_threads / 2)
+ if (uatomic_read(&wi->nr_queued_work) < wi->nr_threads / 2)
/* we cannot shrink work queue during protection period. */
return wi->tm_end_of_protection <= get_msec_time();
@@ -201,7 +201,7 @@ void queue_work(struct work_queue *q, struct work *work)
{
struct worker_info *wi = container_of(q, struct worker_info, q);
- uatomic_inc(&wi->nr_workers);
+ uatomic_inc(&wi->nr_queued_work);
pthread_mutex_lock(&wi->pending_lock);
if (wq_need_grow(wi))
@@ -235,7 +235,7 @@ static void worker_thread_request_done(int fd, int events, void *data)
list_del(&work->w_list);
work->done(work);
- uatomic_dec(&wi->nr_workers);
+ uatomic_dec(&wi->nr_queued_work);
}
}
}
@@ -404,5 +404,5 @@ bool work_queue_empty(struct work_queue *q)
{
struct worker_info *wi = container_of(q, struct worker_info, q);
- return uatomic_read(&wi->nr_workers) == 0;
+ return uatomic_read(&wi->nr_queued_work) == 0;
}
--
1.7.10.4
More information about the sheepdog
mailing list