Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3423635rdg; Tue, 17 Oct 2023 14:31:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6XBwwvEgEOw5CNL2F8ThU8ZSloRGiUPOci2HjKC3QG1ktehugFwQ96xl5FQV+y1/ohgdS X-Received: by 2002:a17:90a:e613:b0:27d:3439:c141 with SMTP id j19-20020a17090ae61300b0027d3439c141mr3341358pjy.39.1697578307608; Tue, 17 Oct 2023 14:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697578307; cv=none; d=google.com; s=arc-20160816; b=k1yZf2SSH0tIAjfXF9L1vowgzQWghhhUTYoI8DSsavBadM+zA194XJEjbJC1QCYQZW EaOx8+HlEFGcIXrDmXzTtq/qnVtBMffcEr5Rzrs1G+yy1Q23iHtfQzU0ootVcc1DmvoR rxbTUtZSmgj1i9NI7JdY+2fvaVJRRbGDBw6mNRMdcARuzEwlmgBGMBa7U4Bn8Ku3vbr0 +t3TUdkWwWvwi4VM+VWY3jpg1yGTwbdZps3/dOQAKtu8i8eivXJxPuTp3p5bhhNsK+Pm 98p+gcQPOwIelAxupG5x3VyT/Q7iK1wtPKkmkxKxMdSc3txD0dkzajRpGKcuxp5zuYyX xK5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=jZRorWcdg/9qyDjZ9MPkuveSNwHmSlMZCo3YWPFaI50=; fh=Vqb1eM/QUPU0LYxkKF2SqHPocclThJR+sRMLXz8y5Qs=; b=TNJ70I3YrJd+csr2OYnLOw1psUwf7K/+ePolxgHltaN+n0g7QyiUitnkiuwrQzZNiA 8oQ4LtIf3mX23MoZoyXDnXBAzf6wfL/tz3KZtVyGCSQmfLyIoLKhMa4tsRSg003CD0Fw XYM/7hpm3WVX1U9Y7AzBsdcCcEQzIvSKE7pte4eofugypGlyrckJfp2laeZpShzKoyCd zdE+HTyJe14LcwGsQXTuI8YSP1xdHLB1Fo5wnrlKZuCCdKZlNVP2Nim/wdmWq7Sz1UhN 9Bjw+4ZHiyQe2hhDuOp7sFLNVlsJBAmuoypVwuZSRZ2bOju7sGrsE7hAUdg6E60EQTMm pvIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xfkFTfvB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id nl17-20020a17090b385100b00263e299dff6si4677pjb.74.2023.10.17.14.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 14:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xfkFTfvB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2C3078106714; Tue, 17 Oct 2023 14:31:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344196AbjJQVbe (ORCPT + 99 others); Tue, 17 Oct 2023 17:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234861AbjJQVbc (ORCPT ); Tue, 17 Oct 2023 17:31:32 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 555FE11C for ; Tue, 17 Oct 2023 14:31:30 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c9c939cc94so46703375ad.1 for ; Tue, 17 Oct 2023 14:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697578290; x=1698183090; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jZRorWcdg/9qyDjZ9MPkuveSNwHmSlMZCo3YWPFaI50=; b=xfkFTfvBkvvdAY4sLe3kcXtOi7u8THDIvoVF++QsjoHJR3n81XorTj2YQo4k2vOJnZ kbLBYz2AnEQyMG6OIL7e4eqOEGZeoAtNqfUXca0+b0glD7aYAdQyCceScnwtaertjrLu gtuszsX49hY255ui/8LqZf+lb3p914h1Ifyen2//5Aw7gF8KP2OZNVVD61F8v3xrBR8z mmCcJSR/k1BAuVNfdVh8m1P7OxWl2yKZx5ZpkhGrRZoIdhX5cAYKLcfQBUgGlEmCjwVC B/eFn1AAKfVkwTXjQi25DL1cDcb51N1oYWKPAPriGJloMnezoE2KiQoO2CYysZ78s3/K Eaiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697578290; x=1698183090; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jZRorWcdg/9qyDjZ9MPkuveSNwHmSlMZCo3YWPFaI50=; b=Y2lyeWKoLsn6awjVxNzkpuesuZcErkIhXIh9On2z1c8E+vm41Lr8R1Zd+sc7L5RnB1 LMzXtjyitG/WpBlg0SVsF6rUCc+boy9ylLB2tM7xNSs/frw2mE+DW/cC+P8Ipq51IhTz os0sGGzA1EAA/yU1h0cGhSL7J3mGAH4S5lYnEgXbX7QWmhZ5x5euVp59SQEJqYh8sxBF l52nkg5d28ALPsRX+hjrtjjsJDYyNFt661BNl52040xL1BSGnBRL9rG67PXtSTQCtgWE 7qdNz0rAmeNJzfLkp0xlRhbNx+zPNvT9OMzWk07QNVGDkF3B/YkZlFZf+8xDNJL6xjxr N98g== X-Gm-Message-State: AOJu0Yxqn7FcMvVLYRzvLBACtz4PP5ro+dnY2wA3PNOVVEzxrj29VVaM Jady9Au+q1dJ0JeEGE+r7oge+f9wlIU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:706:b0:1c5:7c07:e403 with SMTP id kk6-20020a170903070600b001c57c07e403mr64765plb.10.1697578289626; Tue, 17 Oct 2023 14:31:29 -0700 (PDT) Date: Tue, 17 Oct 2023 14:31:28 -0700 In-Reply-To: <20231017093335.18216-1-likexu@tencent.com> Mime-Version: 1.0 References: <20231017093335.18216-1-likexu@tencent.com> Message-ID: Subject: Re: [PATCH] KVM: x86: Clean up included but non-essential header declarations From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , Maxim Levitsky , Ingo Molnar , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 14:31:46 -0700 (PDT) On Tue, Oct 17, 2023, Like Xu wrote: > From: Like Xu > Removing these declarations as part of KVM code refactoring can also (when > the compiler isn't so smart) reduce compile time, compile warnings, and the Really, warnings? On what W= level? W=1 builds just fine with KVM_WERROR=y. If any of the "supported" warn levels triggers a warn=>error, then we'll fix it. > size of compiled artefacts, and more importantly can help developers better > consider decoupling when adding/refactoring unmerged code, thus relieving > some of the burden on the code review process. Can you provide an example? KVM certainly has its share of potential circular dependency pitfalls, e.g. it's largely why we have the ugly and seemingly arbitrary split between x86.h and asm/kvm_host.h. But outside of legitimate collisions like that, I can't think of a single instance where superfluous existing includes caused problems. On the other hand, I distinctly recall multiple instances where a header didn't include what it used and broke the build when the buggy header was included in a new file. > Specific header declaration is supposed to be retained if it makes more > sense for reviewers to understand. No functional changes intended. > > [*] https://lore.kernel.org/all/YdIfz+LMewetSaEB@gmail.com/ This patch violates one of the talking points of Ingo's work: - "Make headers standalone": over 80 headers don't build standalone and depend on various accidental indirect dependencies they gain through other headers, especially once headers get their unnecessary dependencies removed. So there's over 80 commits changing these headers. I think it's also worth noting that Ingo boosted build times by eliminating includes in common "high use" headers, not by playing whack-a-mole with "private" headers and C files. > [**] https://include-what-you-use.org/ > > Signed-off-by: Like Xu > --- > arch/x86/kvm/cpuid.c | 3 --- > arch/x86/kvm/cpuid.h | 1 - > arch/x86/kvm/emulate.c | 2 -- > arch/x86/kvm/hyperv.c | 3 --- > arch/x86/kvm/i8259.c | 1 - > arch/x86/kvm/ioapic.c | 10 ---------- > arch/x86/kvm/irq.c | 3 --- > arch/x86/kvm/irq.h | 3 --- > arch/x86/kvm/irq_comm.c | 2 -- > arch/x86/kvm/lapic.c | 8 -------- > arch/x86/kvm/mmu.h | 1 - > arch/x86/kvm/mmu/mmu.c | 11 ----------- > arch/x86/kvm/mmu/spte.c | 1 - > arch/x86/kvm/mmu/tdp_iter.h | 1 - > arch/x86/kvm/mmu/tdp_mmu.c | 3 --- > arch/x86/kvm/mmu/tdp_mmu.h | 4 ---- > arch/x86/kvm/smm.c | 1 - > arch/x86/kvm/smm.h | 3 --- > arch/x86/kvm/svm/avic.c | 2 -- > arch/x86/kvm/svm/hyperv.h | 2 -- > arch/x86/kvm/svm/nested.c | 2 -- > arch/x86/kvm/svm/pmu.c | 4 ---- > arch/x86/kvm/svm/sev.c | 7 ------- > arch/x86/kvm/svm/svm.c | 29 ----------------------------- > arch/x86/kvm/svm/svm.h | 3 --- > arch/x86/kvm/vmx/hyperv.c | 4 ---- > arch/x86/kvm/vmx/hyperv.h | 7 ------- > arch/x86/kvm/vmx/nested.c | 2 -- > arch/x86/kvm/vmx/nested.h | 1 - > arch/x86/kvm/vmx/pmu_intel.c | 1 - > arch/x86/kvm/vmx/posted_intr.c | 1 - > arch/x86/kvm/vmx/sgx.h | 5 ----- > arch/x86/kvm/vmx/vmx.c | 11 ----------- > arch/x86/kvm/x86.c | 17 ----------------- > arch/x86/kvm/xen.c | 1 - > virt/kvm/async_pf.c | 2 -- > virt/kvm/binary_stats.c | 1 - > virt/kvm/coalesced_mmio.h | 2 -- > virt/kvm/eventfd.c | 2 -- > virt/kvm/irqchip.c | 1 - > virt/kvm/kvm_main.c | 13 ------------- > virt/kvm/pfncache.c | 1 - > virt/kvm/vfio.c | 2 -- > 43 files changed, 184 deletions(-) NAK, I am not taking a wholesale purge of includes. I have no objection to removing truly unnecessary includes, e.g. there are definitely some includes that are no longer necessary due to code being moved around. But changes like the removal of all includes from tdp_mmu.h and smm.h are completely bogus. If anything, smm.h clearly needs more includes, because it is certainly not including everything it is using. > diff --git a/arch/x86/kvm/mmu/tdp_mmu.h b/arch/x86/kvm/mmu/tdp_mmu.h > index 733a3aef3a96..66afdf3e262a 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.h > +++ b/arch/x86/kvm/mmu/tdp_mmu.h > @@ -3,10 +3,6 @@ > #ifndef __KVM_X86_MMU_TDP_MMU_H > #define __KVM_X86_MMU_TDP_MMU_H > > -#include > - > -#include "spte.h" > - > void kvm_mmu_init_tdp_mmu(struct kvm *kvm); > void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm); ... > diff --git a/arch/x86/kvm/smm.h b/arch/x86/kvm/smm.h > index a1cf2ac5bd78..3e067ce1ea1d 100644 > --- a/arch/x86/kvm/smm.h > +++ b/arch/x86/kvm/smm.h > @@ -2,11 +2,8 @@ > #ifndef ASM_KVM_SMM_H > #define ASM_KVM_SMM_H > > -#include > - > #ifdef CONFIG_KVM_SMM > > - > /* > * 32 bit KVM's emulated SMM layout. Based on Intel P6 layout > * (https://www.sandpile.org/x86/smm.htm).