Message ID | 20210118004921.202545-3-ming.lei@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | blk-mq/scsi: tracking device queue depth via sbitmap | expand |
Hi Ming, Thank you for the patch! Yet something to improve: [auto build test ERROR on mkp-scsi/for-next] [also build test ERROR on scsi/for-next block/for-next v5.11-rc4 next-20210115] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Ming-Lei/blk-mq-scsi-tracking-device-queue-depth-via-sbitmap/20210118-085444 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/16943bc0fa2683fd8d8554745fffe62394a42ec9 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Ming-Lei/blk-mq-scsi-tracking-device-queue-depth-via-sbitmap/20210118-085444 git checkout 16943bc0fa2683fd8d8554745fffe62394a42ec9 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/vhost/scsi.c: In function 'vhost_scsi_get_cmd': >> drivers/vhost/scsi.c:617:8: error: too many arguments to function 'sbitmap_get' 617 | tag = sbitmap_get(&svq->scsi_tags, 0, false); | ^~~~~~~~~~~ In file included from include/target/target_core_base.h:7, from drivers/vhost/scsi.c:43: include/linux/sbitmap.h:185:5: note: declared here 185 | int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint); | ^~~~~~~~~~~ drivers/vhost/scsi.c: In function 'vhost_scsi_setup_vq_cmds': >> drivers/vhost/scsi.c:1514:6: error: too few arguments to function 'sbitmap_init_node' 1514 | if (sbitmap_init_node(&svq->scsi_tags, max_cmds, -1, GFP_KERNEL, | ^~~~~~~~~~~~~~~~~ In file included from include/target/target_core_base.h:7, from drivers/vhost/scsi.c:43: include/linux/sbitmap.h:153:5: note: declared here 153 | int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, | ^~~~~~~~~~~~~~~~~ Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA Selected by - SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC - SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && ATMEL_SSC vim +/sbitmap_get +617 drivers/vhost/scsi.c 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 597 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 598 static struct vhost_scsi_cmd * 25b98b64e28423b0 drivers/vhost/scsi.c Mike Christie 2020-11-09 599 vhost_scsi_get_cmd(struct vhost_virtqueue *vq, struct vhost_scsi_tpg *tpg, 95e7c4341b8e28da drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 600 unsigned char *cdb, u64 scsi_tag, u16 lun, u8 task_attr, 95e7c4341b8e28da drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 601 u32 exp_data_len, int data_direction) 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 602 { 25b98b64e28423b0 drivers/vhost/scsi.c Mike Christie 2020-11-09 603 struct vhost_scsi_virtqueue *svq = container_of(vq, 25b98b64e28423b0 drivers/vhost/scsi.c Mike Christie 2020-11-09 604 struct vhost_scsi_virtqueue, vq); 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 605 struct vhost_scsi_cmd *cmd; 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 606 struct vhost_scsi_nexus *tv_nexus; b1935f687bb93b20 drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 607 struct scatterlist *sg, *prot_sg; 3aee26b4ae91048c drivers/vhost/scsi.c Nicholas Bellinger 2013-06-21 608 struct page **pages; 25b98b64e28423b0 drivers/vhost/scsi.c Mike Christie 2020-11-09 609 int tag; 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 610 9871831283e79575 drivers/vhost/scsi.c Asias He 2013-05-06 611 tv_nexus = tpg->tpg_nexus; 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 612 if (!tv_nexus) { 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 613 pr_err("Unable to locate active struct vhost_scsi_nexus\n"); 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 614 return ERR_PTR(-EIO); 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 615 } 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 616 25b98b64e28423b0 drivers/vhost/scsi.c Mike Christie 2020-11-09 @617 tag = sbitmap_get(&svq->scsi_tags, 0, false); 4a47d3a1ff10e564 drivers/vhost/scsi.c Nicholas Bellinger 2013-09-23 618 if (tag < 0) { 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 619 pr_err("Unable to obtain tag for vhost_scsi_cmd\n"); 4a47d3a1ff10e564 drivers/vhost/scsi.c Nicholas Bellinger 2013-09-23 620 return ERR_PTR(-ENOMEM); 4a47d3a1ff10e564 drivers/vhost/scsi.c Nicholas Bellinger 2013-09-23 621 } 4a47d3a1ff10e564 drivers/vhost/scsi.c Nicholas Bellinger 2013-09-23 622 25b98b64e28423b0 drivers/vhost/scsi.c Mike Christie 2020-11-09 623 cmd = &svq->scsi_cmds[tag]; 3aee26b4ae91048c drivers/vhost/scsi.c Nicholas Bellinger 2013-06-21 624 sg = cmd->tvc_sgl; b1935f687bb93b20 drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 625 prot_sg = cmd->tvc_prot_sgl; 3aee26b4ae91048c drivers/vhost/scsi.c Nicholas Bellinger 2013-06-21 626 pages = cmd->tvc_upages; 473f0b15a4c97d39 drivers/vhost/scsi.c Markus Elfring 2017-05-20 627 memset(cmd, 0, sizeof(*cmd)); 3aee26b4ae91048c drivers/vhost/scsi.c Nicholas Bellinger 2013-06-21 628 cmd->tvc_sgl = sg; b1935f687bb93b20 drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 629 cmd->tvc_prot_sgl = prot_sg; 3aee26b4ae91048c drivers/vhost/scsi.c Nicholas Bellinger 2013-06-21 630 cmd->tvc_upages = pages; 4824d3bfb9097ac5 drivers/vhost/scsi.c Nicholas Bellinger 2013-06-07 631 cmd->tvc_se_cmd.map_tag = tag; 95e7c4341b8e28da drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 632 cmd->tvc_tag = scsi_tag; 95e7c4341b8e28da drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 633 cmd->tvc_lun = lun; 95e7c4341b8e28da drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 634 cmd->tvc_task_attr = task_attr; 3c63f66a0dcdd6cb drivers/vhost/scsi.c Asias He 2013-05-06 635 cmd->tvc_exp_data_len = exp_data_len; 3c63f66a0dcdd6cb drivers/vhost/scsi.c Asias He 2013-05-06 636 cmd->tvc_data_direction = data_direction; 3c63f66a0dcdd6cb drivers/vhost/scsi.c Asias He 2013-05-06 637 cmd->tvc_nexus = tv_nexus; 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 638 cmd->inflight = vhost_scsi_get_inflight(vq); 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 639 1a1ff8256af679c8 drivers/vhost/scsi.c Nicholas Bellinger 2015-01-31 640 memcpy(cmd->tvc_cdb, cdb, VHOST_SCSI_MAX_CDB_SIZE); 95e7c4341b8e28da drivers/vhost/scsi.c Nicholas Bellinger 2014-02-22 641 3c63f66a0dcdd6cb drivers/vhost/scsi.c Asias He 2013-05-06 642 return cmd; 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 643 } 057cbf49a1f08297 drivers/vhost/tcm_vhost.c Nicholas Bellinger 2012-07-18 644 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Ming,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on scsi/for-next block/for-next v5.11-rc4 next-20210115]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Ming-Lei/blk-mq-scsi-tracking-device-queue-depth-via-sbitmap/20210118-085444
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: powerpc-randconfig-r001-20210118 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 95d146182fdf2315e74943b93fb3bb0cbafc5d89)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/16943bc0fa2683fd8d8554745fffe62394a42ec9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Ming-Lei/blk-mq-scsi-tracking-device-queue-depth-via-sbitmap/20210118-085444
git checkout 16943bc0fa2683fd8d8554745fffe62394a42ec9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/vhost/scsi.c:617:40: error: too many arguments to function call, expected 2, have 3
tag = sbitmap_get(&svq->scsi_tags, 0, false);
~~~~~~~~~~~ ^~~~~
include/linux/sbitmap.h:185:5: note: 'sbitmap_get' declared here
int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint);
^
>> drivers/vhost/scsi.c:1515:22: error: too few arguments to function call, expected 6, have 5
NUMA_NO_NODE))
^
include/linux/sbitmap.h:153:5: note: 'sbitmap_init_node' declared here
int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
^
2 errors generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for HOTPLUG_CPU
Depends on SMP && (PPC_PSERIES || PPC_PMAC || PPC_POWERNV || FSL_SOC_BOOKE
Selected by
- PM_SLEEP_SMP && SMP && (ARCH_SUSPEND_POSSIBLE || ARCH_HIBERNATION_POSSIBLE && PM_SLEEP
vim +1515 drivers/vhost/scsi.c
25b98b64e28423b0 Mike Christie 2020-11-09 1503
25b98b64e28423b0 Mike Christie 2020-11-09 1504 static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds)
25b98b64e28423b0 Mike Christie 2020-11-09 1505 {
25b98b64e28423b0 Mike Christie 2020-11-09 1506 struct vhost_scsi_virtqueue *svq = container_of(vq,
25b98b64e28423b0 Mike Christie 2020-11-09 1507 struct vhost_scsi_virtqueue, vq);
25b98b64e28423b0 Mike Christie 2020-11-09 1508 struct vhost_scsi_cmd *tv_cmd;
25b98b64e28423b0 Mike Christie 2020-11-09 1509 unsigned int i;
25b98b64e28423b0 Mike Christie 2020-11-09 1510
25b98b64e28423b0 Mike Christie 2020-11-09 1511 if (svq->scsi_cmds)
25b98b64e28423b0 Mike Christie 2020-11-09 1512 return 0;
25b98b64e28423b0 Mike Christie 2020-11-09 1513
25b98b64e28423b0 Mike Christie 2020-11-09 1514 if (sbitmap_init_node(&svq->scsi_tags, max_cmds, -1, GFP_KERNEL,
25b98b64e28423b0 Mike Christie 2020-11-09 @1515 NUMA_NO_NODE))
25b98b64e28423b0 Mike Christie 2020-11-09 1516 return -ENOMEM;
25b98b64e28423b0 Mike Christie 2020-11-09 1517 svq->max_cmds = max_cmds;
25b98b64e28423b0 Mike Christie 2020-11-09 1518
25b98b64e28423b0 Mike Christie 2020-11-09 1519 svq->scsi_cmds = kcalloc(max_cmds, sizeof(*tv_cmd), GFP_KERNEL);
25b98b64e28423b0 Mike Christie 2020-11-09 1520 if (!svq->scsi_cmds) {
25b98b64e28423b0 Mike Christie 2020-11-09 1521 sbitmap_free(&svq->scsi_tags);
25b98b64e28423b0 Mike Christie 2020-11-09 1522 return -ENOMEM;
25b98b64e28423b0 Mike Christie 2020-11-09 1523 }
25b98b64e28423b0 Mike Christie 2020-11-09 1524
25b98b64e28423b0 Mike Christie 2020-11-09 1525 for (i = 0; i < max_cmds; i++) {
25b98b64e28423b0 Mike Christie 2020-11-09 1526 tv_cmd = &svq->scsi_cmds[i];
25b98b64e28423b0 Mike Christie 2020-11-09 1527
25b98b64e28423b0 Mike Christie 2020-11-09 1528 tv_cmd->tvc_sgl = kcalloc(VHOST_SCSI_PREALLOC_SGLS,
25b98b64e28423b0 Mike Christie 2020-11-09 1529 sizeof(struct scatterlist),
25b98b64e28423b0 Mike Christie 2020-11-09 1530 GFP_KERNEL);
25b98b64e28423b0 Mike Christie 2020-11-09 1531 if (!tv_cmd->tvc_sgl) {
25b98b64e28423b0 Mike Christie 2020-11-09 1532 pr_err("Unable to allocate tv_cmd->tvc_sgl\n");
25b98b64e28423b0 Mike Christie 2020-11-09 1533 goto out;
25b98b64e28423b0 Mike Christie 2020-11-09 1534 }
25b98b64e28423b0 Mike Christie 2020-11-09 1535
25b98b64e28423b0 Mike Christie 2020-11-09 1536 tv_cmd->tvc_upages = kcalloc(VHOST_SCSI_PREALLOC_UPAGES,
25b98b64e28423b0 Mike Christie 2020-11-09 1537 sizeof(struct page *),
25b98b64e28423b0 Mike Christie 2020-11-09 1538 GFP_KERNEL);
25b98b64e28423b0 Mike Christie 2020-11-09 1539 if (!tv_cmd->tvc_upages) {
25b98b64e28423b0 Mike Christie 2020-11-09 1540 pr_err("Unable to allocate tv_cmd->tvc_upages\n");
25b98b64e28423b0 Mike Christie 2020-11-09 1541 goto out;
25b98b64e28423b0 Mike Christie 2020-11-09 1542 }
25b98b64e28423b0 Mike Christie 2020-11-09 1543
25b98b64e28423b0 Mike Christie 2020-11-09 1544 tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
25b98b64e28423b0 Mike Christie 2020-11-09 1545 sizeof(struct scatterlist),
25b98b64e28423b0 Mike Christie 2020-11-09 1546 GFP_KERNEL);
25b98b64e28423b0 Mike Christie 2020-11-09 1547 if (!tv_cmd->tvc_prot_sgl) {
25b98b64e28423b0 Mike Christie 2020-11-09 1548 pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
25b98b64e28423b0 Mike Christie 2020-11-09 1549 goto out;
25b98b64e28423b0 Mike Christie 2020-11-09 1550 }
25b98b64e28423b0 Mike Christie 2020-11-09 1551 }
25b98b64e28423b0 Mike Christie 2020-11-09 1552 return 0;
25b98b64e28423b0 Mike Christie 2020-11-09 1553 out:
25b98b64e28423b0 Mike Christie 2020-11-09 1554 vhost_scsi_destroy_vq_cmds(vq);
25b98b64e28423b0 Mike Christie 2020-11-09 1555 return -ENOMEM;
25b98b64e28423b0 Mike Christie 2020-11-09 1556 }
25b98b64e28423b0 Mike Christie 2020-11-09 1557
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Mon, Jan 18, 2021 at 12:42:07PM +0800, kernel test robot wrote: > Hi Ming, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on mkp-scsi/for-next] > [also build test ERROR on scsi/for-next block/for-next v5.11-rc4 next-20210115] > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch] > > url: https://github.com/0day-ci/linux/commits/Ming-Lei/blk-mq-scsi-tracking-device-queue-depth-via-sbitmap/20210118-085444 > base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next > config: powerpc-randconfig-r001-20210118 (attached as .config) > compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 95d146182fdf2315e74943b93fb3bb0cbafc5d89) > reproduce (this is a W=1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # install powerpc cross compiling tool for clang build > # apt-get install binutils-powerpc-linux-gnu > # https://github.com/0day-ci/linux/commit/16943bc0fa2683fd8d8554745fffe62394a42ec9 > git remote add linux-review https://github.com/0day-ci/linux > git fetch --no-tags linux-review Ming-Lei/blk-mq-scsi-tracking-device-queue-depth-via-sbitmap/20210118-085444 > git checkout 16943bc0fa2683fd8d8554745fffe62394a42ec9 > # save the attached .config to linux build tree > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > > All errors (new ones prefixed by >>): > > drivers/vhost/scsi.c:617:40: error: too many arguments to function call, expected 2, have 3 > tag = sbitmap_get(&svq->scsi_tags, 0, false); > ~~~~~~~~~~~ ^~~~~ > include/linux/sbitmap.h:185:5: note: 'sbitmap_get' declared here > int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint); > ^ > >> drivers/vhost/scsi.c:1515:22: error: too few arguments to function call, expected 6, have 5 > NUMA_NO_NODE)) > ^ > include/linux/sbitmap.h:153:5: note: 'sbitmap_init_node' declared here > int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, > ^ > 2 errors generated. > Thanks for the report, and this failure has been fixed in V7.
diff --git a/block/blk-mq.c b/block/blk-mq.c index f285a9123a8b..c5eead257568 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2676,7 +2676,7 @@ blk_mq_alloc_hctx(struct request_queue *q, struct blk_mq_tag_set *set, goto free_cpumask; if (sbitmap_init_node(&hctx->ctx_map, nr_cpu_ids, ilog2(8), - gfp, node)) + gfp, node, false)) goto free_ctxs; hctx->nr_ctx = 0; diff --git a/block/kyber-iosched.c b/block/kyber-iosched.c index dc89199bc8c6..cc8bcfe1d587 100644 --- a/block/kyber-iosched.c +++ b/block/kyber-iosched.c @@ -479,7 +479,8 @@ static int kyber_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) for (i = 0; i < KYBER_NUM_DOMAINS; i++) { if (sbitmap_init_node(&khd->kcq_map[i], hctx->nr_ctx, - ilog2(8), GFP_KERNEL, hctx->numa_node)) { + ilog2(8), GFP_KERNEL, hctx->numa_node, + false)) { while (--i >= 0) sbitmap_free(&khd->kcq_map[i]); goto err_kcqs; diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h index 16353fbee765..734ee6214cd6 100644 --- a/include/linux/sbitmap.h +++ b/include/linux/sbitmap.h @@ -56,6 +56,11 @@ struct sbitmap { */ unsigned int map_nr; + /** + * @round_robin: Allocate bits in strict round-robin order. + */ + bool round_robin; + /** * @map: Allocated bitmap. */ @@ -124,11 +129,6 @@ struct sbitmap_queue { */ atomic_t ws_active; - /** - * @round_robin: Allocate bits in strict round-robin order. - */ - bool round_robin; - /** * @min_shallow_depth: The minimum shallow depth which may be passed to * sbitmap_queue_get_shallow() or __sbitmap_queue_get_shallow(). @@ -144,11 +144,14 @@ struct sbitmap_queue { * given, a good default is chosen. * @flags: Allocation flags. * @node: Memory node to allocate on. + * @round_robin: If true, be stricter about allocation order; always allocate + * starting from the last allocated bit. This is less efficient + * than the default behavior (false). * * Return: Zero on success or negative errno on failure. */ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, - gfp_t flags, int node); + gfp_t flags, int node, bool round_robin); /** * sbitmap_free() - Free memory used by a &struct sbitmap. @@ -174,15 +177,12 @@ void sbitmap_resize(struct sbitmap *sb, unsigned int depth); * sbitmap_get() - Try to allocate a free bit from a &struct sbitmap. * @sb: Bitmap to allocate from. * @alloc_hint: Hint for where to start searching for a free bit. - * @round_robin: If true, be stricter about allocation order; always allocate - * starting from the last allocated bit. This is less efficient - * than the default behavior (false). * * This operation provides acquire barrier semantics if it succeeds. * * Return: Non-negative allocated bit number if successful, -1 otherwise. */ -int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint, bool round_robin); +int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint); /** * sbitmap_get_shallow() - Try to allocate a free bit from a &struct sbitmap, diff --git a/lib/sbitmap.c b/lib/sbitmap.c index d693d9213ceb..7000636933b3 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -33,7 +33,7 @@ static inline bool sbitmap_deferred_clear(struct sbitmap_word *map) } int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, - gfp_t flags, int node) + gfp_t flags, int node, bool round_robin) { unsigned int bits_per_word; unsigned int i; @@ -58,6 +58,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, sb->shift = shift; sb->depth = depth; sb->map_nr = DIV_ROUND_UP(sb->depth, bits_per_word); + sb->round_robin = round_robin; if (depth == 0) { sb->map = NULL; @@ -129,14 +130,14 @@ static int __sbitmap_get_word(unsigned long *word, unsigned long depth, } static int sbitmap_find_bit_in_index(struct sbitmap *sb, int index, - unsigned int alloc_hint, bool round_robin) + unsigned int alloc_hint) { struct sbitmap_word *map = &sb->map[index]; int nr; do { nr = __sbitmap_get_word(&map->word, map->depth, alloc_hint, - !round_robin); + !sb->round_robin); if (nr != -1) break; if (!sbitmap_deferred_clear(map)) @@ -146,7 +147,7 @@ static int sbitmap_find_bit_in_index(struct sbitmap *sb, int index, return nr; } -int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint, bool round_robin) +int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint) { unsigned int i, index; int nr = -1; @@ -158,14 +159,13 @@ int sbitmap_get(struct sbitmap *sb, unsigned int alloc_hint, bool round_robin) * alloc_hint to find the right word index. No point in looping * twice in find_next_zero_bit() for that case. */ - if (round_robin) + if (sb->round_robin) alloc_hint = SB_NR_TO_BIT(sb, alloc_hint); else alloc_hint = 0; for (i = 0; i < sb->map_nr; i++) { - nr = sbitmap_find_bit_in_index(sb, index, alloc_hint, - round_robin); + nr = sbitmap_find_bit_in_index(sb, index, alloc_hint); if (nr != -1) { nr += index << sb->shift; break; @@ -350,7 +350,8 @@ int sbitmap_queue_init_node(struct sbitmap_queue *sbq, unsigned int depth, int ret; int i; - ret = sbitmap_init_node(&sbq->sb, depth, shift, flags, node); + ret = sbitmap_init_node(&sbq->sb, depth, shift, flags, node, + round_robin); if (ret) return ret; @@ -382,7 +383,6 @@ int sbitmap_queue_init_node(struct sbitmap_queue *sbq, unsigned int depth, atomic_set(&sbq->ws[i].wait_cnt, sbq->wake_batch); } - sbq->round_robin = round_robin; return 0; } EXPORT_SYMBOL_GPL(sbitmap_queue_init_node); @@ -424,12 +424,12 @@ int __sbitmap_queue_get(struct sbitmap_queue *sbq) hint = depth ? prandom_u32() % depth : 0; this_cpu_write(*sbq->alloc_hint, hint); } - nr = sbitmap_get(&sbq->sb, hint, sbq->round_robin); + nr = sbitmap_get(&sbq->sb, hint); if (nr == -1) { /* If the map is full, a hint won't do us much good. */ this_cpu_write(*sbq->alloc_hint, 0); - } else if (nr == hint || unlikely(sbq->round_robin)) { + } else if (nr == hint || unlikely(sbq->sb.round_robin)) { /* Only update the hint if we used it. */ hint = nr + 1; if (hint >= depth - 1) @@ -460,7 +460,7 @@ int __sbitmap_queue_get_shallow(struct sbitmap_queue *sbq, if (nr == -1) { /* If the map is full, a hint won't do us much good. */ this_cpu_write(*sbq->alloc_hint, 0); - } else if (nr == hint || unlikely(sbq->round_robin)) { + } else if (nr == hint || unlikely(sbq->sb.round_robin)) { /* Only update the hint if we used it. */ hint = nr + 1; if (hint >= depth - 1) @@ -576,7 +576,7 @@ void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr, smp_mb__after_atomic(); sbitmap_queue_wake_up(sbq); - if (likely(!sbq->round_robin && nr < sbq->sb.depth)) + if (likely(!sbq->sb.round_robin && nr < sbq->sb.depth)) *per_cpu_ptr(sbq->alloc_hint, cpu) = nr; } EXPORT_SYMBOL_GPL(sbitmap_queue_clear); @@ -633,7 +633,7 @@ void sbitmap_queue_show(struct sbitmap_queue *sbq, struct seq_file *m) } seq_puts(m, "}\n"); - seq_printf(m, "round_robin=%d\n", sbq->round_robin); + seq_printf(m, "round_robin=%d\n", sbq->sb.round_robin); seq_printf(m, "min_shallow_depth=%u\n", sbq->min_shallow_depth); } EXPORT_SYMBOL_GPL(sbitmap_queue_show);