[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120813170402.GB15530@x1.osrc.amd.com>
Date: Mon, 13 Aug 2012 19:04:02 +0200
From: Borislav Petkov <bp@...en8.de>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Jan Beulich <JBeulich@...e.com>, Andi Kleen <ak@...ux.intel.com>,
Andy Lutomirski <luto@...capital.net>,
Robert Richter <robert.richter@....com>,
Johannes Weiner <hannes@...xchg.org>,
Hugh Dickins <hughd@...gle.com>, Alex Shi <alex.shu@...el.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
x86@...nel.org, linux-mm@...ck.org,
Thomas Gleixner <tglx@...utronix.de>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-mips@...ux-mips.org, Tim Chen <tim.c.chen@...ux.intel.com>,
linuxppc-dev@...ts.ozlabs.org,
Andrea Arcangeli <aarcange@...hat.com>,
Ingo Molnar <mingo@...hat.com>, Mel Gorman <mgorman@...e.de>,
linux-kernel@...r.kernel.org, linux-sh@...r.kernel.org,
sparclinux@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v2 4/6] x86: Add clear_page_nocache
On Mon, Aug 13, 2012 at 02:43:34PM +0300, Kirill A. Shutemov wrote:
> $ cat test.c
> #include <stdio.h>
> #include <sys/mman.h>
>
> #define SIZE 1024*1024*1024
>
> void clear_page_nocache_sse2(void *page) __attribute__((regparm(1)));
>
> int main(int argc, char** argv)
> {
> char *p;
> unsigned long i, j;
>
> p = mmap(NULL, SIZE, PROT_WRITE|PROT_READ,
> MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
> for(j = 0; j < 100; j++) {
> for(i = 0; i < SIZE; i += 4096) {
> clear_page_nocache_sse2(p + i);
> }
> }
>
> return 0;
> }
> $ cat clear_page_nocache_unroll32.S
> .globl clear_page_nocache_sse2
> .align 4,0x90
> clear_page_nocache_sse2:
> .cfi_startproc
> mov %eax,%edx
> xorl %eax,%eax
> movl $4096/32,%ecx
> .p2align 4
> .Lloop_sse2:
> decl %ecx
> #define PUT(x) movnti %eax,x*4(%edx)
> PUT(0)
> PUT(1)
> PUT(2)
> PUT(3)
> PUT(4)
> PUT(5)
> PUT(6)
> PUT(7)
> #undef PUT
> lea 32(%edx),%edx
> jnz .Lloop_sse2
> nop
> ret
> .cfi_endproc
> .type clear_page_nocache_sse2, @function
> .size clear_page_nocache_sse2, .-clear_page_nocache_sse2
> $ cat clear_page_nocache_unroll64.S
> .globl clear_page_nocache_sse2
> .align 4,0x90
> clear_page_nocache_sse2:
> .cfi_startproc
> mov %eax,%edx
This must still be the 32-bit version becaue it segfaults here. Here's
why:
mmap above gives a ptr which, on 64-bit, is larger than 32-bit, i.e. it
looks like 0x7fffxxxxx000, i.e. starting from top of userspace.
Now, the mov above truncates that ptr and the thing segfaults.
Doing s/edx/rdx/g fixes it though.
Thanks.
--
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists