Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp676455rdg; Thu, 10 Aug 2023 16:12:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2sRsGrJtwK/2zF5dU6eWP92yAh495OSIDqy5xiFIEvprl/W5ldSlgRzVa6ziZhOoEe1sR X-Received: by 2002:a17:906:738a:b0:993:da87:1c81 with SMTP id f10-20020a170906738a00b00993da871c81mr394441ejl.20.1691709156976; Thu, 10 Aug 2023 16:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691709156; cv=none; d=google.com; s=arc-20160816; b=mmIfH6wExAI+E6IWoOyHakw39CTRjoPEPK0yKX6ol+1Uf70R0ga9/YoIN2NaGJS0jh PXxJyVPeQu+J+gDQdUwHtvNWN0adGYsZlmHR7Fgt4mwI+pP0O8exuFn2blrycGGLuge1 xy1jIdRtHLuj1/z1UKqSPQQvU1bqL2bQyhMSmdi+PcgVYL7Shiz4tXjwDc1MAiv1FkJr 7XgPUdXMKtDLrRvk1+UDIuTIL+nbN1bqCFpb3rMNDgDIB8BNef4w0FV77V949dOnY3iy Q7bxtj5x+/lt6GhhymM/mKp9ptHc1o7h68nTKOn4Lf9Of2ZZlWkyBh5xsn7xa/aEmHaQ gLjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iczog4wlh1DjFLdMSzEvmMOPilWHUZVQiRjWpcVknB4=; fh=Fpx2H6dLF2wE6p6H0vbyemSEZSYW8Z7wF8ZRVj+ZCTE=; b=bwrzaYUqtxRRRzrrf2EokfXKR0oXY6Jmt1XqmmtZx3INZPeutuyfkZo4Y2o1tZERY2 fAL+febRWx6eSGsuqbsJpXAer1WhJAVmkPva6dOLUW2mYpidLV580GrFBwIkwOc5yJAc tqbEnlJw6y01icNCo04GfMOCGVxk+e7MB0aDvc4amnytFvKqrL400ylqeOKsUez2KBGB qMF5npncMEOrQ7yPLoPWq+OJuw53Irlg4PCRx+ydm8c+R8a7wG3YSfudFEr7maZibdp+ x7Al2jaQwqKxao3lQfBOJXj3HD+VxtfSa80jSi7PrrauT5G2HU7RL1Awu51ktLolDJNp fVzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=epAa0LKn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a170906080200b00992b6af11f0si2518251ejd.362.2023.08.10.16.12.12; Thu, 10 Aug 2023 16:12:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=epAa0LKn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232288AbjHJWeP (ORCPT + 99 others); Thu, 10 Aug 2023 18:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbjHJWeO (ORCPT ); Thu, 10 Aug 2023 18:34:14 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABE42273D for ; Thu, 10 Aug 2023 15:34:12 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-4036bd4fff1so57591cf.0 for ; Thu, 10 Aug 2023 15:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691706851; x=1692311651; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iczog4wlh1DjFLdMSzEvmMOPilWHUZVQiRjWpcVknB4=; b=epAa0LKnKl5u66Y9RbFdhV8Lv5Y/bmCosxzVw0hc7/eKhboiaA24S7kWFOsvT3d/6v R5IFwTcqvp9Hl6i35RRRje6JKgkiqfcZXUhHwrDZqwjImCaIXKPw6fnTz3qawFl9qWaN y1BRsMkYdM/Vkm71K//EAIh0oMZ2T+tki5MWNLYHdhoMwDETGGk0C72DSKPpcNtdVI/n 6LbzVP/Y6nqhT0KZCcZ0oV8L7F4BxrgoCsvYOMX2D/8fZYXweyhURULxqXDrb/hulRuS zA+fdeTbAiZsAJP20VaE+kk7PO04ERwsCiYM4LqdhVp0INromfUBIr5ctl+cNBTnxFca OXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691706851; x=1692311651; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iczog4wlh1DjFLdMSzEvmMOPilWHUZVQiRjWpcVknB4=; b=LgOVpHffW7H3fXgKPpKXMPbgpnJ2/VJGQpUxjNGQzIj3NcIoEbDyGdyZ7VkQIVP9mp djWUIjkD5gZb1m7Mf1yaWoVQ0yFHzawF5jmrc6oRFKz5Be12+xiGAtF5GZ+xXPLSS8QS 5/C4nFzOZjLvHkr35mz0/CDHckDqNCapsBxFjS8s8mMj5y92uF5BbcNrriWYkiQ+DQ/h hryWAM2Zk9meT86oHsAbWETHWN3PxDQdsXJ2xYjYOjusiC8dpCIRT1eiJ1o0pEyP1y/o n7z3eBcbL9u6uP8Z3gfW5Vk30ZPSCWasIAKJjDjJ01Ou4ZAJoRGdGJuJUWjUYfIi4g+y XOtA== X-Gm-Message-State: AOJu0Yx12OxBEQjRVn/07XZrJzgPNm08Kv+sFjJP+00XdhQDNxAuxSP3 RdxaUnbw5mJQN0qPbM71D7qm88a8BMML24SL0pexow== X-Received: by 2002:ac8:7d55:0:b0:3ef:3361:75d5 with SMTP id h21-20020ac87d55000000b003ef336175d5mr45398qtb.11.1691706851560; Thu, 10 Aug 2023 15:34:11 -0700 (PDT) MIME-Version: 1.0 References: <20230808231330.3855936-1-rananta@google.com> <20230808231330.3855936-3-rananta@google.com> <30e45ef3-309a-63de-e085-be1645c1be79@redhat.com> In-Reply-To: From: Raghavendra Rao Ananta Date: Thu, 10 Aug 2023 15:34:00 -0700 Message-ID: Subject: Re: [PATCH v8 02/14] KVM: Declare kvm_arch_flush_remote_tlbs() globally To: Sean Christopherson Cc: Shaoqin Huang , Gavin Shan , Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose , Paolo Bonzini , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Reiji Watanabe , Colton Lewis , David Matlack , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Thu, Aug 10, 2023 at 3:20=E2=80=AFPM Sean Christopherson wrote: > > On Thu, Aug 10, 2023, Raghavendra Rao Ananta wrote: > > On Thu, Aug 10, 2023 at 5:26=E2=80=AFAM Shaoqin Huang wrote: > > > On 8/10/23 00:38, Raghavendra Rao Ananta wrote: > > > >>> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > > >>> index e3f968b38ae97..ade5d4500c2ce 100644 > > > >>> --- a/include/linux/kvm_host.h > > > >>> +++ b/include/linux/kvm_host.h > > > >>> @@ -1484,6 +1484,8 @@ static inline int kvm_arch_flush_remote_tlb= s(struct kvm *kvm) > > > >>> { > > > >>> return -ENOTSUPP; > > > >>> } > > > >>> +#else > > > >>> +int kvm_arch_flush_remote_tlbs(struct kvm *kvm); > > > >>> #endif > > > >>> > > > >>> #ifdef __KVM_HAVE_ARCH_NONCOHERENT_DMA > > > >> > > > >> Is the declaration inconsistent to that in arch/x86/include/asm/kv= m_host.h? > > > >> In order to keep them consistent, I guess we need move kvm_arch_fl= ush_remote_tlbs() > > > >> from x86's header file to arch/x86/kvm/mmu/mmu.c and 'inline' need= s to be dropped. > > > >> > > > > Unsure of the original intentions, I didn't want to disturb any > > > > existing arrangements. If more people agree to this refactoring, I'= m > > > > happy to move. > > > > > > This is amazing to me. This change can be compiled without any error > > > even if the declaration inconsistent between the kvm_host.h and x86's > > > header file. > > > > > > I'm curious which option make it possible? > > > > > After doing some experiments, I think it works because of the order in > > which the inline-definition and the declaration are laid out. If the > > 'inline' part of the function comes first and then the declaration, we > > don't see any error. However if the positions were reversed, we would > > see an error. (I'm not sure what the technical reason for this is). > > > > Just to be safe, I can move the definition to arch/x86/kvm/mmu/mmu.c > > as a non-inline function. > > No need, asm/kvm_host.h _must_ be included before the declaration, otherw= ise the > declaration wouldn't be made because __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS wo= uldn't > be defined. I.e. we won't run into issues where the non-static declarati= on comes > before the static inline definition. > > C99 explicitly covers this case: > > 6.2.2 Linkages of identifiers > > ... > > If the declaration of a file scope identifier for an object or a functi= on contains the storage- > class specifier static, the identifier has internal linkage. > > For an identifier declared with the storage-class specifier extern in a= scope in which a > prior declaration of that identifier is visible if the prior declaratio= n specifies internal or > external linkage, the linkage of the identifier at the later declaratio= n is the same as the > linkage specified at the prior declaration. If no prior declaration is = visible, or if the prior > declaration specifies no linkage, then the identifier has external link= age. > > In short, because the "static inline" declared internal linkage first, it= wins. Thanks for sharing this! I can keep the 'static inline' definition as is then. However, since a later patch (patch-05/14) defines kvm_arch_flush_remote_tlbs_range() in arch/x86/kvm/mmu/mmu.c, do you think we can move this definition to the .c file as well for consistency? Thank you. Raghavendra Raghavendra