From patchwork Tue Aug 8 09:14:58 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: 13345890 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 CFAFEC001DF for ; Tue, 8 Aug 2023 09:15:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59C626B0075; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54B5D6B0078; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EC6F8D0001; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2F75D6B0075 for ; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F0106140BFA for ; Tue, 8 Aug 2023 09:15:31 +0000 (UTC) X-FDA: 81100379262.29.FD74F81 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf02.hostedemail.com (Postfix) with ESMTP id B091A80027 for ; Tue, 8 Aug 2023 09:15:29 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=nFshiSnJ; spf=pass (imf02.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691486129; 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=Uym2Ib4yS6cvP//xSpA4G+vKrmClYZ/jTf92DopX4wI=; b=tCIM5Ovcl/nn8nGCPdwgdI796edvE5Vdvd8d4kSN8k0oB+XhXFUnWPBugAlYx/e7ui6cIJ JFJlcg9dmYF424zDK4IJo6ruQ3k803mrMZA+/u/+oZrM4EN/OqLwat+FNFlisNQKwG2DDw /fKknpegPUWNnKtRo6gqPF76skE55LE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691486129; a=rsa-sha256; cv=none; b=qJzoPLsb2y54Y8BATYgXagzRrPrEh7AbkwY+KoqNNkKcLKJXRHCLUZDgbzMeks3CwauFnR UjfGihG98KPI5sWtSNsOcYuAmJmS7bJHw/jKxprNe7yJYI7u0BUzQFKr0SmbOKF3Y84iOh xabXfIfG79ZuVlKj+23UZAxeshr8SX8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=nFshiSnJ; spf=pass (imf02.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3789AgcK005289; Tue, 8 Aug 2023 09:15:23 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=Uym2Ib4yS6cvP//xSpA4G+vKrmClYZ/jTf92DopX4wI=; b=nFshiSnJXL/jYixi+6SU+HrqtE5PAHbHVeetcFRYrzQUiDPs+u09Z+4VSVTLjLssQ4/G aO/BycTuCFySTKu2cAtWNfNRH/4bvwgGy/oxQn4rmcJf1wP+tex93yIK0JIxB2DsWJri V0Vr25uL49dONmQdgqPR4hfDiGS222FAIVvcOJtxiYrwapuxxF2SjF5YaZ0pC2Lddf55 gTfg1kFyCi2BYgk9Dw5GfImXXnNh8nrX7e1fSzwehfqYJ2lzhq+jrHuT8gQfCEmZ3yD0 NY6H+6pH0MnZzViAsZcmfAmU3PtE5cguLryrWkzb36wzopg3AY3F+9ZIjQibXXGmRzQ5 wg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjpvr8wj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:22 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3789FLp4027524; Tue, 8 Aug 2023 09:15:21 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjpvr8w6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:21 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37896xQ3030379; Tue, 8 Aug 2023 09:15:20 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa1rn55hy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:20 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FKMS24183088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:20 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 146925805A; Tue, 8 Aug 2023 09:15:20 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D39C158063; Tue, 8 Aug 2023 09:15:16 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:16 +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 v8 3/6] mm/memory_hotplug: Allow architecture to override memmap on memory support check Date: Tue, 8 Aug 2023 14:44:58 +0530 Message-ID: <20230808091501.287660-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0lsKjxdJ7j-98BK5bmCHRNtDqvloK3Us X-Proofpoint-GUID: JqxU4V-9hljRbw6__j7VqJmrm2rU8Sir X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 adultscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Rspamd-Queue-Id: B091A80027 X-Rspam-User: X-Stat-Signature: fpaypbhn1st94cs6smd89ae1pckxoukz X-Rspamd-Server: rspam03 X-HE-Tag: 1691486129-228136 X-HE-Meta: U2FsdGVkX1/2Ax9OS4FpyjjIxAi4USKGAlrYIFeM/uP6OBr1+4Afg7qAgiKN+mADfn872QqCmKzwhMc8C4ct9ZlXcoVy0sensmHaMqS2n2EANHUhziVwb9g3XqJypAfbwmCHBSO3Xp4C0i9rSEkw2hF8Re0ZRgULyns0/PRMV7BYDvAvs+fTHahs8E3kiFldefQ/6PgjbHtx/TqeunUxHM23JCnhKa6WaseYPIbUuRvBwUZCNRdlDMPCMfrGPZY6QoywZjX2qJFlFW4pclZA6TWSH7yahfGihaRrvoZwOihV8t7MBSz9gDQ5OXHcurPwf3vVUDeMmTTgh+RbhnkiMXFh3OeFeb/3R3rjCorclHwpeYxvKa/kIUL5ovFkTkRDfc7/qvQkc0V84ZAjspxLqSj+Eq5/4BFjqOnqzkJxSnoA6C1Rx3FebpUxQDlqnfkphZmrcRYW0f/rNrFC9mdBGIJgWAKUEBNLi3LrSN3coOZ/dQAqr4fAowybbOIrjbxcUZfU70BTc/FtZXjBMhyzSVPP5kTqWZDZRjccrUpVcOz0GbDwudmLT2WYw8qIdyRgMSrT6ErHzbGW4iiD8Jh9cxY6bYK3k3i7wcEUYrgwxPeIsvMMgIrVtDffIFsuALSd9w6YSZbvB1geF0M47VWWQ3W5OdGBLxhPaKtmSUyInV2xqhh38wzKR12wCsC3UnIrEbqzyXYGIXiqG104urRJqpfrzr/0eYLE0bTC0PANsCVWYnCrG5rh6v/XWeDTaiJJreUfdm5YKawgAg2qOx6U+fyQaEa7FPFezOxlnJmlvB6XWYvLK0z0U3AI8BiIh1qbFY2HgFsYmQMhcjho/JqKaF8pdC2ARjDHiHAtEkART7EuxpOzbIxYEqJh8u5nSN8pGvt/QU9tWEpAlPTBbqJkNZb0ipslZ0QL2WVYhqVKFqSYW2BB4Km91GVwNV1TQ8YD1kFyqTZltxylqtQT4DM bfWF0MS/ Fd0C3+vO0421qqrqqbfX5pJJQRbkGC7vM9gWI7bGEDXwmyu2jXvvR/kODxonMXp/3VTRpE2Cka3qWwz6e8xDxbYxv5TWHsa9t2/0Opu0u7PToTuh2gF9xffp6dvN5eR1QJC3w9iT5fFZkc/dJnSHA0dcdnQ0EnbgO/QjSUzEBt3BPFIRADqMIAf7UIU3cGaF9C2MSixWGBwD1cZwy6qq7TACChp5PBW+y5WuvNnKsXNWn52AxcJzQC6j1WI6XLA2VLFEY4zF3EROBN7M= 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: Michal Hocko Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- mm/memory_hotplug.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index eca32ccd45cc..746cb7c08c64 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,10 +1247,26 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } +static inline unsigned long memory_block_memmap_size(void) +{ + return PHYS_PFN(memory_block_size_bytes()) * sizeof(struct page); +} + +#ifndef arch_supports_memmap_on_memory +static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) +{ + /* + * 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 vmemmap_size = nr_vmemmap_pages * sizeof(struct page); + unsigned long vmemmap_size = memory_block_memmap_size(); unsigned long remaining_size = size - vmemmap_size; /* @@ -1281,8 +1297,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(vmemmap_size); } /*