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 EB193C48BC4 for ; Tue, 20 Feb 2024 06:28:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D0DC6B0083; Tue, 20 Feb 2024 01:28:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 880E56B0085; Tue, 20 Feb 2024 01:28:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FAF66B0087; Tue, 20 Feb 2024 01:28:49 -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 5B34C6B0083 for ; Tue, 20 Feb 2024 01:28:49 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 04A631C00B2 for ; Tue, 20 Feb 2024 06:28:48 +0000 (UTC) X-FDA: 81811203978.02.D780CB6 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf15.hostedemail.com (Postfix) with ESMTP id DA2AFA0009 for ; Tue, 20 Feb 2024 06:28:46 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="M6 hcCK9"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf15.hostedemail.com: domain of quic_aiquny@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_aiquny@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708410527; 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=Xd2HlGPjlW3lnWzmcbx40LZsSwC7XGHf2iTmpoAjFfg=; b=m+2qzq87T0OpZvU1LL6gJeDMOSJqzGp+HPwaZcvvSlhET8mOO+BEU6eBAI5L6dAXGQd2Xl xMKWoqThekJQjf3MFnIBQ+AG0N9Yhy600j97j8Y0VqDKton8wCtMZn2niCXZ5MuuEVLFT9 8gJ50jjGiCFTvDVf6/1U4XcSsdbwsw8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="M6 hcCK9"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf15.hostedemail.com: domain of quic_aiquny@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_aiquny@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708410527; a=rsa-sha256; cv=none; b=ddyQ+joFHZ7JXYX4ocsIWMgc7aCZ/Szo17lyE555MrIGAJusqtoa8peoZ/p1792YpJzosG I0m5K34J9j3NsSCGvpogG78feK2ZlqlgkwQmuV0l0xbT7vNFY6wBi5HGL2GJLQDr6X8fYE VlAAry28kAxSjlztcPNLZfgbO/02bsU= Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41K10CfG021178; Tue, 20 Feb 2024 06:28:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=Xd2HlGPjlW3lnWzmcbx40LZsSwC7XGHf2iTmpoAjFfg=; b=M6 hcCK90UJshfW5GkD+Hy2EYg+AsBe+3yMRXMHJaZZtufY1Zu3FUEC2xSSYfutZlEV 7gOl7fkrkWtViNVds6v1lwNRFR+7KbIhLjkhTWhh20OuWhDEVgJmVcBlxgEvMvHA YTnsmV8JoeYnSM8XnUUsplxRltlFp/SZg4eIZ4rTb78PxrVZDdaTuimBBIESfWMT 3FiyyDzufDgUPMfZTvL8CcE58z50rQ2OzOx4a8f5JjctBWqYBIHx5FUWiIvvi2fx vlT3F67kH6ObMhNGhoxBElYQDlE+2TtQBvxWTSN1g8o+dT1o40WzWWPcb6p/nBek ZcyMliMx3FNcxGOv80uA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wc54b20w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 06:28:39 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41K6ScY7005432 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 06:28:38 GMT Received: from [10.239.132.150] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 19 Feb 2024 22:28:35 -0800 Message-ID: Date: Tue, 20 Feb 2024 14:28:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: memblock: avoid to create memmap for memblock nomap regions Content-Language: en-US To: Mike Rapoport , Dmitry Baryshkov CC: Vijayanand Jitta , , , , , , , , , References: <7b18bea8-b996-601d-f490-cb8aadfffa1b@quicinc.com> <42f28e7b-c001-7d01-1eb6-fe963491898e@quicinc.com> <22aca197-8d18-2c9e-b3c4-f6fdc893ceb1@quicinc.com> <76cb3b37-5887-404f-95b7-10a22a7ba65b@quicinc.com> From: "Aiqun Yu (Maria)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: skF8QPo9vkm3DYIUS7msQOzdc31ACWQj X-Proofpoint-ORIG-GUID: skF8QPo9vkm3DYIUS7msQOzdc31ACWQj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-20_05,2024-02-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 clxscore=1011 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402200045 X-Rspamd-Queue-Id: DA2AFA0009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: y5gxyb9tbpbf46i7ib6a7df4pywptttd X-HE-Tag: 1708410526-359461 X-HE-Meta: U2FsdGVkX1+TRn2awwXuuFZe7vuS9oHr24zMx3SVaqs+JkLpN8QKumpOy1iyDVqk0FDZI4Kdt+vRO/+6EBOjtIl5qRHF9DUuTAwIuM5sYzBuQ4HTIbB/efRYrDQTQhFmKVehPGDIoAJxNnSoNfP/C1O2LvjpLpCt2f69qoWwhN0j+nvmUofkHGwMiebdST/7UGxMOmwffXyopvawimsnPmCLWk/XKYiYH1hgA5Kg5xhd8YVJiAsWwU/QOgrRtCaV9+nIH5XBnGGjVK/KQEYB++RM2JPJoO0KmnfMjH/NtP27/qki4/QSCet/3/SeHZldOlhFU6ZLLjxliuWfU33LBaQ1SRkqD/o15GDmngAMR8rWXrDojVhlNp5WbcQgJnQTpiAC+HgV7OdejdNdWQGAcvKyVdyPZDqWw/U1p69u7o/7NWzpuZqyWZEXlZtZce7ot9yDS/zWF5JiKnp1hGtFWdXXQvYsQjXDB4D04W09HQeY9CYbGvG1hix4VS+40kS3u2+5ZWxB+tICNFn86zGa5f9E4fORtUIXakTk4CgQMqsEL3pZT8haWzqWO/zHc5hqPy9BIkPMuYZAha1De4F4xGBiQIL+XAQZOU0MoI3SiJYqKhwvblE8zx5cPrBOBG3JW3KWwsfgyoF7IZyx69NJgCh4SCfOPmGBKakmmDoBDWeHnjsXr3jgUpRMpJUKxtuNYZaJBhFpEN/TUfNSicSOiAgrCG6DmQ3h5nHQmzOTS/I3GoREO3bTzgjV5oB6qyzqaTh5Ay/3n4eyS2UGnlhh4bDllCEbF35lho07zLk8rxsRgU/0QiJO0hokU6bzMxpQ+Anyqrmu8p31PwOqxsO8M40wMr2uSogS0Jbp46M3/iXxXkLzm4OWrFwpR7TtIFJ/4KtIHpR7Q29W/UplXoPGUTu07r5nc8jmnOLWyOhRFB2v+q1Fp4P+ykdWPfA0jqHgYVpzFjmZQoDC94IJoVQ hCqvSGDP MzhFR0oLVUTPvBGBLQSLhhATB0Q== 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 2/14/2024 5:15 PM, Mike Rapoport wrote: > On Wed, Feb 14, 2024 at 10:11:40AM +0200, Dmitry Baryshkov wrote: >> On Wed, 14 Feb 2024 at 09:44, Mike Rapoport wrote: >>> >>> On Thu, Feb 08, 2024 at 02:37:25PM +0800, Aiqun Yu (Maria) wrote: >>>> >>>> On 8/6/2022 3:22 AM, Mike Rapoport wrote: >>>>> Hi Vijay, >>>>> >>>>> On Wed, Aug 03, 2022 at 04:27:33PM +0530, Vijayanand Jitta wrote: >>>>>> >>>>>> On 5/9/2022 5:12 PM, Mike Rapoport wrote: >>>>>>> On Mon, May 09, 2022 at 04:37:30PM +0530, Faiyaz Mohammed wrote: >>>>>>>> >>>>>>>> On 5/5/2022 10:24 PM, Mike Rapoport wrote: >>>>>>>>> On Thu, May 05, 2022 at 08:46:15PM +0530, Faiyaz Mohammed wrote: >>>>>>>>>> On 4/12/2022 10:56 PM, Mike Rapoport wrote: >>>>>>>>>>> On Tue, Apr 12, 2022 at 12:39:32AM +0530, Faiyaz Mohammed wrote: >>>>>>>>>>>> This 'commit 86588296acbf ("fdt: Properly handle "no-map" field in the >>>>>>>>>>>> memory region")' is keeping the no-map regions in memblock.memory with >>>>>>>>>>>> MEMBLOCK_NOMAP flag set to use no-map memory for EFI using memblock api's, >>>>>>>>>>>> but during the initialization sparse_init mark all memblock.memory as >>>>>>>>>>>> present using for_each_mem_pfn_range, which is creating the memmap for >>>>>>>>>>>> no-map memblock regions. To avoid it skiping the memblock.memory regions >>>>>>>>>>>> set with MEMBLOCK_NOMAP set and with this change we will be able to save >>>>>>>>>>>> ~11MB memory for ~612MB carve out. >>>>>>>>>>> The MEMBLOCK_NOMAP is very fragile and caused a lot of issues already. I >>>>>>>>>>> really don't like the idea if adding more implicit assumptions about how >>>>>>>>>>> NOMAP memory may or may not be used in a generic iterator function. >>>>>>>>>> Sorry for delayed response. >>>>>>>>>> Yes, it is possible that implicit assumption can create >>>>>>>>>> misunderstanding. How about adding command line option and control the >>>>>>>>>> no-map region in fdt.c driver, to decide whether to keep "no-map" region >>>>>>>>>> with NOMAP flag or remove?. Something like below >>>>>>>>> I really don't like memblock_remove() for such cases. >>>>>>>>> Pretending there is a hole when there is an actual DRAM makes things really >>>>>>>>> hairy when it comes to memory map and page allocator initialization. >>>>>>>>> You wouldn't want to trade system stability and random memory corruptions >>>>>>>>> for 11M of "saved" memory. >>>>>>>> >>>>>>>> Creating memory map for holes memory is adding 11MB overhead which is >>>>>>>> huge on low memory target and same time 11MB memory saving is good enough >>>>>>>> on low memory target. >>>>>>>> >>>>>>>> Or we can have separate list of NOMAP like reserved?. >>>>>>>> >>>>>>>> Any other suggestion to address this issue?. >>>>>>> >>>>>>> Make your firmware to report the memory that Linux cannot use as a hole, >>>>>>> i.e. _not_ report it as memory. >>>>>> >>>>>> Thanks, Mike for the comments. >>>>>> >>>>>> Few concerns with this approach. >>>>>> >>>>>> 1) One concern is, even if firmware doesn't report these regions as >>>>>> memory, we would need addresses for these to be part of device tree so >>>>>> that the clients would be able to get these addresses. Otherwise there >>>>>> is no way for client to know these addresses. >>>>>> >>>>>> 2) This would also add a dependency on firmware to be able to pass these >>>>>> regions not as memory, though we know that these regions would be used >>>>>> by the clients. Isn't it better to have such control within the kernel ? >>>>> >>>>> If it is memory that is used by the kernel it should be reported as memory >>>>> and have the memory map. >>>>> If this is a hole in the memory layout from the kernel perspective, then >>>>> kernel should not bother with this memory. >>>> Hi Mike, >>>> >>>> We've put effort on bootloader side to implement the similar suggestion of >>>> os bootloader to convey the reserved memory by omit the hole from >>>> /memory@0{reg=[]} directly. >>>> While there is a concern from device tree spec perspective, link [1]: "A >>>> memory device node is required for all devicetrees and describes the >>>> physical memory layout for the system. " >>>> Do you have any idea on this pls? >>> >>> I'm not sure I understand your concern. Isn't there a /memory node that >>> describes the memory available to Linux in your devicetree? >> >> That was the question. It looks like your opinion on /memory was that >> it describes "memory available to Linux", while device tree spec >> defines it as "physical memory layout". > > I suggested a workaround that will allow to save memory map for the > carveout. > The memory map is a run time description of the physical memory layout and > core mm relies on availability of struct page for every physical frame. > Having only partial memory map will lead to subtle bugs and crashes, so > it's not an option. Any idea of a formal solution for this case? It is a real use case for the commercial device. Memory saving is always a good topic for commercial devices. So for a total 128MB memory, ~60MB for kernel total available memory, and ~1M free memory saving is important from OEM point of view. There are 3 types of memory: 1. used by firmware and not available to kernel at any time. Either struct page can be avoided by kernel. Or bootloader not pass this part of physical memory was discussed here. Any good ideas? 2. shared by firmware/subsystem, and can be read/write access by kernel. Just as it is now. Struct page can be allocated inside kernel and also reserved memory for this. 3. freely used by kernel. Just as it is now. > >>>> [1] https://github.com/devicetree-org/devicetree-specification/blob/main/source/chapter3-devicenodes.rst >> >> -- >> With best wishes >> Dmitry > -- Thx and BRs, Aiqun(Maria) Yu