The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Moger, Babu" <babu.moger@amd.com>
To: Borislav Petkov <bp@alien8.de>, kernel test robot <lkp@intel.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	x86@kernel.org, Reinette Chatre <reinette.chatre@intel.com>,
	Julia Lawall <Julia.Lawall@inria.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	cocci@inria.fr
Subject: Re: [tip:x86/cache 3/3] arch/x86/kernel/cpu/resctrl/rdtgroup.c:1621:5-8: Unneeded variable: "ret". Return " 0" on line 1655
Date: Wed, 24 Jan 2024 08:58:27 -0600	[thread overview]
Message-ID: <0578da80-db4c-4c0b-8677-2875a65afd68@amd.com> (raw)
In-Reply-To: <20240124105555.GBZbDsu-zsQ8YTgXjS@fat_crate.local>

Hi Boris,

On 1/24/24 04:55, Borislav Petkov wrote:
> On Wed, Jan 24, 2024 at 06:31:41PM +0800, kernel test robot wrote:
>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/cache
>> head:   54e35eb8611cce5550d3d7689679b1a91c864f28
>> commit: 54e35eb8611cce5550d3d7689679b1a91c864f28 [3/3] x86/resctrl: Read supported bandwidth sources from CPUID
>> config: x86_64-randconfig-102-20240124 (https://download.01.org/0day-ci/archive/20240124/202401241810.jbd8Ipa1-lkp@intel.com/config)
>> compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
>>
>> 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/202401241810.jbd8Ipa1-lkp@intel.com/
>>
>> cocci warnings: (new ones prefixed by >>)
>>>> arch/x86/kernel/cpu/resctrl/rdtgroup.c:1621:5-8: Unneeded variable: "ret". Return "  0" on line 1655

Hmm Interesting..

Looking at the code, I see the ret variable is really not required.

The following patch should fix the problem. Let me know if you want me to
send the patch officially. Thanks

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 2b69e560b05f..6057f96df73f 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1618,7 +1618,6 @@ static int mbm_config_write_domain(struct
rdt_resource *r,
                                   struct rdt_domain *d, u32 evtid, u32 val)
 {
        struct mon_config_info mon_info = {0};
-       int ret = 0;

        /*
         * Read the current config value first. If both are the same then
@@ -1652,7 +1651,7 @@ static int mbm_config_write_domain(struct
rdt_resource *r,
        resctrl_arch_reset_rmid_all(r, d);

 out:
-       return ret;
+       return 0;
 }

 static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)

> 
> Well, AFAICT, even with the tree checked out at
> 
> 92bd5a139033 ("x86/resctrl: Add interface to write mbm_total_bytes_config")
> 
> which is the first patch that added this function, ret is unneeded.
> 
> But scripts/coccinelle/misc/returnvar.cocci doesn't warn about it then,
> only now that that hunk with the "return -EINVAL;" is removed in the
> patch you're reporting this against.
> 
> Lemme add some cocci people to Cc for comment and leave the rest for
> reference.
> 
> Thx.
> 
>> vim +1621 arch/x86/kernel/cpu/resctrl/rdtgroup.c
>>
>> 92bd5a1390335b Babu Moger 2023-01-13  1616  
>> 92bd5a1390335b Babu Moger 2023-01-13  1617  static int mbm_config_write_domain(struct rdt_resource *r,
>> 92bd5a1390335b Babu Moger 2023-01-13  1618  				   struct rdt_domain *d, u32 evtid, u32 val)
>> 92bd5a1390335b Babu Moger 2023-01-13  1619  {
>> 92bd5a1390335b Babu Moger 2023-01-13  1620  	struct mon_config_info mon_info = {0};
>> 92bd5a1390335b Babu Moger 2023-01-13 @1621  	int ret = 0;
>> 92bd5a1390335b Babu Moger 2023-01-13  1622  
>> 92bd5a1390335b Babu Moger 2023-01-13  1623  	/*
>> 92bd5a1390335b Babu Moger 2023-01-13  1624  	 * Read the current config value first. If both are the same then
>> 92bd5a1390335b Babu Moger 2023-01-13  1625  	 * no need to write it again.
>> 92bd5a1390335b Babu Moger 2023-01-13  1626  	 */
>> 92bd5a1390335b Babu Moger 2023-01-13  1627  	mon_info.evtid = evtid;
>> 92bd5a1390335b Babu Moger 2023-01-13  1628  	mondata_config_read(d, &mon_info);
>> 92bd5a1390335b Babu Moger 2023-01-13  1629  	if (mon_info.mon_config == val)
>> 92bd5a1390335b Babu Moger 2023-01-13  1630  		goto out;
>> 92bd5a1390335b Babu Moger 2023-01-13  1631  
>> 92bd5a1390335b Babu Moger 2023-01-13  1632  	mon_info.mon_config = val;
>> 92bd5a1390335b Babu Moger 2023-01-13  1633  
>> 92bd5a1390335b Babu Moger 2023-01-13  1634  	/*
>> 92bd5a1390335b Babu Moger 2023-01-13  1635  	 * Update MSR_IA32_EVT_CFG_BASE MSR on one of the CPUs in the
>> 92bd5a1390335b Babu Moger 2023-01-13  1636  	 * domain. The MSRs offset from MSR MSR_IA32_EVT_CFG_BASE
>> 92bd5a1390335b Babu Moger 2023-01-13  1637  	 * are scoped at the domain level. Writing any of these MSRs
>> 92bd5a1390335b Babu Moger 2023-01-13  1638  	 * on one CPU is observed by all the CPUs in the domain.
>> 92bd5a1390335b Babu Moger 2023-01-13  1639  	 */
>> 92bd5a1390335b Babu Moger 2023-01-13  1640  	smp_call_function_any(&d->cpu_mask, mon_event_config_write,
>> 92bd5a1390335b Babu Moger 2023-01-13  1641  			      &mon_info, 1);
>> 92bd5a1390335b Babu Moger 2023-01-13  1642  
>> 92bd5a1390335b Babu Moger 2023-01-13  1643  	/*
>> 92bd5a1390335b Babu Moger 2023-01-13  1644  	 * When an Event Configuration is changed, the bandwidth counters
>> 92bd5a1390335b Babu Moger 2023-01-13  1645  	 * for all RMIDs and Events will be cleared by the hardware. The
>> 92bd5a1390335b Babu Moger 2023-01-13  1646  	 * hardware also sets MSR_IA32_QM_CTR.Unavailable (bit 62) for
>> 92bd5a1390335b Babu Moger 2023-01-13  1647  	 * every RMID on the next read to any event for every RMID.
>> 92bd5a1390335b Babu Moger 2023-01-13  1648  	 * Subsequent reads will have MSR_IA32_QM_CTR.Unavailable (bit 62)
>> 92bd5a1390335b Babu Moger 2023-01-13  1649  	 * cleared while it is tracked by the hardware. Clear the
>> 92bd5a1390335b Babu Moger 2023-01-13  1650  	 * mbm_local and mbm_total counts for all the RMIDs.
>> 92bd5a1390335b Babu Moger 2023-01-13  1651  	 */
>> 92bd5a1390335b Babu Moger 2023-01-13  1652  	resctrl_arch_reset_rmid_all(r, d);
>> 92bd5a1390335b Babu Moger 2023-01-13  1653  
>> 92bd5a1390335b Babu Moger 2023-01-13  1654  out:
>> 92bd5a1390335b Babu Moger 2023-01-13 @1655  	return ret;
>> 92bd5a1390335b Babu Moger 2023-01-13  1656  }
>> 92bd5a1390335b Babu Moger 2023-01-13  1657  
>>
>> :::::: The code at line 1621 was first introduced by commit
>> :::::: 92bd5a1390335bb3cc76bdf1b4356edbc94d408d x86/resctrl: Add interface to write mbm_total_bytes_config
>>
>> :::::: TO: Babu Moger <babu.moger@amd.com>
>> :::::: CC: Borislav Petkov (AMD) <bp@alien8.de>
>>
>> -- 
>> 0-DAY CI Kernel Test Service
>> https://github.com/intel/lkp-tests/wiki
> 

-- 
Thanks
Babu Moger

  reply	other threads:[~2024-01-24 14:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 10:31 [tip:x86/cache 3/3] arch/x86/kernel/cpu/resctrl/rdtgroup.c:1621:5-8: Unneeded variable: "ret". Return " 0" on line 1655 kernel test robot
2024-01-24 10:55 ` Borislav Petkov
2024-01-24 14:58   ` Moger, Babu [this message]
2024-01-24 16:00     ` Borislav Petkov
2024-01-24 17:52 ` [PATCH] x86/resctrl: Fix unneeded variable warning reported by kernel test robot Babu Moger
2024-01-24 18:25   ` Reinette Chatre
2024-01-24 18:31     ` Borislav Petkov
2024-01-24 18:51       ` Reinette Chatre
2024-01-24 19:14         ` Borislav Petkov
2024-01-24 19:39           ` Moger, Babu
2024-01-24 20:48             ` Borislav Petkov
2024-01-24 20:04           ` Reinette Chatre
2024-01-24 20:45             ` Borislav Petkov
2024-01-24 21:31               ` Reinette Chatre
2024-01-24 22:46                 ` Borislav Petkov
2024-01-24 23:03                   ` Reinette Chatre
2024-01-24 23:34                     ` Borislav Petkov
2024-01-24 23:41                       ` Borislav Petkov
2024-01-25  0:12                       ` Reinette Chatre
2024-01-24 23:50 ` [tip: x86/cache] x86/resctrl: Remove redundant variable in mbm_config_write_domain() tip-bot2 for Babu Moger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0578da80-db4c-4c0b-8677-2875a65afd68@amd.com \
    --to=babu.moger@amd.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=bp@alien8.de \
    --cc=cocci@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=nicolas.palix@imag.fr \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=reinette.chatre@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox