GFS2: Use new workqueue scheme
The recovery workqueue can be unbound and also freezable since we want it to finish what it is doing if the system is to be frozen (although why you'd want to freeze a cluster node is beyond me since it will result in it being ejected from the cluster). It does still make sense for single node GFS2 filesystems though.
The glock workqueue will benefit from being able to run more work items concurrently. A test running postmark shows improved performance and multi-threaded workloads a likely to benefit even more.
The delete workqueue is similar to the recovery workqueue in that it must not get blocked by memory allocations, may run for a long time, and each individual work should only be scheduled once anywhere in the system.
Potentially other GFS2 threads might also be converted to workqueues, but I'll leave that for a later patch.
fs/gfs2/glock.c +6 -2
@@ -1783,10 +1783,14 @@ int __init gfs2_glock_init(void) }#endif - glock_workqueue =create_workqueue ("glock_workqueue" ); + glock_workqueue =alloc_workqueue ("glock_workqueue" ,WQ_RESCUER | +WQ_HIGHPRI |WQ_CPU_INTENSIVE | +WQ_FREEZEABLE ,0 );if (IS_ERR (glock_workqueue))return PTR_ERR (glock_workqueue); - gfs2_delete_workqueue =create_workqueue ("delete_workqueue" ); + gfs2_delete_workqueue =alloc_workqueue ("delete_workqueue" ,WQ_RESCUER | +WQ_UNBOUND |WQ_NON_REENTRANT | +WQ_FREEZEABLE ,0 );if (IS_ERR (gfs2_delete_workqueue)) {destroy_workqueue (glock_workqueue);return PTR_ERR (gfs2_delete_workqueue);
fs/gfs2/main.c +2 -1
@@ -140,7 +140,8 @@ static int __init init_gfs2_fs(void) error = -ENOMEM ; gfs_recovery_wq =alloc_workqueue ("gfs_recovery" , -WQ_NON_REENTRANT |WQ_RESCUER ,0 ); +WQ_NON_REENTRANT |WQ_RESCUER | +WQ_UNBOUND |WQ_FREEZEABLE ,0 );if (!gfs_recovery_wq) goto fail_wq;
Hi,
Quoted 4 lines · Tejun Heo
Hello, Steven.
Thanks for working on this.
I think it will be a big win for GFS2, particularly as the number of cpu cores increases
Quoted 9 lines · Steven Whitehouse
Quoted 8 lines
fs/gfs2/glock.c +0
-0@@ -1783,10 +1783,14 @@ int __init gfs2_glock_init(void) }#endif
Quoted 7 lines
fs/gfs2/glock.c int __init gfs2_glock_init(void) · line 1788
Quoted 4 lines
fs/gfs2/glock.c +3
-1- glock_workqueue =create_workqueue ("glock_workqueue" ); + glock_workqueue =alloc_workqueue ("glock_workqueue" ,WQ_RESCUER | +WQ_HIGHPRI |WQ_CPU_INTENSIVE | +WQ_FREEZEABLE ,0 );Does this really need
WQ_HIGHRPIandWQ_CPU_INTENSIVE?
This would be a tasklet were it not for the fact that it needs to be able to submit block I/O from time to time. It does need to be as fast as possible since it directly affects the latency of operations using large numbers of inodes.
I read your latest set of docs before assigning the flags, so I hope I've understood it correctly.
The glock workqueue is involved in sending requests to the DLM and processing the results of those requests, waking up waiting processes as quickly as possible.
Quoted 27 lines
Quoted 15 lines
fs/gfs2/glock.c +3
-1if (IS_ERR (glock_workqueue))return PTR_ERR (glock_workqueue); - gfs2_delete_workqueue =create_workqueue ("delete_workqueue" ); + gfs2_delete_workqueue =alloc_workqueue ("delete_workqueue" ,WQ_RESCUER | +WQ_UNBOUND |WQ_NON_REENTRANT | +WQ_FREEZEABLE ,0 );if (IS_ERR (gfs2_delete_workqueue)) {destroy_workqueue (glock_workqueue);fs/gfs2/glock.c +0
-0return PTR_ERR (gfs2_delete_workqueue);fs/gfs2/main.c +0
-0fs/gfs2/main.c static int __init init_gfs2_fs(void) · line 144
Quoted 6 lines
fs/gfs2/main.c +2
-1@@ -140,7 +140,8 @@ static int __init init_gfs2_fs(void) error = -ENOMEM ; gfs_recovery_wq =alloc_workqueue ("gfs_recovery" , -WQ_NON_REENTRANT |WQ_RESCUER ,0 ); +WQ_NON_REENTRANT |WQ_RESCUER | +WQ_UNBOUND |WQ_FREEZEABLE ,0 );And do these need to be
WQ_UNBOUND? Unless the flags are specifically needed, I think it would be better to stick with the default. I'm currently working on the documentation. It's still not complete but please take a look for more information the behaviors of each flag.
Quoted 2 lines
Thanks.
I wouldn't say that it was 100% a requirement, but they are long running (potentially a few seconds, or even as far as a minute or two in extreme cases). The recovery workqueue seems to meet this criteria:
Quoted 2 lines
* Long running CPU intensive workloads which can be better managed by the system scheduler.
and the delete_workqueue seems to meet this criteria:
Quoted 4 lines
* Wide fluctuation in the concurrency level requirement is expected and using bound wq may end up creating large number of mostly unused workers across different CPUs as the issuer hops through different CPUs.
It may be that I didn't understand the docs correctly, but I think I've found the right flags. The delete_workqueue is usually unused during normal fs operation, but occasionally it might have a lot to do. It was made a separate workqueue because it needs to be able to manipulate glocks and thus must never block the glock workqueue.
Steve.
Hi,
Quoted 32 lines · Tejun Heo
Hello,
Quoted 7 lines · Steven Whitehouse
Quoted 4 lines · Tejun Heo
Hello, Steven.
Thanks for working on this.
I think it will be a big win for GFS2, particularly as the number of cpu cores increases
Awesome. :-)
Quoted 12 lines
Quoted 7 lines
fs/gfs2/glock.c int __init gfs2_glock_init(void) · line 1788
Quoted 4 lines
fs/gfs2/glock.c +3
-1- glock_workqueue =create_workqueue ("glock_workqueue" ); + glock_workqueue =alloc_workqueue ("glock_workqueue" ,WQ_RESCUER | +WQ_HIGHPRI |WQ_CPU_INTENSIVE | +WQ_FREEZEABLE ,0 );Does this really need
WQ_HIGHRPIandWQ_CPU_INTENSIVE?This would be a tasklet were it not for the fact that it needs to be able to submit block I/O from time to time. It does need to be as fast as possible since it directly affects the latency of operations using large numbers of inodes.
Quoted 6 lines
I read your latest set of docs before assigning the flags, so I hope I've understood it correctly.
The glock workqueue is involved in sending requests to the DLM and processing the results of those requests, waking up waiting processes as quickly as possible.
Quoted 6 lines
I see but then wouldn't
WQ_CPU_INTENSIVEbe unnecessary? It's high priority but doesn't sound like they're gonna hog huge amount of CPU cycles. Also, please note that the high priority is global across all workqueues and thus _must_ be used judiciously. Well, if you were gonna use tasklets for it, it probably is a good candidate tho.
Ah, I see. Maybe I misunderstood. I read the bit about using both WQ_HIGHPRO and WQ_CPU_INTENSIVE which says:
"Work items queued on a highpri CPU-intensive wq start execution as soon as resources are available and don't affect execution of other work items."
and assumed that was what I needed, but maybe I don't need to WQ_CPU_INTENSIVE as you suggest.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
fs/gfs2/main.c static int __init init_gfs2_fs(void) · line 144
Quoted 4 lines
fs/gfs2/main.c +2
-1gfs_recovery_wq =alloc_workqueue ("gfs_recovery" , -WQ_NON_REENTRANT |WQ_RESCUER ,0 ); +WQ_NON_REENTRANT |WQ_RESCUER | +WQ_UNBOUND |WQ_FREEZEABLE ,0 );And do these need to be
WQ_UNBOUND? Unless the flags are specifically needed, I think it would be better to stick with the default. I'm currently working on the documentation. It's still not complete but please take a look for more information the behaviors of each flag.
Quoted 9 lines
Quoted 3 lines
I wouldn't say that it was 100% a requirement, but they are long running (potentially a few seconds, or even as far as a minute or two in extreme cases). The recovery workqueue seems to meet this criteria:
Long running doesn't matter. Normal workqueues can handle them perfectly fine. The only cases you would want to use unbound workqueues are long running CPU hogs and (very) high fluctuation in the number of concurrent work items.
It sounds like maybe the delete workqueue needs that, but that the recovery one certainly doesn't in that case.
Quoted 24 lines
Quoted 10 lines
Quoted 2 lines
* Long running CPU intensive workloads which can be better managed by the system scheduler.
and the
delete_workqueueseems to meet this criteria:Quoted 4 lines
* Wide fluctuation in the concurrency level requirement is expected and using bound wq may end up creating large number of mostly unused workers across different CPUs as the issuer hops through different CPUs.
Quoted 5 lines
It may be that I didn't understand the docs correctly, but I think I've found the right flags. The
delete_workqueueis usually unused during normal fs operation, but occasionally it might have a lot to do. It was made a separate workqueue because it needs to be able to manipulate glocks and thus must never block the glock workqueue.Heh, these being one of the first conversions, I just wanna make sure. Long running CPU-intensive tasks would be things like works running RAID checksums, crypto stuff, IOW, stuff which are actually gonna perform a long calculation. If a work is just gonna be blocking on locks for long period of time, there's no need to use the unbound ones. So, unless I'm misunderstanding, I don't really think
WQ_UNBOUNDis necessary for the latter two.
Quoted 2 lines
Thanks.
Yes, I'll try it without and see if that is ok. I am also trying to be a bit cautious about the flags in case I accidentally introduce some dependency which was not there before.
I'll follow up with an updated patch shortly,
Steve.
[Cluster-devel] GFS2: Use new workqueue scheme (try #2)
In reply to a message not in the archiveIncidentally, this updated patch seems to run the postmark test even faster than the previous version :-)
From 612ea747e44877b7fb969746570913fbb0f81494 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Thu, 9 Sep 2010 15:10:43 +0100
Subject: GFS2: Use new workqueue scheme
The recovery workqueue can be freezable since
we want it to finish what it is doing if the system is to be frozen (although why you'd want to freeze a cluster node is beyond me since it will result in it being ejected from the cluster). It does still make sense for single node GFS2 filesystems though.
The glock workqueue will benefit from being able to run more work items concurrently. A test running postmark shows improved performance and multi-threaded workloads are likely to benefit even more.
The delete workqueue is similar to the recovery workqueue in that it must not get blocked by memory allocations, may run for a long time, and each individual work should only be scheduled once anywhere in the system.
Potentially other GFS2 threads might also be converted to workqueues, but I'll leave that for a later patch.
fs/gfs2/glock.c +5 -2
@@ -1783,10 +1783,13 @@ int __init gfs2_glock_init(void) }#endif - glock_workqueue =create_workqueue ("glock_workqueue" ); + glock_workqueue =alloc_workqueue ("glock_workqueue" ,WQ_RESCUER | +WQ_HIGHPRI |WQ_FREEZEABLE ,0 );if (IS_ERR (glock_workqueue))return PTR_ERR (glock_workqueue); - gfs2_delete_workqueue =create_workqueue ("delete_workqueue" ); + gfs2_delete_workqueue =alloc_workqueue ("delete_workqueue" ,WQ_RESCUER | +WQ_NON_REENTRANT | +WQ_FREEZEABLE ,0 );if (IS_ERR (gfs2_delete_workqueue)) {destroy_workqueue (glock_workqueue);return PTR_ERR (gfs2_delete_workqueue);
fs/gfs2/main.c +2 -1
@@ -140,7 +140,8 @@ static int __init init_gfs2_fs(void) error = -ENOMEM ; gfs_recovery_wq =alloc_workqueue ("gfs_recovery" , -WQ_NON_REENTRANT |WQ_RESCUER ,0 ); +WQ_NON_REENTRANT |WQ_RESCUER | +WQ_FREEZEABLE ,0 );if (!gfs_recovery_wq) goto fail_wq;
Signature · 1 line
1.7.1.1
[Cluster-devel] GFS2: Use new workqueue scheme (try #2)
In reply to a message not in the archiveHi,
Quoted 10 lines · Tejun Heo
Hello,
Quoted 2 lines · Steven Whitehouse
Incidentally, this updated patch seems to run the postmark test even faster than the previous version :-)
Ah, cool. :-)
Just one more thing.
Quoted 9 lines
fs/gfs2/glock.c int __init gfs2_glock_init(void) · line 1792
Quoted 4 lines
fs/gfs2/glock.c +3
-1- gfs2_delete_workqueue =create_workqueue ("delete_workqueue" ); + gfs2_delete_workqueue =alloc_workqueue ("delete_workqueue" ,WQ_RESCUER | +WQ_NON_REENTRANT | +WQ_FREEZEABLE ,0 );The original
create_workqueue()is (cross-CPU) reentrant, so addingWQ_NON_REENTRANTthere is adding one more restriction. Is this intentional?
The original code relied upon the submission code to prevent this from happening. It seemed like a good idea to declare this explicitly, but again it is not actually required, as such.
Quoted 10 lines
fs/gfs2/main.c static int __init init_gfs2_fs(void) · line 144
Quoted 5 lines
fs/gfs2/main.c +2
-1error = -ENOMEM ; gfs_recovery_wq =alloc_workqueue ("gfs_recovery" , -WQ_NON_REENTRANT |WQ_RESCUER ,0 ); +WQ_NON_REENTRANT |WQ_RESCUER | +WQ_FREEZEABLE ,0 );Looks like patch wasn't generated on a clean tree. The same question too. If it worked fine w/
create_workqueue()before, you don't needNON_REENTRANT.
Quoted 2 lines
Thanks.
And the same here. The tree I'm using is my -nmw GFS2 tree since that is where I'd intended to queue the resulting patch,
Steve.