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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F162CE77184 for ; Fri, 20 Dec 2024 03:13:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 793396B0085; Thu, 19 Dec 2024 22:13:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 743696B0088; Thu, 19 Dec 2024 22:13:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E3A56B0089; Thu, 19 Dec 2024 22:13:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3FEDB6B0085 for ; Thu, 19 Dec 2024 22:13:00 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DC3C514066C for ; Fri, 20 Dec 2024 03:12:59 +0000 (UTC) X-FDA: 82913865006.11.1492435 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf25.hostedemail.com (Postfix) with ESMTP id 57387A000C for ; Fri, 20 Dec 2024 03:12:33 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=VvlkFH0i; spf=pass (imf25.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=1734664339; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ulo3A7ybQt4f8+x/tGjUrzmrnvWgna2j4bZ3XTqjK0Q=; b=kA4HE4dsC6Ip2zbW99U9Ib3QXtLGTsmxzmj9vgOJRsuZ5MTKNlzN24qwc8elxZ0Sm7yCEM Wa7fcmSbX9urx77OUAJPXTvGNwxjl1zFzEIVmXyjOJlvg6H+t2UwdnVLEMnU3UDRw0sOgK wDEkpGDq71eas4jGGxYv5p24tHhPUzc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734664339; a=rsa-sha256; cv=none; b=KDNJfDO7XqFDx4Xw7dIPlo4nZ9st6v33Imdv9y3c2U+sdrQDReWQ7x5l/D0goRKkJFFnZi X1RVuHcQFpo+oxwZS7eervC0vIl3oAAjoD8zNaJt/nmf0wudifxhgXywqNdtubDkRXgrDc /G/PdlGXSKrCEJ1pgtlPfBqMgpQYq1Q= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=VvlkFH0i; spf=pass (imf25.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 (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BJNaI3h008323; Fri, 20 Dec 2024 03:12:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=Ulo3A7 ybQt4f8+x/tGjUrzmrnvWgna2j4bZ3XTqjK0Q=; b=VvlkFH0i+RxgUqIWEmuELc gBHP9OYyQtgY0a1iLwUGn55xyJSGO7Y97M5tXuUpkDdFut2mUkIUjjvRVIa54RDx Cf24ggYIfSBr+wdA/ZbYSmmoZNLpwz+JMVVDYMN9uaawUD0YFYu1WTfoOuL/tsso +sEULvH3qnYEO7J4kQvM5vHdtWRm56BxagWEW60uyOqw1HPy2b/qDEbme9vyBffX FszdpwfYYuwA01TCadxXHhZPgpdfYP+dX05fUgjME/rWDIh4qiIowJkzv2Qq3xQy wRykC8farvY/8bKrNDcm/aoAh/VLBYXo5AYCUUZBwZj2CkyQ7ZPTG1aiv/dNkxjA == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43mwaagkq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 03:12:52 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4BK3Cpde029414; Fri, 20 Dec 2024 03:12:51 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43mwaagkq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 03:12:51 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4BJNeroi014323; Fri, 20 Dec 2024 03:12:51 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43hmqyge55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 03:12:51 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4BK3CobR25100988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Dec 2024 03:12:50 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF03558055; Fri, 20 Dec 2024 03:12:50 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B08A5804B; Fri, 20 Dec 2024 03:12:47 +0000 (GMT) Received: from [9.179.0.110] (unknown [9.179.0.110]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 20 Dec 2024 03:12:46 +0000 (GMT) Message-ID: <36f9ab13-e057-40a0-8d0b-9939df056fc6@linux.ibm.com> Date: Fri, 20 Dec 2024 08:42:45 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: migration :shared anonymous migration test is failing To: Baolin Wang , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Ritesh Harjani , "Aneesh Kumar K . V" , Zi Yan , David Hildenbrand , shuah Khan , Dev Jain References: <20241219124717.4907-1-donettom@linux.ibm.com> Content-Language: en-US From: Donet Tom In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: xNu_ylKeCt0kOLPpvCoikL8IRMDk63Wr X-Proofpoint-GUID: 9xzFqPN5oGjx7xE79spXuLuXOZsBn5Uc 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 clxscore=1015 malwarescore=0 bulkscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxlogscore=935 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412200024 X-Rspamd-Queue-Id: 57387A000C X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: dzj4fhfom5mia1h6yw7kj84t6tzkqotz X-HE-Tag: 1734664353-86415 X-HE-Meta: U2FsdGVkX1+4YXoaGqKvCDIfdMZMUsh6Wcig4aNVWJChJ9V4TN9GZf3NmjYQC84DHA/zEtOkSPZqhmQgIvDzqzRbh7rmh7LrvXRX5AxR96M/idZvUSbz39w49Pvvbs47RrMVS+nfV69mUOHOLMq6kMd+jSdK9rvNZhH0Ui7XGLKW2juXl+hWHIc2ajPGfZhcaZU+P+XmpZxQgT71LWMblc8QejQAqXrRWUucjMd5c5DEwewQ/uEhbCm+zh6XvFtfSZ9iLByQcuk0eGdbkbeWlCogBEmwbnBPLklwQ0EnHJIh/ckqcClEYLTack5rEpbyS2G1X+7deIdZULeTQkf601lyP+UkNZS8OZtC1+TEG/mM78k6E74P0a+4zmXnfOqzzRQFe7evTkJU65C3ER4XlLwTlmuwxarzo/MjppRTBFXWiNdFWUx5wQZC8ssXhUG02he9uB++DsCOw44ml57VqVO1ye/3TmgCDSzE0GkK2mapJ2bngJJ2nH6r7xDGnXSZRoMrm9+r7aWWq6ffI3B1J0MTAjBdiEHMPO3HTaQ5MbESKwKWQIOuEgeOIiab1W7PRsYxL+fj55uy7ngP1bOzFH3Bzbo+IycYmfQvzlHUZI5OXZzKnWdchPuDZIuY1rPiZN7N80imi2kPpR/Bb0sdljC4gvAX93T5cHPK7nCUvAHSnFMHJvb0/7WIRxiIFtYMLpEszbArzrHxdu+NBj9dz4okWVHD7ao7zRJOtrJ1jbHea03e4LsXT9DWMdIbYY8jQ+CHV3elclI4iod+aVYO4r6ji2yYi9VdJ1uBocN9RWeqGJdoW8b3ruMdYhd6PeVPM7Vey4mvA53y8L+xBeWoZIfTIdgfxowXl/YnRMDumrh3RkygWsDd0D1uIPF/G0FPXgCJPQpEfVNu/eAxQ9ejwFRY20EgB7W//Mj0uOvbEj/CmCWbA/sbwHVwLwd2KGMSYsE5LLj5IJKxzP5dSwO Dq6Rchoh Fvjbgkh/CJTYwI1TWTm6wPnedl8DLVwIyL1Kujz5LB2LRREJT0irIzXPuejPwg/2Zhi6m74vtY1NrNyye7kJzYtrr/ZADXJcJUAU0g4STaz4Y4hczqIWIw88+LdjHBrSSHpC016RsRDhQwZHIj3188CNPQFgprIbZ+RJgKlzIhPmmU4j0WcKiiOe1gjBYccJCnT4+pFKnwPBBkVAKhes4RUOIFrPJd6c1upfqBpVKkwLbREhT2y97lsx3KeuRtZbN9KyMe0T5h+q0z0t4RGGbIvrPscznSVi6cRas8JOIm4LKjQg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000289, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 12/20/24 08:01, Baolin Wang wrote: > > > On 2024/12/19 20:47, Donet Tom wrote: >> The migration selftest is currently failing for shared anonymous >> mappings due to a race condition. >> >> During migration, the source folio's PTE is unmapped by nuking the >> PTE, flushing the TLB,and then marking the page for migration >> (by creating the swap entries). The issue arises when, immediately >> after the PTE is nuked and the TLB is flushed, but before the page >> is marked for migration, another thread accesses the page. This >> triggers a page fault, and the page fault handler invokes >> do_pte_missing() instead of do_swap_page(), as the page is not yet >> marked for migration. >> >> In the fault handling path, do_pte_missing() calls __do_fault() >> ->shmem_fault() -> shmem_get_folio_gfp() -> filemap_get_entry(). >> This eventually calls folio_try_get(), incrementing the reference >> count of the folio undergoing migration. The thread then blocks >> on folio_lock(), as the migration path holds the lock. This >> results in the migration failing in __migrate_folio(), which expects >> the folio's reference count to be 2. However, the reference count is >> incremented by the fault handler, leading to the failure. >> >> The issue arises because, after nuking the PTE and before marking the >> page for migration, the page is accessed. To address this, we have >> updated the logic to first nuke the PTE, then mark the page for >> migration, and only then flush the TLB. With this patch, If the page is >> accessed immediately after nuking the PTE, the TLB entry is still >> valid, so no fault occurs. After marking the page for migration, > > IMO, I don't think this assumption is correct. At this point, the TLB > entry might also be evicted, so a page fault could still occur. It's > just a matter of probability. In this patch, we mark the page for migration before flushing the TLB. This ensures that if someone accesses the page after the TLB flush, the page fault will occur and in the page fault handler will wait for the migration to complete. So migration will not fail Without this patch, if someone accesses the page after the TLB flush but before it is marked for migration, the migration will fail. > > Additionally, IIUC, if another thread is accessing the shmem folio > causing the migration to fail, I think this is expected, and migration > failure is not a vital issue? > In my case, the shmem migration test is always failing, even after retries. Would it be correct to consider this as expected behavior?