From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE5AC42FCBA; Fri, 24 Jul 2026 10:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888726; cv=none; b=TRmX15bdDKex5ispis9S0/Lti315GtQf1VbxCgKsJfDzFfNs/g1KAQ5cQeNmt+4oSMEdfbKTF/oWCukDj99x/ut8eZ5Z3NAv7dfBNxB4C8me0XY+f3Og6IAwG/1hOUe/c0qQhnAllaWOoGTZb4znnCReTPh9mL5m/w+4/aQcNJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888726; c=relaxed/simple; bh=PTkd813JAn6wO/CqG5+sfWiGVF8RyWenBAffF9OaPTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DXGyhKsYeTrdClBZejXL7DVSgJAOk35Glsu8RlTlXCtqlSIsppoiHEn20zjbKwpFKUj3BFGv18rS88D31fz/Y97Ej6cOjd6+kCnDClzmKJEAjQqSM4Fx6Ig3EqDK3Bk8+a5e1EHybjAX1zROzpCLP+jzWD35jUwwequY0Bujv64= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=SYgESkRN; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="SYgESkRN" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 53A8C1477; Fri, 24 Jul 2026 03:25:19 -0700 (PDT) Received: from e142334-100.cambridge.arm.com (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D3083F66F; Fri, 24 Jul 2026 03:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784888723; bh=PTkd813JAn6wO/CqG5+sfWiGVF8RyWenBAffF9OaPTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYgESkRNnBZJfRvPIAM2Qt/TdjRWqMzPBuD4hU94OL1ezv2gj3cU8HFwZ8nTnwxfm ANbgDoeQZ+2WHT5aRpezBSm9mb/FES6quOK2ZBDucx6beJ1r/uG/Xcs2ktDs2NdTWP umVLYO3cSq91pKgdGhdg2w6PzxcAOjpcG25Vz5Hc= From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sarthak.sharma@arm.com Cc: Muhammad Usama Anjum Subject: [PATCH v2 5/5] selftests/mm: retry migration failures for the full runtime Date: Fri, 24 Jul 2026 11:24:28 +0100 Message-ID: <20260724102431.1199519-6-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724102431.1199519-1-usama.anjum@arm.com> References: <20260724102431.1199519-1-usama.anjum@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit move_pages() is best effort and can temporarily fail when concurrent faults race with page unmapping. A busy shared-anon workload can exhaust the current 100 retries long before the intended 20-second runtime and produce a false failure. Use the full runtime as the retry window. Since the initial page location is unknown, require it to reach both alternating NUMA targets to confirm that cross-node migration made progress despite transient contention. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - Retry per-page failures for the full runtime - Verify that both alternating NUMA targets are reached --- tools/testing/selftests/mm/migration.c | 39 ++++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 29f7492453d43..4d55a424058a9 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -7,7 +7,7 @@ #include "kselftest_harness.h" #include "hugepage_settings.h" -#include +#include #include #include #include @@ -20,7 +20,6 @@ #define TWOMEG (2<<20) #define RUNTIME (20) -#define MAX_RETRIES 100 #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) HUGETLB_SETUP_DEFAULT_PAGES(1) @@ -110,7 +109,7 @@ int migrate(uint64_t *ptr, int n1, int n2) int ret, tmp; int status = 0; struct timespec ts1, ts2; - int failures = 0; + int success = 0; if (clock_gettime(CLOCK_MONOTONIC, &ts1)) return -1; @@ -119,29 +118,33 @@ int migrate(uint64_t *ptr, int n1, int n2) if (clock_gettime(CLOCK_MONOTONIC, &ts2)) return -1; - if (ts2.tv_sec - ts1.tv_sec >= RUNTIME) - return 0; + if (ts2.tv_sec - ts1.tv_sec >= RUNTIME) { + /* Reaching both targets verifies a cross-node move. */ + if (success >= 2) + return 0; + else + return -2; + } ret = move_pages(0, 1, (void **) &ptr, &n2, &status, MPOL_MF_MOVE_ALL); - if (ret) { - if (ret > 0) { - /* Migration is best effort; try again */ - if (++failures < MAX_RETRIES) - continue; - printf("Didn't migrate %d pages\n", ret); - } - else - perror("Couldn't migrate pages"); - return -2; + if (ret < 0) { + perror("Couldn't migrate pages"); + return ret; } - failures = 0; + /* Migration is best effort. Try again */ + if (ret > 0 || status < 0) + continue; + if (status != n2) { + printf("Page is on node %d instead of target node %d\n", + status, n2); + return status; + } + success++; tmp = n2; n2 = n1; n1 = tmp; } - - return 0; } void *access_mem(void *ptr) -- 2.47.3