Re: [PATCH] staging: greybus: Convert uart.c from IDR to XArray

From: kernel test robot
Date: Sat Aug 14 2021 - 13:38:00 EST


Hi "Fabio,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]

url: https://github.com/0day-ci/linux/commits/Fabio-M-De-Francesco/staging-greybus-Convert-uart-c-from-IDR-to-XArray/20210814-225807
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 0bd35146642bdc56f1b87d75f047b1c92bd2bd39
config: i386-randconfig-s002-20210814 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-348-gf0e6938b-dirty
# https://github.com/0day-ci/linux/commit/901c5fde0540c767590bce646219889730c4a41b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Fabio-M-De-Francesco/staging-greybus-Convert-uart-c-from-IDR-to-XArray/20210814-225807
git checkout 901c5fde0540c767590bce646219889730c4a41b
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/staging/greybus/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

In file included from include/linux/radix-tree.h:19,
from include/linux/idr.h:15,
from include/linux/kernfs.h:13,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:21,
from drivers/staging/greybus/uart.c:15:
drivers/staging/greybus/uart.c: In function 'get_gb_by_minor':
>> include/linux/xarray.h:530:39: error: 'struct mutex' has no member named 'xa_lock'; did you mean 'wait_lock'?
530 | #define xa_lock(xa) spin_lock(&(xa)->xa_lock)
| ^~~~~~~
drivers/staging/greybus/uart.c:346:2: note: in expansion of macro 'xa_lock'
346 | xa_lock(&table_lock);
| ^~~~~~~
include/linux/xarray.h:531:43: error: 'struct mutex' has no member named 'xa_lock'; did you mean 'wait_lock'?
531 | #define xa_unlock(xa) spin_unlock(&(xa)->xa_lock)
| ^~~~~~~
drivers/staging/greybus/uart.c:358:2: note: in expansion of macro 'xa_unlock'
358 | xa_unlock(&table_lock);
| ^~~~~~~~~


vim +530 include/linux/xarray.h

9b89a035514468 Matthew Wilcox 2017-11-10 420
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 421) /**
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 422) * xa_for_each_range() - Iterate over a portion of an XArray.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 423) * @xa: XArray.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 424) * @index: Index of @entry.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 425) * @entry: Entry retrieved from array.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 426) * @start: First index to retrieve from array.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 427) * @last: Last index to retrieve from array.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 428) *
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 429) * During the iteration, @entry will have the value of the entry stored
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 430) * in @xa at @index. You may modify @index during the iteration if you
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 431) * want to skip or reprocess indices. It is safe to modify the array
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 432) * during the iteration. At the end of the iteration, @entry will be set
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 433) * to NULL and @index will have a value less than or equal to max.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 434) *
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 435) * xa_for_each_range() is O(n.log(n)) while xas_for_each() is O(n). You have
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 436) * to handle your own locking with xas_for_each(), and if you have to unlock
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 437) * after each iteration, it will also end up being O(n.log(n)).
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 438) * xa_for_each_range() will spin if it hits a retry entry; if you intend to
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 439) * see retry entries, you should use the xas_for_each() iterator instead.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 440) * The xas_for_each() iterator will expand into more inline code than
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 441) * xa_for_each_range().
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 442) *
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 443) * Context: Any context. Takes and releases the RCU lock.
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 444) */
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 445) #define xa_for_each_range(xa, index, entry, start, last) \
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 446) for (index = start, \
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 447) entry = xa_find(xa, &index, last, XA_PRESENT); \
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 448) entry; \
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 449) entry = xa_find_after(xa, &index, last, XA_PRESENT))
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 450)
b803b42823d0d9 Matthew Wilcox 2017-11-14 451 /**
4a31896c5b5a27 Matthew Wilcox 2018-12-17 452 * xa_for_each_start() - Iterate over a portion of an XArray.
b803b42823d0d9 Matthew Wilcox 2017-11-14 453 * @xa: XArray.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 454 * @index: Index of @entry.
b803b42823d0d9 Matthew Wilcox 2017-11-14 455 * @entry: Entry retrieved from array.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 456 * @start: First index to retrieve from array.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 457 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 458 * During the iteration, @entry will have the value of the entry stored
4a31896c5b5a27 Matthew Wilcox 2018-12-17 459 * in @xa at @index. You may modify @index during the iteration if you
4a31896c5b5a27 Matthew Wilcox 2018-12-17 460 * want to skip or reprocess indices. It is safe to modify the array
4a31896c5b5a27 Matthew Wilcox 2018-12-17 461 * during the iteration. At the end of the iteration, @entry will be set
4a31896c5b5a27 Matthew Wilcox 2018-12-17 462 * to NULL and @index will have a value less than or equal to max.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 463 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 464 * xa_for_each_start() is O(n.log(n)) while xas_for_each() is O(n). You have
4a31896c5b5a27 Matthew Wilcox 2018-12-17 465 * to handle your own locking with xas_for_each(), and if you have to unlock
4a31896c5b5a27 Matthew Wilcox 2018-12-17 466 * after each iteration, it will also end up being O(n.log(n)).
4a31896c5b5a27 Matthew Wilcox 2018-12-17 467 * xa_for_each_start() will spin if it hits a retry entry; if you intend to
4a31896c5b5a27 Matthew Wilcox 2018-12-17 468 * see retry entries, you should use the xas_for_each() iterator instead.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 469 * The xas_for_each() iterator will expand into more inline code than
4a31896c5b5a27 Matthew Wilcox 2018-12-17 470 * xa_for_each_start().
4a31896c5b5a27 Matthew Wilcox 2018-12-17 471 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 472 * Context: Any context. Takes and releases the RCU lock.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 473 */
4a31896c5b5a27 Matthew Wilcox 2018-12-17 474 #define xa_for_each_start(xa, index, entry, start) \
00ed452c210a0b Matthew Wilcox (Oracle 2020-01-12 475) xa_for_each_range(xa, index, entry, start, ULONG_MAX)
4a31896c5b5a27 Matthew Wilcox 2018-12-17 476
4a31896c5b5a27 Matthew Wilcox 2018-12-17 477 /**
4a31896c5b5a27 Matthew Wilcox 2018-12-17 478 * xa_for_each() - Iterate over present entries in an XArray.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 479 * @xa: XArray.
b803b42823d0d9 Matthew Wilcox 2017-11-14 480 * @index: Index of @entry.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 481 * @entry: Entry retrieved from array.
b803b42823d0d9 Matthew Wilcox 2017-11-14 482 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 483 * During the iteration, @entry will have the value of the entry stored
4a31896c5b5a27 Matthew Wilcox 2018-12-17 484 * in @xa at @index. You may modify @index during the iteration if you want
4a31896c5b5a27 Matthew Wilcox 2018-12-17 485 * to skip or reprocess indices. It is safe to modify the array during the
4a31896c5b5a27 Matthew Wilcox 2018-12-17 486 * iteration. At the end of the iteration, @entry will be set to NULL and
4a31896c5b5a27 Matthew Wilcox 2018-12-17 487 * @index will have a value less than or equal to max.
b803b42823d0d9 Matthew Wilcox 2017-11-14 488 *
b803b42823d0d9 Matthew Wilcox 2017-11-14 489 * xa_for_each() is O(n.log(n)) while xas_for_each() is O(n). You have
b803b42823d0d9 Matthew Wilcox 2017-11-14 490 * to handle your own locking with xas_for_each(), and if you have to unlock
b803b42823d0d9 Matthew Wilcox 2017-11-14 491 * after each iteration, it will also end up being O(n.log(n)). xa_for_each()
b803b42823d0d9 Matthew Wilcox 2017-11-14 492 * will spin if it hits a retry entry; if you intend to see retry entries,
b803b42823d0d9 Matthew Wilcox 2017-11-14 493 * you should use the xas_for_each() iterator instead. The xas_for_each()
b803b42823d0d9 Matthew Wilcox 2017-11-14 494 * iterator will expand into more inline code than xa_for_each().
b803b42823d0d9 Matthew Wilcox 2017-11-14 495 *
b803b42823d0d9 Matthew Wilcox 2017-11-14 496 * Context: Any context. Takes and releases the RCU lock.
b803b42823d0d9 Matthew Wilcox 2017-11-14 497 */
4a31896c5b5a27 Matthew Wilcox 2018-12-17 498 #define xa_for_each(xa, index, entry) \
4a31896c5b5a27 Matthew Wilcox 2018-12-17 499 xa_for_each_start(xa, index, entry, 0)
4a31896c5b5a27 Matthew Wilcox 2018-12-17 500
4a31896c5b5a27 Matthew Wilcox 2018-12-17 501 /**
4a31896c5b5a27 Matthew Wilcox 2018-12-17 502 * xa_for_each_marked() - Iterate over marked entries in an XArray.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 503 * @xa: XArray.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 504 * @index: Index of @entry.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 505 * @entry: Entry retrieved from array.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 506 * @filter: Selection criterion.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 507 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 508 * During the iteration, @entry will have the value of the entry stored
4a31896c5b5a27 Matthew Wilcox 2018-12-17 509 * in @xa at @index. The iteration will skip all entries in the array
4a31896c5b5a27 Matthew Wilcox 2018-12-17 510 * which do not match @filter. You may modify @index during the iteration
4a31896c5b5a27 Matthew Wilcox 2018-12-17 511 * if you want to skip or reprocess indices. It is safe to modify the array
4a31896c5b5a27 Matthew Wilcox 2018-12-17 512 * during the iteration. At the end of the iteration, @entry will be set to
4a31896c5b5a27 Matthew Wilcox 2018-12-17 513 * NULL and @index will have a value less than or equal to max.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 514 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 515 * xa_for_each_marked() is O(n.log(n)) while xas_for_each_marked() is O(n).
4a31896c5b5a27 Matthew Wilcox 2018-12-17 516 * You have to handle your own locking with xas_for_each(), and if you have
4a31896c5b5a27 Matthew Wilcox 2018-12-17 517 * to unlock after each iteration, it will also end up being O(n.log(n)).
4a31896c5b5a27 Matthew Wilcox 2018-12-17 518 * xa_for_each_marked() will spin if it hits a retry entry; if you intend to
4a31896c5b5a27 Matthew Wilcox 2018-12-17 519 * see retry entries, you should use the xas_for_each_marked() iterator
4a31896c5b5a27 Matthew Wilcox 2018-12-17 520 * instead. The xas_for_each_marked() iterator will expand into more inline
4a31896c5b5a27 Matthew Wilcox 2018-12-17 521 * code than xa_for_each_marked().
4a31896c5b5a27 Matthew Wilcox 2018-12-17 522 *
4a31896c5b5a27 Matthew Wilcox 2018-12-17 523 * Context: Any context. Takes and releases the RCU lock.
4a31896c5b5a27 Matthew Wilcox 2018-12-17 524 */
4a31896c5b5a27 Matthew Wilcox 2018-12-17 525 #define xa_for_each_marked(xa, index, entry, filter) \
4a31896c5b5a27 Matthew Wilcox 2018-12-17 526 for (index = 0, entry = xa_find(xa, &index, ULONG_MAX, filter); \
4a31896c5b5a27 Matthew Wilcox 2018-12-17 527 entry; entry = xa_find_after(xa, &index, ULONG_MAX, filter))
b803b42823d0d9 Matthew Wilcox 2017-11-14 528
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 529 #define xa_trylock(xa) spin_trylock(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 @530 #define xa_lock(xa) spin_lock(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 531 #define xa_unlock(xa) spin_unlock(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 532 #define xa_lock_bh(xa) spin_lock_bh(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 533 #define xa_unlock_bh(xa) spin_unlock_bh(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 534 #define xa_lock_irq(xa) spin_lock_irq(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 535 #define xa_unlock_irq(xa) spin_unlock_irq(&(xa)->xa_lock)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 536 #define xa_lock_irqsave(xa, flags) \
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 537 spin_lock_irqsave(&(xa)->xa_lock, flags)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 538 #define xa_unlock_irqrestore(xa, flags) \
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 539 spin_unlock_irqrestore(&(xa)->xa_lock, flags)
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 540) #define xa_lock_nested(xa, subclass) \
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 541) spin_lock_nested(&(xa)->xa_lock, subclass)
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 542) #define xa_lock_bh_nested(xa, subclass) \
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 543) spin_lock_bh_nested(&(xa)->xa_lock, subclass)
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 544) #define xa_lock_irq_nested(xa, subclass) \
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 545) spin_lock_irq_nested(&(xa)->xa_lock, subclass)
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 546) #define xa_lock_irqsave_nested(xa, flags, subclass) \
82a958497dc912 Matthew Wilcox (Oracle 2020-01-17 547) spin_lock_irqsave_nested(&(xa)->xa_lock, flags, subclass)
f6bb2a2c0b81c4 Matthew Wilcox 2018-04-10 548

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip