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 333B3C04A6A for ; Fri, 28 Jul 2023 01:06:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F05A6B0072; Thu, 27 Jul 2023 21:06:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A0C46B0074; Thu, 27 Jul 2023 21:06:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 343E16B0075; Thu, 27 Jul 2023 21:06:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 26ACA6B0072 for ; Thu, 27 Jul 2023 21:06:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EC1A81606BF for ; Fri, 28 Jul 2023 01:06:23 +0000 (UTC) X-FDA: 81059229846.04.5332278 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf07.hostedemail.com (Postfix) with ESMTP id 58B0D40005 for ; Fri, 28 Jul 2023 01:06:20 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690506382; 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=P95/xo2dD37Vct+FaT2WeWy/0AAYP8pYi+EPr7dihsU=; b=uAwUqLrqNa1S9d55T3sP0WTm0CX/96lLx1hLfnveQjZNDtX5gax0g6fOv2Lm5xS7it8Ejp we+44kmyRu/yhCkND8ja61Dz/LxRsqcpo/OsW7ByGV4oDZsuGVv9chOo+CdZIcQNcMFLf8 2UXGtx7xbypGZ2tvk+yvtqfblfOGrR0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690506382; a=rsa-sha256; cv=none; b=RXTLaUEF9dpHNscOC7gL94hAojabVCF09u9aYDHDlWDe4ps1iXZ+IwyxVyZn+4LgjSTzS8 KMYpsVjkROrfxHzYGhgb48H9E7AHTDlzPyQsolUwPTrjEwEatrnG9niC/Ssg56ux3Iozdk WU69881paMGsmlhXGS5uDYg0Yzgs5ms= Received: from dggpemm500014.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RBqC01h5nzLnvh; Fri, 28 Jul 2023 09:03:40 +0800 (CST) Received: from [10.174.178.120] (10.174.178.120) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 28 Jul 2023 09:06:16 +0800 Message-ID: Date: Fri, 28 Jul 2023 09:06:16 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , , , , , , , , Subject: Re: [RFC PATCH] arm64: mm: Fix kernel page tables incorrectly deleted during memory removal To: , , References: <20230717115150.1806954-1-mawupeng1@huawei.com> <20230721103628.GA12601@willie-the-truck> <35a0dad6-4f3b-f2c3-f835-b13c1e899f8d@huawei.com> <732e0db0-eb41-6c58-85b7-46257b4ba0b7@redhat.com> <3149f5f8-7878-dfe1-5745-870fddcc1108@huawei.com> Content-Language: en-US From: mawupeng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.120] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 58B0D40005 X-Stat-Signature: ckqnuec5ffrhpoaoum3nybs1hit8meiw X-Rspam-User: X-HE-Tag: 1690506380-209116 X-HE-Meta: U2FsdGVkX1/TZMbZYkKCykCWEBNdjGo/CxJNPMaLDHvY6X6JZLrjNyLGVAwtJafAEvQnMVayCJzrE9y7eq2xPssZ2Kk+UTkj09J1yGsovkpEL/gHy0aptD77HtgkR9l54TRHf6ffjT9zyuen3oYHEp9tyYxY6HC37JWu1zcrWtvBKSSuAEgkmEM3akGrL7D678Ah+yBV6x3Ld3Y9cbfHmlTf+R8v5qQBITlIdQmP65SAXfzeBzdgsFAbDcgs77mb96SSaarBrptUpPMtFls3mJNj1o0AOAIKEs5beOHYHi8nrQJnP9sHBxAXReMAlpTGCIxnhD10zTSc3zz3y/EaFv3MVcFybDMv8RrXy4RUl2yMA24upAwhwVyBIWvlW17IEH/gumYb76E2vmxOG8lzB9hykrpOw6lNLIUihaLdaZ9WTk4vRM3AsOnXtbyJDN4YISxsL02x9NpqWOP7kh5G2xfJFklsf25dJsAvs9XvxtOl+g53vwJf8I2V8sbxYTDYZkC/NP5TQuBj73bLacKYVyQ1SnGafy984XAeHFNaiJea7TVkwZmbjl3tmnaXFR2aFjzuN4tVClwwtpp0Fhxb5R/JsIUUjcd+pPtp+pLsFHSPxIb0hB7Qw4aJ8Gi4+ewCCN2F2jwAcPXEQY+LonxDFjUjhE1SJACFA4480ueo5iF5EY43x0QKaSUr6o6VvEaVw72+RoSRxFSvviT1RsxTIfPqlZ5UJp+z+XVI9W5R5xr6blHpOc9FQlQOW/RjpElbbhuPnR60PtHkLwj2B3v2N76lTjwKboOzHsV/oQJw22bari/2TfYi2mc0Cl/bUgxjn20EI0UJrdKimKCbNi4DBhW0nm4ugERH6Ga4TOhroKOPm6ghC5/I/vOFQwsVrh0rnCKLIBRASTTFgGZAfYqJuCvhh4sqG7WNEnndVhdn62u3MkDooZS9kGVJfpJ9oJQRYpamYUzsoFXfywfUhXQ LXiWwOJE mi7zt9gGkNQnxJAjEVHZ2gS4soELZGvuWqkYcLq1rXydDA8AJzaGS+JZJlZQ29CEOCQSpVLAHQ9KRwvAdEeXk92TVQ6AJXG9X5QPnMu+a6sn+ESNMEqu7ZJImoZuyOV31RnED6XIj38bVHr2z0LmQxMz2iPYxcWol9EhvTBMwpa7tMm/Rydh1z8YpgUzZbAh7zHhc 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: On 2023/7/26 15:50, David Hildenbrand wrote: > On 26.07.23 08:20, mawupeng wrote: >> >> >> On 2023/7/24 14:11, David Hildenbrand wrote: >>> On 24.07.23 07:54, Anshuman Khandual wrote: >>>> >>>> >>>> On 7/24/23 06:55, mawupeng wrote: >>>>> >>>>> On 2023/7/21 18:36, Will Deacon wrote: >>>>>> On Mon, Jul 17, 2023 at 07:51:50PM +0800, Wupeng Ma wrote: >>>>>>> From: Ma Wupeng >>>>>>> >>>>>>> During our test, we found that kernel page table may be unexpectedly >>>>>>> cleared with rodata off. The root cause is that the kernel page is >>>>>>> initialized with pud size(1G block mapping) while offline is memory >>>>>>> block size(MIN_MEMORY_BLOCK_SIZE 128M), eg, if 2G memory is hot-added, >>>>>>> when offline a memory block, the call trace is shown below, >>> >>> Is someone adding memory in 2 GiB granularity and then removing parts of it in 128 MiB granularity? That would be against what we support using the add_memory() / offline_and_remove_memory() API and that driver should be fixed instead. >> >> Yes, this kind of situation. >> >> The problem occurs in the following scenarios: >> 1. use mem=xxG to reserve memory. >> 2. add_momory to online memory. >> 3. offline part of the memroy via offline_and_remove_memory. >> >> During my research, ACPI memory removal use memory_subsys_offline to offline memory section and >> this will not delete page table entry which do not trigger this kind of problem. >> >> So I understand what you are talking about. >> 1. 3rd-party driver shouldn't use add_memory/offline_and_remove_memory to online/offline memory. >>     If it have to use, this can be achieved by driver. >> 2. memory_subsys_offline is perfered to do such thing. > > No, my point is that > > 1) If you use add_memory() and offline_and_remove_memory() in the *same >    granularity* it has to be working, otherwise it has to be fixed. > > 2) If you use add_memory() and offline_and_remove_memory() in different >    granularity (especially, add_memory() in bigger granularity) , then >    change your code to do add_memory() in the same granularity. > > > If you run into 1), then we populated a PUD for boot memory that also covers yet unpopulated physical memory ranges that are later populated by add_memory(). If that's the case, then we can either fix it by > > a) Not doing that. Use PMD tables instead for that piece of memory. > > b) Detecting that that PUD still covers memory and refusing to remove >    that PUD. > > c) Rejecting to hotadd memory in this situation at that location. We >    have mhp_get_pluggable_range() -> arch_get_mappable_range() to kind- >    of handle something like that. Thank you for your patient answer. This I do understand and answer my question. >