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 77752E77184 for ; Fri, 20 Dec 2024 02:55:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2D0A6B0085; Thu, 19 Dec 2024 21:55:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EDC756B0088; Thu, 19 Dec 2024 21:55:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA4386B0089; Thu, 19 Dec 2024 21:55:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C018B6B0085 for ; Thu, 19 Dec 2024 21:55:51 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 53932805E1 for ; Fri, 20 Dec 2024 02:55:51 +0000 (UTC) X-FDA: 82913821452.10.4F08D58 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf29.hostedemail.com (Postfix) with ESMTP id A2EA8120003 for ; Fri, 20 Dec 2024 02:55:01 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=bUkyTKRy; spf=pass (imf29.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=1734663333; 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=AkPWhe6t5tG0LVW3RaZ+lb0vbNfr9Mz8hx4PTGsrbOk=; b=jaX6SRgnlIM1r44ZTIj0PXxwc573BquCnj/+eJmHa9TWJsdL1sM6rlsCq1fmlYR42w9Sax pO+C4tkwc0c1/clleW7/BfKm13zGT1BKw7Rs4XWY4djxKxZI5e1j8+BKIjve5lNeeSQkbM jL7EtoZ2ilVVRBJ6Xc97HHgSqABPzWY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=bUkyTKRy; spf=pass (imf29.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734663333; a=rsa-sha256; cv=none; b=3SDDPy/Wgq4kIMSaJXY1DPHl1OiBXWrkjpiJw0KE9NfXEPv6T028KV2neiLlURtGagFPs0 4dZmy1CainpcINwH6SQ22IOIECsnJTJlMwGj3nxYB307KDx7T19BLE17WrwyumKiZNlVQy xy9I6Y+TUrKz+B+o8K1omp1uk9bApCs= 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 4BJNaURs008630; Fri, 20 Dec 2024 02:55:43 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=AkPWhe 6t5tG0LVW3RaZ+lb0vbNfr9Mz8hx4PTGsrbOk=; b=bUkyTKRyeeYySx9cIisHMO K2Jctdtj1RP56AaBz/fDLW/NCf0tW/3Qi7e8Q/yhvFBhYI3qqggbAFGjqDQPJyJw AniuP0xVTceEKJlNVTTH31nwy5JG6FlFDyBAM2Htwik44mWBMClLSxnrvVp8TK0W NCrpnTvhM/qWVEpINQF5B12UECoCKn3IvmPpAuc764vWoq6t+Z72ZbK52wIxF5ny XNRcJH73AoGcbg/JHipO3t6T6w3RXNJYl4qtAUmlkxHpxsrklYpmPdr0frO9fsrY A0kZ5B69RsnCE/5iIG3R1h8lEbuT7AUduE8G7e4FfzGhbHtVTeZWIuTRiLHC7o3Q == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43mwaagjb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 02:55:43 +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 4BK2thnD029000; Fri, 20 Dec 2024 02:55:43 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43mwaagjb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 02:55:43 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4BK10Mfx005564; Fri, 20 Dec 2024 02:55:42 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43hnbng89c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 02:55:42 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4BK2tgmx39322134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Dec 2024 02:55:42 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B16258055; Fri, 20 Dec 2024 02:55:42 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54FE35804B; Fri, 20 Dec 2024 02:55:37 +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 02:55:36 +0000 (GMT) Message-ID: <9bc000ab-1982-41f0-9ca0-2a4ead9aa982@linux.ibm.com> Date: Fri, 20 Dec 2024 08:25:35 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: migration :shared anonymous migration test is failing To: David Hildenbrand , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Ritesh Harjani , Baolin Wang , "Aneesh Kumar K . V" , Zi Yan , 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: 03vuiCjA-V0Qgf5Yk4pq8FtvDd6iHdPe X-Proofpoint-GUID: ToskKSOkd6mHJudQZOBHIWO1YrXlmpnc 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=792 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412200020 X-Rspamd-Queue-Id: A2EA8120003 X-Stat-Signature: 7oruugnybcrha3diupak7pjbh33kgdct X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734663301-126314 X-HE-Meta: U2FsdGVkX18QNs2rf06rGVHNPiZVU1mOjpNEa0gg41+sb+6BXn4H93ZRa5mf7L08NSlhshBqoIvC5iuvElJV19qBNU2lJiwVwDvXfP/Aul44KgAbmtg5Ciu800fGKuGnE/4jWJ+Dvtcp530e0RYA/AAqxYQAAOwmMPr6RcxHe6bVaOqQX7rN/yqgfo7ip7v06xjrSysbGTawY6nEzhfK57Wjv8uoMXbo6Vn1svtbu7FcOGvJxQytAR9s/uQKd/Fv30wYLeF6/nFTjsMFW9fGcVpRogCkqxLHqqZ4ncHvMvk0MsmNNy+GqDrSlmDCbvJYG5AKA4uJTcAI+Vpq4AQ9YBaSwxK58kZAWFPkHcJ/BbYRqtavdztKfVlWpnkFXcwm/tjXmlbcBFiAylVUe971jBydYH5/qTwndAWaYdiq2/LQQNufwxSmaxr3JuFgWnqxXenRsoCPSPhyuYDtxsx+ZPdgsQ9eSqdCzRdLvyKN1xObrkNSoEWyXiRzxHNctDQefjPLN/7cjnyaeKVZPItzDX/97bgrsEP3XzMmgW8CPGh6mwpk9Py7oykYuuzNCTKBnN10WETYs5T+7wN1DUfWpXZ+PFiYzWBAjRc7ugw6pJnUz4BjZWZNfXen704oS29pavQr2S/IFPz2vByEMiqTcpkpkah6Q8Z4zXzrCiLMeQHhiXKMhW3URIvajMUNS+k/PWUUcePRqH0X/iJirMqKSDIlLZW8q1cK8XXoaqXgqMQZp5DXdOWyX6UQjrYasmPqO9fAhpttDBfdBRkYCIerdshE0Kyg/hVTXaRMUcmkKfTF1FbbG7o+62mQVNqeeT6i7UHM8r6A6EpBUnlEIF5AciWX/VshlrmN5WORZjvp0UZE3eENaP9dC0ZI66zwtWHlPxB7iIjHR93xddc/Ck4rs76rtQztGFP8XB+fY4c/RltP61hKWyhUsNB6JVuBS3M94vPBmpHJFF2jPIClfCA jwSWxfOh R0D/bix+HuT5YfGTqT0Yge3uqMT2D9cpHl1ZkOLqPAzPntAc6GvEyUta5PkftFruWxCge2drCR+YEcztRb+RANWuTjB5Y7w8wgdZKEiaZ0znPqhniR15SGomr7ByrLlcXPuVpYCPkxeP7/0FdzGZMWhLtuR/ku8orZIepzmAcg2i9GPSSPxSF1BMUABnVAACEEzKTKOCLMeAEW49mdilNcTIDy7qDgjzks9RA1pmIMRtS+Dg+4sFAZYeTJCpWcJS9lc/e/2Sds9qQCtuQoCddsEwCJVCfn7JzGSnHala11sG+6F4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, 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/19/24 18:28, David Hildenbrand wrote: > On 19.12.24 13: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. > > But what about if the PTE is not in the TLB yet, and you get an access > from another CPU just after clearing the PTE (but not flushing the > TLB)? The other CPU will still observe PTE=none, trigger a fault etc. > Yes, in this scenario, the migration will fail. Do you think the migration test failure, even after a retry, should be considered a major issue that must be fixed? > So I don't think what you propose rules out all cases. >