public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8•de>
To: "Kirill A. Shutemov" <kirill.shutemov@linux•intel.com>
Cc: linux-mips@linux-mips•org, linux-sh@vger•kernel.org,
	linux-mm@kvack•org, Jan Beulich <JBeulich@suse•com>,
	"H. Peter Anvin" <hpa@zytor•com>,
	sparclinux@vger•kernel.org,
	Andrea Arcangeli <aarcange@redhat•com>,
	Andi Kleen <ak@linux•intel.com>,
	Robert Richter <robert.richter@amd•com>,
	x86@kernel•org, Hugh Dickins <hughd@google•com>,
	Ingo Molnar <mingo@redhat•com>, Mel Gorman <mgorman@suse•de>,
	Alex Shi <alex.shu@intel•com>,
	Thomas Gleixner <tglx@linutronix•de>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp•fujitsu.com>,
	Tim Chen <tim.c.chen@linux•intel.com>,
	linux-kernel@vger•kernel.org,
	Andy Lutomirski <luto@amacapital•net>,
	Johannes Weiner <hannes@cmpxchg•org>,
	Andrew Morton <akpm@linux-foundation•org>,
	linuxppc-dev@lists•ozlabs.org
Subject: Re: [PATCH v2 4/6] x86: Add clear_page_nocache
Date: Mon, 13 Aug 2012 19:04:02 +0200	[thread overview]
Message-ID: <20120813170402.GB15530@x1.osrc.amd.com> (raw)
In-Reply-To: <20120813114334.GA21855@otc-wbsnb-06>

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.

  parent reply	other threads:[~2012-08-13 17:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 15:02 [PATCH v2 0/6] Avoid cache trashing on clearing huge/gigantic page Kirill A. Shutemov
2012-08-09 15:02 ` [PATCH v2 1/6] THP: Use real address for NUMA policy Kirill A. Shutemov
2012-08-09 15:02 ` [PATCH v2 2/6] mm: make clear_huge_page tolerate non aligned address Kirill A. Shutemov
2012-08-09 15:03 ` [PATCH v2 3/6] THP: Pass real, not rounded, address to clear_huge_page Kirill A. Shutemov
2012-08-09 15:03 ` [PATCH v2 4/6] x86: Add clear_page_nocache Kirill A. Shutemov
2012-08-09 15:22   ` Jan Beulich
2012-08-13 11:43     ` Kirill A. Shutemov
2012-08-13 12:02       ` Jan Beulich
2012-08-13 16:27       ` Andi Kleen
2012-08-13 17:04       ` Borislav Petkov [this message]
2012-08-13 19:07         ` Kirill A. Shutemov
2012-08-09 15:23   ` H. Peter Anvin
2012-08-09 15:03 ` [PATCH v2 5/6] mm: make clear_huge_page cache clear only around the fault address Kirill A. Shutemov
2012-08-09 15:03 ` [PATCH v2 6/6] x86: switch the 64bit uncached page clear to SSE/AVX v2 Kirill A. Shutemov
2012-08-09 15:28   ` Jan Beulich

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=20120813170402.GB15530@x1.osrc.amd.com \
    --to=bp@alien8$(echo .)de \
    --cc=JBeulich@suse$(echo .)com \
    --cc=aarcange@redhat$(echo .)com \
    --cc=ak@linux$(echo .)intel.com \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=alex.shu@intel$(echo .)com \
    --cc=hannes@cmpxchg$(echo .)org \
    --cc=hpa@zytor$(echo .)com \
    --cc=hughd@google$(echo .)com \
    --cc=kamezawa.hiroyu@jp$(echo .)fujitsu.com \
    --cc=kirill.shutemov@linux$(echo .)intel.com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-mips@linux-mips$(echo .)org \
    --cc=linux-mm@kvack$(echo .)org \
    --cc=linux-sh@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=luto@amacapital$(echo .)net \
    --cc=mgorman@suse$(echo .)de \
    --cc=mingo@redhat$(echo .)com \
    --cc=robert.richter@amd$(echo .)com \
    --cc=sparclinux@vger$(echo .)kernel.org \
    --cc=tglx@linutronix$(echo .)de \
    --cc=tim.c.chen@linux$(echo .)intel.com \
    --cc=x86@kernel$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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