From patchwork Tue Jul 11 04:48:29 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: 13308122 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 31FF0EB64DC for ; Tue, 11 Jul 2023 04:49:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C452D8E0005; Tue, 11 Jul 2023 00:49:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF5118D0001; Tue, 11 Jul 2023 00:49:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABD4B8E0005; Tue, 11 Jul 2023 00:49:20 -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 9AEA48D0001 for ; Tue, 11 Jul 2023 00:49:20 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7645C1401A3 for ; Tue, 11 Jul 2023 04:49:20 +0000 (UTC) X-FDA: 80998102080.02.E3FDDE8 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf13.hostedemail.com (Postfix) with ESMTP id 3C15720007 for ; Tue, 11 Jul 2023 04:49:18 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=aYdTTAn3; spf=pass (imf13.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689050958; a=rsa-sha256; cv=none; b=8lqbVNps2jPwUresB3lGr0PTnosn32th9WUzQdaYjc3LpIWVkGxFW53k7N+kwNx5n/K8V+ 7eHh3KRU8SsJcp06e7TLO/kiDV0vPc1lPJrFmA+pNWRmB6Ohw/WfBMeHdb6+AEVEy3PgT5 gTSUZn0S6+guF5NBCAKAF+I16gP3YeA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=aYdTTAn3; spf=pass (imf13.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=1689050958; 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=xCc2t1OCuvmYEBqdWeIf9NwGoHZvnb8ZRoU9LAU+Spo=; b=NcGYpQCq4IuP3Xu0JZrS+PS15eWcBqJ2sNTH+/Sao5V3qRCSznG1fxzy/fNdPFcKdDhPs5 qkcPtxWThfpexUiF4yRnkxnU+MO0ux/zRy9s/lBRT9IT21tw+NlXAConkKG3tnf8wKBdG+ EDzpy6TWAxBp5x/cD6Beqt8vxmPhMVA= Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4jXEn021316; Tue, 11 Jul 2023 04:49:10 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=xCc2t1OCuvmYEBqdWeIf9NwGoHZvnb8ZRoU9LAU+Spo=; b=aYdTTAn3Px4U7WqCq/rLeW0RDoL1Gex2HMxRR4/HHV1xgZsx/6EeffY99C5HWzeiZJ7/ nI+5am/3LUNgP/ZIq3qbf5yD37ouWe8TrnHi1lseVddElkXYo2cJ2D+Th5ehM94id9LA 3o4ev4TNOiSf534hTYQV3t0C0QsI2hporChKL0ewKJyRZVGojcK0/ilM+k5p69xLRhnz ohnrwINk8IX4Nf/6Achx+zY/2+Us+wPQvcTWLlDwMnaOwYHcKo3CXb8Scq0eLqtvO7s5 puPhABv6eSaZgUe++KhSdnx67+RLTdwc7FI081I5iY6Yhjwzaisrtc9cRAAgRg48dqyG bQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs085gdbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:10 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36B4lBiX029956; Tue, 11 Jul 2023 04:49:08 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs085gdb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:08 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4Ak6i017144; Tue, 11 Jul 2023 04:49:07 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma01dal.us.ibm.com (PPS) with ESMTPS id 3rpye6vecr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:06 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4n5Y446661908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:05 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 882EA5805B; Tue, 11 Jul 2023 04:49:05 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0E9258063; Tue, 11 Jul 2023 04:49:00 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.86.43]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 04:49:00 +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 v3 3/7] mm/hotplug: Allow architecture to override memmap on memory support check Date: Tue, 11 Jul 2023 10:18:29 +0530 Message-ID: <20230711044834.72809-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711044834.72809-1-aneesh.kumar@linux.ibm.com> References: <20230711044834.72809-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: JUM55NyZuqPvTG4pSPvoE0tJhOASM2k4 X-Proofpoint-GUID: F0LKoe514ZDp7c8YArMLPNObvg7X4Iys 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-11_02,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3C15720007 X-Stat-Signature: ggi7w34c6gafeggsym9fbus4sdncitck X-Rspam-User: X-HE-Tag: 1689050958-676394 X-HE-Meta: U2FsdGVkX1+KmCliBuhHCPcxqAQt9oW2uGUxRVzGIUINQRsPQQP7PHBd8+6aEjGwsx0e7dD1D0LCRuaxTZK4hWt1pjoQzYssiyyEY0VpL/xGEj7HJvzq7fZmrUUVOoDmIICMJfMAZs3C7barXCOOE0fNLzRhF5Qfwp6/kxGXeH3ZxtkRDNFOweyRhsvctTMC6oiikFbt6fjXcCoK5c9IZiZA2Jyvj0LXqdKXwo2sG5R6XgIgGjJtWBkg03QhDbRGH/CQUtyUUTWWlYmKTJAPbPoNxomTJNX5kCcOSvqUpUNa187H2LtmngzoSbo+QT/DG9ZOZN9R+Pxf2GWqQ4ztvd18T3tMi+gOkZlRCPKdVtNUZObQ7z0YWt/Etk8/tzNmkh7NN09oD00f6y6zLasszFCQCy+YAlEDwOJAwrpPJAnZ5X2t9hjnimdVDue8aqh2Se2UETyh9Y36Z1zTy04TcIYJu1yNjRh44cFlxvbGKrwEQBDhOZmtxTJOB9luibOvu2KIj6RMi4Kz9m/0I5Esu8ElwEkNgGDT68jAuAg0FtVeqkW7bdBS0M0UA0xDrq6EAAKcvLKDf0wa2TnnkszXX46xcHUpkoluVcVzrkHZDAlXU+uQV1vgl20vrJdpFUkJeIMycAg9l2UdG/oz2GEJx3L+IYrvBdz2jE+rbnSxb1PluyVVTGlX47mECCMEfElDj6LXW7Ayjm+jtgwfRA7aK7EDSIpjgwexCiowDKppM32UOegM9Q1BbcR4335HPPgFrPVtT6FHkAxWpPwxtht//shMblwa0Ro6fxYoDfvtu9E5rc4Q3thCh9p9ecuiAMhm6MLhs3/OoGqML92j0EJLqV03CkeIGQaC1JABHAwStUdRPI5CfcE50LjQYps/Md8Y7/AhFgt19GEPxjU0e2F01lbqfDHSt2OjzC0fSf+dHP0MQUfKt+W1hTUdxXA56EMbDu/H2rNdsIZK0ZACeUh T+ELKH2T 8idIcZGWaJb5jNdInK3ECLXemFNqWP3JGodip2bkR4W9JyDKaE2aRwvrqNoLz7TiMZuu2QEJI/3drx4P8NHgb9rWJVVQTqsAiCYX67SHFJTRDwDvYzgEa38oLPimTQknX5top/+cNqWikZhI= 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. Both the PMD_SIZE check and pageblock alignment check are moved there. Signed-off-by: Aneesh Kumar K.V --- mm/memory_hotplug.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1b19462f4e72..07c99b0cc371 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,12 +1247,20 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } -static bool mhp_supports_memmap_on_memory(unsigned long size) +#ifndef arch_supports_memmap_on_memory +static inline bool arch_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; + return IS_ALIGNED(vmemmap_size, PMD_SIZE) && + IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)); +} +#endif + +static bool mhp_supports_memmap_on_memory(unsigned long size) +{ /* * Besides having arch support and the feature enabled at runtime, we * need a few more assumptions to hold true: @@ -1280,9 +1288,8 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * populate a single PMD. */ 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)); + size == memory_block_size_bytes() && + arch_supports_memmap_on_memory(size); } /*