Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3575922pxj; Tue, 1 Jun 2021 08:23:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyiKVYfFqyYLnKr54rszdChahNvM+ekzO5LHJIyK9ZfS8IT5oDi4R2mRLygNCjwWuiQsPN X-Received: by 2002:a6b:dc06:: with SMTP id s6mr22126922ioc.130.1622561000115; Tue, 01 Jun 2021 08:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622561000; cv=none; d=google.com; s=arc-20160816; b=qE7VwXTWYv7ODUo1zNtVzKtYwRardd8hcA9cyicQFjrq+VWTYQRuply6aHhwTNssoY S1sEduI/8ue1lyE9ceEatF04qxt2Qtcr3Y9dO9IaLmXJ09PzHxBh8g+6GmDFTQlOmJn9 MCMZEZETMV2eDu5/PlMGchl3zkciutnmIqIb0EOXQToaMqSbptPH7TvQJAxPv9LFBTmO Yb3zayD8ko77llMT5C/Y3iNfl1frrQyykxCsXae3H3NekN384iS2Yb2/f/WJpa2gd/R3 6yY5ouqw8oE4hXUVeF7qB3R2Bn1m9azi9o3MW7c8sZEgamGh8RaNhe6AJbH82Y56pHOP N7+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=pHv5jx9Q+LhYQCobHpurDtVrGw4A4hDtPM/k4uKj/WQ=; b=spS5xWXTTaQTx4kzuy31r4jjmlpO1YnDw6qu9QFnA3Q5fJr0K/KeDf7Fu4sSJe4AA/ nYHmm0/3tzM0WS90WNMrgjbtupCEggPi+zfs9nZz5XOc65iYoPitS5osErtp5vk7fW2E yaNfaqr+iqY9e6ic+P+vJSMW62Qv6ca3wvhqXXZDdyggg/U9C7II9bw15YeCK2EqJKfa NcWlG0oPpt/CcZXehE2DZBHfkBb3PK6pBCKVyVVwSQ1WIkXDnfSnI8+4sREmbuSlDy4q /TnMAYjscHVX+wiIRLqdsi5zperRxo/NZiMDS6zQSXJ0si8MLMS8lMcjLM43wd7JFljH qIig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si18375835ila.72.2021.06.01.08.23.05; Tue, 01 Jun 2021 08:23:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbhFAPXg (ORCPT + 99 others); Tue, 1 Jun 2021 11:23:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:54340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234142AbhFAPXe (ORCPT ); Tue, 1 Jun 2021 11:23:34 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC13B61287; Tue, 1 Jun 2021 15:21:52 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lo6DG-004qYO-Q2; Tue, 01 Jun 2021 16:21:50 +0100 Date: Tue, 01 Jun 2021 16:21:49 +0100 Message-ID: <87h7ih1ugi.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Cc: will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 7/7] KVM: arm64: Use less bits for hyp_page refcount In-Reply-To: <20210527125134.2116404-8-qperret@google.com> References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-8-qperret@google.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/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: qperret@google.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 May 2021 13:51:34 +0100, Quentin Perret wrote: > > The hyp_page refcount is currently encoded on 4 bytes even though we > never need to count that many objects in a page. Make it 2 bytes to save > some space in the vmemmap. > > As overflows are more likely to happen as well, make sure to catch those > with a BUG in the increment function. > > Signed-off-by: Quentin Perret > --- > arch/arm64/kvm/hyp/include/nvhe/gfp.h | 2 ++ > arch/arm64/kvm/hyp/include/nvhe/memory.h | 2 +- > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/gfp.h b/arch/arm64/kvm/hyp/include/nvhe/gfp.h > index d420e5c0845f..a82f73faf41e 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/gfp.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/gfp.h > @@ -24,6 +24,8 @@ struct hyp_pool { > > static inline void hyp_page_ref_inc(struct hyp_page *p) > { > + if (p->refcount == USHRT_MAX) > + BUG(); nit: BUG_ON(p->refcount == USHRT_MAX); > p->refcount++; > } > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h > index 3fe34fa30ea4..592b7edb3edb 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h > @@ -8,7 +8,7 @@ > #include > > struct hyp_page { > - unsigned int refcount; > + unsigned short refcount; > unsigned short order; > }; > > -- > 2.31.1.818.g46aad6cb9e-goog > > -- Without deviation from the norm, progress is not possible.