kernel/trace/rv/rv.c:812:2-8: preceding lock on line 790 (fwd)
Please check on whether line 812 needs an unlock.
julia
---------- Forwarded message ----------
Date: Mon, 31 Mar 2025 02:25:17 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: kernel/trace/rv/rv.c:812:2-8: preceding lock on line 790
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Gabriele Monaco <[email protected]>
CC: "Steven Rostedt (Google)" <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7f2ff7b6261742ed52aa973ccdf99151b7cc3a50 commit: cb85c660fcd4b3a03ed993affa0b2d1a8af2f06b rv: Add option for nested monitors and include sched date: 6 days ago
:::::: branch date: 17 hours ago
:::::: commit date: 6 days ago
config: loongarch-randconfig-r061-20250330 (https://download.01.org/0day-ci/archive/20250331/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
kernel/trace/rv/rv.c:812:2-8: preceding lock on line 790
vim +812 kernel/trace/rv/rv.c
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 771
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 772 /**
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 773 * rv_register_monitor - register a rv monitor.
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 774 * @monitor: The rv_monitor to be registered.
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 775 * @parent: The parent of the monitor to be registered, NULL if not nested.
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 776 *
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 777 * Returns 0 if successful, error otherwise.
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 778 */
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 779 int rv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent)
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 780 {
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 781 struct rv_monitor_def *r, *p = NULL;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 782 int retval = 0;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 783
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 784 if (strlen(monitor->name) >= MAX_RV_MONITOR_NAME_SIZE) {
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 785 pr_info("Monitor %s has a name longer than %d\n", monitor->name,
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 786 MAX_RV_MONITOR_NAME_SIZE);
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 787 return -EINVAL;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 788 }
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 789
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 @790 mutex_lock(&rv_interface_lock);
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 791
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 792 list_for_each_entry(r, &rv_monitors_list, list) {
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 793 if (strcmp(monitor->name, r->monitor->name) == 0) {
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 794 pr_info("Monitor %s is already registered\n", monitor->name);
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 795 retval = -EEXIST;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 796 goto out_unlock;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 797 }
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 798 }
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 799
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 800 if (parent) {
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 801 list_for_each_entry(r, &rv_monitors_list, list) {
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 802 if (strcmp(parent->name, r->monitor->name) == 0) {
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 803 p = r;
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 804 break;
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 805 }
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 806 }
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 807 }
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 808
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 809 if (p && rv_is_nested_monitor(p)) {
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 810 pr_info("Parent monitor %s is already nested, cannot nest further\n",
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 811 parent->name);
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 @812 return -EINVAL;
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 813 }
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 814
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 815 r = kzalloc(sizeof(struct rv_monitor_def), GFP_KERNEL);
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 816 if (!r) {
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 817 retval = -ENOMEM;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 818 goto out_unlock;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 819 }
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 820
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 821 r->monitor = monitor;
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 822 r->parent = parent;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 823
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 824 retval = create_monitor_dir(r, p);
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 825 if (retval) {
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 826 kfree(r);
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 827 goto out_unlock;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 828 }
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 829
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 830 /* keep children close to the parent for easier visualisation */
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 831 if (p)
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 832 list_add(&r->list, &p->list);
cb85c660fcd4b3a Gabriele Monaco 2025-03-05 833 else
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 834 list_add_tail(&r->list, &rv_monitors_list);
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 835
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 836 out_unlock:
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 837 mutex_unlock(&rv_interface_lock);
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 838 return retval;
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 839 }
102227b970a1525 Daniel Bristot de Oliveira 2022-07-29 840Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 1 line · On Sun, 30 Mar 2025 20:37:59 +0200 (CEST) Julia Lawall <[email protected]>…
Please check on whether line 812 needs an unlock.
Yes it does. Thanks!
-- Steve
Quoted 2 lines · Julia Lawall
Please check on whether line 812 needs an unlock.
Hi,
thanks for reporting!
Indeed that needs an unlock, I missed it after moving some code around, preparing the fix.
Gabriele
Quoted 161 lines
julia
---------- Forwarded message ----------
Date: Mon, 31 Mar 2025 02:25:17 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: kernel/trace/rv/rv.c:812:2-8: preceding lock on line 790BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Gabriele Monaco <[email protected]>
CC: "Steven Rostedt (Google)" <[email protected]>tree:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ma
ster
head:7f2ff7b6261742ed52aa973ccdf99151b7cc3a50
commit:cb85c660fcd4b3a03ed993affa0b2d1a8af2f06brv: Add option for nested monitors and include sched
date: 6 days ago
:::::: branch date: 17 hours ago
:::::: commit date: 6 days ago
config: loongarch-randconfig-r061-20250330
(https://download.01.org/0day-ci/archive/20250331/202503310200.UBXGit
[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tagsQuoted 4 lines
Reported-by kernel test robot <[email protected]>Reported-by Julia Lawall <[email protected]>cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
kernel/trace/rv/rv.c:812:2-8: preceding lock on line 790
vim +812
kernel/trace/rv/rv.c
102227b970a1525Daniel Bristot de Oliveira 2022-07-29 771102227b970a1525Daniel Bristot de Oliveira 2022-07-29 772 /**102227b970a1525Daniel Bristot de Oliveira 2022-07-29 773 *rv_register_monitor- register a rv monitor.102227b970a1525Daniel Bristot de Oliveira 2022-07-29 774 * @monitor: Therv_monitorto be registered.cb85c660fcd4b3aGabriele Monaco 2025-03-05 775 * @parent: The parent of the monitor to be registered, NULL if not nested.102227b970a1525Daniel Bristot de Oliveira 2022-07-29 776 *102227b970a1525Daniel Bristot de Oliveira 2022-07-29 777 * Returns 0 if successful, error otherwise.102227b970a1525Daniel Bristot de Oliveira 2022-07-29 778 */cb85c660fcd4b3aGabriele Monaco 2025-03-05 779 intrv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent)102227b970a1525Daniel Bristot de Oliveira 2022-07-29 780 {cb85c660fcd4b3aGabriele Monaco 2025-03-05
781 structrv_monitor_def*r, *p = NULL;102227b970a1525Daniel Bristot de Oliveira 2022-07-29 782 int
retval = 0;102227b970a1525Daniel Bristot de Oliveira 2022-07-29 783102227b970a1525Daniel Bristot de Oliveira 2022-07-29 784 if
(strlen(monitor->name)>=MAX_RV_MONITOR_NAME_SIZE) {102227b970a1525Daniel Bristot de Oliveira 2022-07-29
785 pr_info("Monitor %s has a name longer than %d\n",monitor->name,102227b970a1525Daniel Bristot de Oliveira 2022-07-29
786MAX_RV_MONITOR_NAME_SIZE);cb85c660fcd4b3aGabriele Monaco 2025-03-05
787 return-EINVAL;102227b970a1525Daniel Bristot de Oliveira 2022-07-29 788 }102227b970a1525Daniel Bristot de Oliveira 2022-07-29 789102227b970a1525Daniel Bristot de Oliveira 2022-07-29
@790mutex_lock(&rv_interface_lock);102227b970a1525Daniel Bristot de Oliveira 2022-07-29 791102227b970a1525Daniel Bristot de Oliveira 2022-07-29
792list_for_each_entry(r, &rv_monitors_list, list){102227b970a1525Daniel Bristot de Oliveira 2022-07-29
793 if (strcmp(monitor->name, r->monitor->name)== 0) {102227b970a1525Daniel Bristot de Oliveira 2022-07-29
794pr_info("Monitor %s is already registered\n", monitor->name);cb85c660fcd4b3aGabriele Monaco 2025-03-05
795 retval =-EEXIST;102227b970a1525Daniel Bristot de Oliveira 2022-07-29
796 gotoout_unlock;102227b970a1525Daniel Bristot de Oliveira 2022-07-29
797 }102227b970a1525Daniel Bristot de Oliveira 2022-07-29 798 }102227b970a1525Daniel Bristot de Oliveira 2022-07-29 799cb85c660fcd4b3aGabriele Monaco 2025-03-05 800 if
(parent) {cb85c660fcd4b3aGabriele Monaco 2025-03-05
801list_for_each_entry(r, &rv_monitors_list, list){cb85c660fcd4b3aGabriele Monaco 2025-03-05
802 if (strcmp(parent->name, r->monitor->name)== 0) {cb85c660fcd4b3aGabriele Monaco 2025-03-05
803 p = r;cb85c660fcd4b3aGabriele Monaco 2025-03-05
804 break;cb85c660fcd4b3aGabriele Monaco 2025-03-05
805 }cb85c660fcd4b3aGabriele Monaco 2025-03-05
806 }cb85c660fcd4b3aGabriele Monaco 2025-03-05 807 }cb85c660fcd4b3aGabriele Monaco 2025-03-05 808cb85c660fcd4b3aGabriele Monaco 2025-03-05 809 if
(p &&rv_is_nested_monitor(p)) {cb85c660fcd4b3aGabriele Monaco 2025-03-05
810 pr_info("Parent monitor %s is already nested, cannot nest further\n",cb85c660fcd4b3aGabriele Monaco 2025-03-05
811parent->name);cb85c660fcd4b3aGabriele Monaco 2025-03-05
@812 return-EINVAL;cb85c660fcd4b3aGabriele Monaco 2025-03-05 813 }cb85c660fcd4b3aGabriele Monaco 2025-03-05 814102227b970a1525Daniel Bristot de Oliveira 2022-07-29 815 r =kzalloc(sizeof(struct rv_monitor_def), GFP_KERNEL);102227b970a1525Daniel Bristot de Oliveira 2022-07-29 816 if
(!r) {102227b970a1525Daniel Bristot de Oliveira 2022-07-29
817 retval =-ENOMEM;102227b970a1525Daniel Bristot de Oliveira 2022-07-29
818 gotoout_unlock;102227b970a1525Daniel Bristot de Oliveira 2022-07-29 819 }102227b970a1525Daniel Bristot de Oliveira 2022-07-29 820102227b970a1525Daniel Bristot de Oliveira 2022-07-29 821 r-Quoted 1 line
monitor = monitor;
cb85c660fcd4b3aGabriele Monaco 2025-03-05 822 r-Quoted 1 line
parent = parent;
102227b970a1525Daniel Bristot de Oliveira 2022-07-29 823cb85c660fcd4b3aGabriele Monaco 2025-03-05
824 retval =create_monitor_dir(r, p);102227b970a1525Daniel Bristot de Oliveira 2022-07-29 825 if
(retval) {102227b970a1525Daniel Bristot de Oliveira 2022-07-29
826 kfree(r);102227b970a1525Daniel Bristot de Oliveira 2022-07-29
827 gotoout_unlock;102227b970a1525Daniel Bristot de Oliveira 2022-07-29 828 }102227b970a1525Daniel Bristot de Oliveira 2022-07-29 829cb85c660fcd4b3aGabriele Monaco 2025-03-05 830 /*
keep children close to the parent for easier visualisation */cb85c660fcd4b3aGabriele Monaco 2025-03-05 831 if
(p)cb85c660fcd4b3aGabriele Monaco 2025-03-05
832list_add(&r->list, &p->list);cb85c660fcd4b3aGabriele Monaco 2025-03-05 833 else102227b970a1525Daniel Bristot de Oliveira 2022-07-29
834list_add_tail(&r->list, &rv_monitors_list);102227b970a1525Daniel Bristot de Oliveira 2022-07-29 835102227b970a1525Daniel Bristot de Oliveira 2022-07-29 836out_unlock:102227b970a1525Daniel Bristot de Oliveira 2022-07-29
837mutex_unlock(&rv_interface_lock);102227b970a1525Daniel Bristot de Oliveira 2022-07-29
838 return retval;102227b970a1525Daniel Bristot de Oliveira 2022-07-29 839 }102227b970a1525Daniel Bristot de Oliveira 2022-07-29 840