public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Grazvydas Ignotas <notasas@gmail.com>
To: linux-kernel@vger.kernel.org,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Grazvydas Ignotas <notasas@gmail.com>
Subject: remap_file_pages regression
Date: Mon, 15 Feb 2016 03:32:55 +0200	[thread overview]
Message-ID: <1455499975-8390-1-git-send-email-notasas@gmail.com> (raw)

Hi,

since remap_file_pages() rework the following simple program fails.
I haven't actually bisected this, only know it worked on 3.19 at least
(I bought a new system now and need 4.2+ for hardware support). If you
are curious, the program is an emulator and is using remap_file_pages()
to implement memory mirroring efficiently (and to remap things during
run time).

Grazvydas

====%<===

#define _GNU_SOURCE
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>

#define SIZE	(4096 * 3)

int main(int argc, char **argv)
{
	unsigned long *p;
	long i;

	p = mmap(NULL, SIZE, PROT_READ | PROT_WRITE,
			MAP_SHARED | MAP_ANONYMOUS, -1, 0);
	if (p == MAP_FAILED) {
		perror("mmap");
		return -1;
	}

	for (i = 0; i < SIZE / 4096; i++)
		p[i * 4096 / sizeof(*p)] = i;

	if (remap_file_pages(p, 4096, 0, 1, 0)) {
		perror("remap_file_pages");
		return -1;
	}

	if (remap_file_pages(p, 4096 * 2, 0, 1, 0)) {
		perror("remap_file_pages");
		return -1;
	}

	assert(p[0] == 1);

	munmap(p, SIZE);

	return 0;
}

             reply	other threads:[~2016-02-15  1:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-15  1:32 Grazvydas Ignotas [this message]
2016-02-15 10:26 ` remap_file_pages regression Kirill A. Shutemov
2016-02-15 22:08   ` Grazvydas Ignotas
2016-02-15 22:17     ` Kirill A. Shutemov

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=1455499975-8390-1-git-send-email-notasas@gmail.com \
    --to=notasas@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /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