All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] ALSA: control: Use xarray for faster lookups
@ 2021-10-28 13:00 Takashi Iwai
  2021-10-28 22:34 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Takashi Iwai @ 2021-10-28 13:00 UTC (permalink / raw)
  To: alsa-devel

The control elements are managed in a single linked list and we
traverse the whole list for matching each numid or ctl id per every
inquiry of a control element.  This is OK-ish for a small number of
elements but obviously it doesn't scale.  Especially the matching with
the ctl id takes time because it checks each field of the snd_ctl_id
element, e.g. the name string is matched with strcmp().

This patch adds the hash tables with Xarray in addition to the linked
list for improving the lookup speed of a control element.  There are
two xarray tables added to the card; one for numid and another for ctl
id.  For the numid, we use the numid as the index, while for the ctl
id, we calculate a hash key.

The lookup is done via a single xa_load().  When nothing hits, we look
through the full list entries as a fallback.  So, the inquiry for a
non-existing element would take (even slightly longer) time with this
patch.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---

This is not really meant to be merged now, but just shown as a
reference implementation, as the issue doesn't surface unless you have
a large number of elements and query the late element frequently.  In
my test, 1,000,000 queries of the 1000th element took over 12 seconds,
while the patched kernel took 0.2 second.  But for the most cases (at
most 20 or 30 elements), it doesn't matter much.


 include/sound/core.h |   3 +
 sound/core/control.c | 142 +++++++++++++++++++++++++++++++++----------
 sound/core/init.c    |   2 +
 3 files changed, 115 insertions(+), 32 deletions(-)

diff --git a/include/sound/core.h b/include/sound/core.h
index b7e9b58d3c78..e8bb6d943f3f 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -14,6 +14,7 @@
 #include <linux/pm.h>			/* pm_message_t */
 #include <linux/stringify.h>
 #include <linux/printk.h>
+#include <linux/xarray.h>
 
 /* number of supported soundcards */
 #ifdef CONFIG_SND_DYNAMIC_MINORS
@@ -103,6 +104,8 @@ struct snd_card {
 	size_t user_ctl_alloc_size;	// current memory allocation by user controls.
 	struct list_head controls;	/* all controls for this card */
 	struct list_head ctl_files;	/* active control files */
+	struct xarray ctl_numids;	/* hash table for numids */
+	struct xarray ctl_hash;		/* hash table for ctl id matching */
 
 	struct snd_info_entry *proc_root;	/* root for soundcard specific files */
 	struct proc_dir_entry *proc_root_link;	/* number link to real id */
diff --git a/sound/core/control.c b/sound/core/control.c
index a25c0d64d104..d0253cc4b22d 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -364,6 +364,78 @@ static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
 	return 0;
 }
 
+/* Compute a hash key for the corresponding ctl id
+ * It's for the name lookup, hence the numid is excluded.
+ * The hash key is bound in LONG_MAX to be used for Xarray key.
+ */
+#define MULTIPLIER	37
+static unsigned long get_ctl_id_hash(const struct snd_ctl_elem_id *id)
+{
+	unsigned long h;
+	const unsigned char *p;
+
+	h = id->iface;
+	h = MULTIPLIER * h + id->device;
+	h = MULTIPLIER * h + id->subdevice;
+	for (p = id->name; *p; p++)
+		h = MULTIPLIER * h + *p;
+	h = MULTIPLIER * h + id->index;
+	h &= LONG_MAX;
+	return h;
+}
+
+/* check whether the given id is contained in the given kctl */
+static bool elem_id_matches(const struct snd_kcontrol *kctl,
+			    const struct snd_ctl_elem_id *id)
+{
+	return kctl->id.iface == id->iface &&
+		kctl->id.device == id->device &&
+		kctl->id.subdevice == id->subdevice &&
+		!strncmp(kctl->id.name, id->name, sizeof(kctl->id.name)) &&
+		kctl->id.index <= id->index &&
+		kctl->id.index + kctl->count > id->index;
+}
+
+/* add hash entries to numid and ctl xarray tables */
+static void add_hash_entries(struct snd_card *card,
+			     struct snd_kcontrol *kcontrol)
+{
+	struct snd_ctl_elem_id id = kcontrol->id;
+	int i, err;
+
+	xa_store_range(&card->ctl_numids, kcontrol->id.numid,
+		       kcontrol->id.numid + kcontrol->count - 1,
+		       kcontrol, GFP_KERNEL);
+
+	for (i = 0; i < kcontrol->count; i++) {
+		id.index = kcontrol->id.index + i;
+		err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
+				kcontrol, GFP_KERNEL);
+		/* ignore errors - it's a best effort */
+	}
+}
+
+/* remove hash entries that have been added */
+static void remove_hash_entries(struct snd_card *card,
+				struct snd_kcontrol *kcontrol)
+{
+	struct snd_ctl_elem_id id = kcontrol->id;
+	struct snd_kcontrol *matched;
+	unsigned long h;
+	int i;
+
+	for (i = 0; i < kcontrol->count; i++) {
+		xa_erase(&card->ctl_numids, id.numid);
+		h = get_ctl_id_hash(&id);
+		matched = xa_load(&card->ctl_hash, h);
+		if (matched && (matched == kcontrol ||
+				elem_id_matches(matched, &id)))
+			xa_erase(&card->ctl_hash, h);
+		id.index++;
+		id.numid++;
+	}
+}
+
 enum snd_ctl_add_mode {
 	CTL_ADD_EXCLUSIVE, CTL_REPLACE, CTL_ADD_ON_REPLACE,
 };
@@ -408,6 +480,8 @@ static int __snd_ctl_add_replace(struct snd_card *card,
 	kcontrol->id.numid = card->last_numid + 1;
 	card->last_numid += kcontrol->count;
 
+	add_hash_entries(card, kcontrol);
+
 	for (idx = 0; idx < kcontrol->count; idx++)
 		snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_ADD, kcontrol, idx);
 
@@ -479,6 +553,26 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,
 }
 EXPORT_SYMBOL(snd_ctl_replace);
 
+static int __snd_ctl_remove(struct snd_card *card,
+			    struct snd_kcontrol *kcontrol,
+			    bool remove_hash)
+{
+	unsigned int idx;
+
+	if (snd_BUG_ON(!card || !kcontrol))
+		return -EINVAL;
+	list_del(&kcontrol->list);
+
+	if (remove_hash)
+		remove_hash_entries(card, kcontrol);
+
+	card->controls_count -= kcontrol->count;
+	for (idx = 0; idx < kcontrol->count; idx++)
+		snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx);
+	snd_ctl_free_one(kcontrol);
+	return 0;
+}
+
 /**
  * snd_ctl_remove - remove the control from the card and release it
  * @card: the card instance
@@ -492,16 +586,7 @@ EXPORT_SYMBOL(snd_ctl_replace);
  */
 int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol)
 {
-	unsigned int idx;
-
-	if (snd_BUG_ON(!card || !kcontrol))
-		return -EINVAL;
-	list_del(&kcontrol->list);
-	card->controls_count -= kcontrol->count;
-	for (idx = 0; idx < kcontrol->count; idx++)
-		snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx);
-	snd_ctl_free_one(kcontrol);
-	return 0;
+	return __snd_ctl_remove(card, kcontrol, true);
 }
 EXPORT_SYMBOL(snd_ctl_remove);
 
@@ -642,9 +727,11 @@ int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id,
 		up_write(&card->controls_rwsem);
 		return -ENOENT;
 	}
+	remove_hash_entries(card, kctl);
 	kctl->id = *dst_id;
 	kctl->id.numid = card->last_numid + 1;
 	card->last_numid += kctl->count;
+	add_hash_entries(card, kctl);
 	up_write(&card->controls_rwsem);
 	return 0;
 }
@@ -665,15 +752,9 @@ EXPORT_SYMBOL(snd_ctl_rename_id);
  */
 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid)
 {
-	struct snd_kcontrol *kctl;
-
 	if (snd_BUG_ON(!card || !numid))
 		return NULL;
-	list_for_each_entry(kctl, &card->controls, list) {
-		if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
-			return kctl;
-	}
-	return NULL;
+	return xa_load(&card->ctl_numids, numid);
 }
 EXPORT_SYMBOL(snd_ctl_find_numid);
 
@@ -699,21 +780,15 @@ struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card,
 		return NULL;
 	if (id->numid != 0)
 		return snd_ctl_find_numid(card, id->numid);
-	list_for_each_entry(kctl, &card->controls, list) {
-		if (kctl->id.iface != id->iface)
-			continue;
-		if (kctl->id.device != id->device)
-			continue;
-		if (kctl->id.subdevice != id->subdevice)
-			continue;
-		if (strncmp(kctl->id.name, id->name, sizeof(kctl->id.name)))
-			continue;
-		if (kctl->id.index > id->index)
-			continue;
-		if (kctl->id.index + kctl->count <= id->index)
-			continue;
+	kctl = xa_load(&card->ctl_hash, get_ctl_id_hash(id));
+	if (kctl && elem_id_matches(kctl, id))
 		return kctl;
-	}
+
+	/* no matching in hash table - try all as the last resort */
+	list_for_each_entry(kctl, &card->controls, list)
+		if (elem_id_matches(kctl, id))
+			return kctl;
+
 	return NULL;
 }
 EXPORT_SYMBOL(snd_ctl_find_id);
@@ -2195,8 +2270,11 @@ static int snd_ctl_dev_free(struct snd_device *device)
 	down_write(&card->controls_rwsem);
 	while (!list_empty(&card->controls)) {
 		control = snd_kcontrol(card->controls.next);
-		snd_ctl_remove(card, control);
+		__snd_ctl_remove(card, control, false);
 	}
+
+	xa_destroy(&card->ctl_numids);
+	xa_destroy(&card->ctl_hash);
 	up_write(&card->controls_rwsem);
 	put_device(&card->ctl_dev);
 	return 0;
diff --git a/sound/core/init.c b/sound/core/init.c
index ac335f5906c6..a1979fe27d53 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -282,6 +282,8 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
 	rwlock_init(&card->ctl_files_rwlock);
 	INIT_LIST_HEAD(&card->controls);
 	INIT_LIST_HEAD(&card->ctl_files);
+	xa_init(&card->ctl_numids);
+	xa_init(&card->ctl_hash);
 	spin_lock_init(&card->files_lock);
 	INIT_LIST_HEAD(&card->files_list);
 	mutex_init(&card->memory_mutex);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
  2021-10-28 13:00 [PATCH RFC] ALSA: control: Use xarray for faster lookups Takashi Iwai
@ 2021-10-28 22:34 ` kernel test robot
  2021-10-28 23:13 ` kernel test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-28 22:34 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2570 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211028]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.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/d9e50e9647a202433a7b1c261b0edb0021f16004
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
        git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64 

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

All warnings (new ones prefixed by >>):

   sound/core/control.c: In function 'add_hash_entries':
>> sound/core/control.c:404:16: warning: variable 'err' set but not used [-Wunused-but-set-variable]
     404 |         int i, err;
         |                ^~~


vim +/err +404 sound/core/control.c

   398	
   399	/* add hash entries to numid and ctl xarray tables */
   400	static void add_hash_entries(struct snd_card *card,
   401				     struct snd_kcontrol *kcontrol)
   402	{
   403		struct snd_ctl_elem_id id = kcontrol->id;
 > 404		int i, err;
   405	
   406		xa_store_range(&card->ctl_numids, kcontrol->id.numid,
   407			       kcontrol->id.numid + kcontrol->count - 1,
   408			       kcontrol, GFP_KERNEL);
   409	
   410		for (i = 0; i < kcontrol->count; i++) {
   411			id.index = kcontrol->id.index + i;
   412			err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
   413					kcontrol, GFP_KERNEL);
   414			/* ignore errors - it's a best effort */
   415		}
   416	}
   417	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 19985 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
  2021-10-28 13:00 [PATCH RFC] ALSA: control: Use xarray for faster lookups Takashi Iwai
  2021-10-28 22:34 ` kernel test robot
@ 2021-10-28 23:13 ` kernel test robot
  2021-10-29  0:29   ` kernel test robot
  2021-10-29  0:36 ` kernel test robot
  3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-28 23:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5295 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211028]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: mips-randconfig-s031-20211028 (attached as .config)
compiler: mips64-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/0day-ci/linux/commit/d9e50e9647a202433a7b1c261b0edb0021f16004
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
        git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=mips 

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


sparse warnings: (new ones prefixed by >>)
   command-line: note: in included file:
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQUIRE redefined
   builtin:0:0: sparse: this was the original definition
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_SEQ_CST redefined
   builtin:0:0: sparse: this was the original definition
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQ_REL redefined
   builtin:0:0: sparse: this was the original definition
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_RELEASE redefined
   builtin:0:0: sparse: this was the original definition
>> sound/core/control.c:377:11: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned long h @@     got restricted snd_ctl_elem_iface_t const [usertype] iface @@
   sound/core/control.c:377:11: sparse:     expected unsigned long h
   sound/core/control.c:377:11: sparse:     got restricted snd_ctl_elem_iface_t const [usertype] iface
   sound/core/control.c:890:17: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control.c:890:26: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control.c:891:17: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control.c:891:26: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control.c:910:48: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control.c:1604:40: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control.c: note: in included file:
   sound/core/control_compat.c:193:21: sparse: sparse: incorrect type in assignment (different base types) @@     expected int [assigned] err @@     got restricted snd_ctl_elem_type_t [usertype] type @@
   sound/core/control_compat.c:193:21: sparse:     expected int [assigned] err
   sound/core/control_compat.c:193:21: sparse:     got restricted snd_ctl_elem_type_t [usertype] type
   sound/core/control_compat.c:203:14: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:205:14: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:207:14: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:209:14: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:237:21: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:238:21: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:269:21: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer
   sound/core/control_compat.c:270:21: sparse: sparse: restricted snd_ctl_elem_type_t degrades to integer

vim +377 sound/core/control.c

   366	
   367	/* Compute a hash key for the corresponding ctl id
   368	 * It's for the name lookup, hence the numid is excluded.
   369	 * The hash key is bound in LONG_MAX to be used for Xarray key.
   370	 */
   371	#define MULTIPLIER	37
   372	static unsigned long get_ctl_id_hash(const struct snd_ctl_elem_id *id)
   373	{
   374		unsigned long h;
   375		const unsigned char *p;
   376	
 > 377		h = id->iface;
   378		h = MULTIPLIER * h + id->device;
   379		h = MULTIPLIER * h + id->subdevice;
   380		for (p = id->name; *p; p++)
   381			h = MULTIPLIER * h + *p;
   382		h = MULTIPLIER * h + id->index;
   383		h &= LONG_MAX;
   384		return h;
   385	}
   386	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33872 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
  2021-10-28 13:00 [PATCH RFC] ALSA: control: Use xarray for faster lookups Takashi Iwai
@ 2021-10-29  0:29   ` kernel test robot
  2021-10-28 23:13 ` kernel test robot
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-29  0:29 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: llvm, kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2543 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211028]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: i386-randconfig-a012-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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/d9e50e9647a202433a7b1c261b0edb0021f16004
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
        git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 

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

All warnings (new ones prefixed by >>):

>> sound/core/control.c:404:9: warning: variable 'err' set but not used [-Wunused-but-set-variable]
           int i, err;
                  ^
   1 warning generated.


vim +/err +404 sound/core/control.c

   398	
   399	/* add hash entries to numid and ctl xarray tables */
   400	static void add_hash_entries(struct snd_card *card,
   401				     struct snd_kcontrol *kcontrol)
   402	{
   403		struct snd_ctl_elem_id id = kcontrol->id;
 > 404		int i, err;
   405	
   406		xa_store_range(&card->ctl_numids, kcontrol->id.numid,
   407			       kcontrol->id.numid + kcontrol->count - 1,
   408			       kcontrol, GFP_KERNEL);
   409	
   410		for (i = 0; i < kcontrol->count; i++) {
   411			id.index = kcontrol->id.index + i;
   412			err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
   413					kcontrol, GFP_KERNEL);
   414			/* ignore errors - it's a best effort */
   415		}
   416	}
   417	

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36622 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
@ 2021-10-29  0:29   ` kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-29  0:29 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2605 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211028]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: i386-randconfig-a012-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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/d9e50e9647a202433a7b1c261b0edb0021f16004
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
        git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 

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

All warnings (new ones prefixed by >>):

>> sound/core/control.c:404:9: warning: variable 'err' set but not used [-Wunused-but-set-variable]
           int i, err;
                  ^
   1 warning generated.


vim +/err +404 sound/core/control.c

   398	
   399	/* add hash entries to numid and ctl xarray tables */
   400	static void add_hash_entries(struct snd_card *card,
   401				     struct snd_kcontrol *kcontrol)
   402	{
   403		struct snd_ctl_elem_id id = kcontrol->id;
 > 404		int i, err;
   405	
   406		xa_store_range(&card->ctl_numids, kcontrol->id.numid,
   407			       kcontrol->id.numid + kcontrol->count - 1,
   408			       kcontrol, GFP_KERNEL);
   409	
   410		for (i = 0; i < kcontrol->count; i++) {
   411			id.index = kcontrol->id.index + i;
   412			err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
   413					kcontrol, GFP_KERNEL);
   414			/* ignore errors - it's a best effort */
   415		}
   416	}
   417	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36622 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
  2021-10-28 13:00 [PATCH RFC] ALSA: control: Use xarray for faster lookups Takashi Iwai
                   ` (2 preceding siblings ...)
  2021-10-29  0:29   ` kernel test robot
@ 2021-10-29  0:36 ` kernel test robot
  3 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-29  0:36 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1802 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on tiwai-sound/for-next]
[also build test ERROR on v5.15-rc7 next-20211028]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: mips-rs90_defconfig (attached as .config)
compiler: mipsel-linux-gcc (GCC) 11.2.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/d9e50e9647a202433a7b1c261b0edb0021f16004
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
        git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash

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 >>):

   mipsel-linux-ld: sound/core/control.o: in function `add_hash_entries':
>> control.c:(.text.add_hash_entries+0x74): undefined reference to `xa_store_range'

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 19411 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
  2021-10-30  1:13 kernel test robot
@ 2021-10-31 14:17   ` kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-31 14:17 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: llvm, kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3532 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211029]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: arm-randconfig-c002-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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 arm cross compiling tool for clang build
         # apt-get install binutils-arm-linux-gnueabi
         # https://github.com/0day-ci/linux/commit/d9e50e9647a202433a7b1c261b0edb0021f16004
         git remote add linux-review https://github.com/0day-ci/linux
         git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
         git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer

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


clang-analyzer warnings: (new ones prefixed by >>)

 >> sound/core/control.c:412:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
                    err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
                    ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/err +412 sound/core/control.c

d9e50e9647a202 Takashi Iwai 2021-10-28  398
d9e50e9647a202 Takashi Iwai 2021-10-28  399  /* add hash entries to numid and ctl xarray tables */
d9e50e9647a202 Takashi Iwai 2021-10-28  400  static void add_hash_entries(struct snd_card *card,
d9e50e9647a202 Takashi Iwai 2021-10-28  401  			     struct snd_kcontrol *kcontrol)
d9e50e9647a202 Takashi Iwai 2021-10-28  402  {
d9e50e9647a202 Takashi Iwai 2021-10-28  403  	struct snd_ctl_elem_id id = kcontrol->id;
d9e50e9647a202 Takashi Iwai 2021-10-28  404  	int i, err;
d9e50e9647a202 Takashi Iwai 2021-10-28  405
d9e50e9647a202 Takashi Iwai 2021-10-28  406  	xa_store_range(&card->ctl_numids, kcontrol->id.numid,
d9e50e9647a202 Takashi Iwai 2021-10-28  407  		       kcontrol->id.numid + kcontrol->count - 1,
d9e50e9647a202 Takashi Iwai 2021-10-28  408  		       kcontrol, GFP_KERNEL);
d9e50e9647a202 Takashi Iwai 2021-10-28  409
d9e50e9647a202 Takashi Iwai 2021-10-28  410  	for (i = 0; i < kcontrol->count; i++) {
d9e50e9647a202 Takashi Iwai 2021-10-28  411  		id.index = kcontrol->id.index + i;
d9e50e9647a202 Takashi Iwai 2021-10-28 @412  		err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
d9e50e9647a202 Takashi Iwai 2021-10-28  413  				kcontrol, GFP_KERNEL);
d9e50e9647a202 Takashi Iwai 2021-10-28  414  		/* ignore errors - it's a best effort */
d9e50e9647a202 Takashi Iwai 2021-10-28  415  	}
d9e50e9647a202 Takashi Iwai 2021-10-28  416  }
d9e50e9647a202 Takashi Iwai 2021-10-28  417

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29791 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
@ 2021-10-31 14:17   ` kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-10-31 14:17 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3596 bytes --]

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211029]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: arm-randconfig-c002-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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 arm cross compiling tool for clang build
         # apt-get install binutils-arm-linux-gnueabi
         # https://github.com/0day-ci/linux/commit/d9e50e9647a202433a7b1c261b0edb0021f16004
         git remote add linux-review https://github.com/0day-ci/linux
         git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
         git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer

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


clang-analyzer warnings: (new ones prefixed by >>)

 >> sound/core/control.c:412:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
                    err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
                    ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/err +412 sound/core/control.c

d9e50e9647a202 Takashi Iwai 2021-10-28  398
d9e50e9647a202 Takashi Iwai 2021-10-28  399  /* add hash entries to numid and ctl xarray tables */
d9e50e9647a202 Takashi Iwai 2021-10-28  400  static void add_hash_entries(struct snd_card *card,
d9e50e9647a202 Takashi Iwai 2021-10-28  401  			     struct snd_kcontrol *kcontrol)
d9e50e9647a202 Takashi Iwai 2021-10-28  402  {
d9e50e9647a202 Takashi Iwai 2021-10-28  403  	struct snd_ctl_elem_id id = kcontrol->id;
d9e50e9647a202 Takashi Iwai 2021-10-28  404  	int i, err;
d9e50e9647a202 Takashi Iwai 2021-10-28  405
d9e50e9647a202 Takashi Iwai 2021-10-28  406  	xa_store_range(&card->ctl_numids, kcontrol->id.numid,
d9e50e9647a202 Takashi Iwai 2021-10-28  407  		       kcontrol->id.numid + kcontrol->count - 1,
d9e50e9647a202 Takashi Iwai 2021-10-28  408  		       kcontrol, GFP_KERNEL);
d9e50e9647a202 Takashi Iwai 2021-10-28  409
d9e50e9647a202 Takashi Iwai 2021-10-28  410  	for (i = 0; i < kcontrol->count; i++) {
d9e50e9647a202 Takashi Iwai 2021-10-28  411  		id.index = kcontrol->id.index + i;
d9e50e9647a202 Takashi Iwai 2021-10-28 @412  		err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
d9e50e9647a202 Takashi Iwai 2021-10-28  413  				kcontrol, GFP_KERNEL);
d9e50e9647a202 Takashi Iwai 2021-10-28  414  		/* ignore errors - it's a best effort */
d9e50e9647a202 Takashi Iwai 2021-10-28  415  	}
d9e50e9647a202 Takashi Iwai 2021-10-28  416  }
d9e50e9647a202 Takashi Iwai 2021-10-28  417

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29791 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC] ALSA: control: Use xarray for faster lookups
@ 2021-10-30  1:13 kernel test robot
  2021-10-31 14:17   ` kernel test robot
  0 siblings, 1 reply; 9+ messages in thread
From: kernel test robot @ 2021-10-30  1:13 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 15360 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211028130027.18764-1-tiwai@suse.de>
References: <20211028130027.18764-1-tiwai@suse.de>
TO: Takashi Iwai <tiwai@suse.de>

Hi Takashi,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.15-rc7 next-20211029]
[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/Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: arm-randconfig-c002-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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 arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/d9e50e9647a202433a7b1c261b0edb0021f16004
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-control-Use-xarray-for-faster-lookups/20211028-210215
        git checkout d9e50e9647a202433a7b1c261b0edb0021f16004
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   sound/core/control.c:103:11: note: Loop condition is false.  Exiting loop
                   cread = snd_kctl_event(ctl->events.next);
                           ^
   include/sound/control.h:95:27: note: expanded from macro 'snd_kctl_event'
   #define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list)
                             ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   sound/core/control.c:105:3: note: Memory is released
                   kfree(cread);
                   ^~~~~~~~~~~~
   sound/core/control.c:102:2: note: Loop condition is true.  Entering loop body
           while (!list_empty(&ctl->events)) {
           ^
   sound/core/control.c:103:11: note: Left side of '&&' is false
                   cread = snd_kctl_event(ctl->events.next);
                           ^
   include/sound/control.h:95:27: note: expanded from macro 'snd_kctl_event'
   #define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list)
                             ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   sound/core/control.c:103:11: note: Taking false branch
                   cread = snd_kctl_event(ctl->events.next);
                           ^
   include/sound/control.h:95:27: note: expanded from macro 'snd_kctl_event'
   #define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list)
                             ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   sound/core/control.c:103:11: note: Loop condition is false.  Exiting loop
                   cread = snd_kctl_event(ctl->events.next);
                           ^
   include/sound/control.h:95:27: note: expanded from macro 'snd_kctl_event'
   #define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list)
                             ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   sound/core/control.c:104:3: note: Calling 'list_del'
                   list_del(&cread->list);
                   ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:147:14: note: Use of memory after it is freed
           entry->next = LIST_POISON1;
           ~~~~~~~~~~~ ^
>> sound/core/control.c:412:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
                   err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
                   ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/core/control.c:412:3: note: Value stored to 'err' is never read
                   err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
                   ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/core/control.c:1381:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(uinfo->value.enumerated.name, names);
           ^~~~~~
   sound/core/control.c:1381:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(uinfo->value.enumerated.name, names);
           ^~~~~~
   sound/core/control.c:2273:3: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
                   __snd_ctl_remove(card, control, false);
                   ^                      ~~~~~~~
   sound/core/control.c:2271:2: note: Loop condition is true.  Entering loop body
           while (!list_empty(&card->controls)) {
           ^
   sound/core/control.c:2272:13: note: Left side of '&&' is false
                   control = snd_kcontrol(card->controls.next);
                             ^
   include/sound/control.h:87:25: note: expanded from macro 'snd_kcontrol'
   #define snd_kcontrol(n) list_entry(n, struct snd_kcontrol, list)
                           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   sound/core/control.c:2272:13: note: Taking false branch
                   control = snd_kcontrol(card->controls.next);
                             ^
   include/sound/control.h:87:25: note: expanded from macro 'snd_kcontrol'
   #define snd_kcontrol(n) list_entry(n, struct snd_kcontrol, list)
                           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   sound/core/control.c:2272:13: note: Loop condition is false.  Exiting loop
                   control = snd_kcontrol(card->controls.next);
                             ^
   include/sound/control.h:87:25: note: expanded from macro 'snd_kcontrol'
   #define snd_kcontrol(n) list_entry(n, struct snd_kcontrol, list)
                           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   sound/core/control.c:2273:3: note: Calling '__snd_ctl_remove'
                   __snd_ctl_remove(card, control, false);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/core/control.c:562:18: note: 'card' is non-null
           if (snd_BUG_ON(!card || !kcontrol))
                           ^
   include/sound/core.h:416:25: note: expanded from macro 'snd_BUG_ON'
           int __ret_warn_on = !!(condition); \
                                  ^~~~~~~~~
   sound/core/control.c:562:17: note: Left side of '||' is false
           if (snd_BUG_ON(!card || !kcontrol))
                          ^
   sound/core/control.c:562:26: note: Assuming 'kcontrol' is non-null
           if (snd_BUG_ON(!card || !kcontrol))
                                   ^
   include/sound/core.h:416:25: note: expanded from macro 'snd_BUG_ON'
           int __ret_warn_on = !!(condition); \
                                  ^~~~~~~~~
   sound/core/control.c:562:2: note: Taking false branch
           if (snd_BUG_ON(!card || !kcontrol))
           ^
   sound/core/control.c:566:6: note: 'remove_hash' is false
           if (remove_hash)
               ^~~~~~~~~~~
   sound/core/control.c:566:2: note: Taking false branch
           if (remove_hash)
           ^

vim +/err +412 sound/core/control.c

d9e50e9647a202 Takashi Iwai 2021-10-28  398  
d9e50e9647a202 Takashi Iwai 2021-10-28  399  /* add hash entries to numid and ctl xarray tables */
d9e50e9647a202 Takashi Iwai 2021-10-28  400  static void add_hash_entries(struct snd_card *card,
d9e50e9647a202 Takashi Iwai 2021-10-28  401  			     struct snd_kcontrol *kcontrol)
d9e50e9647a202 Takashi Iwai 2021-10-28  402  {
d9e50e9647a202 Takashi Iwai 2021-10-28  403  	struct snd_ctl_elem_id id = kcontrol->id;
d9e50e9647a202 Takashi Iwai 2021-10-28  404  	int i, err;
d9e50e9647a202 Takashi Iwai 2021-10-28  405  
d9e50e9647a202 Takashi Iwai 2021-10-28  406  	xa_store_range(&card->ctl_numids, kcontrol->id.numid,
d9e50e9647a202 Takashi Iwai 2021-10-28  407  		       kcontrol->id.numid + kcontrol->count - 1,
d9e50e9647a202 Takashi Iwai 2021-10-28  408  		       kcontrol, GFP_KERNEL);
d9e50e9647a202 Takashi Iwai 2021-10-28  409  
d9e50e9647a202 Takashi Iwai 2021-10-28  410  	for (i = 0; i < kcontrol->count; i++) {
d9e50e9647a202 Takashi Iwai 2021-10-28  411  		id.index = kcontrol->id.index + i;
d9e50e9647a202 Takashi Iwai 2021-10-28 @412  		err = xa_insert(&card->ctl_hash, get_ctl_id_hash(&id),
d9e50e9647a202 Takashi Iwai 2021-10-28  413  				kcontrol, GFP_KERNEL);
d9e50e9647a202 Takashi Iwai 2021-10-28  414  		/* ignore errors - it's a best effort */
d9e50e9647a202 Takashi Iwai 2021-10-28  415  	}
d9e50e9647a202 Takashi Iwai 2021-10-28  416  }
d9e50e9647a202 Takashi Iwai 2021-10-28  417  

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29791 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-31 14:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 13:00 [PATCH RFC] ALSA: control: Use xarray for faster lookups Takashi Iwai
2021-10-28 22:34 ` kernel test robot
2021-10-28 23:13 ` kernel test robot
2021-10-29  0:29 ` kernel test robot
2021-10-29  0:29   ` kernel test robot
2021-10-29  0:36 ` kernel test robot
2021-10-30  1:13 kernel test robot
2021-10-31 14:17 ` kernel test robot
2021-10-31 14:17   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.