From: Matthew Wilcox <willy@infradead.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kernel test robot <lkp@intel.com>,
kbuild-all@lists.01.org,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [linux-next:master 9762/11953] mm/page_vma_mapped.c:246 page_vma_mapped_walk() warn: always true condition '(pvmw->nr_pages >= (1 << ( - (12)))) => (0-u64max >= 0)'
Date: Mon, 14 Mar 2022 13:36:51 +0000 [thread overview]
Message-ID: <Yi9E85ntvuTg1QMf@casper.infradead.org> (raw)
In-Reply-To: <20220314133038.GS3315@kadam>
On Mon, Mar 14, 2022 at 04:30:38PM +0300, Dan Carpenter wrote:
> On Sun, Mar 13, 2022 at 04:06:37AM +0000, Matthew Wilcox wrote:
> > On Sun, Mar 13, 2022 at 11:01:09AM +0800, kernel test robot wrote:
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > > head: 71941773e143369a73c9c4a3b62fbb60736a1182
> > > commit: b786e44a4dbfe64476e7120ec7990b89a37be37d [9762/11953] mm: Convert page_vma_mapped_walk to work on PFNs
> > > config: riscv-randconfig-m031-20220312 (https://download.01.org/0day-ci/archive/20220313/202203131056.WINF40Gt-lkp@intel.com/config )
> > > compiler: riscv64-linux-gcc (GCC) 11.2.0
> > >
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > > smatch warnings:
> > > mm/page_vma_mapped.c:246 page_vma_mapped_walk() warn: always true condition '(pvmw->nr_pages >= (1 << ( - (12)))) => (0-u64max >= 0)'
> >
> > Looks like a duplicate of https://lore.kernel.org/lkml/YgpzPru8aFA5sHOI@casper.infradead.org/
> >
> > Dan, any thoughts? Do you consider this a false positive from smatch?
> >
>
> That's really weird that HPAGE_PMD_NR ends up as zero... Does it wrap
> to zero?
It's actually weirder than that:
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
so it should be (1<<(0-12))
> Anyway, it would be easy to silence the warning based on that it's on an
> impossible path but I think that's not the right idea.
>
> if (is_impossible_path())
> return;
>
> A lot of the bugs that Smatch finds are in impossible to reach error
> handling code. I'll instead silence it based on that the macro
> definition changes. Add it to smatch_data/kernel.unconstant_macros:
>
>
> - if (!possibly_false_rl(rl_left, expr->op, rl_right)) {
> + if (!possibly_false_rl(rl_left, expr->op, rl_right) &&
> + !is_unconstant_macro(expr->left) &&
> + !is_unconstant_macro(expr->right)) {
> char *name = expr_to_str(expr);
>
> sm_warning("always true condition '(%s) => (%s %s %s)'", name,
>
> I'll test this out overnight, tonight.
Thanks! I'd be happy to rearrange this code to avoid the smatch report,
but it's not quite clear to me how I could/should do that.
prev parent reply other threads:[~2022-03-14 13:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-13 3:01 kernel test robot
2022-03-13 4:06 ` Matthew Wilcox
2022-03-14 13:30 ` Dan Carpenter
2022-03-14 13:36 ` Matthew Wilcox [this message]
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=Yi9E85ntvuTg1QMf@casper.infradead.org \
--to=willy@infradead.org \
--cc=dan.carpenter@oracle.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
/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