From patchwork Mon Jun 26 10:22:10 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: 13292604 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 A65EEEB64DC for ; Mon, 26 Jun 2023 10:22:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E51B8D0006; Mon, 26 Jun 2023 06:22:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3961B8D0001; Mon, 26 Jun 2023 06:22:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25E9A8D0006; Mon, 26 Jun 2023 06:22:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 188B18D0001 for ; Mon, 26 Jun 2023 06:22:45 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BF303A0674 for ; Mon, 26 Jun 2023 10:22:44 +0000 (UTC) X-FDA: 80944510248.14.A0EA161 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf12.hostedemail.com (Postfix) with ESMTP id 67FC04000B for ; Mon, 26 Jun 2023 10:22:42 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=NLR0qQNo; spf=pass (imf12.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=1687774962; a=rsa-sha256; cv=none; b=B/lzO3TvyXgT7oLd66Nh+y3eEvYL/2yNgx4CNx5bTltHTr3pvW+q/UVT1kjParpJaIyvtc ydLAYUDr9iIBP36KXI+4B2Pbmy286+aPRJlMAddE8+8Gcoa7wdkYewchVVV2LwDUP/jeHp utYk5OlxBMshwSO9hb2Iatt+4IZ+r7o= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=NLR0qQNo; spf=pass (imf12.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=1687774962; 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=OutdXd031v+aPB7lFIBkRLXayQgfZl+QfPvoEBGYOAY=; b=zJzc5oVvip56IZX+NwRAQzd/JyHIBR97TlC88iNpBzyWQTcJcC7qc9feJ4sacDzJlbsMNY DO7Z/qjVLrIOpDpMRq6QCzJGMvSH42WDPgaN9sAxOh47tV3pQ4kn0fyY9r1P9N3jayK+M/ cAL8dN6Uyn1VUjPfXmIx89RouNeQpcw= 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 35QAGwvk008510; Mon, 26 Jun 2023 10:22:36 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=OutdXd031v+aPB7lFIBkRLXayQgfZl+QfPvoEBGYOAY=; b=NLR0qQNowd+TjO4mL3RafjC5Q/u6k0IjwSP1LHwNP3w5lZ1oBNObDaN5MLQEmsg4bt84 jqDaQn9/ukchGxIcmatmHo/RtephMn/A1nMrGCOecnE6HRegcPw9hxVQr/2bW7Jl51y9 NioowWQfGAuWP4Huny3fiMnbm5Le/G1CTLFmUN71lEqeeOzqu0h70GQTemHXQ7zmFPxz wsmJXU5PYRDyq6sovul6gmhH36KH6jZ+vLk4p+J1LNyPEB10EZQXc2TvGYyx3ioC7V3P 6YTmtYB8z84E07bCSuJZvjoOd87Wnwx6Rmwab0I0q5cqfCC+Jq+Z94PLx1JYvT3JzkVp Iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rf8sn03we-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jun 2023 10:22:35 +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 35QAJDvS013672; Mon, 26 Jun 2023 10:22:35 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rf8sn03vy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jun 2023 10:22:35 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35Q89geG023990; Mon, 26 Jun 2023 10:22:34 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([9.208.130.100]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3rdr45teq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jun 2023 10:22:34 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35QAMYlV6947344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Jun 2023 10:22:34 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E99B658057; Mon, 26 Jun 2023 10:22:33 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1E1658059; Mon, 26 Jun 2023 10:22:29 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.116.175]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Jun 2023 10:22:29 +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: [RFC PATCH 3/5] mm/hotplug: Simplify the handling of MHP_MEMMAP_ON_MEMORY flag Date: Mon, 26 Jun 2023 15:52:10 +0530 Message-ID: <20230626102212.119919-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230626102212.119919-1-aneesh.kumar@linux.ibm.com> References: <20230626102212.119919-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qKbBUn7tv0d9_83dVdL0DTE0aa5r2hqc X-Proofpoint-GUID: eM2vG3u38snH7SpxZ7SCpzpK2CQFnRUC 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-06-26_06,2023-06-22_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306260091 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 67FC04000B X-Stat-Signature: ixkyidaw9q386rkbxxw7t599reyghiws X-Rspam-User: X-HE-Tag: 1687774962-321755 X-HE-Meta: U2FsdGVkX18V9F/SqrDrLQkCWA1mkPhd2wbfM4D86Ajok0tsuc1zAkD1PAxURmEOCBLLKH44ujNJtmMGtmAYppb+slATBhDX7F0K+UuYPLdj22llu/WrPdWBJx7WaQgeN4T+OMm0Caln1eGqErvDHG327mlne3FCCb9ZVtqqfWUKq+c8V42rrTYKAYfYNc6hHSH0ImwtTyJBWQgJm7TBvt11BIVo6FE6vrj1heoarw+fIoAV6hK2OYca3IYJoFMg4OLaBi+BYxVere9+dx+reOjrgLeObP1IMsSyXB4vQILBFluzZjygxoW/2wfs0OctSUc4X8iXkKlR0imhu+H7N4nDjv/RWMYcwqCAAxcLrjP+FXfniDk+PefOp3R/lVvIjFpLX++B+4OddsShMHb3j1DadjjpJHhHbNlNzEDhaK4SVqLXOZZFB7jV8qyz27+9wBSQDSPnJ5OCLjM9krWRqzVUr3NoafHvAC8S7KETarRQ68hHNzewaHwHZ5ycyR07vmhSw010xFTPY0cIqvb1fpBJVx1J2iUClJJfVe1tuC5fUJplMBngXjrUf2wBqgOl4588MQO5gZqBmFIFdbu/W0PL3SQCnKqtCZbgJucDjqvRm117tItcC4kVHd7yOOyYyrGWEEMpEkNkW8MfVswbdg+xY5iliOtcEfdkVj9N1OnGn+QmTdt4m90/DIhTC/TSKci8FjLQNu8Qh7XAcpCuG650CUhLl4DzY1Ve8kypetGsrdRSe9O5eIlSJ2jKzzG2MuZSwez8h5FYxp2/K5L1mJmXOgd33SlZRbnJvQjxQ9GxAHBnwTa95U/N/h7CVpx+CIaz5pAh+CijdU9ndl64lQuTlNfeNrumhJtIXSjmJg5njroLeyvVMx//ARFAlM4j9vXyVg4D7+l9lBqZriJgvREcR3Y+qNx11KkAV81dYynZhqqFxWsHdvkFkz7CU4+XpfXC7OT/bvwQfwOHiqr BEmBm8oO Kl04B8VXTq3pn1wtkV8xZsZfCJTyfRkiYyDs0V+PzZiVeAW4JIUvMR76039CiZe1J9uA8obB8Pn3CmSjks7Rwce7sDAxuXNkJpO/AzzuSXegjndvBHr0ht4TOzAOZRV7efswENugdXdWCgkLGiogMgSdxkZMmCL3lLEV3+17Nfdv/QV0MNtYtIyyBwao6YqpyGVss 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: Instead of checking for memmap on memory feature enablement within the functions checking for alignment, use the kernel parameter to control the memory hotplug flags. The generic kernel now enables memmap on memory feature if the hotplug flag request for the same. The ACPI code now can pass the flag unconditionally because the kernel will fallback to not using the feature if the alignment rules are not met. Signed-off-by: Aneesh Kumar K.V --- drivers/acpi/acpi_memhotplug.c | 3 +-- include/linux/memory_hotplug.h | 14 ++++++++++++++ mm/memory_hotplug.c | 19 ++++--------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 24f662d8bd39..4d0096fc4cc2 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -211,8 +211,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) if (!info->length) continue; - if (mhp_supports_memmap_on_memory(info->length)) - mhp_flags |= MHP_MEMMAP_ON_MEMORY; + mhp_flags |= get_memmap_on_memory_flags(); result = __add_memory(mgid, info->start_addr, info->length, mhp_flags); diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 2387391ee93a..add3e7829c80 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -362,4 +362,18 @@ bool mhp_supports_memmap_on_memory(unsigned long size); bool __mhp_supports_memmap_on_memory(unsigned long size); #endif /* CONFIG_MEMORY_HOTPLUG */ +#ifdef CONFIG_MHP_MEMMAP_ON_MEMORY +extern bool memmap_on_memory; +static inline unsigned long get_memmap_on_memory_flags(void) +{ + if (memmap_on_memory) + return MHP_MEMMAP_ON_MEMORY; + return 0; +} +#else +static inline unsigned long get_memmap_on_memory_flags(void) +{ + return 0; +} +#endif #endif /* __LINUX_MEMORY_HOTPLUG_H */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7cb112fb4996..9cfa6fa31df5 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -46,19 +46,9 @@ /* * memory_hotplug.memmap_on_memory parameter */ -static bool memmap_on_memory __ro_after_init; +bool memmap_on_memory __ro_after_init; module_param(memmap_on_memory, bool, 0444); MODULE_PARM_DESC(memmap_on_memory, "Enable memmap on memory for memory hotplug"); - -static inline bool mhp_memmap_on_memory(void) -{ - return memmap_on_memory; -} -#else -static inline bool mhp_memmap_on_memory(void) -{ - return false; -} #endif enum { @@ -1317,10 +1307,9 @@ bool __mhp_supports_memmap_on_memory(unsigned long size) * altmap as an alternative source of memory, and we do not exactly * 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)); + return size == memory_block_size_bytes() && + IS_ALIGNED(vmemmap_size, PMD_SIZE) && + IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)); } bool __weak mhp_supports_memmap_on_memory(unsigned long size)