Inconsistent context format. Optimize it,
not only save a line and also make it easier to understand.
Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
fs/resctrl/rdtgroup.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 1beb124e25f6..8bf87211eadb 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2608,10 +2608,8 @@ static int rdt_get_tree(struct fs_context *fc)
goto out_root;
ret = schemata_list_create();
- if (ret) {
- schemata_list_destroy();
- goto out_ctx;
- }
+ if (ret)
+ goto out_schemata_free;
ret = closid_init();
if (ret)
--
2.43.5
Hi Shaopeng, On 6/10/25 7:15 PM, Shaopeng Tan wrote: > Inconsistent context format. Optimize it, What does "Inconsistent context format" mean? > not only save a line and also make it easier to understand. The changelog needs to follow rules found in "Changelog" section of Documentation/process/maintainer-tip.rst. Here is an example: schemata_list_destroy() has to be called if schemata_list_create() fails. rdt_get_tree() calls schemata_list_destroy() in two different ways: directly if schemata_list_create() itself fails and on the exit path via the out_schemata_free goto label. Remove schemata_list_destroy() call on schemata_list_create() failure. Use existing out_schemata_free goto label instead. > > Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> > --- > fs/resctrl/rdtgroup.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c > index 1beb124e25f6..8bf87211eadb 100644 > --- a/fs/resctrl/rdtgroup.c > +++ b/fs/resctrl/rdtgroup.c > @@ -2608,10 +2608,8 @@ static int rdt_get_tree(struct fs_context *fc) > goto out_root; > > ret = schemata_list_create(); > - if (ret) { > - schemata_list_destroy(); > - goto out_ctx; > - } > + if (ret) > + goto out_schemata_free; > > ret = closid_init(); > if (ret) Please address the issue of now unused "out_ctx" label reported in [1]. Looks good to me otherwise. Thank you for the cleanup. Reinette [1] https://lore.kernel.org/lkml/202506120440.lz9OAoXE-lkp@intel.com/
Hi Shaopeng, One small follow-up ... since this is a resctrl fs change, could you please switch prefix to be "fs/resctrl"? Thank you Reinette
Hi Shaopeng, kernel test robot noticed the following build warnings: [auto build test WARNING on tip/master] [also build test WARNING on brauner-vfs/vfs.all linus/master v6.16-rc1 next-20250611] [cannot apply to tip/auto-latest bp/for-next] [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/Shaopeng-Tan/x86-resctrl-Remove-unnecessary-cpumask_nth_andnot/20250611-104547 base: tip/master patch link: https://lore.kernel.org/r/20250611021547.2766889-3-tan.shaopeng%40jp.fujitsu.com patch subject: [PATCH 2/2] x86/resctrl: Optimize code in rdt_get_tree() config: x86_64-randconfig-002-20250612 (https://download.01.org/0day-ci/archive/20250612/202506120440.lz9OAoXE-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250612/202506120440.lz9OAoXE-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/202506120440.lz9OAoXE-lkp@intel.com/ All warnings (new ones prefixed by >>): fs/resctrl/rdtgroup.c: In function 'rdt_get_tree': >> fs/resctrl/rdtgroup.c:2684:1: warning: label 'out_ctx' defined but not used [-Wunused-label] 2684 | out_ctx: | ^~~~~~~ vim +/out_ctx +2684 fs/resctrl/rdtgroup.c 7168ae330e8105 James Morse 2025-05-15 2583 7168ae330e8105 James Morse 2025-05-15 2584 static int rdt_get_tree(struct fs_context *fc) 7168ae330e8105 James Morse 2025-05-15 2585 { 7168ae330e8105 James Morse 2025-05-15 2586 struct rdt_fs_context *ctx = rdt_fc2context(fc); 7168ae330e8105 James Morse 2025-05-15 2587 unsigned long flags = RFTYPE_CTRL_BASE; 7168ae330e8105 James Morse 2025-05-15 2588 struct rdt_mon_domain *dom; 7168ae330e8105 James Morse 2025-05-15 2589 struct rdt_resource *r; 7168ae330e8105 James Morse 2025-05-15 2590 int ret; 7168ae330e8105 James Morse 2025-05-15 2591 7168ae330e8105 James Morse 2025-05-15 2592 cpus_read_lock(); 7168ae330e8105 James Morse 2025-05-15 2593 mutex_lock(&rdtgroup_mutex); 7168ae330e8105 James Morse 2025-05-15 2594 /* 7168ae330e8105 James Morse 2025-05-15 2595 * resctrl file system can only be mounted once. 7168ae330e8105 James Morse 2025-05-15 2596 */ 7168ae330e8105 James Morse 2025-05-15 2597 if (resctrl_mounted) { 7168ae330e8105 James Morse 2025-05-15 2598 ret = -EBUSY; 7168ae330e8105 James Morse 2025-05-15 2599 goto out; 7168ae330e8105 James Morse 2025-05-15 2600 } 7168ae330e8105 James Morse 2025-05-15 2601 7168ae330e8105 James Morse 2025-05-15 2602 ret = rdtgroup_setup_root(ctx); 7168ae330e8105 James Morse 2025-05-15 2603 if (ret) 7168ae330e8105 James Morse 2025-05-15 2604 goto out; 7168ae330e8105 James Morse 2025-05-15 2605 7168ae330e8105 James Morse 2025-05-15 2606 ret = rdt_enable_ctx(ctx); 7168ae330e8105 James Morse 2025-05-15 2607 if (ret) 7168ae330e8105 James Morse 2025-05-15 2608 goto out_root; 7168ae330e8105 James Morse 2025-05-15 2609 7168ae330e8105 James Morse 2025-05-15 2610 ret = schemata_list_create(); b67b139e5b652e Shaopeng Tan 2025-06-11 2611 if (ret) b67b139e5b652e Shaopeng Tan 2025-06-11 2612 goto out_schemata_free; 7168ae330e8105 James Morse 2025-05-15 2613 7168ae330e8105 James Morse 2025-05-15 2614 ret = closid_init(); 7168ae330e8105 James Morse 2025-05-15 2615 if (ret) 7168ae330e8105 James Morse 2025-05-15 2616 goto out_schemata_free; 7168ae330e8105 James Morse 2025-05-15 2617 7168ae330e8105 James Morse 2025-05-15 2618 if (resctrl_arch_mon_capable()) 7168ae330e8105 James Morse 2025-05-15 2619 flags |= RFTYPE_MON; 7168ae330e8105 James Morse 2025-05-15 2620 7168ae330e8105 James Morse 2025-05-15 2621 ret = rdtgroup_add_files(rdtgroup_default.kn, flags); 7168ae330e8105 James Morse 2025-05-15 2622 if (ret) 7168ae330e8105 James Morse 2025-05-15 2623 goto out_closid_exit; 7168ae330e8105 James Morse 2025-05-15 2624 7168ae330e8105 James Morse 2025-05-15 2625 kernfs_activate(rdtgroup_default.kn); 7168ae330e8105 James Morse 2025-05-15 2626 7168ae330e8105 James Morse 2025-05-15 2627 ret = rdtgroup_create_info_dir(rdtgroup_default.kn); 7168ae330e8105 James Morse 2025-05-15 2628 if (ret < 0) 7168ae330e8105 James Morse 2025-05-15 2629 goto out_closid_exit; 7168ae330e8105 James Morse 2025-05-15 2630 7168ae330e8105 James Morse 2025-05-15 2631 if (resctrl_arch_mon_capable()) { 7168ae330e8105 James Morse 2025-05-15 2632 ret = mongroup_create_dir(rdtgroup_default.kn, 7168ae330e8105 James Morse 2025-05-15 2633 &rdtgroup_default, "mon_groups", 7168ae330e8105 James Morse 2025-05-15 2634 &kn_mongrp); 7168ae330e8105 James Morse 2025-05-15 2635 if (ret < 0) 7168ae330e8105 James Morse 2025-05-15 2636 goto out_info; 7168ae330e8105 James Morse 2025-05-15 2637 7168ae330e8105 James Morse 2025-05-15 2638 ret = mkdir_mondata_all(rdtgroup_default.kn, 7168ae330e8105 James Morse 2025-05-15 2639 &rdtgroup_default, &kn_mondata); 7168ae330e8105 James Morse 2025-05-15 2640 if (ret < 0) 7168ae330e8105 James Morse 2025-05-15 2641 goto out_mongrp; 7168ae330e8105 James Morse 2025-05-15 2642 rdtgroup_default.mon.mon_data_kn = kn_mondata; 7168ae330e8105 James Morse 2025-05-15 2643 } 7168ae330e8105 James Morse 2025-05-15 2644 7168ae330e8105 James Morse 2025-05-15 2645 ret = rdt_pseudo_lock_init(); 7168ae330e8105 James Morse 2025-05-15 2646 if (ret) 7168ae330e8105 James Morse 2025-05-15 2647 goto out_mondata; 7168ae330e8105 James Morse 2025-05-15 2648 7168ae330e8105 James Morse 2025-05-15 2649 ret = kernfs_get_tree(fc); 7168ae330e8105 James Morse 2025-05-15 2650 if (ret < 0) 7168ae330e8105 James Morse 2025-05-15 2651 goto out_psl; 7168ae330e8105 James Morse 2025-05-15 2652 7168ae330e8105 James Morse 2025-05-15 2653 if (resctrl_arch_alloc_capable()) 7168ae330e8105 James Morse 2025-05-15 2654 resctrl_arch_enable_alloc(); 7168ae330e8105 James Morse 2025-05-15 2655 if (resctrl_arch_mon_capable()) 7168ae330e8105 James Morse 2025-05-15 2656 resctrl_arch_enable_mon(); 7168ae330e8105 James Morse 2025-05-15 2657 7168ae330e8105 James Morse 2025-05-15 2658 if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable()) 7168ae330e8105 James Morse 2025-05-15 2659 resctrl_mounted = true; 7168ae330e8105 James Morse 2025-05-15 2660 7168ae330e8105 James Morse 2025-05-15 2661 if (resctrl_is_mbm_enabled()) { 7168ae330e8105 James Morse 2025-05-15 2662 r = resctrl_arch_get_resource(RDT_RESOURCE_L3); 7168ae330e8105 James Morse 2025-05-15 2663 list_for_each_entry(dom, &r->mon_domains, hdr.list) 7168ae330e8105 James Morse 2025-05-15 2664 mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL, 7168ae330e8105 James Morse 2025-05-15 2665 RESCTRL_PICK_ANY_CPU); 7168ae330e8105 James Morse 2025-05-15 2666 } 7168ae330e8105 James Morse 2025-05-15 2667 7168ae330e8105 James Morse 2025-05-15 2668 goto out; 7168ae330e8105 James Morse 2025-05-15 2669 7168ae330e8105 James Morse 2025-05-15 2670 out_psl: 7168ae330e8105 James Morse 2025-05-15 2671 rdt_pseudo_lock_release(); 7168ae330e8105 James Morse 2025-05-15 2672 out_mondata: 7168ae330e8105 James Morse 2025-05-15 2673 if (resctrl_arch_mon_capable()) 7168ae330e8105 James Morse 2025-05-15 2674 kernfs_remove(kn_mondata); 7168ae330e8105 James Morse 2025-05-15 2675 out_mongrp: 7168ae330e8105 James Morse 2025-05-15 2676 if (resctrl_arch_mon_capable()) 7168ae330e8105 James Morse 2025-05-15 2677 kernfs_remove(kn_mongrp); 7168ae330e8105 James Morse 2025-05-15 2678 out_info: 7168ae330e8105 James Morse 2025-05-15 2679 kernfs_remove(kn_info); 7168ae330e8105 James Morse 2025-05-15 2680 out_closid_exit: 7168ae330e8105 James Morse 2025-05-15 2681 closid_exit(); 7168ae330e8105 James Morse 2025-05-15 2682 out_schemata_free: 7168ae330e8105 James Morse 2025-05-15 2683 schemata_list_destroy(); 7168ae330e8105 James Morse 2025-05-15 @2684 out_ctx: 7168ae330e8105 James Morse 2025-05-15 2685 rdt_disable_ctx(); 7168ae330e8105 James Morse 2025-05-15 2686 out_root: 7168ae330e8105 James Morse 2025-05-15 2687 rdtgroup_destroy_root(); 7168ae330e8105 James Morse 2025-05-15 2688 out: 7168ae330e8105 James Morse 2025-05-15 2689 rdt_last_cmd_clear(); 7168ae330e8105 James Morse 2025-05-15 2690 mutex_unlock(&rdtgroup_mutex); 7168ae330e8105 James Morse 2025-05-15 2691 cpus_read_unlock(); 7168ae330e8105 James Morse 2025-05-15 2692 return ret; 7168ae330e8105 James Morse 2025-05-15 2693 } 7168ae330e8105 James Morse 2025-05-15 2694 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.