From patchwork Fri Jul 21 13:19:50 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: 13321978 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 64743EB64DC for ; Fri, 21 Jul 2023 13:20:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED7BB6B0071; Fri, 21 Jul 2023 09:20:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E882E8D0002; Fri, 21 Jul 2023 09:20:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D28468D0001; Fri, 21 Jul 2023 09:20:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C17266B0071 for ; Fri, 21 Jul 2023 09:20:15 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 86EE91A02E5 for ; Fri, 21 Jul 2023 13:20:15 +0000 (UTC) X-FDA: 81035677590.13.1B0ADC3 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf22.hostedemail.com (Postfix) with ESMTP id 1DF1CC000B for ; Fri, 21 Jul 2023 13:20:12 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=IozPQREW; spf=pass (imf22.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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=1689945613; a=rsa-sha256; cv=none; b=AeoZXKqADm1AZx420BkQPnABBQS0GpTVHSNKyMjhZbpQ9e8rtoo1mZdYC40T3TrBSMcZIn TZB6YWk2F4KmWNDyRRsf1PTIuks8LIobzK3/Djob41BhE14iaK4frpMvCmXt1ALMUmija+ MwQjp1htitiKPDyU47h/UOT8huzl/08= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=IozPQREW; spf=pass (imf22.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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=1689945613; 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:references:dkim-signature; bh=Uwgcxc2z4kEB6P/RRcGFv0aRyWeiXf6BgQRzfUhra7U=; b=5Wzua0ogHgVQpDNaVdfD5ttBqTajyzh3WB1wzKDktyLr2awaeYHD/n5xMC1yvISCp0GvwW iwtWsBt+apo4TDu0bNldmgzE9Jynq9S0T2x/Oq3+eEtgvMEvMPczp0hOWo3uCkRfGuxAP/ 4MMYiJcdAOD62j7N0Hy/7qlvxStER94= Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36LDBcSK009397; Fri, 21 Jul 2023 13:20:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=Uwgcxc2z4kEB6P/RRcGFv0aRyWeiXf6BgQRzfUhra7U=; b=IozPQREWBVQ8R4llhfgkW2Ge4zvEaaEzrprrayQDIfGv4fewwS30VymNYEiB+8/dE5gQ 2RpFgr9T1Ne2vTR6iIOKU6rr8e32YJhwnFgI8avdJQKsXIAYY9T4Z19SvOxNFLgTkltJ sI6Q35z7HbKEoMehBajSBljLPISLKwyTgphX2QrV1sYBMJXP41M+Carse/eDn6REe0YG QjGXCieOe7zbGnmmcTkqtCKi1/kPAnh+bb+/m/uu64mnF1nR1jSaCMQPls/87mRP54Z+ iA4akZTWNCYWXuk8D+wD6yUJnAcvjdp9CrQukD8h3KR2vIATTN8fLSfUEnCPbxBCg6DY zQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rye3fs837-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 13:20:05 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36LCk8in018128; Fri, 21 Jul 2023 13:20:04 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rye3fs82n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 13:20:04 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36LDBR6c030678; Fri, 21 Jul 2023 13:20:03 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv79k4cxc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 13:20:03 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36LDK2kX2949654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jul 2023 13:20:03 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7905958066; Fri, 21 Jul 2023 13:20:02 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F161258063; Fri, 21 Jul 2023 13:19:57 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.117.127]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jul 2023 13:19:57 +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] mm/hotplug: Enable runtime update of memmap_on_memory parameter Date: Fri, 21 Jul 2023 18:49:50 +0530 Message-ID: <20230721131951.306706-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qEnX3fKJR7mUZ59B9XPaEQihZtq3JnNP X-Proofpoint-ORIG-GUID: -NtmF2eRzS3wEFAGjxRA23-0mB_NPtaB X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-21_08,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 mlxscore=0 priorityscore=1501 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=673 malwarescore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210118 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1DF1CC000B X-Stat-Signature: ak3jkey7mhjbk51au5kxhkb8ry8sg7jj X-Rspam-User: X-HE-Tag: 1689945612-330474 X-HE-Meta: U2FsdGVkX1/pW3sqMIv//fReL8cG79d6R7YgqD+VnZgvUic9IFdaMT9KQqSrKJ9uE+MHBBvZroru19tOPf2CQ1q5hXOmo/xDFYBC6hhHqb/eT5+N6fpUynNFik9wfKhnnV4N+ewDtVowzAs4Tcjvba/6fsyQ3NX3lIDWthILhA52AWCRUnieGdRT21NY/0U4AAPFGg9msvQDlXywO+TMCVwatpczQtybaxmeSoKiEif/TZP5WXXKTGwGloCLnzMDYlpMDmDr+BMRdnLYFrbQ9ughtKoFH7NwxvhWcpj+mWv4+kAAy+bEHeqIFOzhgvyGEmmbzky2rOrLDbr/DckCGbVlcxvfgNs1eCJTtPDVhANkc98LeRHRCgcHq67mnsG8zxdrxD8l4vEvhaGfyAqv+4nAnwmrumDpqbzHckKRJm01LfztkdBzCO+kRnabsQN5J4WOf4BQV7EPqMPIcjQuM1cbsfeOsvlOcPBs+lqRmU/yBA/MLmOJmiIbCjZ8vHzAZEsSerVTJvApNDwBF82JeN7u617uF75jTtbhy0ZU5ibjozAvGo58kXFy9Eh1Idli98WqqH3ElsqoBxuC02s7ZWQEWtTWF5bvAVYf/2rgyXKU1lP9at4gefhGWLkge1ReJ4s3mtA5rzH0aSUsXmKMuP5G7zGcN3muu6Z99SsIYapJr17nuR6HmoenafStfi4oDR0jn74XlNmJKVgKSHmRinFv/owwJCfAghEiMOax+4e5IvzSwP2vMsy59VXjlgXLuf+z94dAOjTvabcvkFm+HF+2J4FKdOoJWhlTpyXK1QkT9wcur5rfAKApRTGJyEMugvoYoofcM1jiVCZ9mzI6g8LOh7MiPqvroygrSGtfSJJyK8fG8VwJXy2A8UpbXtEYmj89DVEoz8Df6dImUfz1x7k28Y4mt9g7vvSUnr37GPflNe4zd58PwlFaM02XD8Jh1uTzekPdMYb6/Axjpxb bVk7clXA 1DatxPr+Bptf2FSUDmjy1e5sBr1rSXPgzo1DILxih7gJbezBc2go+Lxd/CgpnzWD54XG3B/5yuEzEH9m0yH3hlQ4Sh5/udmNvL2dx/RIKbQR0Unty4j0OmBISxHgfD7AYXeHuhFWf9oTgc3yFJLjuv5nZqbuUZaNo8tcQe4F0bbdF5USOZbfC6K4ew1qMbGt2nIbtxrD/gKBvOkC904NBaSTI6ig8iOzLg9jUKrGNm6COL0Q7XObRDRNIEw== 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: Signed-off-by: Aneesh Kumar K.V --- This is dependent on patches posted at https://lore.kernel.org/linux-mm/20230718024409.95742-1-aneesh.kumar@linux.ibm.com/ mm/memory_hotplug.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 6a8adbe030f9..21a5113fe9be 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -86,7 +86,12 @@ static int set_memmap_mode(const char *val, const struct kernel_param *kp) mode = MEMMAP_ON_MEMORY_DISABLE; matched: + /* + * Avoid changing memmap mode during hotplug. + */ + get_online_mems(); *((int *)kp->arg) = mode; + put_online_mems(); if (mode == MEMMAP_ON_MEMORY_FORCE) { pr_info("Memory hotplug will reserve %ld pages in each memory block\n", memory_block_align_base(memory_block_size_bytes())); @@ -108,7 +113,7 @@ static const struct kernel_param_ops memmap_mode_ops = { .set = set_memmap_mode, .get = get_memmap_mode, }; -module_param_cb(memmap_on_memory, &memmap_mode_ops, &memmap_mode, 0444); +module_param_cb(memmap_on_memory, &memmap_mode_ops, &memmap_mode, 0644); MODULE_PARM_DESC(memmap_on_memory, "Enable memmap on memory for memory hotplug\n" "With value \"force\" it could result in memory wastage due to memmap size limitations \n" "For example, if the memmap for a memory block requires 1 MiB, but the pageblock \n" @@ -2162,18 +2167,16 @@ static int __ref try_remove_memory(u64 start, u64 size) * We only support removing memory added with MHP_MEMMAP_ON_MEMORY in * the same granularity it was added - a single memory block. */ - if (mhp_memmap_on_memory()) { - ret = walk_memory_blocks(start, size, &mhp_altmap, - get_vmemmap_altmap_cb); - if (ret) { - if (size != memory_block_size_bytes()) { - pr_warn("Refuse to remove %#llx - %#llx," - "wrong granularity\n", - start, start + size); - return -EINVAL; - } - altmap = &mhp_altmap; + ret = walk_memory_blocks(start, size, &mhp_altmap, + get_vmemmap_altmap_cb); + if (ret) { + if (size != memory_block_size_bytes()) { + pr_warn("Refuse to remove %#llx - %#llx," + "wrong granularity\n", + start, start + size); + return -EINVAL; } + altmap = &mhp_altmap; } /* remove memmap entry */