From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F757C7619A for ; Wed, 5 Apr 2023 11:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ji65Y9oHlSyVavu7PRHZjVTZSn1Vg5/N5V9tsCxkJFE=; b=Q7Bp2F3vW58JaW 9g4mpdP0z+IutCrPkDIJtvFLdCvnEFmFM535tzl1EdifbSjdNCkNrud8H4+46z/7vDzOLqx8awbut 8TUPQebFdhRoE49EHM5xGi/FR/uzq66yM4zl3E3S4hjG9XPf6j0IbsTnfNR+8gjFHHnxDn6tNtdXS Mb+Q+lVxWCkUJxQUkEAXqKBnIB0swy1JhBi+gxE/cmn9UQNBPLWAYfVMN9zk5sTjzB1Q8bs+Si00l QU5Duoprz2g7wlN8LANydSDmnJ2ON6y/CJGRIfNqk8Afa2yDv5+aRMfUCMRVzjPXcNzwxCyzFZFNI F+i8mp5DOeoIS5xHbnXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pk1Dk-004Fmq-2v; Wed, 05 Apr 2023 11:22:32 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pk1Dh-004Fli-2R for linux-arm-kernel@lists.infradead.org; Wed, 05 Apr 2023 11:22:31 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 97F4C63C10; Wed, 5 Apr 2023 11:22:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D138FC433D2; Wed, 5 Apr 2023 11:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680693747; bh=n5bovVcIGChq7kihZFHIqaH3XLd0jEi9fAnLi2ARFXg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QFCkzTis6C7yiC2pnqti6GUoxekNSyS3phRbbQYWG8Bz4SfK6atyD3PlGpx49yyT+ IbBrjX43pBFpzgEGnO+c0gV6Js8BcOb1bXO4hCNqKZ9kbmfGDGRjhVwgDH2XPSGVRa foXqb0kRgq07uQnVGkrG3fsOcPt09UKO+yhuXAmOFeeP69AE5G9RQSbkj3cnK/OGUQ IvSCjVh6Z9X4VCabeguzHDQs05s9FfEfOf+gjVTKJrzqBiYXfePYbel/64F3jo7eL1 QWI7eCvz4yRlUoq/aR+pfN8iaxbBmYtj/o63C9P8yfwGNc1uJZKNytcha06pltkgsL FoaaysDkr7v9Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pk1Dd-005xWR-Kz; Wed, 05 Apr 2023 12:22:25 +0100 Date: Wed, 05 Apr 2023 12:22:25 +0100 Message-ID: <86r0syvaj2.wl-maz@kernel.org> From: Marc Zyngier To: Suzuki K Poulose Cc: will@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com Subject: Re: [PATCH] arm: Do not add padding alignment for hugetlbfs backed memory In-Reply-To: <20230405110905.669217-1-suzuki.poulose@arm.com> References: <20230405110905.669217-1-suzuki.poulose@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: suzuki.poulose@arm.com, will@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230405_042229_892205_DDDD0044 X-CRM114-Status: GOOD ( 27.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 05 Apr 2023 12:09:05 +0100, Suzuki K Poulose wrote: > > The arm code tries to align the memory allocation size to 2M to potentially > make use of the transparent hugepages. But this would be problematic if we > try to allocate from the hugetlbfs, where the allocation size could be more than > 2M. Given we support upto 1G, let use leave it to the user to align the > requested memory when hugetlbfs is used. > > Without the patch: > $ echo 1 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages > $ mount -t hugetlbfs -o pagesize=1G none /root/hugemem/ > $ lkvm run -m 1024 --hugetlbfs /root/hugemem/ ... > # lkvm run -k ... -m 1024 -c 6 > Fatal: Can't ftruncate for mem mapping size 1075838976 > > Signed-off-by: Suzuki K Poulose > --- > arm/kvm.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arm/kvm.c b/arm/kvm.c > index d51cc15d..9f958232 100644 > --- a/arm/kvm.c > +++ b/arm/kvm.c > @@ -37,7 +37,9 @@ void kvm__init_ram(struct kvm *kvm) > * 2M trumps 64K, so let's go with that. > */ > kvm->ram_size = kvm->cfg.ram_size; > - kvm->arch.ram_alloc_size = kvm->ram_size + SZ_2M; > + kvm->arch.ram_alloc_size = kvm->ram_size; > + if (!kvm->cfg.hugetlbfs_path) > + kvm->arch.ram_alloc_size += SZ_2M; > kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, > kvm->cfg.hugetlbfs_path, > kvm->arch.ram_alloc_size); Seems sensible. For hugetlbfs, we're guaranteed that the memory is aligned, so no need for any additional alignment (which is what this +2MB was about). Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel