From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Gregory Price <gourry.memverge@gmail.com>
Cc: <linux-mm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arch@vger.kernel.org>, <linux-api@vger.kernel.org>,
<linux-cxl@vger.kernel.org>, <luto@kernel.org>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <hpa@zytor.com>, <arnd@arndb.de>,
<akpm@linux-foundation.org>, <x86@kernel.org>,
Gregory Price <gregory.price@memverge.com>
Subject: Re: [RFC v2 5/5] ktest: sys_move_phys_pages ktest
Date: Mon, 2 Oct 2023 15:09:24 +0100 [thread overview]
Message-ID: <20231002150924.00006a7b@Huawei.com> (raw)
In-Reply-To: <20230919230909.530174-6-gregory.price@memverge.com>
On Tue, 19 Sep 2023 19:09:08 -0400
Gregory Price <gourry.memverge@gmail.com> wrote:
> Implement simple ktest that looks up the physical address via
> /proc/self/pagemap and migrates the page based on that information.
>
> Signed-off-by: Gregory Price <gregory.price@memverge.com>
One trivial comment inline.
> ---
> tools/testing/selftests/mm/migration.c | 101 +++++++++++++++++++++++++
> 1 file changed, 101 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c
> index 6908569ef406..67fbae243f94 100644
> --- a/tools/testing/selftests/mm/migration.c
> +++ b/tools/testing/selftests/mm/migration.c
> @@ -5,6 +5,8 @@
> */
>
> #include "../kselftest_harness.h"
> +#include <stdint.h>
> +#include <stdio.h>
> #include <strings.h>
> #include <pthread.h>
> #include <numa.h>
> @@ -14,11 +16,17 @@
> #include <sys/types.h>
> #include <signal.h>
> #include <time.h>
> +#include <unistd.h>
>
> #define TWOMEG (2<<20)
> #define RUNTIME (20)
>
> +#define GET_BIT(X, Y) ((X & ((uint64_t)1<<Y)) >> Y)
> +#define GET_PFN(X) (X & 0x7FFFFFFFFFFFFFull)
> #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1)))
> +#define PAGEMAP_ENTRY 8
> +const int __endian_bit = 1;
> +#define is_bigendian() ((*(char *)&__endian_bit) == 0)
>
> FIXTURE(migration)
> {
> @@ -94,6 +102,47 @@ int migrate(uint64_t *ptr, int n1, int n2)
> return 0;
> }
>
> +
Trivial, but 3 lines definitely more than needed.
> +
> +int migrate_phys(uint64_t paddr, int n1, int n2)
> +{
> + int ret, tmp;
> + int status = 0;
> + struct timespec ts1, ts2;
> +
> + if (clock_gettime(CLOCK_MONOTONIC, &ts1))
> + return -1;
> +
> + while (1) {
> + if (clock_gettime(CLOCK_MONOTONIC, &ts2))
> + return -1;
> +
> + if (ts2.tv_sec - ts1.tv_sec >= RUNTIME)
> + return 0;
> +
> + /*
> + * FIXME: move_phys_pages was syscall 454 during RFC.
> + * Update this when an official syscall number is adopted
> + * and the libnuma interface is implemented.
> + */
> + ret = syscall(454, 1, (void **) &paddr, &n2, &status,
> + MPOL_MF_MOVE_ALL);
> + if (ret) {
> + if (ret > 0)
> + printf("Didn't migrate %d pages\n", ret);
> + else
> + perror("Couldn't migrate pages");
> + return -2;
> + }
> +
> + tmp = n2;
> + n2 = n1;
> + n1 = tmp;
> + }
> +
> + return 0;
> +}
next prev parent reply other threads:[~2023-10-02 14:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 23:09 [RFC v2 0/5] move_phys_pages syscall Gregory Price
2023-09-19 23:09 ` [RFC v2 1/5] mm/migrate: fix do_pages_move for compat pointers Gregory Price
2023-09-20 9:36 ` Arnd Bergmann
2023-09-19 23:09 ` [RFC v2 2/5] mm/migrate: remove unused mm argument from do_move_pages_to_node Gregory Price
2023-10-02 13:44 ` Jonathan Cameron
2023-09-19 23:09 ` [RFC v2 3/5] mm/migrate: refactor add_page_for_migration for code re-use Gregory Price
2023-10-02 13:51 ` Jonathan Cameron
2023-09-19 23:09 ` [RFC v2 4/5] mm/migrate: Create move_phys_pages syscall Gregory Price
2023-10-02 14:07 ` Jonathan Cameron
2023-10-03 17:58 ` Gregory Price
2023-09-19 23:09 ` [RFC v2 5/5] ktest: sys_move_phys_pages ktest Gregory Price
2023-10-02 14:09 ` Jonathan Cameron [this message]
2023-09-19 23:09 ` [RFC] man/move_phys_pages: migrate pages based on physical address Gregory Price
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=20231002150924.00006a7b@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gourry.memverge@gmail.com \
--cc=gregory.price@memverge.com \
--cc=hpa@zytor.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).