Skip to contentSkip to conversation

fs/resctrl: Free mon_data structures on rdt_get_tree() failure

PATCH In review Tony Luck 3 participants 8 messages May 7 – May 10 RDT - resource allocation

lore
Share & tools
lore

Tony Luck

author maintainer
#0 lore raw

PATCH 1/1 fs/resctrl: Free mon_data structures on rdt_get_tree() failure

If mkdir_mondata_all() succeeds but a subsequent call in rdt_get_tree() fails, the mon_data structures allocated by mon_get_kn_priv() are leaked. Add mon_put_kn_priv() to the out_mondata error path to free them.

Fixes ee4f0ec938ad ("fs/resctrl: Simplify allocation of mon_data structures")
Assisted-by GitHub Copilot CLI:claude-sonnet-4.6

---

Did I really need AI to help, no. But I wanted to see if it can at least save me from some typing. Here's the prompt I used (contains just as much typed content as this change!)

Reinette Chatre <[email protected]> reported a problem in rdt_get_tree(). If the mkdir_mondata_all() succeeds, the some memory is allocated by mon_get_kn_priv(). If a subsequent call in rdt_get_tree() fails, then a call to mon_put_kn_priv() is needed to free any mon_data structures.

Create and apply a patch to fix this. Research a suitable Fixes: tag. Give credit to Reinette for reporting. Add a correctly formatted

Assisted-by tag with AI model version. Keep the commit comment

concise.

 fs/resctrl/rdtgroup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/resctrl/rdtgroup.c +3 -1
index 5dfdaa6f9d8f..aad573b62fd7 100644
@@ -2879,8 +2879,10 @@ static int rdt_get_tree(struct fs_context *fc)
 out_psl:
 	rdt_pseudo_lock_release();
 out_mondata:
-	if (resctrl_arch_mon_capable())
+	if (resctrl_arch_mon_capable()) {
+		mon_put_kn_priv();
 		kernfs_remove(kn_mondata);
+	}
 out_mongrp:
 	if (resctrl_arch_mon_capable()) {
 		rdtgroup_unassign_cntrs(&rdtgroup_default);
Signature · 1 line
2.54.0
author maintainer
#1 lore raw
Quoted 3 lines

Did I really need AI to help, no. But I wanted to see if it can at least save me from some typing. Here's the prompt I used (contains just as much typed content as this change!)

Bother ... trusted AI again.

fs/resctrl/rdtgroup.c:2883:17: error: implicit declaration of function 'mon_put_kn_priv' [-Wimplicit -function-declaration]

:-(

-Tony

maintainer
#2 lore raw
In reply to Tony Luck

Hi Tony,

Quoted 6 lines · Tony Luck
fs/resctrl/rdtgroup.c +0 -0
index 5dfdaa6f9d8f..aad573b62fd7 100644
@@ -2879,8 +2879,10 @@ static int rdt_get_tree(struct fs_context *fc)
 out_psl:

fs/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 2888

Quoted 10 lines
fs/resctrl/rdtgroup.c +3 -1
 	rdt_pseudo_lock_release();
 out_mondata:
-	if (resctrl_arch_mon_capable())
+	if (resctrl_arch_mon_capable()) {
+		mon_put_kn_priv();
 		kernfs_remove(kn_mondata);
+	}
 out_mongrp:
 	if (resctrl_arch_mon_capable()) {
 		rdtgroup_unassign_cntrs(&rdtgroup_default);

From what I can tell the other [1] fix will conflict here. To help manage dependencies I thus think it will be simpler if these rdt_get_tree() fixes are grouped in the same series.

Reinette

[1] https://lore.kernel.org/lkml/[email protected]/

#3 lore raw
In reply to Tony Luck
kernel test robot noticed the following build warnings:

Hi Tony,

kernel test robot noticed the following build warnings:

[auto build test WARNING on v7.1-rc2]
[also build test WARNING on linus/master next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Luck/fs-resctrl-Free-mon_data-structures-on-rdt_get_tree-failure/20260509-184342
base:   v7.1-rc2
patch link:    https://lore.kernel.org/r/20260507201730.16509-1-tony.luck%40intel.com
patch subject: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20260509/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260509/[email protected]/reproduce)

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]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

fs/resctrl/rdtgroup.c: In function 'rdt_get_tree':
fs/resctrl/rdtgroup.c:2883:17: error: implicit declaration of function 'mon_put_kn_priv' [-Wimplicit-function-declaration]

    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~
   fs/resctrl/rdtgroup.c: At top level:
>> fs/resctrl/rdtgroup.c:3144:13: warning: conflicting types for 'mon_put_kn_priv'; have 'void(void)'
    3144 | static void mon_put_kn_priv(void)
         |             ^~~~~~~~~~~~~~~
   fs/resctrl/rdtgroup.c:3144:13: error: static declaration of 'mon_put_kn_priv' follows non-static declaration
   fs/resctrl/rdtgroup.c:2883:17: note: previous implicit declaration of 'mon_put_kn_priv' with type 'void(void)'
    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~

vim +3144 fs/resctrl/rdtgroup.c

7168ae330e8105 James Morse 2025-05-15  3138  
7168ae330e8105 James Morse 2025-05-15  3139  /**
7168ae330e8105 James Morse 2025-05-15  3140   * mon_put_kn_priv() - Free all allocated mon_data structures.
7168ae330e8105 James Morse 2025-05-15  3141   *
7168ae330e8105 James Morse 2025-05-15  3142   * Called when resctrl file system is unmounted.
7168ae330e8105 James Morse 2025-05-15  3143   */
7168ae330e8105 James Morse 2025-05-15 @3144  static void mon_put_kn_priv(void)
7168ae330e8105 James Morse 2025-05-15  3145  {
7168ae330e8105 James Morse 2025-05-15  3146  	struct mon_data *priv, *tmp;
7168ae330e8105 James Morse 2025-05-15  3147  
7168ae330e8105 James Morse 2025-05-15  3148  	lockdep_assert_held(&rdtgroup_mutex);
7168ae330e8105 James Morse 2025-05-15  3149  
7168ae330e8105 James Morse 2025-05-15  3150  	list_for_each_entry_safe(priv, tmp, &mon_data_kn_priv_list, list) {
7168ae330e8105 James Morse 2025-05-15  3151  		list_del(&priv->list);
7168ae330e8105 James Morse 2025-05-15  3152  		kfree(priv);
7168ae330e8105 James Morse 2025-05-15  3153  	}
7168ae330e8105 James Morse 2025-05-15  3154  }
7168ae330e8105 James Morse 2025-05-15  3155  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#4 lore raw
In reply to Tony Luck
kernel test robot noticed the following build errors:

Hi Tony,

kernel test robot noticed the following build errors:

[auto build test ERROR on v7.1-rc2]
[also build test ERROR on linus/master next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Luck/fs-resctrl-Free-mon_data-structures-on-rdt_get_tree-failure/20260509-184342
base:   v7.1-rc2
patch link:    https://lore.kernel.org/r/20260507201730.16509-1-tony.luck%40intel.com
patch subject: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20260510/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260510/[email protected]/reproduce)

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]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> fs/resctrl/rdtgroup.c:2883:3: error: call to undeclared function 'mon_put_kn_priv'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    2883 |                 mon_put_kn_priv();
         |                 ^
>> fs/resctrl/rdtgroup.c:3144:13: error: conflicting types for 'mon_put_kn_priv'
    3144 | static void mon_put_kn_priv(void)
         |             ^
   fs/resctrl/rdtgroup.c:2883:3: note: previous implicit declaration is here
    2883 |                 mon_put_kn_priv();
         |                 ^

2 errors generated.

vim +/mon_put_kn_priv +2883 fs/resctrl/rdtgroup.c

2784
2785 static int rdt_get_tree(struct fs_context *fc)
2786 {
2787 struct rdt_fs_context *ctx = rdt_fc2context(fc);
2788 unsigned long flags = RFTYPE_CTRL_BASE;
2789 struct rdt_l3_mon_domain *dom;
2790 struct rdt_resource *r;
2791 int ret;
2792
2793 DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount);
2794
2795 cpus_read_lock();
2796 mutex_lock(&rdtgroup_mutex);
2797 /*
2798 * resctrl file system can only be mounted once.
2799 */
2800 if (resctrl_mounted) {
2801 ret = -EBUSY;
2802 goto out;
2803 }
2804
2805 ret = setup_rmid_lru_list();
2806 if (ret)
2807 goto out;
2808
2809 ret = rdtgroup_setup_root(ctx);
2810 if (ret)
2811 goto out;
2812
2813 ret = rdt_enable_ctx(ctx);
2814 if (ret)
2815 goto out_root;
2816
2817 ret = schemata_list_create();
2818 if (ret)
2819 goto out_schemata_free;
2820
2821 ret = closid_init();
2822 if (ret)
2823 goto out_schemata_free;
2824
2825 if (resctrl_arch_mon_capable())
2826 flags |= RFTYPE_MON;
2827
2828 ret = rdtgroup_add_files(rdtgroup_default.kn, flags);
2829 if (ret)
2830 goto out_closid_exit;
2831
2832 kernfs_activate(rdtgroup_default.kn);
2833
2834 ret = rdtgroup_create_info_dir(rdtgroup_default.kn);
2835 if (ret < 0)
2836 goto out_closid_exit;
2837
2838 if (resctrl_arch_mon_capable()) {
2839 ret = mongroup_create_dir(rdtgroup_default.kn,
2840 &rdtgroup_default, "mon_groups",
2841 &kn_mongrp);
2842 if (ret < 0)
2843 goto out_info;
2844
2845 rdtgroup_assign_cntrs(&rdtgroup_default);
2846
2847 ret = mkdir_mondata_all(rdtgroup_default.kn,
2848 &rdtgroup_default, &kn_mondata);
2849 if (ret < 0)
2850 goto out_mongrp;
2851 rdtgroup_default.mon.mon_data_kn = kn_mondata;
2852 }
2853
2854 ret = rdt_pseudo_lock_init();
2855 if (ret)
2856 goto out_mondata;
2857
2858 ret = kernfs_get_tree(fc);
2859 if (ret < 0)
2860 goto out_psl;
2861
2862 if (resctrl_arch_alloc_capable())
2863 resctrl_arch_enable_alloc();
2864 if (resctrl_arch_mon_capable())
2865 resctrl_arch_enable_mon();
2866
2867 if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable())
2868 resctrl_mounted = true;
2869
2870 if (resctrl_is_mbm_enabled()) {
2871 r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
2872 list_for_each_entry(dom, &r->mon_domains, hdr.list)
2873 mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL,
2874 RESCTRL_PICK_ANY_CPU);
2875 }
2876
2877 goto out;
2878
2879 out_psl:
2880 rdt_pseudo_lock_release();
2881 out_mondata:
2882 if (resctrl_arch_mon_capable()) {

> 2883			mon_put_kn_priv();

2884 kernfs_remove(kn_mondata);
2885 }
2886 out_mongrp:
2887 if (resctrl_arch_mon_capable()) {
2888 rdtgroup_unassign_cntrs(&rdtgroup_default);
2889 kernfs_remove(kn_mongrp);
2890 }
2891 out_info:
2892 kernfs_remove(kn_info);
2893 out_closid_exit:
2894 closid_exit();
2895 out_schemata_free:
2896 schemata_list_destroy();
2897 rdt_disable_ctx();
2898 out_root:
2899 rdtgroup_destroy_root();
2900 out:
2901 rdt_last_cmd_clear();
2902 mutex_unlock(&rdtgroup_mutex);
2903 cpus_read_unlock();
2904 return ret;
2905 }
2906

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw
In reply to Tony Luck
kernel test robot noticed the following build errors:

Hi Tony,

kernel test robot noticed the following build errors:

[auto build test ERROR on v7.1-rc2]
[also build test ERROR on linus/master next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Luck/fs-resctrl-Free-mon_data-structures-on-rdt_get_tree-failure/20260509-184342
base:   v7.1-rc2
patch link:    https://lore.kernel.org/r/20260507201730.16509-1-tony.luck%40intel.com
patch subject: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20260509/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260509/[email protected]/reproduce)

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]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

fs/resctrl/rdtgroup.c: In function 'rdt_get_tree':

>> fs/resctrl/rdtgroup.c:2883:17: error: implicit declaration of function 'mon_put_kn_priv' [-Wimplicit-function-declaration]
    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~
   fs/resctrl/rdtgroup.c: At top level:
   fs/resctrl/rdtgroup.c:3144:13: warning: conflicting types for 'mon_put_kn_priv'; have 'void(void)'
    3144 | static void mon_put_kn_priv(void)
         |             ^~~~~~~~~~~~~~~
>> fs/resctrl/rdtgroup.c:3144:13: error: static declaration of 'mon_put_kn_priv' follows non-static declaration
   fs/resctrl/rdtgroup.c:2883:17: note: previous implicit declaration of 'mon_put_kn_priv' with type 'void(void)'
    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~

vim +/mon_put_kn_priv +2883 fs/resctrl/rdtgroup.c

2784
2785 static int rdt_get_tree(struct fs_context *fc)
2786 {
2787 struct rdt_fs_context *ctx = rdt_fc2context(fc);
2788 unsigned long flags = RFTYPE_CTRL_BASE;
2789 struct rdt_l3_mon_domain *dom;
2790 struct rdt_resource *r;
2791 int ret;
2792
2793 DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount);
2794
2795 cpus_read_lock();
2796 mutex_lock(&rdtgroup_mutex);
2797 /*
2798 * resctrl file system can only be mounted once.
2799 */
2800 if (resctrl_mounted) {
2801 ret = -EBUSY;
2802 goto out;
2803 }
2804
2805 ret = setup_rmid_lru_list();
2806 if (ret)
2807 goto out;
2808
2809 ret = rdtgroup_setup_root(ctx);
2810 if (ret)
2811 goto out;
2812
2813 ret = rdt_enable_ctx(ctx);
2814 if (ret)
2815 goto out_root;
2816
2817 ret = schemata_list_create();
2818 if (ret)
2819 goto out_schemata_free;
2820
2821 ret = closid_init();
2822 if (ret)
2823 goto out_schemata_free;
2824
2825 if (resctrl_arch_mon_capable())
2826 flags |= RFTYPE_MON;
2827
2828 ret = rdtgroup_add_files(rdtgroup_default.kn, flags);
2829 if (ret)
2830 goto out_closid_exit;
2831
2832 kernfs_activate(rdtgroup_default.kn);
2833
2834 ret = rdtgroup_create_info_dir(rdtgroup_default.kn);
2835 if (ret < 0)
2836 goto out_closid_exit;
2837
2838 if (resctrl_arch_mon_capable()) {
2839 ret = mongroup_create_dir(rdtgroup_default.kn,
2840 &rdtgroup_default, "mon_groups",
2841 &kn_mongrp);
2842 if (ret < 0)
2843 goto out_info;
2844
2845 rdtgroup_assign_cntrs(&rdtgroup_default);
2846
2847 ret = mkdir_mondata_all(rdtgroup_default.kn,
2848 &rdtgroup_default, &kn_mondata);
2849 if (ret < 0)
2850 goto out_mongrp;
2851 rdtgroup_default.mon.mon_data_kn = kn_mondata;
2852 }
2853
2854 ret = rdt_pseudo_lock_init();
2855 if (ret)
2856 goto out_mondata;
2857
2858 ret = kernfs_get_tree(fc);
2859 if (ret < 0)
2860 goto out_psl;
2861
2862 if (resctrl_arch_alloc_capable())
2863 resctrl_arch_enable_alloc();
2864 if (resctrl_arch_mon_capable())
2865 resctrl_arch_enable_mon();
2866
2867 if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable())
2868 resctrl_mounted = true;
2869
2870 if (resctrl_is_mbm_enabled()) {
2871 r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
2872 list_for_each_entry(dom, &r->mon_domains, hdr.list)
2873 mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL,
2874 RESCTRL_PICK_ANY_CPU);
2875 }
2876
2877 goto out;
2878
2879 out_psl:
2880 rdt_pseudo_lock_release();
2881 out_mondata:
2882 if (resctrl_arch_mon_capable()) {

> 2883			mon_put_kn_priv();

2884 kernfs_remove(kn_mondata);
2885 }
2886 out_mongrp:
2887 if (resctrl_arch_mon_capable()) {
2888 rdtgroup_unassign_cntrs(&rdtgroup_default);
2889 kernfs_remove(kn_mongrp);
2890 }
2891 out_info:
2892 kernfs_remove(kn_info);
2893 out_closid_exit:
2894 closid_exit();
2895 out_schemata_free:
2896 schemata_list_destroy();
2897 rdt_disable_ctx();
2898 out_root:
2899 rdtgroup_destroy_root();
2900 out:
2901 rdt_last_cmd_clear();
2902 mutex_unlock(&rdtgroup_mutex);
2903 cpus_read_unlock();
2904 return ret;
2905 }
2906

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#6 lore raw
In reply to Tony Luck
kernel test robot noticed the following build warnings:

Hi Tony,

kernel test robot noticed the following build warnings:

[auto build test WARNING on v7.1-rc2]
[also build test WARNING on linus/master next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Luck/fs-resctrl-Free-mon_data-structures-on-rdt_get_tree-failure/20260509-184342
base:   v7.1-rc2
patch link:    https://lore.kernel.org/r/20260507201730.16509-1-tony.luck%40intel.com
patch subject: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20260510/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260510/[email protected]/reproduce)

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]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

fs/resctrl/rdtgroup.c: In function 'rdt_get_tree':
fs/resctrl/rdtgroup.c:2883:17: error: implicit declaration of function 'mon_put_kn_priv' [-Wimplicit-function-declaration]

    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~
   fs/resctrl/rdtgroup.c: At top level:
>> fs/resctrl/rdtgroup.c:3144:13: warning: conflicting types for 'mon_put_kn_priv'; have 'void(void)'
    3144 | static void mon_put_kn_priv(void)
         |             ^~~~~~~~~~~~~~~
   fs/resctrl/rdtgroup.c:3144:13: error: static declaration of 'mon_put_kn_priv' follows non-static declaration
   fs/resctrl/rdtgroup.c:2883:17: note: previous implicit declaration of 'mon_put_kn_priv' with type 'void(void)'
    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~

vim +3144 fs/resctrl/rdtgroup.c

7168ae330e8105 James Morse 2025-05-15  3138  
7168ae330e8105 James Morse 2025-05-15  3139  /**
7168ae330e8105 James Morse 2025-05-15  3140   * mon_put_kn_priv() - Free all allocated mon_data structures.
7168ae330e8105 James Morse 2025-05-15  3141   *
7168ae330e8105 James Morse 2025-05-15  3142   * Called when resctrl file system is unmounted.
7168ae330e8105 James Morse 2025-05-15  3143   */
7168ae330e8105 James Morse 2025-05-15 @3144  static void mon_put_kn_priv(void)
7168ae330e8105 James Morse 2025-05-15  3145  {
7168ae330e8105 James Morse 2025-05-15  3146  	struct mon_data *priv, *tmp;
7168ae330e8105 James Morse 2025-05-15  3147  
7168ae330e8105 James Morse 2025-05-15  3148  	lockdep_assert_held(&rdtgroup_mutex);
7168ae330e8105 James Morse 2025-05-15  3149  
7168ae330e8105 James Morse 2025-05-15  3150  	list_for_each_entry_safe(priv, tmp, &mon_data_kn_priv_list, list) {
7168ae330e8105 James Morse 2025-05-15  3151  		list_del(&priv->list);
7168ae330e8105 James Morse 2025-05-15  3152  		kfree(priv);
7168ae330e8105 James Morse 2025-05-15  3153  	}
7168ae330e8105 James Morse 2025-05-15  3154  }
7168ae330e8105 James Morse 2025-05-15  3155  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#7 lore raw
In reply to Tony Luck
kernel test robot noticed the following build errors:

Hi Tony,

kernel test robot noticed the following build errors:

[auto build test ERROR on v7.1-rc2]
[also build test ERROR on linus/master next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Luck/fs-resctrl-Free-mon_data-structures-on-rdt_get_tree-failure/20260509-184342
base:   v7.1-rc2
patch link:    https://lore.kernel.org/r/20260507201730.16509-1-tony.luck%40intel.com
patch subject: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20260510/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260510/[email protected]/reproduce)

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]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

fs/resctrl/rdtgroup.c: In function 'rdt_get_tree':

>> fs/resctrl/rdtgroup.c:2883:17: error: implicit declaration of function 'mon_put_kn_priv' [-Wimplicit-function-declaration]
    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~
   fs/resctrl/rdtgroup.c: At top level:
   fs/resctrl/rdtgroup.c:3144:13: warning: conflicting types for 'mon_put_kn_priv'; have 'void(void)'
    3144 | static void mon_put_kn_priv(void)
         |             ^~~~~~~~~~~~~~~
>> fs/resctrl/rdtgroup.c:3144:13: error: static declaration of 'mon_put_kn_priv' follows non-static declaration
   fs/resctrl/rdtgroup.c:2883:17: note: previous implicit declaration of 'mon_put_kn_priv' with type 'void(void)'
    2883 |                 mon_put_kn_priv();
         |                 ^~~~~~~~~~~~~~~

vim +/mon_put_kn_priv +2883 fs/resctrl/rdtgroup.c

2784
2785 static int rdt_get_tree(struct fs_context *fc)
2786 {
2787 struct rdt_fs_context *ctx = rdt_fc2context(fc);
2788 unsigned long flags = RFTYPE_CTRL_BASE;
2789 struct rdt_l3_mon_domain *dom;
2790 struct rdt_resource *r;
2791 int ret;
2792
2793 DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount);
2794
2795 cpus_read_lock();
2796 mutex_lock(&rdtgroup_mutex);
2797 /*
2798 * resctrl file system can only be mounted once.
2799 */
2800 if (resctrl_mounted) {
2801 ret = -EBUSY;
2802 goto out;
2803 }
2804
2805 ret = setup_rmid_lru_list();
2806 if (ret)
2807 goto out;
2808
2809 ret = rdtgroup_setup_root(ctx);
2810 if (ret)
2811 goto out;
2812
2813 ret = rdt_enable_ctx(ctx);
2814 if (ret)
2815 goto out_root;
2816
2817 ret = schemata_list_create();
2818 if (ret)
2819 goto out_schemata_free;
2820
2821 ret = closid_init();
2822 if (ret)
2823 goto out_schemata_free;
2824
2825 if (resctrl_arch_mon_capable())
2826 flags |= RFTYPE_MON;
2827
2828 ret = rdtgroup_add_files(rdtgroup_default.kn, flags);
2829 if (ret)
2830 goto out_closid_exit;
2831
2832 kernfs_activate(rdtgroup_default.kn);
2833
2834 ret = rdtgroup_create_info_dir(rdtgroup_default.kn);
2835 if (ret < 0)
2836 goto out_closid_exit;
2837
2838 if (resctrl_arch_mon_capable()) {
2839 ret = mongroup_create_dir(rdtgroup_default.kn,
2840 &rdtgroup_default, "mon_groups",
2841 &kn_mongrp);
2842 if (ret < 0)
2843 goto out_info;
2844
2845 rdtgroup_assign_cntrs(&rdtgroup_default);
2846
2847 ret = mkdir_mondata_all(rdtgroup_default.kn,
2848 &rdtgroup_default, &kn_mondata);
2849 if (ret < 0)
2850 goto out_mongrp;
2851 rdtgroup_default.mon.mon_data_kn = kn_mondata;
2852 }
2853
2854 ret = rdt_pseudo_lock_init();
2855 if (ret)
2856 goto out_mondata;
2857
2858 ret = kernfs_get_tree(fc);
2859 if (ret < 0)
2860 goto out_psl;
2861
2862 if (resctrl_arch_alloc_capable())
2863 resctrl_arch_enable_alloc();
2864 if (resctrl_arch_mon_capable())
2865 resctrl_arch_enable_mon();
2866
2867 if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable())
2868 resctrl_mounted = true;
2869
2870 if (resctrl_is_mbm_enabled()) {
2871 r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
2872 list_for_each_entry(dom, &r->mon_domains, hdr.list)
2873 mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL,
2874 RESCTRL_PICK_ANY_CPU);
2875 }
2876
2877 goto out;
2878
2879 out_psl:
2880 rdt_pseudo_lock_release();
2881 out_mondata:
2882 if (resctrl_arch_mon_capable()) {

> 2883			mon_put_kn_priv();

2884 kernfs_remove(kn_mondata);
2885 }
2886 out_mongrp:
2887 if (resctrl_arch_mon_capable()) {
2888 rdtgroup_unassign_cntrs(&rdtgroup_default);
2889 kernfs_remove(kn_mongrp);
2890 }
2891 out_info:
2892 kernfs_remove(kn_info);
2893 out_closid_exit:
2894 closid_exit();
2895 out_schemata_free:
2896 schemata_list_destroy();
2897 rdt_disable_ctx();
2898 out_root:
2899 rdtgroup_destroy_root();
2900 out:
2901 rdt_last_cmd_clear();
2902 mutex_unlock(&rdtgroup_mutex);
2903 cpus_read_unlock();
2904 return ret;
2905 }
2906

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki