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 F3512C43334 for ; Sat, 2 Jul 2022 10:48:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83D4D6B0071; Sat, 2 Jul 2022 06:48:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7ECA86B0073; Sat, 2 Jul 2022 06:48:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DBC86B0074; Sat, 2 Jul 2022 06:48:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5DAED6B0071 for ; Sat, 2 Jul 2022 06:48:45 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3189F21681 for ; Sat, 2 Jul 2022 10:48:45 +0000 (UTC) X-FDA: 79641836610.23.47E271D Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf30.hostedemail.com (Postfix) with ESMTP id 979C480047 for ; Sat, 2 Jul 2022 10:48:43 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=guanghuifeng@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VI6ToP3_1656758915; Received: from 30.39.96.230(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0VI6ToP3_1656758915) by smtp.aliyun-inc.com; Sat, 02 Jul 2022 18:48:37 +0800 Message-ID: <6dc308db-3685-4df5-506a-71f9e3794ec8@linux.alibaba.com> Date: Sat, 2 Jul 2022 18:48:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3] arm64: mm: fix linear mapping mem access performance degradation To: Catalin Marinas Cc: baolin.wang@linux.alibaba.com, will@kernel.org, akpm@linux-foundation.org, david@redhat.com, jianyong.wu@arm.com, james.morse@arm.com, quic_qiancai@quicinc.com, christophe.leroy@csgroup.eu, jonathan@marek.ca, mark.rutland@arm.com, thunder.leizhen@huawei.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, rppt@kernel.org, geert+renesas@glider.be, ardb@kernel.org, linux-mm@kvack.org, yaohongbo@linux.alibaba.com, alikernel-developer@linux.alibaba.com References: <1656586222-98555-1-git-send-email-guanghuifeng@linux.alibaba.com> From: "guanghui.fgh" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656758924; a=rsa-sha256; cv=none; b=AhJBMadPBC2hLKm+hAJSuKbF11oYSLMVFsCnY6wd46pxORL0L0ppD6/G6wuKA+qD/TAOnS qgZ2qxYhDTJGn7cEl4AIk1b0t12XUvF+p4Ul51OdDKsQkY385kbkKCzWyhVCMWfhNfKgvv EP2hfnQEbitkwxYjwws2XYTAAgHq7KU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf30.hostedemail.com: domain of guanghuifeng@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=guanghuifeng@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656758924; 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=58z7Nx43gpvNxRmUdXWtXlt1xY1JlGnGsfh5SUKFewA=; b=q9iU2Pk1TOrhcKw8QdrT0hQ8OBIJ3snSAHLt/moydDg4FGbPPmBqYeFApVTip1BrwV9CNu 2ZYZ9ye/TCMnpv3c2D1fjZczv2ffmYE4tWa9mO3HbFn3NtbSjwrPynGJUWdOALK3IjdnvA Ur6VkkKqvgITNjQdICWMEttScwYxdEk= X-Rspamd-Queue-Id: 979C480047 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf30.hostedemail.com: domain of guanghuifeng@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=guanghuifeng@linux.alibaba.com X-Rspamd-Server: rspam02 X-Stat-Signature: 53eqknjzgmppmcpijnahmizm9o7qd9t4 X-HE-Tag: 1656758923-728025 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: Thanks. 在 2022/7/2 1:24, Catalin Marinas 写道: > On Thu, Jun 30, 2022 at 06:50:22PM +0800, Guanghui Feng wrote: >> +static void init_pmd_remap(pud_t *pudp, unsigned long addr, unsigned long end, >> + phys_addr_t phys, pgprot_t prot, >> + phys_addr_t (*pgtable_alloc)(int), int flags) >> +{ >> + unsigned long next; >> + pmd_t *pmdp; >> + phys_addr_t map_offset; >> + pmdval_t pmdval; >> + >> + pmdp = pmd_offset(pudp, addr); >> + do { >> + next = pmd_addr_end(addr, end); >> + >> + if (!pmd_none(*pmdp) && pmd_sect(*pmdp)) { >> + phys_addr_t pte_phys = pgtable_alloc(PAGE_SHIFT); >> + pmd_clear(pmdp); >> + pmdval = PMD_TYPE_TABLE | PMD_TABLE_UXN; >> + if (flags & NO_EXEC_MAPPINGS) >> + pmdval |= PMD_TABLE_PXN; >> + __pmd_populate(pmdp, pte_phys, pmdval); >> + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > This doesn't follow the architecture requirements for "break before > make" when changing live page tables. While it may work, it risks > triggering a TLB conflict abort. The correct sequence normally is: > > pmd_clear(); > flush_tlb_kernel_range(); > __pmd_populate(); > > However, do we have any guarantees that the kernel doesn't access the > pmd range being unmapped temporarily? The page table itself might live > in one of these sections, so set_pmd() etc. can get a translation fault. Thanks. 1. When reserving and remapping mem, there is only one boot cpu running, no other cpu/thread/process running. At the same time, only the boot cpu remap and modify linear mem mapping when there is no cpu access the same linear mapped mem(the boot cpu is rebuilding it, and other cpu have't been booted). 2.Because the kernel image and linear mem mapping are splited in two method: map_kernel and map_mem. When rebuilding the linear mem mapping(mapped by map_mem), there is no effect to the kernle image mapping. As a result, I thins there is no effect to the linear mem mapping and kernel image mapping. >