Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2347013pxb; Thu, 11 Feb 2021 10:02:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN0UTtZNkQBlnqqp5OnGsDK8p10BvWkzlZ2tFEdDkBy6qjXYmsrhHuKKFc+TNUH1M7uz5+ X-Received: by 2002:a17:906:a2c9:: with SMTP id by9mr9504020ejb.546.1613066563936; Thu, 11 Feb 2021 10:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613066563; cv=none; d=google.com; s=arc-20160816; b=F+KC+e1yt+IQsdsz4xKOONkq14Va8q7DpgD1MAKidNuF3pT11GUeo8+332mbVno5nZ bD+D8hw0pXiKTwoD1Kd3cBjhlp9AinnlWYfdjvIX+D+OLopke8/2qeLiIZX+grrvMshV XAicvXJDMxrY3gjCuD1DtC7HAaW/lBPtxe4ko9/BFMaqDGj3eCazudVpR7MZtQ9GFAgc YHUcZBY8F+Eom093vSFx+BPonpJSBqVSBRwJzHyKk4gYooKdCI0QzpusB3yOwBSifGwa s4w+YL79WosVLHSTTSXMlA0zTK9AKnjgAqjV19Dnqu5u9lpq3xDNU5el5Be1M7lWwLgG 62ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8P4xaiVI2tG5b2Ole1+tnRAqZYtVrf1Whd339/8WB6E=; b=dMF+zJISQXr3cRMpFBghc/mDj21nRjI8wsDC1VB2w5/uugmI0yxaPkfxr3oPOwaRaW hTmkFYkPUtjm99vBjXC0cmzFkv17aLlGhkuPvOfBPJSFV4eiFmdgi3wAWVpQ7Z17s+54 CT+mOICyMzRP7EPMz9vvBDbl0fA6b57BqhPSpM2R9MHXYo/cjc96ROXqNs0p7e+o2LGD AUQubkBrHuo9dBJ/y9q5SiGzU5bO+9ah4tZSxkM4TC7i7H3ZIyNJzxp+mA8tQ/rCgOGj Wu92UvkOZLSqbPMUue/T/c+3hymLTXUgLWixO2gg+FIZ1JWzkuXWjBsIiwcQDXu+DYZH Ze3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Z7604+y3; 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 m28si4528141eda.290.2021.02.11.10.02.20; Thu, 11 Feb 2021 10:02: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=Z7604+y3; 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 S232565AbhBKSAt (ORCPT + 99 others); Thu, 11 Feb 2021 13:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232347AbhBKReR (ORCPT ); Thu, 11 Feb 2021 12:34:17 -0500 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E2CC061786 for ; Thu, 11 Feb 2021 09:33:37 -0800 (PST) Received: by mail-oi1-x22d.google.com with SMTP id r75so6946493oie.11 for ; Thu, 11 Feb 2021 09:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8P4xaiVI2tG5b2Ole1+tnRAqZYtVrf1Whd339/8WB6E=; b=Z7604+y34s6xeuNm8+wCbPBgFd8e3828pzQ7LIQY6cCrUgusKKUU//W1K74Ram4Mjr /GehiA5L2HNaOD/080Z7HsglI2qkhP1tvsfaz3RpwH3oxFStnn2UxYLJIuL9q8YHtjcl Mc9Hboop2KfBy3Zq6GUCuI8+RfXoPxFEYmk1yIUHi9rlq4kqOoQ9yeAh4PgKkT6STNCq sa6lOsfeGvtddTG8xb3BiJiRZ6Hm5Ag+ldsY6HnjtxuYwbdjlu95k3kjedFqrGEc2eq7 oDiukko4tEMupzQluzSZ8C7ea5oHMQQgOVxIdShF+9kC9AUt4xoc0sm6Jc4DG6f1eFaG 5GEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8P4xaiVI2tG5b2Ole1+tnRAqZYtVrf1Whd339/8WB6E=; b=XmYtAhRk5Ds63laAOkEA5fS1sBJUOBoEMvAHpGzp767I5/yU53v0KZ9qCBidqhFLxn QMfSRB30lorRRgrX3NIaoZZJ9XjhBL0uRQh9NUOwcdrE+piQFeileiQIhDO/OcxPIst5 Ey/FgZg/K3I15JbMdGFYZsFm1CNQpV5OLxhKpTcO20XE4JS1yuGs+7oNDG7VwieYwREA 3r2jd+QFzxLOGJYjDavsBR3MuIL33Sy6ZywEI9rwBqN6W4J3XLe1ygmhF5T/Pn7fmCJR 25Ri+2/1OFIm8Xe+88PWaoMbJ27NoEdSs1NoNZbcW3kIES+Yg3kW8FL7tpX75SHASzK0 o51g== X-Gm-Message-State: AOAM5312iqtE/0Eb3ppa+xuPnsmjme6rVi3+urrJ58WC+1VsOm+Dj/Dg 9KiPCxdO2ciGpdtuH4y420+D/FEB24z3zjTB1YFRGg== X-Received: by 2002:aca:3b06:: with SMTP id i6mr3487837oia.81.1613064816828; Thu, 11 Feb 2021 09:33:36 -0800 (PST) MIME-Version: 1.0 References: <20210210230625.550939-1-seanjc@google.com> <20210210230625.550939-10-seanjc@google.com> <756fed52-8151-97ee-11f2-91f150afab42@redhat.com> In-Reply-To: From: Ben Gardon Date: Thu, 11 Feb 2021 09:33:25 -0800 Message-ID: Subject: Re: [PATCH 09/15] KVM: selftests: Move per-VM GPA into perf_test_args To: Sean Christopherson Cc: Paolo Bonzini , kvm , LKML , Yanan Wang , Andrew Jones , Peter Xu , Aaron Lewis Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 11, 2021 at 7:58 AM Sean Christopherson wrote: > > On Thu, Feb 11, 2021, Paolo Bonzini wrote: > > On 11/02/21 02:56, Sean Christopherson wrote: > > > > > + pta->gpa = (vm_get_max_gfn(vm) - guest_num_pages) * pta->guest_page_size; > > > > > + pta->gpa &= ~(pta->host_page_size - 1); > > > > Also not related to this patch, but another case for align. > > > > > > > > > if (backing_src == VM_MEM_SRC_ANONYMOUS_THP || > > > > > backing_src == VM_MEM_SRC_ANONYMOUS_HUGETLB) > > > > > - guest_test_phys_mem &= ~(KVM_UTIL_HUGEPAGE_ALIGNMENT - 1); > > > > > - > > > > > + pta->gpa &= ~(KVM_UTIL_HUGEPAGE_ALIGNMENT - 1); > > > > also align > > > > > > > > > #ifdef __s390x__ > > > > > /* Align to 1M (segment size) */ > > > > > - guest_test_phys_mem &= ~((1 << 20) - 1); > > > > > + pta->gpa &= ~((1 << 20) - 1); > > > > And here again (oof) > > > > > > Yep, I'll fix all these and the align() comment in v2. > > > > This is not exactly align in fact; it is x & ~y rather than (x + y) & ~y. > > Are you going to introduce a round-down macro or is it a bug? (I am > > lazy...). > > Good question. I, too, was lazy. I didn't look at the guts of align() when I > moved it, and I didn't look closely at Ben's suggestion. I'll take a closer > look today and make sure everything is doing what it's supposed to do. Ooh, great point Paolo, that helper is indeed rounding up. My comment in patch #2 was totally wrong. I forgot anyone would ever want to round up. :/ My misunderstanding and the above use cases are probably good evidence that it would be helpful to have both align_up and align_down helpers.