From patchwork Fri Aug 30 05:16:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13784282 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07378CA0EE0 for ; Fri, 30 Aug 2024 05:16:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A5816B0095; Fri, 30 Aug 2024 01:16:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 455E56B00B6; Fri, 30 Aug 2024 01:16:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31E3F6B00B8; Fri, 30 Aug 2024 01:16:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 13E236B00B6 for ; Fri, 30 Aug 2024 01:16:33 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 760DFC138D for ; Fri, 30 Aug 2024 05:16:32 +0000 (UTC) X-FDA: 82507751424.18.873BDDD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf17.hostedemail.com (Postfix) with ESMTP id E9E9840007 for ; Fri, 30 Aug 2024 05:16:30 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724994969; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=q5Bbo9z3iiieq1lwlFSsauTrsxkXFTD0RbIPhtFlIro=; b=ZzzKlO2fSKVFY1uFzxgsA28KoYub0wRriBw6HyzDig/9Ir8Ory098C8rC9gM9OV9L2Q/qF uQXns+TAzcVBmT45dKRmXYhFcZeBPdeFEXQUVZpxHCU6PjwIUNYXC2s4xJS37VzefDeMjS 60l2dtj2nM5/M3mtV7yk1fVPZpM3zzU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724994970; a=rsa-sha256; cv=none; b=BRa44ZFt1hpHb9ZLvDIYoRufnYKxKtHsfdVXTpoN3Bz9ZYhXHrw3daiRPaQluGJFvZsMit wjv1r7pC+F+/ImmyugMgUm1V6wPW3wntu1pG/g7VnBwapCAW3g7BeYd7yF4RxLF+fXTOdr qw1sohZxgT/P7Vvktrpqbegyn3+mOAA= 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 270A51063; Thu, 29 Aug 2024 22:16:56 -0700 (PDT) Received: from e116581.blr.arm.com (e116581.arm.com [10.162.40.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 855F83F66E; Thu, 29 Aug 2024 22:16:19 -0700 (PDT) From: Dev Jain To: akpm@linux-foundation.org, shuah@kernel.org, david@redhat.com, willy@infradead.org Cc: ryan.roberts@arm.com, anshuman.khandual@arm.com, catalin.marinas@arm.com, cl@gentwo.org, vbabka@suse.cz, mhocko@suse.com, apopple@nvidia.com, osalvador@suse.de, baolin.wang@linux.alibaba.com, dave.hansen@linux.intel.com, will@kernel.org, baohua@kernel.org, ioworker0@gmail.com, gshan@redhat.com, mark.rutland@arm.com, kirill.shutemov@linux.intel.com, hughd@google.com, aneesh.kumar@kernel.org, yang@os.amperecomputing.com, peterx@redhat.com, broonie@kernel.org, mgorman@techsingularity.net, ying.huang@intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Dev Jain Subject: [PATCH] selftests/mm: Relax test to fail after 100 migration failures Date: Fri, 30 Aug 2024 10:46:09 +0530 Message-Id: <20240830051609.4037834-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: fa6toqjcx8eysaxffdugcimc7xxryxih X-Rspamd-Queue-Id: E9E9840007 X-Rspamd-Server: rspam11 X-HE-Tag: 1724994990-62621 X-HE-Meta: U2FsdGVkX1/78qAx3afKVql5tltUciEYNyVGO6oAsqPU6wfnAdMKnErORz4IHjRkY+IOJBQJj8PVNnoTTB2JviqPcGsmq22yTi7uWXkxJySyXms0EODL7ZC7YgfHE1N5hwrP8o4ZDjpewaE4q5RSNqZuFYCj7Lk0h0dAlKRXgtPYRh9r4+iYY8LOnre30Zo8mMqeo94Nm8pTRgk92+iZ1eCVEckRJR/roUh//ZmHQ8ZfNX+iM11wmUCRUYBFPzcoZTz/Yi16R7WzVCPQtIaZCxD3KMd+p9C3a+3xm9gy9oHVo7P3AydgbR3wcl+Y1eK5IDiItTo8+9bOaJk49TXgKYP6Z8uAjbLbGrpRpzpC8ZD2djvaKC426R7iD/+Z9UeeoRgdXF5N3QhtGzDtIRNq/3M4caCYCBpnC/nj53l/G01m3sOBeVGhNSkiN+XAv0ft1LfX18zxwlTH6xZXphEcRl10ty09TFzXNf2iZ4azZ1w0PIyKAr4V4ZxCs51XCex84LhcYGBcCljKt2zhHoZKHFnJ+fJdLdu2yHNl8ZhZ7PrDw1wk+QLgGw1U1mIzHnTUGtlAD+v5rsZAidGCggMFuM3DXLBePDYCznKVFVkWXG/2lCykTgJr5jh6FLwNY0N37ys1Fj+8OuIciLEfjU/zZMvBqYYq/Z9tmQgSuHwLbz7okig2x3DdxHBMhydD87rDbPOdZqj+YRHHrnqDhBytafEvaTwex3je8WXWG/8DecWwObg0uKjjzcEmMBok3L+jyoE8UWsovA4DMqPwo6NzMh/Dm5mZZs+9ccSJjpQnSTZloF4bu5XASmPRAkncYdaQ2nuISCvK5cCx6xV2a4UJEihxn6eGYYAL7xI4O3amQJuZoe8+pwXDo+wmjqnQrtZEpUxxCWLb/ozaEZJFRUOUbuASp2Beg1J2PGPUup+xfiSpNzuvfAN+jUam0wAnEGXJ351T1yHda2nWsoWrTMV PqjzF9OA 1CwEIh5CwpAshONfu/Q4CqoKWc7uFfDtEItb2GX/2XBjXD/zEGbKbJVLfQ/ZrZ4gZSEgy9K/pGbaV/XW/Ia5uelwLc/XuEv3CrviPmaurCTjm2BxFI+/CTkHpMrSH6lBl1nHVUaqw6r9csRkn98RsruSj06T8ixvG3dCTdYVx+42igEmoCuPuTyRZl9OdwhMzHGgki6TF87c5J+Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: It was recently observed at [1] that during the folio unmapping stage of migration, when the PTEs are cleared, a racing thread faulting on that folio may increase the refcount of the folio, sleep on the folio lock (the migration path has the lock), and migration ultimately fails when asserting the actual refcount against the expected. Thereby, the migration selftest fails on shared-anon mappings. The above enforces the fact that migration is a best-effort service, therefore, it is wrong to fail the test for just a single failure; hence, fail the test after 100 consecutive failures (where 100 is still a subjective choice). Note that, this has no effect on the execution time of the test since that is controlled by a timeout. [1] https://lore.kernel.org/all/20240801081657.1386743-1-dev.jain@arm.com/ Signed-off-by: Dev Jain Suggested-by: David Hildenbrand Reviewed-by: Ryan Roberts Tested-by: Ryan Roberts --- The above patch was part of the following: https://lore.kernel.org/all/20240809103129.365029-1-dev.jain@arm.com/ I decided to send it separately since it should be applied nevertheless. tools/testing/selftests/mm/migration.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 6908569ef406..64bcbb7151cf 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -15,10 +15,10 @@ #include #include -#define TWOMEG (2<<20) -#define RUNTIME (20) - -#define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) +#define TWOMEG (2<<20) +#define RUNTIME (20) +#define MAX_RETRIES 100 +#define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) FIXTURE(migration) { @@ -65,6 +65,7 @@ int migrate(uint64_t *ptr, int n1, int n2) int ret, tmp; int status = 0; struct timespec ts1, ts2; + int failures = 0; if (clock_gettime(CLOCK_MONOTONIC, &ts1)) return -1; @@ -79,13 +80,17 @@ int migrate(uint64_t *ptr, int n1, int n2) ret = move_pages(0, 1, (void **) &ptr, &n2, &status, MPOL_MF_MOVE_ALL); if (ret) { - if (ret > 0) + 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; } - + failures = 0; tmp = n2; n2 = n1; n1 = tmp;