From patchwork Thu Dec 19 10:27:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donet Tom X-Patchwork-Id: 13914927 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 BA132E77184 for ; Thu, 19 Dec 2024 10:27:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 197EB6B0082; Thu, 19 Dec 2024 05:27:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 120F76B0083; Thu, 19 Dec 2024 05:27:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB5F26B0085; Thu, 19 Dec 2024 05:27:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CE2956B0082 for ; Thu, 19 Dec 2024 05:27:33 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7441E14155A for ; Thu, 19 Dec 2024 10:27:33 +0000 (UTC) X-FDA: 82911331608.28.6A172A1 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf19.hostedemail.com (Postfix) with ESMTP id D70601A0007 for ; Thu, 19 Dec 2024 10:26:56 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=sV4AGMNS; spf=pass (imf19.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734604029; 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:dkim-signature; bh=8BdCbc0aWpyGMPoKibD+Rzg4VO7AiW9QJCqyQkaUKJI=; b=PUOtWZHvNz9kmw2pwsK/nzN2RrgEXyI39bBWGDcZ2Urzs+TWJumk/z5nhjmFR7d8SGy8Pr saP0HjZLhlSPFLvrORxaa4cQkk5GYbyZ+58dRIZyAL/qyzUkQMUIaUHwKAqeQVOgYm81rz V3GjIykqlt6gYh5/JeNjEE7bTfaAZl8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734604029; a=rsa-sha256; cv=none; b=CFYN8S2+GlsDScDM6XTfN3ijvLCcxxjh3106lBhPDAczToNbr4PuHHijW25KiELbiAN+Ia 86pkOYb3YQCm0Xv+ia/B7kvulmMyScSoabA49ZD+LAiSik8WnJY3ul4MZOjptIfIDTKAnm C5Mvfq8oPn3YeOtORIAZ1SsSTtiU6kA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=sV4AGMNS; spf=pass (imf19.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BJ0w5RB009282; Thu, 19 Dec 2024 10:27:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=8BdCbc0aWpyGMPoKibD+Rzg4VO7AiW9QJCqyQkaUK JI=; b=sV4AGMNSISzEP4hGSkp+agy+gJOn0zA8y+4pXIDw/NZX3k1DgmJoZcTwF Oe/aDn5DiIePEx+rLbqKm/BBNekCnfMwOLDHE6f/LWzscSJ7zBZAf1oWz7QpMe1g p1joTZos7oAGHsgAjZUgWVxAsIZj/jQl9F32fq9fjeyF8WhAez3UO3kGMjq2Nwcb DyIjcwaRpfx+010v8uIICQkzsMiv1BZCzKsQHvCwhqPHDpDICmOB3JVgQmNRE1xJ I/BCKsQg3kMR0lqeiG1NtHXPOSWNpsdWOh2Ly1srvQzDTlKabL0p/WLxuMv3KrOR T7duYMLD33m2T4dwuVlPujuQ4QqyA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43kyv4vvr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Dec 2024 10:27:26 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4BJAMphA023538; Thu, 19 Dec 2024 10:27:25 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43kyv4vvqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Dec 2024 10:27:25 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4BJ732tv029728; Thu, 19 Dec 2024 10:27:25 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 43hmbsvwgt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Dec 2024 10:27:24 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4BJARNQH55902470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Dec 2024 10:27:23 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2582220067; Thu, 19 Dec 2024 10:27:23 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9796D20065; Thu, 19 Dec 2024 10:27:21 +0000 (GMT) Received: from ltczz402-lp1.aus.stglabs.ibm.com (unknown [9.40.194.31]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 19 Dec 2024 10:27:21 +0000 (GMT) From: Donet Tom To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Ritesh Harjani , Baolin Wang , Zi Yan , David Hildenbrand , shuah Khan , Dev Jain Subject: [PATCH] selftests/mm: Added new test cases to the migration test Date: Thu, 19 Dec 2024 04:27:20 -0600 Message-ID: <20241219102720.4487-1-donettom@linux.ibm.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4VB2ASD33czmFKJnF1RMbaav34FvzEOH X-Proofpoint-ORIG-GUID: XaV_nVvu-X8CjbA6panhQFhjzWYpS6qW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=827 mlxscore=0 spamscore=0 impostorscore=0 priorityscore=1501 adultscore=0 phishscore=0 bulkscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412190080 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D70601A0007 X-Stat-Signature: 7i7mi34uaaj19no1pxbij6xojjmimixo X-Rspam-User: X-HE-Tag: 1734604016-533509 X-HE-Meta: U2FsdGVkX1+coFTZp8zvbJ4gXYR9Gn03e8snWbHQBHS/m5uePdA70GqGF+jHcqwSX6bglOhnGNhQIR96YQsE8QKwqVqy5wnNzlorusphlRcwO2Bo53+Bk4mKAIoecoyQZQiTj/T+NtNUnndh0Cf/aeeBgGa9AkMjAaRFgfnDZPqGcehpDlXLmjkSaK/A4ukg2ksZe77FF7US/En81tsGgMayHcj41C3jkkx7rXkTNnoML/4z9+M1fUJHa1PHAywiYfaoUMCa834/p62cmTBsNtA8PM8oGKDMQvRL+OtGI2mQXNmvMk4yDX39avLnEJA1kYiIFQBiCRyAHwKRJyRvawOGD6YqsF21zG5s1X2lUI1gFHVv5k4LZNs0NmmgRKiIXpdzYgI/W86XPku9HfbfqxaWm+o7WlXFITqWYEZxw7tIkVdS134XiDSuvyewE9QPMsmF+4HiLBXFrD7DpG9lOoDO3HcL3qTvq3MOKDzngrfkvLfzLyNG7G8fp7PZ+AL/FAyktySle48VDZUKP3Cerex3wVdrpTedK+nIJkf4Se+YWn/yD6HQLIXNnVw+8jUf5286+bkIq3TS8mfnMbvLBOwJ2H9IyfmzkUmB/FKrnPww2gB5SgQ6fyxXYyLudkrFGQMqkOouWZd0Pz1uqdJVgRYDrsMoxRTb650DzWugrukjRs544OYD4gn2t0+wl4HMZS6SqSBKTqhU7vlEx9YTaFvfmTYCvRMuISdosAvLtdF5K8xfv/JOBgbmzbBEY6NSKi44Lxih/rlVsqBeKc+nTMA4EKttCiJ730plD9rGoBigF0/h/jhqiqqwejazBeTs6+zaFLkCYSiAnbBkz0wReLNHmE5NzDMEokkbUgFobS6VqMoLlLOTGpWCqItRcFkvwvBES95+OvLlsmaD1OHM3A4VbMQgrstpQcDs+xRVaRMDoElf6mYb0qPqE8CrJaqusKHyybb/1tg5FLS/LPm G0vetZ/m CinmPhvbOCkTr0tvljDhTihC8YZSla6er4tjEp2gLfu4NorkgW65dJ7EXal8Vo5bsCLcAIZjDnj5L+jqPixSCMKq2Y3aWoezR0KqoO1RUTJIK7jgx+kgJyELZ40subxL+DTObF47t+gncQkilyQCsJQJPg3imLKbk4jlx9hjG+vwSwTy/MtmvWf6sIqjZ72TvLQYwMrA6NyPr93keV+iqbXkWQpOqc5Bf5jvSaj6RJdCw/Tl5vn9NC07z5sC+KbB0o6NoUriQwJik5pkYd7mQ9d8b3ppWt6ENk5l4a8LTZN5scPFqJ4V4oBRNUFFqCW6XnjRlRqd8WB2/zlVGKc7AxM6fVQIfpAKGr/yrs3WtS+Q/XfQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Added three new test cases to the migration tests: 1. Shared anon THP migration test This test will mmap shared anon memory, madvise it to MADV_HUGEPAGE, then do migration entry testing. One thread will move pages back and forth between nodes whilst other threads try and access them. 2. Private anon hugetlb migration test This test will mmap private anon hugetlb memory and then do the migration entry testing. 3. Shared anon hugetlb migration test This test will mmap shared anon hugetlb memory and then do the migration entry testing. Test results ============ # ./tools/testing/selftests/mm/migration TAP version 13 1..6 # Starting 6 tests from 1 test cases. # RUN migration.private_anon ... # OK migration.private_anon ok 1 migration.private_anon # RUN migration.shared_anon ... # OK migration.shared_anon ok 2 migration.shared_anon # RUN migration.private_anon_thp ... # OK migration.private_anon_thp ok 3 migration.private_anon_thp # RUN migration.shared_anon_thp ... # OK migration.shared_anon_thp ok 4 migration.shared_anon_thp # RUN migration.private_anon_htlb ... # OK migration.private_anon_htlb ok 5 migration.private_anon_htlb # RUN migration.shared_anon_htlb ... # OK migration.shared_anon_htlb ok 6 migration.shared_anon_htlb # PASSED: 6 / 6 tests passed. # Totals: pass:6 fail:0 xfail:0 xpass:0 skip:0 error:0 # Signed-off-by: Donet Tom Reviewed-by: Dev Jain --- tools/testing/selftests/mm/migration.c | 99 ++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 64bcbb7151cf..1e3a595fbf01 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -204,4 +204,103 @@ TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME) ASSERT_EQ(pthread_cancel(self->threads[i]), 0); } +/* + * migration test with shared anon THP page + */ + +TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME) +{ + pid_t pid; + uint64_t *ptr; + int i; + + if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0) + SKIP(return, "Not enough threads or NUMA nodes available"); + + ptr = mmap(NULL, 2 * TWOMEG, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + ASSERT_NE(ptr, MAP_FAILED); + + ptr = (uint64_t *) ALIGN((uintptr_t) ptr, TWOMEG); + ASSERT_EQ(madvise(ptr, TWOMEG, MADV_HUGEPAGE), 0); + + memset(ptr, 0xde, TWOMEG); + for (i = 0; i < self->nthreads - 1; i++) { + pid = fork(); + if (!pid) { + prctl(PR_SET_PDEATHSIG, SIGHUP); + /* Parent may have died before prctl so check now. */ + if (getppid() == 1) + kill(getpid(), SIGHUP); + access_mem(ptr); + } else { + self->pids[i] = pid; + } + } + + ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); + for (i = 0; i < self->nthreads - 1; i++) + ASSERT_EQ(kill(self->pids[i], SIGTERM), 0); +} + +/* + * migration test with private anon hugetlb page + */ +TEST_F_TIMEOUT(migration, private_anon_htlb, 2*RUNTIME) +{ + uint64_t *ptr; + int i; + + if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0) + SKIP(return, "Not enough threads or NUMA nodes available"); + + ptr = mmap(NULL, TWOMEG, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); + ASSERT_NE(ptr, MAP_FAILED); + + memset(ptr, 0xde, TWOMEG); + for (i = 0; i < self->nthreads - 1; i++) + if (pthread_create(&self->threads[i], NULL, access_mem, ptr)) + perror("Couldn't create thread"); + + ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); + for (i = 0; i < self->nthreads - 1; i++) + ASSERT_EQ(pthread_cancel(self->threads[i]), 0); +} + +/* + * migration test with shared anon hugetlb page + */ +TEST_F_TIMEOUT(migration, shared_anon_htlb, 2*RUNTIME) +{ + pid_t pid; + uint64_t *ptr; + int i; + + if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0) + SKIP(return, "Not enough threads or NUMA nodes available"); + + ptr = mmap(NULL, TWOMEG, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); + ASSERT_NE(ptr, MAP_FAILED); + + memset(ptr, 0xde, TWOMEG); + for (i = 0; i < self->nthreads - 1; i++) { + pid = fork(); + if (!pid) { + prctl(PR_SET_PDEATHSIG, SIGHUP); + /* Parent may have died before prctl so check now. */ + if (getppid() == 1) + kill(getpid(), SIGHUP); + access_mem(ptr); + } else { + self->pids[i] = pid; + } + } + + ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); + for (i = 0; i < self->nthreads - 1; i++) + ASSERT_EQ(kill(self->pids[i], SIGTERM), 0); +} + TEST_HARNESS_MAIN