* [mmotm:master 120/306] fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type?
@ 2014-11-14 11:44 kbuild test robot
2014-11-17 13:03 ` Kirill A. Shutemov
0 siblings, 1 reply; 3+ messages in thread
From: kbuild test robot @ 2014-11-14 11:44 UTC (permalink / raw)
To: kbuild, Kirill A. Shutemov; +Cc: Linux Memory Management List, Dan Carpenter
[ You would have to enable transparent huge page tables on a 32 bit
system to trigger this bug and I don't think that's possible.
I don't think Smatch will complain about this if you have the cross
function database turned on because it knows the value of size in that
case. But most people don't build the database so it might be worth
silencing this bug? Should I even bother sending these email for
non-bugs? Let me know. -dan ]
tree: git://git.cmpxchg.org/linux-mmotm.git master
head: e668fb4c5c5e6de5b9432bd36d83b3a0b4ce78e8
commit: be7c8db9daa43935912bc8c898ecea99b32d805b [120/306] mm: fix huge zero page accounting in smaps report
fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type?
git remote add mmotm git://git.cmpxchg.org/linux-mmotm.git
git remote update mmotm
git checkout be7c8db9daa43935912bc8c898ecea99b32d805b
vim +474 fs/proc/task_mmu.c
be7c8db9 Kirill A. Shutemov 2014-11-13 458 mss->resident += size;
be7c8db9 Kirill A. Shutemov 2014-11-13 459 /* Accumulate the size in pages that have been accessed. */
be7c8db9 Kirill A. Shutemov 2014-11-13 460 if (young || PageReferenced(page))
be7c8db9 Kirill A. Shutemov 2014-11-13 461 mss->referenced += size;
be7c8db9 Kirill A. Shutemov 2014-11-13 462 mapcount = page_mapcount(page);
be7c8db9 Kirill A. Shutemov 2014-11-13 463 if (mapcount >= 2) {
be7c8db9 Kirill A. Shutemov 2014-11-13 464 if (dirty || PageDirty(page))
be7c8db9 Kirill A. Shutemov 2014-11-13 465 mss->shared_dirty += size;
be7c8db9 Kirill A. Shutemov 2014-11-13 466 else
be7c8db9 Kirill A. Shutemov 2014-11-13 467 mss->shared_clean += size;
be7c8db9 Kirill A. Shutemov 2014-11-13 468 mss->pss += (size << PSS_SHIFT) / mapcount;
be7c8db9 Kirill A. Shutemov 2014-11-13 469 } else {
be7c8db9 Kirill A. Shutemov 2014-11-13 470 if (dirty || PageDirty(page))
be7c8db9 Kirill A. Shutemov 2014-11-13 471 mss->private_dirty += size;
be7c8db9 Kirill A. Shutemov 2014-11-13 472 else
be7c8db9 Kirill A. Shutemov 2014-11-13 473 mss->private_clean += size;
be7c8db9 Kirill A. Shutemov 2014-11-13 @474 mss->pss += (size << PSS_SHIFT);
be7c8db9 Kirill A. Shutemov 2014-11-13 475 }
be7c8db9 Kirill A. Shutemov 2014-11-13 476 }
be7c8db9 Kirill A. Shutemov 2014-11-13 477
be7c8db9 Kirill A. Shutemov 2014-11-13 478
be7c8db9 Kirill A. Shutemov 2014-11-13 479 static void smaps_pte_entry(pte_t *pte, unsigned long addr,
be7c8db9 Kirill A. Shutemov 2014-11-13 480 struct mm_walk *walk)
e070ad49 Mauricio Lin 2005-09-03 481 {
2165009b Dave Hansen 2008-06-12 482 struct mem_size_stats *mss = walk->private;
---
0-DAY kernel test infrastructure Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [mmotm:master 120/306] fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type?
2014-11-14 11:44 [mmotm:master 120/306] fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type? kbuild test robot
@ 2014-11-17 13:03 ` Kirill A. Shutemov
2014-11-19 23:30 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Kirill A. Shutemov @ 2014-11-17 13:03 UTC (permalink / raw)
To: kbuild test robot, akpm
Cc: kbuild, Linux Memory Management List, Dan Carpenter
On Fri, Nov 14, 2014 at 02:44:15PM +0300, kbuild test robot wrote:
> [ You would have to enable transparent huge page tables on a 32 bit
> system to trigger this bug and I don't think that's possible.
It is. We have THP on 32-bit x86.
> I don't think Smatch will complain about this if you have the cross
> function database turned on because it knows the value of size in that
> case. But most people don't build the database so it might be worth
> silencing this bug? Should I even bother sending these email for
> non-bugs? Let me know. -dan ]
>
> tree: git://git.cmpxchg.org/linux-mmotm.git master
> head: e668fb4c5c5e6de5b9432bd36d83b3a0b4ce78e8
> commit: be7c8db9daa43935912bc8c898ecea99b32d805b [120/306] mm: fix huge zero page accounting in smaps report
>
> fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type?
This should fix the issue.
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 8fd00743bd4d..de80a887d98e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -464,17 +464,16 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page,
mss->shared_dirty += size;
else
mss->shared_clean += size;
- mss->pss += (size << PSS_SHIFT) / mapcount;
+ mss->pss += ((u64)size << PSS_SHIFT) / mapcount;
} else {
if (dirty || PageDirty(page))
mss->private_dirty += size;
else
mss->private_clean += size;
- mss->pss += (size << PSS_SHIFT);
+ mss->pss += (u64)size << PSS_SHIFT;
}
}
-
static void smaps_pte_entry(pte_t *pte, unsigned long addr,
struct mm_walk *walk)
{
--
Kirill A. Shutemov
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [mmotm:master 120/306] fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type?
2014-11-17 13:03 ` Kirill A. Shutemov
@ 2014-11-19 23:30 ` Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2014-11-19 23:30 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild test robot, kbuild, Linux Memory Management List,
Dan Carpenter
On Mon, 17 Nov 2014 15:03:28 +0200 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
> On Fri, Nov 14, 2014 at 02:44:15PM +0300, kbuild test robot wrote:
> > [ You would have to enable transparent huge page tables on a 32 bit
> > system to trigger this bug and I don't think that's possible.
>
> It is. We have THP on 32-bit x86.
>
> > I don't think Smatch will complain about this if you have the cross
> > function database turned on because it knows the value of size in that
> > case. But most people don't build the database so it might be worth
> > silencing this bug? Should I even bother sending these email for
> > non-bugs? Let me know. -dan ]
> >
> > tree: git://git.cmpxchg.org/linux-mmotm.git master
> > head: e668fb4c5c5e6de5b9432bd36d83b3a0b4ce78e8
> > commit: be7c8db9daa43935912bc8c898ecea99b32d805b [120/306] mm: fix huge zero page accounting in smaps report
> >
> > fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type?
>
> This should fix the issue.
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 8fd00743bd4d..de80a887d98e 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -464,17 +464,16 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page,
> mss->shared_dirty += size;
> else
> mss->shared_clean += size;
> - mss->pss += (size << PSS_SHIFT) / mapcount;
> + mss->pss += ((u64)size << PSS_SHIFT) / mapcount;
> } else {
> if (dirty || PageDirty(page))
> mss->private_dirty += size;
> else
> mss->private_clean += size;
> - mss->pss += (size << PSS_SHIFT);
> + mss->pss += (u64)size << PSS_SHIFT;
> }
> }
>
> -
> static void smaps_pte_entry(pte_t *pte, unsigned long addr,
> struct mm_walk *walk)
> {
Please check...
From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm-fix-huge-zero-page-accounting-in-smaps-report-fix-2-fix
use do_div to fix 32-bit build
fs/built-in.o: In function `smaps_account':
task_mmu.c:(.text+0x943a3): undefined reference to `__udivdi3'
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/proc/task_mmu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff -puN fs/proc/task_mmu.c~mm-fix-huge-zero-page-accounting-in-smaps-report-fix-2-fix fs/proc/task_mmu.c
--- a/fs/proc/task_mmu.c~mm-fix-huge-zero-page-accounting-in-smaps-report-fix-2-fix
+++ a/fs/proc/task_mmu.c
@@ -461,11 +461,15 @@ static void smaps_account(struct mem_siz
mss->referenced += size;
mapcount = page_mapcount(page);
if (mapcount >= 2) {
+ u64 pss_delta;
+
if (dirty || PageDirty(page))
mss->shared_dirty += size;
else
mss->shared_clean += size;
- mss->pss += ((u64)size << PSS_SHIFT) / mapcount;
+ pss_delta = (u64)size << PSS_SHIFT;
+ do_div(pss_delta, mapcount);
+ mss->pss += pss_delta;
} else {
if (dirty || PageDirty(page))
mss->private_dirty += size;
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-19 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-14 11:44 [mmotm:master 120/306] fs/proc/task_mmu.c:474 smaps_account() warn: should 'size << 12' be a 64 bit type? kbuild test robot
2014-11-17 13:03 ` Kirill A. Shutemov
2014-11-19 23:30 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).