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=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 DAEF5C48BE6 for ; Wed, 16 Jun 2021 19:00:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5C0D613B4 for ; Wed, 16 Jun 2021 19:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232201AbhFPTCX (ORCPT ); Wed, 16 Jun 2021 15:02:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52438 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbhFPTCP (ORCPT ); Wed, 16 Jun 2021 15:02:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623870008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+UP7OXvbFZ/sTV1fkRUmNAJIdvluY4AVuWJDrajb3uU=; b=DHyd9ccSyl1rnKzunoFQjraBg958cVgV31ECVle7Jcu9FS4lNCwvChxHX+dAk4uwScJlo6 mDFyqHN8S3QjDBQmbkZIbyu8+axkORSanBEKXeuUEolLW8FUgChwNGPVd2wyYYyghLuikU tgzHoppufX/gxYoAxRKNPxVXELP+Dv0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-GHAxmnqiNgifXzBvmXSZBg-1; Wed, 16 Jun 2021 15:00:01 -0400 X-MC-Unique: GHAxmnqiNgifXzBvmXSZBg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BE07100CA8B; Wed, 16 Jun 2021 18:59:59 +0000 (UTC) Received: from starship (unknown [10.40.194.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4477560CC9; Wed, 16 Jun 2021 18:59:51 +0000 (UTC) Message-ID: <1a6d4cc2152eebb5a0656e3718fc96645ee2e785.camel@redhat.com> Subject: Re: [PATCH] KVM: x86: fix 32 bit build From: Maxim Levitsky To: Sean Christopherson Cc: kvm@vger.kernel.org, Joerg Roedel , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Vitaly Kuznetsov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Jim Mattson , Wanpeng Li , Paolo Bonzini Date: Wed, 16 Jun 2021 21:59:50 +0300 In-Reply-To: References: <20210616155032.1117176-1-mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2021-06-16 at 15:59 +0000, Sean Christopherson wrote: > On Wed, Jun 16, 2021, Maxim Levitsky wrote: > > Now that kvm->stat.nx_lpage_splits is 64 bit, use DIV_ROUND_UP_ULL > > when doing division. > > I went the "cast to an unsigned long" route. I prefer the cast approach because > to_zap is also an unsigned long, i.e. using DIV_ROUND_UP_ULL() could look like a > truncation bug. In practice, nx_lpage_splits can't be more than an unsigned long > so it's largely a moot point, I just like the more explicit "this is doing > something odd". > > https://lkml.kernel.org/r/20210615162905.2132937-1-seanjc@google.com > > > Fixes: 7ee093d4f3f5 ("KVM: switch per-VM stats to u64") > > Signed-off-by: Maxim Levitsky > > --- > > arch/x86/kvm/mmu/mmu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > index 720ceb0a1f5c..97372225f183 100644 > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -6054,7 +6054,7 @@ static void kvm_recover_nx_lpages(struct kvm *kvm) > > write_lock(&kvm->mmu_lock); > > > > ratio = READ_ONCE(nx_huge_pages_recovery_ratio); > > - to_zap = ratio ? DIV_ROUND_UP(kvm->stat.nx_lpage_splits, ratio) : 0; > > + to_zap = ratio ? DIV_ROUND_UP_ULL(kvm->stat.nx_lpage_splits, ratio) : 0; > > for ( ; to_zap; --to_zap) { > > if (list_empty(&kvm->arch.lpage_disallowed_mmu_pages)) > > break; > > -- > > 2.26.3 > > Cool, makes sense. I didn't notice your patch (I did look at the list but since the subject didn't mention the build breakage I didn't notice). I just wanted to send this patch to avoid someone else spending time figuring it out. Thanks, Best regards, Maxim Levitsky