From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F09B1E7849A for ; Mon, 2 Oct 2023 14:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237666AbjJBOJc (ORCPT ); Mon, 2 Oct 2023 10:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237662AbjJBOJb (ORCPT ); Mon, 2 Oct 2023 10:09:31 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58F36B7; Mon, 2 Oct 2023 07:09:28 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RzjS861dVz67ydC; Mon, 2 Oct 2023 22:06:48 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 2 Oct 2023 15:09:25 +0100 Date: Mon, 2 Oct 2023 15:09:24 +0100 From: Jonathan Cameron To: Gregory Price CC: , , , , , , , , , , , , , , Gregory Price Subject: Re: [RFC v2 5/5] ktest: sys_move_phys_pages ktest Message-ID: <20231002150924.00006a7b@Huawei.com> In-Reply-To: <20230919230909.530174-6-gregory.price@memverge.com> References: <20230919230909.530174-1-gregory.price@memverge.com> <20230919230909.530174-6-gregory.price@memverge.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Tue, 19 Sep 2023 19:09:08 -0400 Gregory Price 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 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 > +#include > #include > #include > #include > @@ -14,11 +16,17 @@ > #include > #include > #include > +#include > > #define TWOMEG (2<<20) > #define RUNTIME (20) > > +#define GET_BIT(X, Y) ((X & ((uint64_t)1<> 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; > +}