All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Yaxiong Tian <iambestgod@qq.com>, rafael@kernel.org, lukasz.luba@arm.com
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yaxiong Tian <tianyaxiong@kylinos.cn>
Subject: Re: [PATCH v2] PM: EM: Fix potential division-by-zero error in em_compute_costs()
Date: Sat, 12 Apr 2025 09:55:12 +0800	[thread overview]
Message-ID: <202504120921.Wqmipx6e-lkp@intel.com> (raw)
In-Reply-To: <tencent_EE27C7D1D6BDB3EE57A2C467CC59A866C405@qq.com>

Hi Yaxiong,

kernel test robot noticed the following build warnings:

[auto build test WARNING on amd-pstate/linux-next]
[also build test WARNING on amd-pstate/bleeding-edge linus/master v6.15-rc1 next-20250411]
[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/Yaxiong-Tian/PM-EM-Fix-potential-division-by-zero-error-in-em_compute_costs/20250411-093452
base:   https://git.kernel.org/pub/scm/linux/kernel/git/superm1/linux.git linux-next
patch link:    https://lore.kernel.org/r/tencent_EE27C7D1D6BDB3EE57A2C467CC59A866C405%40qq.com
patch subject: [PATCH v2] PM: EM: Fix potential division-by-zero error in em_compute_costs()
config: i386-buildonly-randconfig-003-20250412 (https://download.01.org/0day-ci/archive/20250412/202504120921.Wqmipx6e-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250412/202504120921.Wqmipx6e-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/202504120921.Wqmipx6e-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/power/energy_model.c:247:14: warning: variable 'cost' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     247 |                 } else if (_is_cpu_device(dev)) {
         |                            ^~~~~~~~~~~~~~~~~~~
   kernel/power/energy_model.c:253:19: note: uninitialized use occurs here
     253 |                 table[i].cost = cost;
         |                                 ^~~~
   kernel/power/energy_model.c:247:10: note: remove the 'if' if its condition is always true
     247 |                 } else if (_is_cpu_device(dev)) {
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~
   kernel/power/energy_model.c:238:32: note: initialize the variable 'cost' to silence this warning
     238 |                 unsigned long power_res, cost;
         |                                              ^
         |                                               = 0
   1 warning generated.


vim +247 kernel/power/energy_model.c

   228	
   229	static int em_compute_costs(struct device *dev, struct em_perf_state *table,
   230				    const struct em_data_callback *cb, int nr_states,
   231				    unsigned long flags)
   232	{
   233		unsigned long prev_cost = ULONG_MAX;
   234		int i, ret;
   235	
   236		/* Compute the cost of each performance state. */
   237		for (i = nr_states - 1; i >= 0; i--) {
   238			unsigned long power_res, cost;
   239	
   240			if ((flags & EM_PERF_DOMAIN_ARTIFICIAL) && cb->get_cost) {
   241				ret = cb->get_cost(dev, table[i].frequency, &cost);
   242				if (ret || !cost || cost > EM_MAX_POWER) {
   243					dev_err(dev, "EM: invalid cost %lu %d\n",
   244						cost, ret);
   245					return -EINVAL;
   246				}
 > 247			} else if (_is_cpu_device(dev)) {
   248				/* increase resolution of 'cost' precision */
   249				power_res = table[i].power * 10;
   250				cost = power_res / table[i].performance;
   251			}
   252	
   253			table[i].cost = cost;
   254	
   255			if (table[i].cost >= prev_cost) {
   256				table[i].flags = EM_PERF_STATE_INEFFICIENT;
   257				dev_dbg(dev, "EM: OPP:%lu is inefficient\n",
   258					table[i].frequency);
   259			} else {
   260				prev_cost = table[i].cost;
   261			}
   262		}
   263	
   264		return 0;
   265	}
   266	

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

  reply	other threads:[~2025-04-12  1:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11  1:28 [PATCH v2] PM: EM: Fix potential division-by-zero error in em_compute_costs() Yaxiong Tian
2025-04-12  1:55 ` kernel test robot [this message]
2025-04-14  8:08 ` Lukasz Luba
2025-04-14  9:08   ` Yaxiong Tian
2025-04-17  7:20     ` Geert Uytterhoeven
2025-04-17  7:41       ` Yaxiong Tian
2025-04-15  1:12   ` Yaxiong Tian
2025-04-15  1:58     ` Yaxiong Tian
2025-04-15 17:19       ` Rafael J. Wysocki
2025-04-14  9:04 ` [PATCH v3] " Yaxiong Tian
2025-04-15  8:50   ` Lukasz Luba
2025-04-15 17:17   ` Rafael J. Wysocki
2025-04-16  2:56     ` Yaxiong Tian
2025-04-16 11:58       ` Rafael J. Wysocki
2025-04-16 15:26         ` Lukasz Luba
2025-04-17  0:56         ` Yaxiong Tian
2025-04-17  1:07 ` [PATCH v4] " Yaxiong Tian
2025-04-17  5:57   ` Lukasz Luba
2025-04-17  7:43     ` Yaxiong Tian
2025-04-17 13:27       ` Lukasz Luba
2025-04-18  1:26         ` Yaxiong Tian
2025-04-28  1:45           ` Yaxiong Tian

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=202504120921.Wqmipx6e-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=iambestgod@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=lukasz.luba@arm.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rafael@kernel.org \
    --cc=tianyaxiong@kylinos.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.