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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8BD0C433F5 for ; Mon, 9 May 2022 22:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231944AbiEIWvQ (ORCPT ); Mon, 9 May 2022 18:51:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231911AbiEIWvO (ORCPT ); Mon, 9 May 2022 18:51:14 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D35762C4F42 for ; Mon, 9 May 2022 15:47:18 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id gj17-20020a17090b109100b001d8b390f77bso572054pjb.1 for ; Mon, 09 May 2022 15:47:18 -0700 (PDT) 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=HqfHpv0KlKI7R/yNkzZ4Z0O6e/LDYyZQrPZnAWmT71E=; b=gBcOu1AAKpSXofktmoX+I7Bsue1fm8qXDW5SAW2z78o+w1vB0SSgx4IklNVsM6AAzZ rRanfgSmN+B+INR8d1D8AkH0tSIFfSoPJ6A1yAUns87zIIglHwwo2m30NPBXwdX6TkWW SEK+nrP1tpdnPeU3iaz+GJi7tRkKbBkzOi5H4MwWVtOkVkQ/68e+8sIXf2yl0Iu4H6Hw OTlElUOOi39t2GII8YY4Ffe6Y2H/8k+QiYj5KX2vieq1bsIMVrRUSDXE38zuU0bl3Ntb BAua97uPHpzdm6iAaITSrNyyPFguQ121LRQWWdm6DNlKn8HkFJ2uJNJ4JUyeP1z+xoqX Ts5A== 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=HqfHpv0KlKI7R/yNkzZ4Z0O6e/LDYyZQrPZnAWmT71E=; b=ceRoiSRwAg1ncszRhBiu82pTNVYRq74TlQ9BoHxrlR/jf+hJuo8+jHzhI+1AwhOr/F BfwM36a36xVOZizhh6XxvU3AJ1DTcl7BiwfajwbD7M2RgC+AuKPo9N3wGLxabxf3d2CI o2AOoz5Yak2Tg/xeY2yAQRq4QXTf4v8qBdQRl5HuPClpsKYgPQTg9r9vgJXIJybIriyO j+PumgEtIul5w5S9DdqvbXxaXK4WXBDASCe09fdLkmozKR/HO7P5hLLjbRVxAnxM8JVK Y3l7x83V949mUT/j4lrG9O1FkueSD4GwJXyQybanefSTM8wCEJ9P2B5rbgYXhyRe5F0J ZC8w== X-Gm-Message-State: AOAM533hLcDJdfQuAn8jzCK6qQ1bjgnA5mSixf23R+h8icr4Jx35GHAP UA6YAD1FYE1tXGalbhL3woXY/g== X-Google-Smtp-Source: ABdhPJzlAs+WsB2F0OyBXHzmXsCE5yKPzcqLqI7jJtlr5bkfm/U8b2uxGA/nhaBtBW85p0tqZlWDJg== X-Received: by 2002:a17:902:c2c7:b0:159:9f9:85f3 with SMTP id c7-20020a170902c2c700b0015909f985f3mr18070842pla.18.1652136437989; Mon, 09 May 2022 15:47:17 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id 3-20020a17090a018300b001cb978f906esm259814pjc.0.2022.05.09.15.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 15:47:17 -0700 (PDT) Date: Mon, 9 May 2022 22:47:14 +0000 From: Sean Christopherson To: David Matlack Cc: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Ben Gardon , Peter Xu , "Maciej S. Szmigiero" , "moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)" , "open list:KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)" , "open list:KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)" , "open list:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv)" , Peter Feiner Subject: Re: [PATCH v4 20/20] KVM: x86/mmu: Extend Eager Page Splitting to nested MMUs Message-ID: References: <20220422210546.458943-1-dmatlack@google.com> <20220422210546.458943-21-dmatlack@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Mon, May 09, 2022, David Matlack wrote: > On Mon, May 9, 2022 at 9:48 AM Sean Christopherson wrote: > > > +static void kvm_nested_mmu_try_split_huge_pages(struct kvm *kvm, > > > + const struct kvm_memory_slot *slot, > > > + gfn_t start, gfn_t end, > > > + int target_level) > > > +{ > > > + int level; > > > + > > > + /* > > > + * Split huge pages starting with KVM_MAX_HUGEPAGE_LEVEL and working > > > + * down to the target level. This ensures pages are recursively split > > > + * all the way to the target level. There's no need to split pages > > > + * already at the target level. > > > + */ > > > + for (level = KVM_MAX_HUGEPAGE_LEVEL; level > target_level; level--) { > > > > Unnecessary braces. > > The brace is unnecessary, but when the inner statement is split across > multiple lines I tend to prefer using braces. (That's why I did the > same in the other patch and you had the same feedback.) I couldn't > find any guidance about this in CodingStyle so I'm fine with getting > rid of the braces if that's what you prefer. The style varies by subsystem, e.g. I believe perf requires braces in this case. Absent a "hard" rule, I value consistency above all else, e.g. because KVM doesn't (usually) include the braces, I started looking for the second statement, i.e. the lack of an opening brace is an indicator (to me at elast) that a loop/if contains a single statement. I actually like Golang's forced braces, but mostly because they are 100% mandatory and so all code is consistent. > > > + slot_handle_level_range(kvm, slot, > > > + nested_mmu_try_split_huge_pages, > > > + level, level, start, end - 1, > > > + true, false); > > > > IMO it's worth running over by 4 chars to drop 2 lines: > > Will do. > > > > > for (level = KVM_MAX_HUGEPAGE_LEVEL; level > target_level; level--) > > slot_handle_level_range(kvm, slot, nested_mmu_try_split_huge_pages, > > level, level, start, end - 1, true, false); > > > + } > > > +} > > > + > > > /* Must be called with the mmu_lock held in write-mode. */ > > > > Add a lockdep assertion, not a comment. > > Agreed but this is an existing comment, so better left to a separate patch. Doh, I mistook the /* for a +.