The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
@ 2026-05-07 20:17 Tony Luck
  2026-05-07 20:21 ` Luck, Tony
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Tony Luck @ 2026-05-07 20:17 UTC (permalink / raw)
  To: Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman, Peter Newman,
	James Morse, Babu Moger, Drew Fustini, Dave Martin, Chen Yu
  Cc: Borislav Petkov, x86, linux-kernel, patches, Tony Luck

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")
Reported-by: Reinette Chatre <reinette.chatre@intel.com>
Assisted-by: GitHub Copilot CLI:claude-sonnet-4.6
Signed-off-by: Tony Luck <tony.luck@intel.com>
---

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 <reinette.chatre@intel.com> 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(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5dfdaa6f9d8f..aad573b62fd7 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -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);
-- 
2.54.0


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

* RE: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
@ 2026-05-07 20:21 ` Luck, Tony
  2026-05-07 20:43 ` Reinette Chatre
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Luck, Tony @ 2026-05-07 20:21 UTC (permalink / raw)
  To: Fenghua Yu, Chatre, Reinette, Wieczor-Retman, Maciej,
	Peter Newman, James Morse, Babu Moger, Drew Fustini, Dave Martin,
	Chen, Yu C
  Cc: Borislav Petkov, x86@kernel.org, linux-kernel@vger.kernel.org,
	patches@lists.linux.dev

> 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

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

* Re: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
  2026-05-07 20:21 ` Luck, Tony
@ 2026-05-07 20:43 ` Reinette Chatre
  2026-05-09 17:21 ` kernel test robot
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Reinette Chatre @ 2026-05-07 20:43 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Maciej Wieczor-Retman, Peter Newman,
	James Morse, Babu Moger, Drew Fustini, Dave Martin, Chen Yu
  Cc: Borislav Petkov, x86, linux-kernel, patches

Hi Tony,

On 5/7/26 1:17 PM, Tony Luck wrote:
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 5dfdaa6f9d8f..aad573b62fd7 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -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);

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/5d38c1fb-8f91-472b-8897-24b2f50c772b@intel.com/

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

* Re: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
  2026-05-07 20:21 ` Luck, Tony
  2026-05-07 20:43 ` Reinette Chatre
@ 2026-05-09 17:21 ` kernel test robot
  2026-05-09 18:18 ` kernel test robot
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-05-09 17:21 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman,
	Peter Newman, James Morse, Babu Moger, Drew Fustini, Dave Martin,
	Chen Yu
  Cc: oe-kbuild-all, Borislav Petkov, x86, linux-kernel, patches,
	Tony Luck

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/202605091918.1k5t3HFX-lkp@intel.com/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/202605091918.1k5t3HFX-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605091918.1k5t3HFX-lkp@intel.com/

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

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

* Re: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
                   ` (2 preceding siblings ...)
  2026-05-09 17:21 ` kernel test robot
@ 2026-05-09 18:18 ` kernel test robot
  2026-05-09 18:53 ` kernel test robot
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-05-09 18:18 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman,
	Peter Newman, James Morse, Babu Moger, Drew Fustini, Dave Martin,
	Chen Yu
  Cc: llvm, oe-kbuild-all, Borislav Petkov, x86, linux-kernel, patches,
	Tony Luck

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/202605100235.vTKbmFSo-lkp@intel.com/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/202605100235.vTKbmFSo-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605100235.vTKbmFSo-lkp@intel.com/

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	

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

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

* Re: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
                   ` (3 preceding siblings ...)
  2026-05-09 18:18 ` kernel test robot
@ 2026-05-09 18:53 ` kernel test robot
  2026-05-09 20:25 ` kernel test robot
  2026-05-10  4:27 ` kernel test robot
  6 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-05-09 18:53 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman,
	Peter Newman, James Morse, Babu Moger, Drew Fustini, Dave Martin,
	Chen Yu
  Cc: oe-kbuild-all, Borislav Petkov, x86, linux-kernel, patches,
	Tony Luck

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/202605092051.BqXDw4a6-lkp@intel.com/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/202605092051.BqXDw4a6-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605092051.BqXDw4a6-lkp@intel.com/

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

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

* Re: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
                   ` (4 preceding siblings ...)
  2026-05-09 18:53 ` kernel test robot
@ 2026-05-09 20:25 ` kernel test robot
  2026-05-10  4:27 ` kernel test robot
  6 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-05-09 20:25 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman,
	Peter Newman, James Morse, Babu Moger, Drew Fustini, Dave Martin,
	Chen Yu
  Cc: oe-kbuild-all, Borislav Petkov, x86, linux-kernel, patches,
	Tony Luck

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/202605100458.mxl1D57O-lkp@intel.com/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/202605100458.mxl1D57O-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605100458.mxl1D57O-lkp@intel.com/

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

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

* Re: [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure
  2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
                   ` (5 preceding siblings ...)
  2026-05-09 20:25 ` kernel test robot
@ 2026-05-10  4:27 ` kernel test robot
  6 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-05-10  4:27 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Maciej Wieczor-Retman,
	Peter Newman, James Morse, Babu Moger, Drew Fustini, Dave Martin,
	Chen Yu
  Cc: oe-kbuild-all, Borislav Petkov, x86, linux-kernel, patches,
	Tony Luck

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/202605101202.R93VjWIJ-lkp@intel.com/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/202605101202.R93VjWIJ-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605101202.R93VjWIJ-lkp@intel.com/

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

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

end of thread, other threads:[~2026-05-10  4:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 20:17 [PATCH] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Tony Luck
2026-05-07 20:21 ` Luck, Tony
2026-05-07 20:43 ` Reinette Chatre
2026-05-09 17:21 ` kernel test robot
2026-05-09 18:18 ` kernel test robot
2026-05-09 18:53 ` kernel test robot
2026-05-09 20:25 ` kernel test robot
2026-05-10  4:27 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox