null_blk: documentation, defaults and mapping
Subsystems (2)
cover null_blk: documentation, defaults and mapping
Hi,
These three patches cover:
* Incorporated the feedback from Randy Dunlap into documentation. Can be merged with the previous documentation commit (6824518).
* Set use_per_node_hctx to false per default to save resources.
* Allow submit_queues and use_per_node_hctx to be used simultanesly. If the submit_queues is a multiple of nr_online_nodes, its trivial. Simply map them to the nodes. For example: 8 submit queues are mapped as node0[0,1], node1[2,3], ...
If uneven, we are left with an uneven number of submit_queues that must be mapped. These are mapped toward the first node and onward. E.g. 5 submit queues mapped onto 4 nodes are mapped as node0[0,1], node1[2], ...
Matias Bjørling (3):
null_blk: corrections to documentation
null_blk: set use_per_node_hctx param to false
null_blk: support submit_queues on use_per_node_hctx
Documentation/block/null_blk.txt | 27 +++++++++++++------------ drivers/block/null_blk.c | 43 ++++++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 19 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/3 null_blk: corrections to documentation
From: Matias Bjørling <[email protected]>
Randy Dunlap reported a couple of grammar errors and unfortunate usages of socket/node/core.
--- Documentation/block/null_blk.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
Documentation/block/null_blk.txt +10 -10
@@ -18,7 +18,7 @@ The following instances are possible: - Bio-based. IO requests are submitted directly to the device driver. - Directly accepts bio data structure and returns them. -All of them has a completion queue for each core in the system. +All of them have a completion queue for each core in the system. II. Module parameters applicable for all instances:
@@ -30,7 +30,7 @@ queue_mode=[0-2]: Default: 2-Multi-queue 2: Multi-queue. home_node=[0--nr_nodes]: Default: NUMA_NO_NODE - Selects what socket the data structures is allocated from. + Selects what CPU node the data structures are allocated from. gb=[Size in GB]: Default: 250GB The size of the device reported to the system.
@@ -38,34 +38,34 @@ gb=[Size in GB]: Default: 250GB bs=[Block size (in bytes)]: Default: 512 bytes The block size reported to the system. -nr_devices=[Num. devices]: Default: 2 +nr_devices=[Number of devices]: Default: 2 Number of block devices instantiated. They are instantiated as /dev/nullb0, etc. -irq_mode=[0-2]: Default: Soft-irq +irq_mode=[0-2]: Default: 1-Soft-irq The completion mode used for completing IOs to the block-layer. 0: None. - 1: Soft-irq. Uses ipi to complete IOs across sockets. Simulates the overhead - when IOs are issued from another socket than the home the device is + 1: Soft-irq. Uses IPI to complete IOs across CPU nodes. Simulates the overhead + when IOs are issued from another CPU node than the home the device is connected to. 2: Timer: Waits a specific period (completion_nsec) for each IO before completion. -completion_nsec=[Num. ns]: Default: 10.000ns +completion_nsec=[ns]: Default: 10.000ns Combined with irq_mode=2 (timer). The time each completion event must wait. submit_queues=[0..nr_cpus]: The number of submission queues attached to the device driver. If unset, it defaults to 1 on single-queue and bio-based instances. For multi-queue, - its ignored when use_per_node_hctx module parameter is 1. + it is ignored when use_per_node_hctx module parameter is 1. -hw_queue_depth=[0..qdepth]: Defaults: 64 +hw_queue_depth=[0..qdepth]: Default: 64 The hardware queue depth of the device. III: Multi-queue specific parameters -use_per_node_hctx=[0/1]: Defaults: 1 +use_per_node_hctx=[0/1]: Default: 1 If 1, the multi-queue block layer is instantiated with a hardware dispatch queue for each CPU node in the system. If 0, it is instantiated with the number of queues defined in the submit_queues parameter.
Signature · 1 line
1.8.3.2
Re: [PATCH 1/3] null_blk: corrections to documentation
Quoted 7 lines · Matias Bjorling
From: Matias Bjørling <[email protected]>
Randy Dunlap reported a couple of grammar errors and unfortunate usages of socket/node/core.
Signed-off-by Matias Bjorling <[email protected]>---
Thanks, looks good.
Signature · 1 line
~Randy
PATCH 2/3 null_blk: set use_per_node_hctx param to false
In reply to Matias BjorlingFrom: Matias Bjørling <[email protected]>
The defaults for the module is to instantiate itself with blk-mq and a submit queue for each CPU node in the system.
To save resources, initialize instead with a single submit queue.
--- Documentation/block/null_blk.txt | 9 +++++---- drivers/block/null_blk.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-)
Documentation/block/null_blk.txt +5 -4
@@ -65,7 +65,8 @@ hw_queue_depth=[0..qdepth]: Default: 64 III: Multi-queue specific parameters -use_per_node_hctx=[0/1]: Default: 1 - If 1, the multi-queue block layer is instantiated with a hardware dispatch - queue for each CPU node in the system. If 0, it is instantiated with the - number of queues defined in the submit_queues parameter. +use_per_node_hctx=[0/1]: Default: 0 + 0: The number of submit queues are set to the value of the submit_queues + parameter. + 1: The multi-queue block layer is instantiated with a hardware dispatch + queue for each CPU node in the system.
drivers/block/null_blk.c +2 -2
@@ -101,9 +101,9 @@ static int hw_queue_depth = 64;module_param (hw_queue_depth, int,S_IRUGO );MODULE_PARM_DESC (hw_queue_depth,"Queue depth for each hardware queue. Default: 64" ); -static bool use_per_node_hctx = true; +static bool use_per_node_hctx = false;module_param (use_per_node_hctx, bool,S_IRUGO ); -MODULE_PARM_DESC (use_per_node_hctx,"Use per-node allocation for hardware context queues. Default: true" ); +MODULE_PARM_DESC (use_per_node_hctx,"Use per-node allocation for hardware context queues. Default: false" );static void put_tag (struct nullb_queue *nq,unsigned int tag) {
Signature · 1 line
1.8.3.2
PATCH 3/3 null_blk: support submit_queues on use_per_node_hctx
In reply to Matias BjorlingFrom: Matias Bjørling <[email protected]>
In the case of both the submit_queues param and use_per_node_hctx param are used. We limit the number af submit_queues to the number of online nodes.
If the submit_queues is a multiple of nr_online_nodes, its trivial. Simply map them to the nodes. For example: 8 submit queues are mapped as node0[0,1], node1[2,3], ...
If uneven, we are left with an uneven number of submit_queues that must be mapped. These are mapped toward the first node and onward. E.g. 5 submit queues mapped onto 4 nodes are mapped as node0[0,1], node1[2], ...
--- drivers/block/null_blk.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
drivers/block/null_blk.c +35 -4
@@ -1,4 +1,5 @@#include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/sched.h> #include <linux/fs.h>
@@ -346,8 +347,37 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)static struct blk_mq_hw_ctx *null_alloc_hctx (struct blk_mq_reg *reg,unsigned int hctx_index) { -return kzalloc_node (sizeof (struct blk_mq_hw_ctx ),GFP_KERNEL , - hctx_index); +int b_size =DIV_ROUND_UP (reg->nr_hw_queues, nr_online_nodes); +int tip = (reg->nr_hw_queues % nr_online_nodes); +int node =0 , i, n; + +/* +* Split submit queues evenly wrt to the number of nodes. If uneven, +* fill the first buckets with one extra, until the rest is filled with +* no extra. +*/ +for (i =0 , n =1 ; i < hctx_index; i++, n++) { +if (n % b_size ==0 ) { + n =0 ; + node++; + + tip--; +if (!tip) + b_size = reg->nr_hw_queues / nr_online_nodes; + } + } + +/* +* A node might not be online, therefore map the relative node id to the +* real node id. +*/ +for_each_online_node (n) { +if (!node) +break ; + node--; + } + +return kzalloc_node (sizeof (struct blk_mq_hw_ctx ),GFP_KERNEL , n); }static void null_free_hctx (struct blk_mq_hw_ctx *hctx,unsigned int hctx_index)
@@ -591,10 +621,11 @@ static int __init null_init(void)#endif if (queue_mode ==NULL_Q_MQ && use_per_node_hctx) { -if (submit_queues >0 ) +if (submit_queues < nr_online_nodes) {pr_warn ("null_blk: submit_queues param is set to %u." , nr_online_nodes); - submit_queues = nr_online_nodes; + submit_queues = nr_online_nodes; + } }else if (submit_queues > nr_cpu_ids) submit_queues = nr_cpu_ids;else if (!submit_queues)
Signature · 1 line
1.8.3.2
Quoted 4 lines · Matias Bjorling
Hi,
These three patches cover:
Quoted 10 lines
* Incorporated the feedback from Randy Dunlap into documentation. Can be merged with the previous documentation commit (6824518).
* Setuse_per_node_hctxto false per default to save resources.
* Allowsubmit_queuesanduse_per_node_hctxto be used simultanesly. If thesubmit_queuesis a multiple ofnr_online_nodes, its trivial. Simply map them to the nodes. For example: 8 submit queues are mapped as node0[0,1], node1[2,3], ...
If uneven, we are left with an uneven number ofsubmit_queuesthat must be mapped. These are mapped toward the first node and onward. E.g. 5 submit queues mapped onto 4 nodes are mapped as node0[0,1], node1[2], ...
Thanks, applied.
Signature · 1 line
Jens Axboe