Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1330961pxb; Thu, 4 Feb 2021 10:09:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCn3rMmZMdwlgKc9jZQoqhB0GmBk9VpI5F/yaPqLg7HDk2qOl5Lhqe6E2WCdxNSXoMovX+ X-Received: by 2002:a17:906:408b:: with SMTP id u11mr302452ejj.299.1612462183768; Thu, 04 Feb 2021 10:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612462183; cv=none; d=google.com; s=arc-20160816; b=Cwms2gyxyhacMKrxLxr+FjqQf9hDzc89Qzbc4C+bVO0yybhw9cDStUzZ2SKj4w1qIn 6RnseY0mUpeIZgevD/OZA+/ykN4GH4tB1zVWg2RHC0uYWljFevAH+7FhGXjvYxcluONU dDz/zAHNfyxKoEPyVQAElu+oPtkTzMy/HZ1OQb7SVq0lPzvOQdu8OimMGRFtc9Ouw3Yl iXFfwawXXx8cI9dpnga+RQT/CBmvG7+54b7w481dsML0nlBb1w2euHBA+LUq+L4UVlUd VRmkGRX9YSr5CdkCDbV2c1SnAMWyQxKebvu6MUxwc0JI9NjqLhL/jyykwXULgGHwP7jC zj2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sgNBgGYoMlIjzXJS7k+uTJr90AGrN8C+0QKMchqVgEw=; b=lmG0flcC2sLeHtQTDSizeu6trXd1Rrng78uHLRChT5pzqkoSWMcIy6DQ6nnihEWkIe fCUV+ZREaqbCC6Mmq46zo4f3asjiN/gLAVhrC4jlay1/lXVuZEchQ0XII7Fw7QSsYDfy 8puHtwOLTcdGUfSJdjY6wuvbSYpyiGQAu5a6jUEFuYx2XgLTLpNGOqfIQJpl0gW9VSbO cIrri7wyWfYkhR4EfvB/9+P2DtDLcjqwhj7ok6glviMyYmI5lEDBLEMk5IK8C4jJMfnn iqwBe9juIdF9tx63DBtfBFUfMRk4DJNQkDipcPrzIikugOgd5CB/poPSLOpAuXDZDWH0 49dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Sge4JAbg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si3790565edg.119.2021.02.04.10.09.17; Thu, 04 Feb 2021 10:09:43 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=Sge4JAbg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238880AbhBDSF0 (ORCPT + 99 others); Thu, 4 Feb 2021 13:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238716AbhBDSB6 (ORCPT ); Thu, 4 Feb 2021 13:01:58 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7997EC06178C for ; Thu, 4 Feb 2021 10:01:17 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id c12so4591434wrc.7 for ; Thu, 04 Feb 2021 10:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=sgNBgGYoMlIjzXJS7k+uTJr90AGrN8C+0QKMchqVgEw=; b=Sge4JAbgrFLOizl11w9D9oQSAmAxwysJJW+ccrQVWH3ezom8wIwM6z9XWUlzOfNRhC Jiz/Z0fwGZlSo+kWjB2iV8VlRI25x/wqVzkaVWFrDTrJLatKYfuN8jzaHg7RCdkDaqE5 VKKxtZNvMbU6xv1PrGxNgfs24F1XOAtvlS9QjdUgxxt0D6WrAVj8qoUhNoxMQ0JIEGRi jm32ZYSURfxm7Bbxf95Qa4KEt5B3gzPag9r32O6cMQusXyCbiODFioaUjENYLWWWP+Tb YbDAdDPDq8CFjHTGCe1PVUYpFrmKe/cvt2yMg6pVlCCnPTMOFH/igkbptVPNcYEO4OqS OrGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sgNBgGYoMlIjzXJS7k+uTJr90AGrN8C+0QKMchqVgEw=; b=R8FMGFCSs1doo8jafWYCQjoWtzvjXJM8QQtFjHg0G/3ibZuaSd1v7DKl/9Hy5MLMpP mawkDXwBQgWhztU6OKDjZHO+salQMFfveBYVFFots4VI0EVVKE4PVVwqXAiuOUub9Oy6 LKateqBxF/EXoaY8ZnrElcJyTqsGdKask+wx602WDbFtOKGzmwSETsm/YFko9lmztcu6 hoMf4ofQbPZKX5My8lOarYV1ZR4UXjRM6s8Vz/9NZcTAw2O4JaADY3yuiMjJFq9Zs1My HzMX8rzj2szEKPbXya3alnHJji9FV9uhKFhWSjIJC3UoDYE0jRh0J+6Bi4Lsrq6z0EKC nLqQ== X-Gm-Message-State: AOAM5303Kov/+P4HnqAd57eIgruKOJ/ntVMp9+tbovfv2uEsfwA8mdRA HnSU5shTRwa7CypWzpx2Hwb3Xw== X-Received: by 2002:adf:b749:: with SMTP id n9mr534156wre.267.1612461676095; Thu, 04 Feb 2021 10:01:16 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id t18sm8959891wrr.56.2021.02.04.10.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 10:01:15 -0800 (PST) Date: Thu, 4 Feb 2021 18:01:12 +0000 From: Quentin Perret To: Will Deacon Cc: Catalin Marinas , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Fuad Tabba , Mark Rutland , David Brazdil Subject: Re: [RFC PATCH v2 12/26] KVM: arm64: Introduce a Hyp buddy page allocator Message-ID: 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210204174849.GA21303@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). > 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? Thanks, Quentin