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 AA77CC4332F for ; Fri, 10 Nov 2023 08:36:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15C8D4401C9; Fri, 10 Nov 2023 03:36:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10BC14401C7; Fri, 10 Nov 2023 03:36:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F15334401C9; Fri, 10 Nov 2023 03:36:53 -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 E19EA4401C7 for ; Fri, 10 Nov 2023 03:36:53 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B79C2B5C4D for ; Fri, 10 Nov 2023 08:36:53 +0000 (UTC) X-FDA: 81441389106.16.B77DA65 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf12.hostedemail.com (Postfix) with ESMTP id EF54C4000F for ; Fri, 10 Nov 2023 08:36:50 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699605411; 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; bh=T8GZ50Wl1jeQhqMnBzYcbTMq73o/P/lMO4stA4Hj8bU=; b=i7E1Gtec2OuT2EaihIytjjrLPZCbL4d9pDhi3rVhRLNXtwV4ryYCy01CQhHrtLn4CQ2hGr EZaHZrm2hiTAKSG2wj0pk45Maz2KaW7KMyRKcA0DLZpd/zuHy5Jns2Mvas6A0qAw/qucFL z/NZ7JspfAL8txqS8C1QC7qyGWbXZkU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699605411; a=rsa-sha256; cv=none; b=SjlByTtEBfMs0pxb4oyzc4UjMXYTe6p71Nf2twVSMnBZFcUemWjJIYQaw1q066PYaHGJnz MHMuys+pfjEJEh36NSnTDMjkQ9fKTQMvSyvVCJNS3Tt+Ocg0452VipiZR6kYcoR7M0S0H1 uBS0bIZGUVFy5zlSdoxuCzzjN38eoqU= Received: from kwepemm000020.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SRXB81ncWzMmqx; Fri, 10 Nov 2023 16:32:16 +0800 (CST) Received: from [10.174.179.160] (10.174.179.160) by kwepemm000020.china.huawei.com (7.193.23.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 16:36:45 +0800 Message-ID: Date: Fri, 10 Nov 2023 16:36:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [Question]: major faults are still triggered after mlockall when numa balancing Content-Language: en-US To: Aneesh Kumar K.V , , CC: , Matthew Wilcox , , , , , , , , , , , , Nanyong Sun , Kefeng Wang References: <9e62fd9a-bee0-52bf-50a7-498fa17434ee@huawei.com> <87h6lunqqw.fsf@linux.ibm.com> From: "zhangpeng (AS)" In-Reply-To: <87h6lunqqw.fsf@linux.ibm.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.160] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm000020.china.huawei.com (7.193.23.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: EF54C4000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: msu5ztf1czwpzkkch3gjc1jyuc48er4c X-HE-Tag: 1699605410-300944 X-HE-Meta: U2FsdGVkX1/ZknSSkgfdqpP5YoYHX4Y9Xgscx1y3VEiEP26f8M3PBCffSh5DaXYODcEwnh77sweqozE28u7UrosfI3HJUWEoXsydayCT0rXfqAZpoIRDd9Vh+TlZQaHrZ3d0JupRjytFmZn3O5eh2T1iLeRqU/eLDYXS4A+lKQlJ1x/DaG6PlDVf3T1F4TRNkvxhZAfa1PdOyOpmPGeb1JCe8kNvLqL2aTfqpxyfqRXQ9P+2lsGe73oJWX3b3cUsCLjgY/jwPmoKs2E8zLHNQoItw0x61LP1oBf+17LPPO1mnnhVTJ9P1VQ786XyDjzng1ReXIwPTMbW7JWarZ6D9PyQ2QRSkDVp7H3gqUXZbn96JvxXb7CR3LJzcor8eCLR1+ipbIIQtCc3L3tUX8JwSvDzisl63/XGci9v11kov2hvKXaLhEYUQ0zpbZY7CbxsjoGsQzztvF9eNQKQ2xxqVx7fgqRskyqpJO5WjjM/k5G9HjlEIqPXKgGItJ9LuDJTt44HBBzYtPhCxnOizWB/olOAMcPLVURrHlJ7pZC3qIftiIYT+UYIkZQP2G37wfeqxJctBA/A3WJbnlejuAlQlNg9974M/zWtc8eURUyuELpBprU/SNp0ThCR5/w0DTnFJpo3tp7gHfogF8aAYEIIGgRzFU4NSrS3JRNhi+pxSMH2uOOSW0Prps7jnm84bFjiO3vikNtJwvupoe53KFx/iRsOt11FkPySIjXOIfwZZLdvty9PEGLfW9vwEFzWNNGFe8EDELiyqydaCY3Rs0vjka1m/yf0xg13Ht9CSf07lgIr6GcXsXgK8d1EdXt2pa2pO2JaHDHUfI1sO579g5IiSl3HG5tE7HUPWJtcQ8NBHUpsjziUXMqML8cB7ptuYUaCrAxoW9hMAEYVb6Uy7zraoQ31Uye5BsY4k5r1yMQIu31uNkZk2R+xQqljMBRhC78pk4P6xeL7IRfezszVgUC d68hN9CE ZdNiEH+GbfVpJWpVhmkVGDrOOBSmRjNv+44K5XzitEzUTzPvYtugq7sOuEYYCXXbS51CKRIqvfuwdeZpOYv8jk0mfHDpqwwniE6ZCjzJJxExn6xw7owvgiaWZjLCxkQ5M/+/Tac3ZwWf51tRojLa5jTh4lErzDVLbAWmU 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: On 2023/11/10 13:04, Aneesh Kumar K.V wrote: > "zhangpeng (AS)" writes: > >> Hi everyone, >> >> There is a performance issue that has been bothering us recently. >> This problem can reproduce in the latest mainline version (Linux 6.6). >> >> We use mlockall(MCL_CURRENT | MCL_FUTURE) in the user mode process >> to avoid performance problems caused by major fault. >> >> There is a stage in numa fault which will set pte as 0 in do_numa_page() : >> ptep_modify_prot_start() will clear the vmf->pte, until >> ptep_modify_prot_commit() assign a value to the vmf->pte. >> >> For the data segment of the user-mode program, the global variable area >> is a private mapping. After the pagecache is loaded, the private >> anonymous page is generated after the COW is triggered. Mlockall can >> lock COW pages (anonymous pages), but the original file pages cannot >> be locked and may be reclaimed. If the global variable (private anon page) >> is accessed when vmf->pte is zero which is concurrently set by numa fault, >> a file page fault will be triggered. >> >> At this time, the original private file page may have been reclaimed. >> If the page cache is not available at this time, a major fault will be >> triggered and the file will be read, causing additional overhead. >> >> Our problem scenario is as follows: >> >> task 1 task 2 >> ------ ------ >> /* scan global variables */ >> do_numa_page() >> spin_lock(vmf->ptl) >> ptep_modify_prot_start() >> /* set vmf->pte as null */ >> /* Access global variables */ >> handle_pte_fault() >> /* no pte lock */ >> do_pte_missing() >> do_fault() >> do_read_fault() >> ptep_modify_prot_commit() >> /* ptep update done */ >> pte_unmap_unlock(vmf->pte, vmf->ptl) >> do_fault_around() >> __do_fault() >> filemap_fault() >> /* page cache is not available >> and a major fault is triggered */ >> do_sync_mmap_readahead() >> /* page_not_uptodate and goto >> out_retry. */ >> >> Is there any way to avoid such a major fault? >> > This is also true w.r.t change_pte_range() in addition to do_numa_page() > ? > > -aneesh It seems that change_pte_range() should have similar problems. However, the trigger frequency of do numa fault is generally relatively high, and it is more likely to occur in actual scenarios. -- Best Regards, Peng