From patchwork Tue Jul 25 10:02:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 13326262 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 DD4F0C001DE for ; Tue, 25 Jul 2023 10:05:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76BD36B0083; Tue, 25 Jul 2023 06:05:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71B586B0085; Tue, 25 Jul 2023 06:05:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 595406B0087; Tue, 25 Jul 2023 06:05:31 -0400 (EDT) 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 4358E6B0083 for ; Tue, 25 Jul 2023 06:05:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1B75E1C9703 for ; Tue, 25 Jul 2023 10:05:31 +0000 (UTC) X-FDA: 81049702062.14.912F486 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf24.hostedemail.com (Postfix) with ESMTP id 7E348180022 for ; Tue, 25 Jul 2023 10:05:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=shP7B5uj; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf24.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690279528; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=D6w7Lot4e8BcNeMjCVSUtPdDiB71BA0lpgavvF7b3RE=; b=4FSoRoGUXk7McNsdkEtVHCHIAO1OgQqDCzNW/yKTFd0TNxiBXY7QbIewdYsK5MYuiFC1gg 7hPJmlC++Yy8t3UJLf3Gdk/6sYkjalQ6Mi41ufm8E//FCohQNLviDLMwSMPxVPUdmlrAzD wyvN8AsT3sAS6vXOfFnMiex+7yobtVE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=shP7B5uj; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf24.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690279528; a=rsa-sha256; cv=none; b=vP5GF3eZihOnNpoFmn+4gc75JJDWH0lt0l/2AziVpuqcWUhUnD9isLKmwyaOQyj4gBQv7X 3qCuYhzKRVxjKBMIeBWtiIsErGgYpYBjkmpAJ+mgaWhrFYp8VimvcFZNL3jDlo/tam1CUq Opp7MaIUgE9RZtrRbJzMMVkVmbw+OgA= Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36PA4sBX021896; Tue, 25 Jul 2023 10:05:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=D6w7Lot4e8BcNeMjCVSUtPdDiB71BA0lpgavvF7b3RE=; b=shP7B5ujmWDO+U2BiS7P6H6gPz3mHhqA/ZfnNIRxek6l4gFdg2c1xroGKxcOYXVouvAt Fwap1KMxUVYk6S9pl55JMEvAiq+/TfMSP4mVuvJQ+kia2geGq3yi4vb+T3wUFamBRcXT xkNKnxQQAImeVfA8Dn/KX6CQ/WKW+STHxGeJayR3yQIZELAFmYU7THD39vHI1tMJFHZ+ wCyrREvaO16QWnn+HK5ojqMfJ6n9UiSPsnfbZaTRd7Lc84CjYkTrFcdX6oqtUl/9r4hs /Ni5aHvTK51QkdJPWxJWL/Cu4T/S4ulUag86sXXaPSEUKK9QxO90RqACddWF0kxu/WAZ 8g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s255jsdxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:05:21 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36PA5KkD024411; Tue, 25 Jul 2023 10:05:20 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s255jsdqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:05:16 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36P9hPjv002281; Tue, 25 Jul 2023 10:02:35 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3s0unjam2j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:35 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36PA2YEJ21889350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jul 2023 10:02:35 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8AAC58060; Tue, 25 Jul 2023 10:02:34 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F08BA5805C; Tue, 25 Jul 2023 10:02:30 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 25 Jul 2023 10:02:30 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: Oscar Salvador , David Hildenbrand , Michal Hocko , Vishal Verma , "Aneesh Kumar K.V" Subject: [PATCH v5 3/7] mm/hotplug: Allow architecture to override memmap on memory support check Date: Tue, 25 Jul 2023 15:32:08 +0530 Message-ID: <20230725100212.531277-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725100212.531277-1-aneesh.kumar@linux.ibm.com> References: <20230725100212.531277-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wa5YJNwiOKhzS4Z2on0AOQ9xoLeTsKUK X-Proofpoint-ORIG-GUID: HOPEk8GXVZCohyAsTaTDWTuv_qE2mfns X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-25_04,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307250087 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7E348180022 X-Stat-Signature: xw3pxsre56gsj9o8mikzat33x3g5zrhc X-HE-Tag: 1690279528-256307 X-HE-Meta: U2FsdGVkX19f/lt5OkV+S1ot25AvnmAzBlE/Qzh9i7uTBW0oATBYW2e+v6JnQa7vw/QVI5sNvPJHekDrM0wSbTPKtiUGUH05HFsU9b9obYAa0/H51WPhe2PIgm4v6gOasu6NBG8Zrr46ZNX9hoBDqJcQG6xubF+Bsy7AN+PujRjZ9foaV+p1v4WphkeLcQcY4l2WA512LUGp7dSs4uXfPWHrNSJtiwooCfUp4LLAlIMq/LwzOOaehCuE3hWh/9MbEe77qMZlqo8YIRbaIJh/RcuE+Dw7d+8G3HyDqZBgZkY+8Wdq1+m7F6aHWkvsJzObSOZYn955Q6rSIAyDVSuUa8FSwbQSHAUP5qWkilOHAi8m0BG7UwQo4iOjy2l1FOXoDvP+YO2BuqhtsMg0CgnSnp3OqJLoXBL2eLaIVJe4wmqSNCLrGw+MH4+zbn7pEXtaQlQSrCXO3Yt4LKBvQKwyO+U8YGEOPWYp6BZ0BOOOmJQwQgf+ZjY+Sl6muMpwbJ9UphExxtmY28Eh06ZgKUhl//+IZFCa/7Rx1YwfIzTFFlr+wo0y+tSA/673tIBxJ2FYx6GjsprXlGLZMii2H05eLuK9ZqBVxWq83XDREv2RUOfgcd2JFwQVJIxP0C/NNDJxl1igZdce45CLZCxJguxh8xc7AJItHIw6AVAfHMMaLM+bdUTU3MPgjsHxVnSKlBXGp1R5KZcG9R++amkG635udixnY+HOpvzL9zhla1sqVkNoaWD9hrAFbuD+HGowvscwAHCQ1JboOuQkhBB6XLF3e1TZG92TezZxkA6LXT+7Ah2XYGdmlbiaPbmIWQF9a5WycC5Onk41XMvouyv7gQMg7p/bb/SNDQP58CG1EswSramxauQHvm2AMvpYHhsa6/RBRLE4p6jhyq56jtmPbO/tuucqsU9djcHWPH57EffFj9n1HdU1DCy4U1HWFcIaviR4AWwOag1Cw/+SJ6C2oZO vfIW+fyD /Zx9mfhuDWwxDNgEVvo0VFpJytFPSQZeqRiO7hYX1cmIjgq7cRZrVOB5Rj8kNiOhacAjYT7ELezYQj+F6jow8ND4kqGmwdWZJeYhsT79KlUJrIF9vFyYpSncKvevWgRxmFKG4Jv6/xlfxOSJF+FS1FsNeG3ho+odntOsHP62BX00f8uhy7PU5MPoygjCaM3V3wKM14d1/OBNmNd0ptRo9dZriIXnpPbsY1Y/eIfBDOghVzKfuHkFcZ5Tc/BFGVRqN82c4 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: Some architectures would want different restrictions. Hence add an architecture-specific override. The PMD_SIZE check is moved there. Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- mm/memory_hotplug.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index eca32ccd45cc..457824a6ecb8 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,9 +1247,24 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } +#ifndef arch_supports_memmap_on_memory +static inline bool arch_supports_memmap_on_memory(unsigned long size) +{ + unsigned long nr_vmemmap_pages = size >> PAGE_SHIFT; + unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); + + /* + * As default, we want the vmemmap to span a complete PMD such that we + * can map the vmemmap using a single PMD if supported by the + * architecture. + */ + return IS_ALIGNED(vmemmap_size, PMD_SIZE); +} +#endif + static bool mhp_supports_memmap_on_memory(unsigned long size) { - unsigned long nr_vmemmap_pages = size / PAGE_SIZE; + unsigned long nr_vmemmap_pages = size >> PAGE_SHIFT; unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); unsigned long remaining_size = size - vmemmap_size; @@ -1281,8 +1296,8 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) */ return mhp_memmap_on_memory() && size == memory_block_size_bytes() && - IS_ALIGNED(vmemmap_size, PMD_SIZE) && - IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)); + IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)) && + arch_supports_memmap_on_memory(size); } /*