Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCCE7C433FE for ; Wed, 1 Dec 2021 02:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346052AbhLACZH (ORCPT ); Tue, 30 Nov 2021 21:25:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345996AbhLACZF (ORCPT ); Tue, 30 Nov 2021 21:25:05 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBAC3C061574 for ; Tue, 30 Nov 2021 18:21:45 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id gb13-20020a17090b060d00b001a674e2c4a8so45629pjb.4 for ; Tue, 30 Nov 2021 18:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gie1EwZxonCzFvugUYBX8WOXYkfnwgMVP4++lOOlv+c=; b=BHHWYuF18555l0y3u6rGa+kEPLUpRnTak219rl+ifA1BegpvG+NBgLb0it0I4y1PBo opX2RyrCSzAxdaDMxLHZgYuQBb3UVPD2vfYENDpOiOvKud4gngvK2ESBdq2wzO7bvYFs Uom+60iWQDBpxbmPU70HUiBcp58Q+IzMSy+kvlJ0vEJ1p8v4tuSDuU8pkpbNTFB618qG GRyKbd/AR+lkFA4jCgEvLeAjD26ZWOnk3TJw1kKRu0Qd77in9KBkimE5/N26zN4jm81l dcBG7UIm2ufF53HRCOZW7kupF9U+VKWo5L41OJTTQxhPRxp8ZLBeqKPhTwxyhB0gaVmZ Kypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gie1EwZxonCzFvugUYBX8WOXYkfnwgMVP4++lOOlv+c=; b=jnI27pFbNT2czGq+QDVOQq3x/eyy4atcLCcVMoDIzEdh0QewsgzM/C5FenTu6utUla P/fKDz7r9r5vXp94wsJ2XMe59d5tcQ6VozZQM3HA+3FlmS7CKOVxK4BsTUI+W+uJcekD 5bnC50i2Hph/OtBNg4HZ85nxY8aXOBrN81t5Wwas4F8Kxk2LXnB+ravoyYzAknXJ9qIP cGcSAf9y/JhHpmkMtxQvG+/Juz2RLEKLGYSfl5v+9ZY7A4HUssghdo8d+rzYJKFJNQU/ uAP1UwnDoWCFh+pVIWodgQtxDWg2hSneVVy2uaeq/3QkLMbTrBvKmLIRHvKU4AmIZ1ai aMTw== X-Gm-Message-State: AOAM532hNwxzwKoyUGn0lXZbypmviLQITd420H7vzkHmwvqv4Lc2xpcG w1hYiD5pvvy9Ea+jHljdTCEO1w== X-Google-Smtp-Source: ABdhPJx7ckMHu0ZBbHoG3wVdN35yNz+jTnr/6AkXoHITLna8yQnOkJAuMipyrJqERvLCPmT0P99eUg== X-Received: by 2002:a17:902:748c:b0:141:c45e:c612 with SMTP id h12-20020a170902748c00b00141c45ec612mr3544713pll.73.1638325305343; Tue, 30 Nov 2021 18:21:45 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j13sm21251711pfc.151.2021.11.30.18.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 18:21:44 -0800 (PST) Date: Wed, 1 Dec 2021 02:21:41 +0000 From: Sean Christopherson To: "Maciej S. Szmigiero" Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Igor Mammedov , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandru Elisei , Atish Patra , Ben Gardon , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 18/29] KVM: x86: Use nr_memslot_pages to avoid traversing the memslots array Message-ID: References: <74663af27fd6e25b7846da343f7013b1e9885a4b.1638304316.git.maciej.szmigiero@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74663af27fd6e25b7846da343f7013b1e9885a4b.1638304316.git.maciej.szmigiero@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 30, 2021, Maciej S. Szmigiero wrote: > From: "Maciej S. Szmigiero" > > There is no point in recalculating from scratch the total number of pages > in all memslots each time a memslot is created or deleted. Use KVM's > cached nr_memslot_pages to compute the default max number of MMU pages. > > Note that even with nr_memslot_pages capped at ULONG_MAX we can't safely > multiply it by KVM_PERMILLE_MMU_PAGES (20) since this operation can > possibly overflow an unsigned long variable. > > Write this "* 20 / 1000" operation as "/ 50" instead to avoid such > overflow. > > Signed-off-by: Maciej S. Szmigiero > [sean: use common KVM field and rework changelog accordingly] > Signed-off-by: Sean Christopherson My SoB can definitely be dropped for this one, just consider it review feedback that happened to have an SoB attached. Reviewed-by: Sean Christopherson