From: kbuild test robot <lkp@intel.com>
To: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
Cc: kbuild-all@lists.01.org, linux-btrfs@vger.kernel.org,
Josef Bacik <josef@toxicpanda.com>
Subject: [josef-btrfs:zygo-reworked 74/75] fs//btrfs/extent-tree.c:2096:53: warning: integer overflow in expression
Date: Tue, 10 Mar 2020 06:06:46 +0800 [thread overview]
Message-ID: <202003100642.vaMgXFAQ%lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5277 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/josef/btrfs-next.git zygo-reworked
head: 298bd0d9427133e845fe0c781edcf0f8bcb2325d
commit: 982c26add9a6aef4f44f1215de139c2d93d990de [74/75] btrfs: use a stable rolling avg for delayed refs avg
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 982c26add9a6aef4f44f1215de139c2d93d990de
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sh
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
fs//btrfs/extent-tree.c: In function '__btrfs_run_delayed_refs':
>> fs//btrfs/extent-tree.c:2096:53: warning: integer overflow in expression [-Woverflow]
if (fs_info->delayed_ref_runtime >= (NSEC_PER_SEC * 1000) &&
^
vim +2096 fs//btrfs/extent-tree.c
1997
1998 /*
1999 * Returns 0 on success or if called with an already aborted transaction.
2000 * Returns -ENOMEM or -EIO on failure and will abort the transaction.
2001 */
2002 static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2003 unsigned long nr)
2004 {
2005 struct btrfs_fs_info *fs_info = trans->fs_info;
2006 struct btrfs_delayed_ref_root *delayed_refs;
2007 struct btrfs_delayed_ref_head *locked_ref = NULL;
2008 ktime_t start = ktime_get();
2009 int ret;
2010 unsigned long count = 0;
2011 unsigned long actual_count = 0;
2012
2013 delayed_refs = &trans->transaction->delayed_refs;
2014 do {
2015 if (!locked_ref) {
2016 locked_ref = btrfs_obtain_ref_head(trans);
2017 if (IS_ERR_OR_NULL(locked_ref)) {
2018 if (PTR_ERR(locked_ref) == -EAGAIN) {
2019 continue;
2020 } else {
2021 break;
2022 }
2023 }
2024 count++;
2025 }
2026 /*
2027 * We need to try and merge add/drops of the same ref since we
2028 * can run into issues with relocate dropping the implicit ref
2029 * and then it being added back again before the drop can
2030 * finish. If we merged anything we need to re-loop so we can
2031 * get a good ref.
2032 * Or we can get node references of the same type that weren't
2033 * merged when created due to bumps in the tree mod seq, and
2034 * we need to merge them to prevent adding an inline extent
2035 * backref before dropping it (triggering a BUG_ON at
2036 * insert_inline_extent_backref()).
2037 */
2038 spin_lock(&locked_ref->lock);
2039 btrfs_merge_delayed_refs(trans, delayed_refs, locked_ref);
2040
2041 ret = btrfs_run_delayed_refs_for_head(trans, locked_ref,
2042 &actual_count);
2043 if (ret < 0 && ret != -EAGAIN) {
2044 /*
2045 * Error, btrfs_run_delayed_refs_for_head already
2046 * unlocked everything so just bail out
2047 */
2048 return ret;
2049 } else if (!ret) {
2050 /*
2051 * Success, perform the usual cleanup of a processed
2052 * head
2053 */
2054 ret = cleanup_ref_head(trans, locked_ref);
2055 if (ret > 0 ) {
2056 /* We dropped our lock, we need to loop. */
2057 ret = 0;
2058 continue;
2059 } else if (ret) {
2060 return ret;
2061 }
2062 }
2063
2064 /*
2065 * Either success case or btrfs_run_delayed_refs_for_head
2066 * returned -EAGAIN, meaning we need to select another head
2067 */
2068
2069 locked_ref = NULL;
2070 cond_resched();
2071 } while ((nr != -1 && count < nr) || locked_ref);
2072
2073 /*
2074 * We don't want to include ref heads since we can have empty ref heads
2075 * and those will drastically skew our runtime down since we just do
2076 * accounting, no actual extent tree updates.
2077 */
2078 if (actual_count > 0) {
2079 u64 runtime = ktime_to_ns(ktime_sub(ktime_get(), start));
2080 u64 avg;
2081
2082 /*
2083 * We weigh the current average higher than our current runtime
2084 * to avoid large swings in the average.
2085 */
2086 spin_lock(&delayed_refs->lock);
2087 fs_info->delayed_ref_nr_run += actual_count;
2088 fs_info->delayed_ref_runtime += runtime;
2089 avg = div64_u64(fs_info->delayed_ref_runtime,
2090 fs_info->delayed_ref_nr_run);
2091
2092 /*
2093 * Once we've built up a fair bit of data, start decaying
2094 * everything by 3/4.
2095 */
> 2096 if (fs_info->delayed_ref_runtime >= (NSEC_PER_SEC * 1000) &&
2097 fs_info->delayed_ref_nr_run > 1000) {
2098 fs_info->delayed_ref_runtime *= 3;
2099 fs_info->delayed_ref_runtime >>= 2;
2100 fs_info->delayed_ref_nr_run *= 3;
2101 fs_info->delayed_ref_nr_run >>= 2;
2102 }
2103 fs_info->avg_delayed_ref_runtime = avg;
2104 spin_unlock(&delayed_refs->lock);
2105 }
2106 return 0;
2107 }
2108
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 53761 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [josef-btrfs:zygo-reworked 74/75] fs//btrfs/extent-tree.c:2096:53: warning: integer overflow in expression
Date: Tue, 10 Mar 2020 06:06:46 +0800 [thread overview]
Message-ID: <202003100642.vaMgXFAQ%lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5419 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/josef/btrfs-next.git zygo-reworked
head: 298bd0d9427133e845fe0c781edcf0f8bcb2325d
commit: 982c26add9a6aef4f44f1215de139c2d93d990de [74/75] btrfs: use a stable rolling avg for delayed refs avg
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 982c26add9a6aef4f44f1215de139c2d93d990de
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sh
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
fs//btrfs/extent-tree.c: In function '__btrfs_run_delayed_refs':
>> fs//btrfs/extent-tree.c:2096:53: warning: integer overflow in expression [-Woverflow]
if (fs_info->delayed_ref_runtime >= (NSEC_PER_SEC * 1000) &&
^
vim +2096 fs//btrfs/extent-tree.c
1997
1998 /*
1999 * Returns 0 on success or if called with an already aborted transaction.
2000 * Returns -ENOMEM or -EIO on failure and will abort the transaction.
2001 */
2002 static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2003 unsigned long nr)
2004 {
2005 struct btrfs_fs_info *fs_info = trans->fs_info;
2006 struct btrfs_delayed_ref_root *delayed_refs;
2007 struct btrfs_delayed_ref_head *locked_ref = NULL;
2008 ktime_t start = ktime_get();
2009 int ret;
2010 unsigned long count = 0;
2011 unsigned long actual_count = 0;
2012
2013 delayed_refs = &trans->transaction->delayed_refs;
2014 do {
2015 if (!locked_ref) {
2016 locked_ref = btrfs_obtain_ref_head(trans);
2017 if (IS_ERR_OR_NULL(locked_ref)) {
2018 if (PTR_ERR(locked_ref) == -EAGAIN) {
2019 continue;
2020 } else {
2021 break;
2022 }
2023 }
2024 count++;
2025 }
2026 /*
2027 * We need to try and merge add/drops of the same ref since we
2028 * can run into issues with relocate dropping the implicit ref
2029 * and then it being added back again before the drop can
2030 * finish. If we merged anything we need to re-loop so we can
2031 * get a good ref.
2032 * Or we can get node references of the same type that weren't
2033 * merged when created due to bumps in the tree mod seq, and
2034 * we need to merge them to prevent adding an inline extent
2035 * backref before dropping it (triggering a BUG_ON at
2036 * insert_inline_extent_backref()).
2037 */
2038 spin_lock(&locked_ref->lock);
2039 btrfs_merge_delayed_refs(trans, delayed_refs, locked_ref);
2040
2041 ret = btrfs_run_delayed_refs_for_head(trans, locked_ref,
2042 &actual_count);
2043 if (ret < 0 && ret != -EAGAIN) {
2044 /*
2045 * Error, btrfs_run_delayed_refs_for_head already
2046 * unlocked everything so just bail out
2047 */
2048 return ret;
2049 } else if (!ret) {
2050 /*
2051 * Success, perform the usual cleanup of a processed
2052 * head
2053 */
2054 ret = cleanup_ref_head(trans, locked_ref);
2055 if (ret > 0 ) {
2056 /* We dropped our lock, we need to loop. */
2057 ret = 0;
2058 continue;
2059 } else if (ret) {
2060 return ret;
2061 }
2062 }
2063
2064 /*
2065 * Either success case or btrfs_run_delayed_refs_for_head
2066 * returned -EAGAIN, meaning we need to select another head
2067 */
2068
2069 locked_ref = NULL;
2070 cond_resched();
2071 } while ((nr != -1 && count < nr) || locked_ref);
2072
2073 /*
2074 * We don't want to include ref heads since we can have empty ref heads
2075 * and those will drastically skew our runtime down since we just do
2076 * accounting, no actual extent tree updates.
2077 */
2078 if (actual_count > 0) {
2079 u64 runtime = ktime_to_ns(ktime_sub(ktime_get(), start));
2080 u64 avg;
2081
2082 /*
2083 * We weigh the current average higher than our current runtime
2084 * to avoid large swings in the average.
2085 */
2086 spin_lock(&delayed_refs->lock);
2087 fs_info->delayed_ref_nr_run += actual_count;
2088 fs_info->delayed_ref_runtime += runtime;
2089 avg = div64_u64(fs_info->delayed_ref_runtime,
2090 fs_info->delayed_ref_nr_run);
2091
2092 /*
2093 * Once we've built up a fair bit of data, start decaying
2094 * everything by 3/4.
2095 */
> 2096 if (fs_info->delayed_ref_runtime >= (NSEC_PER_SEC * 1000) &&
2097 fs_info->delayed_ref_nr_run > 1000) {
2098 fs_info->delayed_ref_runtime *= 3;
2099 fs_info->delayed_ref_runtime >>= 2;
2100 fs_info->delayed_ref_nr_run *= 3;
2101 fs_info->delayed_ref_nr_run >>= 2;
2102 }
2103 fs_info->avg_delayed_ref_runtime = avg;
2104 spin_unlock(&delayed_refs->lock);
2105 }
2106 return 0;
2107 }
2108
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 53761 bytes --]
next reply other threads:[~2020-03-09 22:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 22:06 kbuild test robot [this message]
2020-03-09 22:06 ` [josef-btrfs:zygo-reworked 74/75] fs//btrfs/extent-tree.c:2096:53: warning: integer overflow in expression kbuild test robot
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=202003100642.vaMgXFAQ%lkp@intel.com \
--to=lkp@intel.com \
--cc=ce3g8jdj@umail.furryterror.org \
--cc=josef@toxicpanda.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-btrfs@vger.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 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.