linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michel Lespinasse <walken@google.com>
To: Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>,
	Mel Gorman <mgorman@suse.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrea Arcangeli <aarcange@redhat.com>
Cc: linux-mm@kvack.org, Rik van Riel <riel@surriel.com>
Subject: [RFC PATCH 6/6] mm: fix cache coloring on x86_64
Date: Wed, 31 Oct 2012 03:33:25 -0700	[thread overview]
Message-ID: <1351679605-4816-7-git-send-email-walken@google.com> (raw)
In-Reply-To: <1351679605-4816-1-git-send-email-walken@google.com>

From: Rik van Riel <riel@surriel.com>

Fix the x86-64 cache alignment code to take pgoff into account.
Use the x86 and MIPS cache alignment code as the basis for a generic
cache alignment function.

The old x86 code will always align the mmap to aliasing boundaries,
even if the program mmaps the file with a non-zero pgoff.

If program A mmaps the file with pgoff 0, and program B mmaps the
file with pgoff 1. The old code would align the mmaps, resulting in
misaligned pages:

A:  0123
B:  123

After this patch, they are aligned so the pages line up:

A: 0123
B:  123

Proposed-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Michel Lespinasse <walken@google.com>

---
 arch/x86/kernel/sys_x86_64.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index fa9227214753..5df5837ce6a3 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -136,7 +136,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	info.low_limit = begin;
 	info.high_limit = end;
 	info.align_mask = filp ? get_align_mask() : 0;
-	info.align_offset = 0;
+	info.align_offset = pgoff << PAGE_SHIFT;
 	return vm_unmapped_area(&info);
 }
 
@@ -175,7 +175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	info.low_limit = 0;  // XXX could be PAGE_SIZE ???
 	info.high_limit = mm->mmap_base;
 	info.align_mask = filp ? get_align_mask() : 0;
-	info.align_offset = 0;
+	info.align_offset = pgoff << PAGE_SHIFT;
 	addr = vm_unmapped_area(&info);
 	if (!(addr & ~PAGE_MASK))
 		return addr;
-- 
1.7.7.3

--
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>

  parent reply	other threads:[~2012-10-31 10:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 10:33 [RFC PATCH 0/6] mm: use augmented rbtrees for finding unmapped areas Michel Lespinasse
2012-10-31 10:33 ` [RFC PATCH 1/6] mm: augment vma rbtree with rb_subtree_gap Michel Lespinasse
2012-11-01 21:43   ` Rik van Riel
2012-10-31 10:33 ` [RFC PATCH 2/6] mm: check rb_subtree_gap correctness Michel Lespinasse
2012-11-01 21:49   ` Rik van Riel
2012-10-31 10:33 ` [RFC PATCH 3/6] mm: rearrange vm_area_struct for fewer cache misses Michel Lespinasse
2012-10-31 10:33 ` [RFC PATCH 4/6] mm: vm_unmapped_area() lookup function Michel Lespinasse
2012-11-02 16:52   ` Rik van Riel
2012-11-02 22:41     ` Michel Lespinasse
2012-11-03  0:40       ` Rik van Riel
2012-10-31 10:33 ` [RFC PATCH 5/6] mm: use vm_unmapped_area() on x86_64 architecture Michel Lespinasse
2012-11-02 20:39   ` Rik van Riel
2012-10-31 10:33 ` Michel Lespinasse [this message]
2012-10-31 11:03 ` [RFC PATCH 0/6] mm: use augmented rbtrees for finding unmapped areas Michel Lespinasse

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=1351679605-4816-7-git-send-email-walken@google.com \
    --to=walken@google.com \
    --cc=aarcange@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=riel@surriel.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;
as well as URLs for NNTP newsgroup(s).