Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1676935pxf; Fri, 12 Mar 2021 16:28:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnnlNfTsCSUtxgqWsEB6BCnTPa7sYBNEjJYMeT54YNaacRHYRe5yRX14rDLaevRmpg2ghD X-Received: by 2002:aa7:c907:: with SMTP id b7mr17484535edt.37.1615595304863; Fri, 12 Mar 2021 16:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615595304; cv=none; d=google.com; s=arc-20160816; b=fWjp0RXCa3JhoQCpBGKqyGhT5qmfuPRZ6/Zzll6ikQ1GYjIjBTQvVWo6czaccuVumk RSNZZRVupi1oytCzBFPpyPDM5WuYQ+cvgv5KJU010pXFDzKVS8ikll9ecch0W9V0M2Yn B9IEdz7vDcqa8EE9Kv+YWaDC28AYiCU7r5iPilLf7vNOzGL5lIryfj9GoobdOK+d2XsF ZluQ1p9e57F6z+lk67ttjR4F0hTe971z3w0HIhgjY34wzK7fvl7BHCnM1WBQiuCXB3RU eg3LXnzt4q/q/uudp835dm5iNxHRJlIyeAr92a5F4EpXta4hyEk79mr6kLXwUZvTqp6L /Gyg== 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=vNRpYg3mNXhJ4EvT4QVsetlahXm7tTJ+Ei2tmIgYcGk=; b=MR9leSK7+FJQSWwC1VrSlHWLNNj/6kGW7lXJvKj6giGYfY15Z9D0DrmMojuAfuxqn9 hZFHb7rrwCYBSUfG35hhOwq/9b90+5mQA+CI5Ce0HJ6hJSXEnkLt2d45vOuXtTzMdKba Y/Zk+1jXdiuoyTGa8u/DKgGjXfdVdPPpjzdIvNbT7/UV5dxZlOhP+qctQq++594hOBSr uq6VLdrI8FhndxWoJTrWAhsZzLU6J5HeVPMxENQceQzsXfEQdO8cKHqnqbPKXXBQUgSD PW1aMvdAUKQzV5Wnpoe2gV8tbCUKwwJYdxVyv2D7qVesS+yiv2M1w263gAYStclXV/eJ QUjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CwuBwBYE; 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 q28si5369703edc.389.2021.03.12.16.28.00; Fri, 12 Mar 2021 16:28:24 -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=CwuBwBYE; 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 S231907AbhCMA1D (ORCPT + 99 others); Fri, 12 Mar 2021 19:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbhCMA0o (ORCPT ); Fri, 12 Mar 2021 19:26:44 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B68BC061761 for ; Fri, 12 Mar 2021 16:26:44 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d23so9463794plq.2 for ; Fri, 12 Mar 2021 16:26:44 -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=vNRpYg3mNXhJ4EvT4QVsetlahXm7tTJ+Ei2tmIgYcGk=; b=CwuBwBYEqQ0MfZY/RYslKueCBMpAtG8LOwNU5tg4QcEpihijcpdWqSNQzo7XIkAMQ4 0+WF9LwmesCxenPaTSRwhrlJ6tiNHdcs9EDFeYwYkIlsxY+Aq6GuzW/IPcWiNHkMV9ZC s3eXk860yJTAMfSN09JR0Tlev4icJsi8QVf3hRl76DzHYCvLcx8EMZePHXT+AalyHl3b 47jxQXpDCPT62S3w9eOPvM1OBF4EVSArHcYP0kPHogzuTMBOvRihfXFsi2OLrAspQKVM 7cl7JcXUpU0GIzeQgEIaK43ro6uMdiZZ/iLoGCMVy2S8Ka52YA98xU/Y5fw3gGEJvW2b Ft2A== 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=vNRpYg3mNXhJ4EvT4QVsetlahXm7tTJ+Ei2tmIgYcGk=; b=iKK3SnZlqlMGU2N9mJKdXs4B+L+k+NSUAxgyFhWY5PgMT4RNqGVg0uRIylffxEYsSB 8eYGQlXAbS3sSYBGhODd47njlUd2m2w+cDzHPX4qT0QYLS2D4Ey2s8dRZ0cL9xGbtyo/ WRx+zWUzvKu5e+hs1tQeWV7fIsm9hArAv+CvfwZ6MM8clvXaRxSVLqIxf1whPqnavH40 lnjdaxbIzUTFQAypv1pcEM1qHhCJ54C7BUd6IEhBX+ieyyQhctyQEqqeZmIqZffTnxQ8 Fvl9jHrpLVny4nJ9TMJi9Yk8voPLom2GMUugnxNLeMDjr2EL1+sv9O+011Sh4v+YN8gj X/Bg== X-Gm-Message-State: AOAM530Sa59oEmXGfW5pJjhE8p33jrfOqZRMCEx7NS9KNt7DHp4oW3qs EjTIu2G3ryF1FDd+KhG8HaZ3Fw== X-Received: by 2002:a17:903:189:b029:e5:d7c3:a264 with SMTP id z9-20020a1709030189b02900e5d7c3a264mr1056141plg.6.1615595203624; Fri, 12 Mar 2021 16:26:43 -0800 (PST) Received: from google.com ([2620:15c:f:10:e1a6:2eeb:4e45:756]) by smtp.gmail.com with ESMTPSA id co20sm3409772pjb.32.2021.03.12.16.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 16:26:43 -0800 (PST) Date: Fri, 12 Mar 2021 16:26:36 -0800 From: Sean Christopherson To: "wangyanan (Y)" Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Andrew Jones , Peter Xu , Aaron Lewis , Paolo Bonzini Subject: Re: [PATCH 04/15] KVM: selftests: Force stronger HVA alignment (1gb) for hugepages Message-ID: References: <20210210230625.550939-1-seanjc@google.com> <20210210230625.550939-5-seanjc@google.com> <9a870968-f381-3e0b-2840-62b7c2b2e032@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9a870968-f381-3e0b-2840-62b7c2b2e032@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021, wangyanan (Y) wrote: > > On 2021/2/11 7:06, Sean Christopherson wrote: > > Align the HVA for hugepage memslots to 1gb, as opposed to incorrectly > > assuming all architectures' hugepages are 512*page_size. > > > > For x86, multiplying by 512 is correct, but only for 2mb pages, e.g. > > systems that support 1gb pages will never be able to use them for mapping > > guest memory, and thus those flows will not be exercised. > > > > For arm64, powerpc, and s390 (and mips?), hardcoding the multiplier to > > 512 is either flat out wrong, or at best correct only in certain > > configurations. > > > > Hardcoding the _alignment_ to 1gb is a compromise between correctness and > > simplicity. Due to the myriad flavors of hugepages across architectures, > > attempting to enumerate the exact hugepage size is difficult, and likely > > requires probing the kernel. > > > > But, there is no need for precision since a stronger alignment will not > > prevent creating a smaller hugepage. For all but the most extreme cases, > > e.g. arm64's 16gb contiguous PMDs, aligning to 1gb is sufficient to allow > > KVM to back the guest with hugepages. > I have implemented a helper get_backing_src_pagesz() to get granularity of > different > backing src types (anonymous/thp/hugetlb) which is suitable for different > architectures. > See: > https://lore.kernel.org/lkml/20210225055940.18748-6-wangyanan55@huawei.com/ > if it looks fine for you, maybe we can use the accurate page sizes for > GPA/HVA alignment:). Works for me. I'll probably just wait until your series is queued to send v2. Thanks again!