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 105EEE77173 for ; Mon, 9 Dec 2024 05:01:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 864436B031B; Mon, 9 Dec 2024 00:01:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 81E756B031D; Mon, 9 Dec 2024 00:01:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B4FC6B031E; Mon, 9 Dec 2024 00:01:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3F2006B031B for ; Mon, 9 Dec 2024 00:01:02 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A72B4ACB01 for ; Mon, 9 Dec 2024 05:01:01 +0000 (UTC) X-FDA: 82874220912.28.0EC3FA7 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf01.hostedemail.com (Postfix) with ESMTP id 8DD684000E for ; Mon, 9 Dec 2024 05:00:43 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733720450; 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=+/9xgkqjqo66ofmNdWTdMqaQBenkeZAR8cffkroGbMw=; b=XIUnvrK4zg+ezALRhD0ENuFW10q45FrUdgOoWVlwVBli6G9Me+G7etqfuoDEEGLk0cRTFo kmhKFF9TyTpcKSjP+6VCYvHUnOUpm9JZBhBfAc6c4Gl9LLtpO4tPgTKJwVllGiZXUA6jfL wEQAWLuhsW5ajDQ1LwboDipejD819t0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733720450; a=rsa-sha256; cv=none; b=OnJLXLJnA00Vpa13mCJhqRYb1ucC07iIQKxwaqNcyFZGXYEkJah00SFgPGu4LTn9VWDGcV sxN4lakTPCEXAFyXBrgonRTHEfMS7wrDsv9hUCWoCiQw+q45+XMWOfH9APz7iVP4t0tFTb 2LkXbyCgs/FqH+JSYzBWPW5A8cgzRjI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Y68kR6XSqz1V5sW; Mon, 9 Dec 2024 12:57:51 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 9D1381400DC; Mon, 9 Dec 2024 13:00:54 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 9 Dec 2024 13:00:54 +0800 Message-ID: <59025011-0525-49d2-9dd9-e275991748ad@huawei.com> Date: Mon, 9 Dec 2024 13:00:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -next] mm: don't try THP align for FS without get_unmapped_area To: Andrew Morton CC: "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Christophe Leroy , Rick Edgecombe , , Yang Shi , David Hildenbrand , Ryan Roberts References: <20241206070345.2526501-1-wangkefeng.wang@huawei.com> <20241206223456.255b00b35cb554987e48daae@linux-foundation.org> Content-Language: en-US From: Kefeng Wang In-Reply-To: <20241206223456.255b00b35cb554987e48daae@linux-foundation.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8DD684000E X-Stat-Signature: e7ekrputjauiqah75dubx5ty7w4tzi4g X-Rspam-User: X-HE-Tag: 1733720443-994581 X-HE-Meta: U2FsdGVkX1+ZAWHwxwUuII/ggSKjYbvVu7O2N2wImGca8Htm7tyHLyXl7aFSCs15Kxz/h8WKvnvGjstZd6OhkejycUhprFnsKgwpjw7Vav810DLApPvZIXK5aP1yAYApp6G2eqkhtJ0GMXNqsQ0oI/n3a3Kj41Pl8U/fAhuuFjDbuZhjKjIxtBeeqB/hb6XgVhA2V6m3cD1A9LRhOvMmmCe4w1Da64GE6yugX+SgG8K9gbcWqaThNPGBoxVIw5mcVFb6QxGQOpFEFDVieFWYi8XTUlNwV8d2fRbHP5R4huxNi+8jrTu8gsp6CQJI+Lr80t8aigTrF7j00H6G7nsLzbZLGwN8DlfCifRLgl0mJgNawz6qYzxLUHgvDDQfEAj6hfFhvMQ+FIS9bC4qEzImk5VC5VdRI0eTEevDRFtz2aWR1lY83dgajv8ZSEhdcyA5PR6g2nZ2GFbjeZ/7nXqw4rkXgU6oTMl/OZNPDybRs1ae5dtCh2OUeimy6UojuTcY6wCMzqrIVjvb/2XQUx79jx4qQxlFr8pUCfeUyoqvkzDhue4dm+oQafldipHLeq5SoGtbHqNVLHgxVTh5BnfGjAwbStMxQR5fzhHHM2iCyFjafBMU5ZHm1SLmclL/LASoMYXadNDlmTGwkyxILbliQzbzFWbC6MStnX50icl5mKN7tId5gkarpPPXYnnVHapBEgeWNACEU68JCYPBOueXOaYPZ7IpDSS7fCfe6UYEaLpHW43+yS/ZqIRGzbguutGIxXSgcUrHnEoI7L0V/0iosHRBOJKBbuJry1YqJGvSIkS9cHVs9nNpSYmXJeQxzb0zGxBfdiOw0yd6Vrmmj6g1A6roWHIcAkkzTLz9h8WXPU/CLXUruCkqATfnrcdWzQqerQKtGlTYTCHkFLtXSa0z7q/YXBRAi8nD2p/UjuzPikilfLo5XoPqot3JIKetufRoma6KZfImFxfXU97UcR3 2KO96TZm 6Wst0blvpDSSyzXBnwLmCswXgIiEZb95MMVU+ch3OpwAwhuvatRNsr6Se60wyfVny81jRHbnvJT5fGzuaru7ENdq2XClJ8mIpYF1LhNM1BZjJHXSDRAY4OXZUiOXL9NM6C0+ba1mU85jbSXpzWdzvDbx8TlbvbxU3ieR0EoIx4wUFzOk2LbMo13kDk56LxcYyRP+0NNtGyjsm4Cifz107GzY7zYxoPuLCXPLuTgynmm6w9TM= 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 2024/12/7 14:34, Andrew Morton wrote: > On Fri, 6 Dec 2024 15:03:45 +0800 Kefeng Wang wrote: > >> Commit ed48e87c7df3 ("thp: add thp_get_unmapped_area_vmflags()") >> changes thp_get_unmapped_area() to thp_get_unmapped_area_vmflags() >> in __get_unmapped_area(), which won't setup get_area for anonymous >> mappings, but it leads to always try THP align when file ops without >> '.get_unmapped_area' callback too as the get_area is NULL. >> >> Since commit efa7df3e3bb5 ("mm: align larger anonymous mappings on >> THP boundaries") only want to enable THP align for anonymous, adding >> !file check to fix it. > > The above is tough. I attempted a rewrite, please review for accuracy > and completeness: Forgive my English, thanks for rewriting the better changelog. > > : Commit ed48e87c7df3 ("thp: add thp_get_unmapped_area_vmflags()") changes > : thp_get_unmapped_area() to thp_get_unmapped_area_vmflags() in > : __get_unmapped_area(), which doesn't initialize local get_area for > : anonymous mappings. This leads to us always trying THP alignment even for > : file_operations which have a NULL ->get_unmapped_area() callback. > : > : Since commit efa7df3e3bb5 ("mm: align larger anonymous mappings on THP > : boundaries") we only want to enable THP alignment for anonymous mappings, > : so add a !file check to avoid attempting THP alignment for file mappings. > > Also, the changelog failed to describe the userspace-visible effects of > the flaw, which is basically essential when fixing bugs. > > The bug has been there since 6.10 so it would be interesting to learn > why it took this long to be noticed. Found issue by code inspection. THP alignment is used for easy or more pmd mappings, from vma side, I don't think it will introduce usespace- visible effects, only different vma address, but I don't know if there's any other effect.