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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A1B57C433DB for ; Thu, 4 Feb 2021 18:01:22 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id EA4E064F4D for ; Thu, 4 Feb 2021 18:01:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA4E064F4D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 488F34B346; Thu, 4 Feb 2021 13:01:21 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2dOrHbKfURw7; Thu, 4 Feb 2021 13:01:20 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 337E14B338; Thu, 4 Feb 2021 13:01:20 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4CD184B338 for ; Thu, 4 Feb 2021 13:01:18 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eszHYpx4TGtG for ; Thu, 4 Feb 2021 13:01:17 -0500 (EST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 3A6EA4B32C for ; Thu, 4 Feb 2021 13:01:17 -0500 (EST) Received: by mail-wr1-f45.google.com with SMTP id z6so4577463wrq.10 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=qUNtJ1lWAvjVvlsf2MsMDXDjYzGyETjYQuA0p2FNdv8B5oaMESePLYZJke+1jrJTyi PmDnPJvstNducsIE9aN6DfHVTXZmVuwb2h1PchJbRzE6EkCv2pK/LkECJ0gHU3akGPFk EFUeKCu7isDXmndW+b4tKgvvolxxvvKeSadsr0q5hzAlQU1uHz2kJhqKEugTS3ZOrkb/ IUTyUdotHjYiVllErcVLgrcCcrQMTN2yWL3la54AvNd6AwgDi9Br3sV6vXlsEC44WgLe CuI1VikYG0g7Czn6VSL+bnk0q3HpKYlVIQb/oOE6dT3oKHEQjvNYCb6KRU7K1cdoSA6b /oqw== X-Gm-Message-State: AOAM531m7gkTPNmtRhXnZXgF3W0/PZqi3Iqfzj0a8uBMnWRtEHAYogiR wA3+f87s5bhWm/PzTCuv1K7Gqg== X-Google-Smtp-Source: ABdhPJxzVwJVmeoEOZDZT5PwvHVmhUwJ0gSawClAAnwU0xD6ZtCQJxYDI7bHVG6gBHJ0ToO7Ntu4zQ== 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 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-Disposition: inline In-Reply-To: <20210204174849.GA21303@willie-the-truck> Cc: devicetree@vger.kernel.org, kernel-team@android.com, android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Frank Rowand , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A3E37C433DB for ; Thu, 4 Feb 2021 18:02:33 +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 49AD064F38 for ; Thu, 4 Feb 2021 18:02:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49AD064F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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=h5iMZLnznxuiKWIYwhiqW/8n5/g6mtufnZMcM/y4UCA=; b=Ecg8+Dr7q5RZwOockzQE2uGe8 00/H2x+lQyafT8ODY4MvIkq4viFQhmNn40dvhShHkUck3+65PoHXWTnR0FiwKs8rW4DUp2z028phS npp6+3PtXTEAvXhgNr6SNmwOr/O4GVZTVrfY4h8j/yyyfEkmBplMsqbDfh2cLU1oECAzu8hVfpZX3 Rt46ys0pizSOgIIzjiOIcq2ATSNvv1IPR5qKYCuZj6U+eSIZr4MLu/AT95n8YU7O06NEhn3iZtMAf ypDIgb4aEu81duS4AOgb5AcOr8Sk2AIbIVbYQjy0TlKS8ABb32k5SCtN49noIX8+IhdUkfqc3rxYU QRkZTYE4A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7iwS-0005dD-2h; Thu, 04 Feb 2021 18:01:20 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7iwP-0005bx-G5 for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2021 18:01:18 +0000 Received: by mail-wr1-x42f.google.com with SMTP id m13so4573137wro.12 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=TSfazLbMmZmi7rX4JY7Zk9FzrOffiSygPo8B2HQiFzF+HIGg/YJXKE0rrKG13yhgGZ Cv8EuPu1ULsaD82zu1gADukGhJdrk3mGIhUgp04/1siwTTzX72vEkttmXZgJF5xkIVqH BmZuqoben7PUO28gZ+GzW+FiRx2PnY7UolhZScrUvUrR4JKMIrjIW2a6d3+vvSD66psg 36qgZQKcsGiZkwvPb+/COG6Sbn0d6Rea2J9OFW5aOJLHvzjOiIwIKCH3OwS4hFt27joV 482W5Ii/myAYE9XBMgbWYKgrE9Ogl4oP/Q8PZ57egaVYAtjGwU/DdCX6Pu1hALpM6+L1 P7sQ== X-Gm-Message-State: AOAM5307iaIp+Fo0L5wkdBWxVzEFwue84JZn8W+a079PKtc+qnm7Wt6a fpQHSkc2ZmlxE1l53P+o/zVuoA== X-Google-Smtp-Source: ABdhPJxzVwJVmeoEOZDZT5PwvHVmhUwJ0gSawClAAnwU0xD6ZtCQJxYDI7bHVG6gBHJ0ToO7Ntu4zQ== 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 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-Disposition: inline In-Reply-To: <20210204174849.GA21303@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210204_130117_590391_3E79EFBB X-CRM114-Status: GOOD ( 27.06 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 A84B8C433DB for ; Thu, 4 Feb 2021 18:02:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6270564DE8 for ; Thu, 4 Feb 2021 18:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237175AbhBDSCt (ORCPT ); Thu, 4 Feb 2021 13:02:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238720AbhBDSB6 (ORCPT ); Thu, 4 Feb 2021 13:01:58 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F797C06178B for ; Thu, 4 Feb 2021 10:01:17 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id p15so4577280wrq.8 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=ibSX5+KYDMOg0n0mhR7/B9Aqj7OB1kPXOOmV7JkQV431KdW9BWvg55UF3XycC59yPM W1hg0LDe6vuZz33+oCDpvTlgzyhGBBOimshrjy/iSGY3Dle3iFgaTovI8GCF9c11/1dl xBq8+tjdRYklR8Eoek23NvS2VtBpejKYv8lZWRFv6Tfxp5VZvlS6PdDdkEx42itoKGgG ZuessHpbzqMNB4fLAIg461D8aR9n+Y2ZtpI/+FAu6hC966vq9+roL6Zp7c7TS/213Uae iMUIg7Y7fQvnvtGKQEcSN4Q7gUeS0unjpCFgthCzPU8C9A8syZsMfVok8DQIaCRnDy1l yErw== X-Gm-Message-State: AOAM5329AAtk6/jnPdqyKs+NZ4EywFRLZ8fbpkX+gM1DjngMwBSBqcee uexlGNCgerdMGlBRZ66SGSEs/g== X-Google-Smtp-Source: ABdhPJxzVwJVmeoEOZDZT5PwvHVmhUwJ0gSawClAAnwU0xD6ZtCQJxYDI7bHVG6gBHJ0ToO7Ntu4zQ== 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: devicetree@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