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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0318CC433DB for ; Thu, 4 Feb 2021 18:14:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97C0C64F4D for ; Thu, 4 Feb 2021 18:14:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97C0C64F4D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AErcYMOQniitnbE1XU7Xq4UKZHMW1BIzatq7Ys6byNA=; b=XnN8wsQKhv5dYts8bB7CuxTFN IQ69wOrGfQ8zkZoCcTy/7XI/wBQZVVrESJkdWVuOURkBG8DpJ4RuDSe0aR5LL3gk7a8kX0bmDVETn bAjNlsJeBS0xgl0h6L4c1zHv+LreZWTvmLr7JXgXngZDdNOr562iNZpIbrVGOFyg7+sfPt8Dpwt4P fe0eHHD+MyBpf4zD9R+84RACoK456hz6Kq7a388VXdzUBc/U2ueEGft/fvXzgcADS/tlyhBpWqnGH hRdxnz6D/8VgTkgqLXln29jY4+E6Q7NYEoATQyJIstrnmZhp2J2Zg0btMkGsYGLl6UF+EslGL1N0t /hFxRLe+g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7j8C-00081T-K4; Thu, 04 Feb 2021 18:13:28 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7j89-00080v-Dj for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2021 18:13:26 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 842EB64F44; Thu, 4 Feb 2021 18:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612462404; bh=zbLV6tzEcrYE6Zr1vCAoOlEuk2uUe3OTj1GoEj/vbsQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Rd/0Jes6vV9yhhSHANL1rZUNuB/fQhP/iQfuTS2kgxeRItC0waSOIU/ltYfOmsQM0 ZOh5bzruLkhY7RB7lxLFOiSL9Kjd69Q+qgJS3+fMStjqDUqEZaHW3SgnJ+U6Uxmbtf JuHL4djLRKjhNdUibBNSXtkiMpM2SaAoKfcd6dJCeStsbY+3lqJfvoSwZc+0p+nhdk IrxtdsVlS5TwIZIajddo+hofOfxWHdUjicQRnmuHEJYEm6P8vftmPm9YU+O9eGrpPH sqZYPYp+4xXVacbgRM8c7kQu0NeNmolcwTczxstovtLGDGbp+hlTPjBeVn9wd2gz+N FsPz5jPY6jH+Q== Date: Thu, 4 Feb 2021 18:13:18 +0000 From: Will Deacon To: Quentin Perret Subject: Re: [RFC PATCH v2 12/26] KVM: arm64: Introduce a Hyp buddy page allocator Message-ID: <20210204181317.GE21303@willie-the-truck> References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-13-qperret@google.com> <20210202181307.GA17311@willie-the-truck> <20210204143106.GA20792@willie-the-truck> <20210204174849.GA21303@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210204_131325_618230_1E6C86A5 X-CRM114-Status: GOOD ( 26.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, kernel-team@android.com, Suzuki K Poulose , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Frank Rowand , kvmarm@lists.cs.columbia.edu, Julien Thierry 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 Thu, Feb 04, 2021 at 06:01:12PM +0000, Quentin Perret wrote: > On Thursday 04 Feb 2021 at 17:48:49 (+0000), Will Deacon wrote: > > On Thu, Feb 04, 2021 at 02:52:52PM +0000, Quentin Perret wrote: > > > On Thursday 04 Feb 2021 at 14:31:08 (+0000), Will Deacon wrote: > > > > On Wed, Feb 03, 2021 at 06:33:30PM +0000, Quentin Perret wrote: > > > > > On Tuesday 02 Feb 2021 at 18:13:08 (+0000), Will Deacon wrote: > > > > > > On Fri, Jan 08, 2021 at 12:15:10PM +0000, Quentin Perret wrote: > > > > > > > + * __find_buddy(pool, page 0, order 0) => page 1 > > > > > > > + * __find_buddy(pool, page 0, order 1) => page 2 > > > > > > > + * __find_buddy(pool, page 1, order 0) => page 0 > > > > > > > + * __find_buddy(pool, page 2, order 0) => page 3 > > > > > > > + */ > > > > > > > +static struct hyp_page *__find_buddy(struct hyp_pool *pool, struct hyp_page *p, > > > > > > > + unsigned int order) > > > > > > > +{ > > > > > > > + phys_addr_t addr = hyp_page_to_phys(p); > > > > > > > + > > > > > > > + addr ^= (PAGE_SIZE << order); > > > > > > > + if (addr < pool->range_start || addr >= pool->range_end) > > > > > > > + return NULL; > > > > > > > > > > > > Are these range checks only needed because the pool isn't required to be > > > > > > an exact power-of-2 pages in size? If so, maybe it would be more > > > > > > straightforward to limit the max order on a per-pool basis depending upon > > > > > > its size? > > > > > > > > > > More importantly, it is because pages outside of the pool are not > > > > > guaranteed to be covered by the hyp_vmemmap, so I really need to make > > > > > sure I don't dereference them. > > > > > > > > Wouldn't having a per-pool max order help with that? > > > > > > The issue is, I have no alignment guarantees for the pools, so I may end > > > up with max_order = 0 ... > > > > Yeah, so you would still need the range tracking, > > Hmm actually I don't think I would, but that would essentially mean the > 'buddy' allocator is now turned into a free list of single pages > (because we cannot create pages of order 1). Right, I'm not suggesting we do that. > > but it would at least help > > to reduce HYP_MAX_ORDER failed searches each time. Still, we can always do > > that later. > > Sorry but I am not following. In which case do we have HYP_MAX_ORDER > failed searches? I was going from memory, but the loop in __hyp_alloc_pages() searches up to HYP_MAX_ORDER, whereas this is _never_ going to succeed beyond some per-pool order determined by the size of the pool. But I doubt it matters -- I thought we did more than just check a list. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel