From: Zhouping Liu <zliu@redhat.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Subject: mm: move_pages syscall can't return ENOENT when pages are not present
Date: Wed, 09 May 2012 04:58:34 -0400 (EDT) [thread overview]
Message-ID: <85e08d38-234a-4bc6-8c4f-6c92b50dc9b1@zmail13.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <50e8b720-2459-4cf4-bfbd-fcc4cd408249@zmail13.collab.prod.int.phx2.redhat.com>
hi, all
Recently, I found an error in move_pages syscall:
depending on move_pages(2), when page is not present,
it should fail with ENOENT, in fact, it's ok without
any errno.
the following reproducer can easily reproduce
the issue, suggest you get more details by strace.
inside reproducer, I try to move a non-exist page from
node 1 to node 0.
I have tested it on the latest kernel 3.4-rc5 with 2 and 4 numa nodes.
[zliu@ZhoupingLiu ~]$ gcc -o reproducer reproducer.c -lnuma
[zliu@ZhoupingLiu ~]$ ./reproducer
from_node is 1, to_node is 0
ERROR: move_pages expected FAIL.
I'm not in mail list, please CC me.
/*
* Copyright (C) 2012 Red Hat, Inc.
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
* Compiled: gcc -o reproducer reproducer.c -lnuma
* Description:
* it's designed to check move_pages syscall, when
* page is not present, it should fail with ENOENT.
*/
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <numa.h>
#include <numaif.h>
#define TEST_PAGES 4
int main(int argc, char **argv)
{
void *pages[TEST_PAGES];
int onepage;
int nodes[TEST_PAGES];
int status, ret;
int i, from_node = 1, to_node = 0;
onepage = getpagesize();
for (i = 0; i < TEST_PAGES - 1; i++) {
pages[i] = numa_alloc_onnode(onepage, from_node);
nodes[i] = to_node;
}
nodes[TEST_PAGES - 1] = to_node;
/*
* the follow page is not available, also not aligned,
* depend on move_pages(2), it can't be moved, and should
* return ENOENT errno.
*/
pages[TEST_PAGES - 1] = pages[TEST_PAGES - 2] - onepage * 4 + 1;
printf("from_node is %u, to_node is %u\n", from_node, to_node);
ret = move_pages(0, TEST_PAGES, pages, nodes, &status, MPOL_MF_MOVE);
if (ret == -1) {
if (errno != ENOENT)
perror("move_pages expected ENOENT errno, but it's");
else
printf("Succeed\n");
} else {
printf("ERROR: move_pages expected FAIL.\n");
}
for (i = 0; i < TEST_PAGES; i++)
numa_free(pages[i], onepage);
return 0;
}
--
Thanks,
Zhouping
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next parent reply other threads:[~2012-05-09 8:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <50e8b720-2459-4cf4-bfbd-fcc4cd408249@zmail13.collab.prod.int.phx2.redhat.com>
2012-05-09 8:58 ` Zhouping Liu [this message]
2012-05-09 9:28 ` Xiaotian Feng
2012-05-09 12:50 ` Wanlong Gao
2012-05-09 13:33 ` Zhouping Liu
2012-05-09 14:56 ` Wanlong Gao
2012-05-09 14:08 ` Brice Goglin
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=85e08d38-234a-4bc6-8c4f-6c92b50dc9b1@zmail13.collab.prod.int.phx2.redhat.com \
--to=zliu@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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