bdi: add a user-tunable cpu_list for the bdi flusher threads
Subsystems (2)
PATCH 1/1 bdi: add a user-tunable cpu_list for the bdi flusher threads
Hi,
In realtime environments, it may be desirable to keep the per-bdi flusher threads from running on certain cpus. This patch adds a cpu_list file to /sys/class/bdi/* to enable this. The default is to tie the flusher threads to the same numa node as the backing device (though I could be convinced to make it a mask of all cpus to avoid a change in behaviour).
Comments, as always, are appreciated.
Cheers,
Jeff
include/linux/backing-dev.h +4 -0
@@ -18,6 +18,7 @@#include <linux/writeback.h> #include <linux/atomic.h> #include <linux/sysctl.h> +#include <linux/mutex.h> struct page ;struct device ;
@@ -105,6 +106,9 @@ struct backing_dev_info {struct timer_list laptop_mode_wb_timer; +cpumask_t *flusher_cpumask;/* used for writeback thread scheduling */ +struct mutex flusher_cpumask_mutex; +#ifdef CONFIG_DEBUG_FS struct dentry *debug_dir;struct dentry *debug_stats;
mm/backing-dev.c +79 -0
127 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
mm/backing-dev.c static ssize_t max_ratio_store(struct device *dev, · line 245
Quoted 9 lines
mm/backing-dev.c +9
-0+ ret =cpulist_parse (buf, newmask); +if (!ret) { +spin_lock (&bdi->wb_lock); + task = wb->task; +get_task_struct (task); +spin_unlock (&bdi->wb_lock); +if (task) + ret =set_cpus_allowed_ptr (task, newmask); +put_task_struct (task);
If that test for a non-null task is needed then surely the get and put need to be similarly protected :).
mm/backing-dev.c int bdi_init(struct backing_dev_info *bdi) · line 708
Quoted 3 lines
mm/backing-dev.c +3
-0+ bdi->flusher_cpumask =kmalloc (sizeof (cpumask_t),GFP_KERNEL ); +if (!bdi->flusher_cpumask) +return -ENOMEM ;
The bare GFP_KERNEL raises an eyebrow. Some bdi_init() callers like blk_alloc_queue_node() look like they'll want to pass in a gfp_t for the allocation.
And shouldn't this be freed in the error path of bdi_init()?
- z
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Zach Brown
Quoted 4 lines
mm/backing-dev.c +4
-0+ ret =cpulist_parse (buf, newmask); +if (!ret) { +spin_lock (&bdi->wb_lock); + task = wb->task;
Quoted 8 lines
mm/backing-dev.c static ssize_t max_ratio_store(struct device *dev, · line 245
Quoted 5 lines
mm/backing-dev.c +5
-0+get_task_struct (task); +spin_unlock (&bdi->wb_lock); +if (task) + ret =set_cpus_allowed_ptr (task, newmask); +put_task_struct (task);If that test for a non-null task is needed then surely the get and put need to be similarly protected :).
How embarrassing.
Quoted 7 lines
mm/backing-dev.c int bdi_init(struct backing_dev_info *bdi) · line 708
Quoted 3 lines
mm/backing-dev.c +3
-0+ bdi->flusher_cpumask =kmalloc (sizeof (cpumask_t),GFP_KERNEL ); +if (!bdi->flusher_cpumask) +return -ENOMEM ;The bare
GFP_KERNELraises an eyebrow. Somebdi_init()callers likeblk_alloc_queue_node()look like they'll want to pass in agfp_tfor the allocation.
I'd be surprised if that was necessary, seeing how every single caller of blk_alloc_queue_node passes in GFP_KERNEL. I'll make the change, though, there aren't too many callers of bdi_init out there.
Quoted 1 line
And shouldn't this be freed in the error path of
bdi_init()?
Yes. ;-)
Thanks!
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Jeff Moyer
Quoted 7 lines
mm/backing-dev.c int bdi_init(struct backing_dev_info *bdi) · line 708
Quoted 3 lines
mm/backing-dev.c +3
-0+ bdi->flusher_cpumask =kmalloc (sizeof (cpumask_t),GFP_KERNEL ); +if (!bdi->flusher_cpumask) +return -ENOMEM ;The bare
GFP_KERNELraises an eyebrow. Somebdi_init()callers likeblk_alloc_queue_node()look like they'll want to pass in agfp_tfor the allocation.I'd be surprised if that was necessary, seeing how every single caller of
blk_alloc_queue_nodepasses inGFP_KERNEL. I'll make the change, though, there aren't too many callers ofbdi_initout there.
No other callers of bdi_init want anything but GFP_KERNEL. In the case of blk_alloc_queue_node, even *it* doesn't honor the gfp_t passed in! Have a look at blkcg_init_queue (called from blk_alloc_queue_node) to see what I mean. Maybe that's a bug?
I've written the patch to modify bdi_init to take a gfp_t, but I'm actually not in favor of this change, so I'm not going to post it (unless, of course, you can provide a compelling argument). :-)
Cheers,
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Jeff Moyer
Quoted 8 lines · Jeff Moyer
Quoted 7 lines
mm/backing-dev.c int bdi_init(struct backing_dev_info *bdi) · line 708
Quoted 3 lines
mm/backing-dev.c +3
-0+ bdi->flusher_cpumask =kmalloc (sizeof (cpumask_t),GFP_KERNEL ); +if (!bdi->flusher_cpumask) +return -ENOMEM ;The bare
GFP_KERNELraises an eyebrow. Somebdi_init()callers likeblk_alloc_queue_node()look like they'll want to pass in agfp_tfor the allocation.
Quoted 8 lines
Quoted 3 lines
I'd be surprised if that was necessary, seeing how every single caller of
blk_alloc_queue_nodepasses inGFP_KERNEL. I'll make the change, though, there aren't too many callers ofbdi_initout there.No other callers of
bdi_initwant anything butGFP_KERNEL. In the case ofblk_alloc_queue_node, even *it* doesn't honor thegfp_tpassed in! Have a look atblkcg_init_queue(called fromblk_alloc_queue_node) to see what I mean. Maybe that's a bug?
Heh, indeed.
Quoted 3 lines
I've written the patch to modify
bdi_initto take agfp_t, but I'm actually not in favor of this change, so I'm not going to post it (unless, of course, you can provide a compelling argument). :-)
No argument here, it just jumped out at me in the code. I didn't check out the callers or history of why it was that way :).
- z
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>