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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 E09D0C07E99 for ; Fri, 9 Jul 2021 21:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B265E6135F for ; Fri, 9 Jul 2021 21:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbhGIV4W (ORCPT ); Fri, 9 Jul 2021 17:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhGIV4U (ORCPT ); Fri, 9 Jul 2021 17:56:20 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5854C0613DD for ; Fri, 9 Jul 2021 14:53:35 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id p4-20020a17090a9304b029016f3020d867so6818252pjo.3 for ; Fri, 09 Jul 2021 14:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MZOA2XtQ30UKVk79SAgvpwg07B6ibw25WfTMs1wX3wg=; b=IHpJ/O/YNCyIx4/laDpAon1vX+8b5IFxxvglK8qpKhTPOdXtzVfowf6Gn/lj3L8b8G ZLdmYlc2pmGf7R7ikoL3oohwJdn/OZb3wEznR+VIu738fICua1/lPUkE+onuLQ+f2+51 ZfAVPWJwKXhqTB7+T4dvTXU1f1GV+C4573rQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MZOA2XtQ30UKVk79SAgvpwg07B6ibw25WfTMs1wX3wg=; b=OI/Fj3deEEL1ExcGAloWhqmTT1EYD6l/nJZq35s+YLewx5ReJd9UN634GbzIfV0kUt MNBwShCwl2ta0+itGYog1/vuBTy2A3W1zEmvrYwVvamtB+BPBnA/nKtC+sIu95W0PP68 M0m7lusCk+U71f3zAc1DTYU4LPMaUV0mz2i8L5lE5uWvLwOrMqXxR4Fs4QOyYxUnuJXC hOD+mQo/fyELvj3HkRoaS72qZQAa6QFwzNCgB08dJTZsF99JJaYI3/sBI0Lol28m22s9 iSPPWCuLmAWeUs8/A5pd3SLHqolxBfbhMtwdt0SZewF11SOe/liunSbM3y3E/VI/nFda +66g== X-Gm-Message-State: AOAM531yYZKhMI7w/q05gUZHJ/GkUzR0P5tmSoURoDYQ7Ied8OAaLuug yjsHUfJHPZyTz958shPms4ewjw== X-Google-Smtp-Source: ABdhPJwIjvak1eY/U96Fw1Oiw9RnSDu8AcJfIY+8EEtq4BMJ3aC1wMo18+OQIYafwjiNiLBisKi3AQ== X-Received: by 2002:a17:90a:9a1:: with SMTP id 30mr40550193pjo.53.1625867615194; Fri, 09 Jul 2021 14:53:35 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:2538:c0b6:d152:9164]) by smtp.gmail.com with ESMTPSA id d129sm7222990pfd.218.2021.07.09.14.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 14:53:34 -0700 (PDT) Date: Sat, 10 Jul 2021 06:53:29 +0900 From: Sergey Senozhatsky To: Joel Fernandes Cc: Sergey Senozhatsky , Marc Zyngier , Will Deacon , Suleiman Souhlal , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCHv2 2/4] arm64: add guest pvstate support Message-ID: References: <20210709043713.887098-1-senozhatsky@chromium.org> <20210709043713.887098-3-senozhatsky@chromium.org> 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-kernel@vger.kernel.org Hi Joel, On (21/07/09 14:58), Joel Fernandes wrote: [..] > > +struct vcpu_state { > > + bool preempted; > > + u8 reserved[63]; > > +}; > > + > > #ifdef CONFIG_PARAVIRT > > #include > > > > @@ -20,8 +25,22 @@ static inline u64 paravirt_steal_clock(int cpu) > > > > int __init pv_time_init(void); > > > > +bool dummy_vcpu_is_preempted(unsigned int cpu); > > + > > +extern struct static_key pv_vcpu_is_preempted_enabled;. > > pv_vcpu_is_preempted_enabled static_key is not used in any patch. > Maybe it is stale? Oh, it is, thanks. > > +DECLARE_STATIC_CALL(pv_vcpu_is_preempted, dummy_vcpu_is_preempted); > > + > > +static inline bool paravirt_vcpu_is_preempted(unsigned int cpu) > > +{ > > + return static_call(pv_vcpu_is_preempted)(cpu); > > +} > > + > > +int __init pv_vcpu_state_init(void); > > + > > #else > > > > +#define pv_vcpu_state_init() do {} while (0) > > + > > #define pv_time_init() do {} while (0) > > > > #endif // CONFIG_PARAVIRT > > diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c > > index 75fed4460407..d8fc46795d94 100644 > > --- a/arch/arm64/kernel/paravirt.c > > +++ b/arch/arm64/kernel/paravirt.c > > @@ -40,6 +40,11 @@ struct pv_time_stolen_time_region { > > > > static DEFINE_PER_CPU(struct pv_time_stolen_time_region, stolen_time_region); > > > > +static DEFINE_PER_CPU(struct vcpu_state, vcpus_states); > > +struct static_key pv_vcpu_is_preempted_enabled; > > + > > +DEFINE_STATIC_CALL(pv_vcpu_is_preempted, dummy_vcpu_is_preempted); > > Could we use DEFINE_STATIC_CALL_NULL and get rid of the dummy > function? I believe that makes the function trampoline as return > instruction, till it is updated. Is DEFINE_STATIC_CALL_NULL for cases when function returns void? We need something that returns `false` to vcpu_is_preempted() or per_cpu(vcpus_states) once pv vcpu-state is initialised. [..] > > +static bool __vcpu_is_preempted(unsigned int cpu) > > +{ > > + struct vcpu_state *st; > > + > > + st = &per_cpu(vcpus_states, cpu); > > + return READ_ONCE(st->preempted); > > I guess you could just do: > { > return READ_ONCE(per_cpu(vcpus_states, cpu).preempted); > } Ack. 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=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 DC0ECC07E9B for ; Sat, 10 Jul 2021 10:18:43 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 6A6BC613D2 for ; Sat, 10 Jul 2021 10:18:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A6BC613D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0E40A4A523; Sat, 10 Jul 2021 06:18:43 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@chromium.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PZL6XB1q2iwR; Sat, 10 Jul 2021 06:18:41 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BDAD049FA6; Sat, 10 Jul 2021 06:18:40 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2AFFA4A003 for ; Fri, 9 Jul 2021 17:53:38 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2gUXb8x8M7n8 for ; Fri, 9 Jul 2021 17:53:36 -0400 (EDT) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 4328B40856 for ; Fri, 9 Jul 2021 17:53:36 -0400 (EDT) Received: by mail-pj1-f47.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso7814947pjx.1 for ; Fri, 09 Jul 2021 14:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MZOA2XtQ30UKVk79SAgvpwg07B6ibw25WfTMs1wX3wg=; b=IHpJ/O/YNCyIx4/laDpAon1vX+8b5IFxxvglK8qpKhTPOdXtzVfowf6Gn/lj3L8b8G ZLdmYlc2pmGf7R7ikoL3oohwJdn/OZb3wEznR+VIu738fICua1/lPUkE+onuLQ+f2+51 ZfAVPWJwKXhqTB7+T4dvTXU1f1GV+C4573rQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MZOA2XtQ30UKVk79SAgvpwg07B6ibw25WfTMs1wX3wg=; b=c2dRPMBHDbTleSPjY3znS9ymdABY7SVEviiW0wU2l5F1NAH8eL1anXz/wPXztX/bc5 +aUwZo6mA0rL/DkZnTWwppMLkr9id70JB6FOSaYXXTQKsUo+jAqeRg39Cb5dpq3Qj5IE zMs4ZIghuUNzFHkDQgvLDicaq77RXByrbsEI+QI5qPH6ktWqzpkHHh8VLmrMtUoq2kXl ipXH7FnF0lP4rLUypgx2ofmYQ3KGYU9Ea2Y7DFNsfKOrWoLXvU4rvrIzmtQw+CuPILrI bA9kP3QB2r/KZt35PjqOcj+GH6GjmKHPFDzHyACiJUMoOgiShp6KT7da2uGi+C8B5B8v ovUA== X-Gm-Message-State: AOAM532j4ipJ5SLXVQ+Ez3NPBVb61ZKsW1Pm7lbxeIMVZNzD4C6PgRWo gsUjwRI3djYZO+g7oMCL0JqJeA== X-Google-Smtp-Source: ABdhPJwIjvak1eY/U96Fw1Oiw9RnSDu8AcJfIY+8EEtq4BMJ3aC1wMo18+OQIYafwjiNiLBisKi3AQ== X-Received: by 2002:a17:90a:9a1:: with SMTP id 30mr40550193pjo.53.1625867615194; Fri, 09 Jul 2021 14:53:35 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:2538:c0b6:d152:9164]) by smtp.gmail.com with ESMTPSA id d129sm7222990pfd.218.2021.07.09.14.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 14:53:34 -0700 (PDT) Date: Sat, 10 Jul 2021 06:53:29 +0900 From: Sergey Senozhatsky To: Joel Fernandes Subject: Re: [PATCHv2 2/4] arm64: add guest pvstate support Message-ID: References: <20210709043713.887098-1-senozhatsky@chromium.org> <20210709043713.887098-3-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Sat, 10 Jul 2021 06:18:40 -0400 Cc: Marc Zyngier , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Sergey Senozhatsky , Suleiman Souhlal , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Joel, On (21/07/09 14:58), Joel Fernandes wrote: [..] > > +struct vcpu_state { > > + bool preempted; > > + u8 reserved[63]; > > +}; > > + > > #ifdef CONFIG_PARAVIRT > > #include > > > > @@ -20,8 +25,22 @@ static inline u64 paravirt_steal_clock(int cpu) > > > > int __init pv_time_init(void); > > > > +bool dummy_vcpu_is_preempted(unsigned int cpu); > > + > > +extern struct static_key pv_vcpu_is_preempted_enabled;. > > pv_vcpu_is_preempted_enabled static_key is not used in any patch. > Maybe it is stale? Oh, it is, thanks. > > +DECLARE_STATIC_CALL(pv_vcpu_is_preempted, dummy_vcpu_is_preempted); > > + > > +static inline bool paravirt_vcpu_is_preempted(unsigned int cpu) > > +{ > > + return static_call(pv_vcpu_is_preempted)(cpu); > > +} > > + > > +int __init pv_vcpu_state_init(void); > > + > > #else > > > > +#define pv_vcpu_state_init() do {} while (0) > > + > > #define pv_time_init() do {} while (0) > > > > #endif // CONFIG_PARAVIRT > > diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c > > index 75fed4460407..d8fc46795d94 100644 > > --- a/arch/arm64/kernel/paravirt.c > > +++ b/arch/arm64/kernel/paravirt.c > > @@ -40,6 +40,11 @@ struct pv_time_stolen_time_region { > > > > static DEFINE_PER_CPU(struct pv_time_stolen_time_region, stolen_time_region); > > > > +static DEFINE_PER_CPU(struct vcpu_state, vcpus_states); > > +struct static_key pv_vcpu_is_preempted_enabled; > > + > > +DEFINE_STATIC_CALL(pv_vcpu_is_preempted, dummy_vcpu_is_preempted); > > Could we use DEFINE_STATIC_CALL_NULL and get rid of the dummy > function? I believe that makes the function trampoline as return > instruction, till it is updated. Is DEFINE_STATIC_CALL_NULL for cases when function returns void? We need something that returns `false` to vcpu_is_preempted() or per_cpu(vcpus_states) once pv vcpu-state is initialised. [..] > > +static bool __vcpu_is_preempted(unsigned int cpu) > > +{ > > + struct vcpu_state *st; > > + > > + st = &per_cpu(vcpus_states, cpu); > > + return READ_ONCE(st->preempted); > > I guess you could just do: > { > return READ_ONCE(per_cpu(vcpus_states, cpu).preempted); > } Ack. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-9.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 C3D3AC07E9B for ; Fri, 9 Jul 2021 21:55:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 881A3613C2 for ; Fri, 9 Jul 2021 21:55:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 881A3613C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dSmUXaC+JhM9wJv0WfyWuVz8LaWlt/l+RPtE572tV4s=; b=N8nPIOSlZ3ffXK g5MLYQ9KeqFBKUzkyzlIL9LzywsOOTfbtjFSdD/ipJ3U5W4U/I0UBcbxdsihWnAPxgGWyS9pGuXh/ y7SJLuOvIDKXfmKDtFcYd1ogKQQTg2AybfVHrSAeRJE7Wu5N7+4OzozC4u1xxP6laYuxJxf4YDjnh mMA7qIoh/nuC/gWh3Mdrli9mZe38nNSZPN1f5AX/I4VC14bhKal7A2jdB7odLPnFx+SWJWZKRzATN Z32yWQfeGQ5DJT2Wxag20BtRNo4/ZkCqMJAbgPMHzUQTfktx7iCPUrxs2kvjWJiyj2jsynVG1Bv3q CAGf9J6fMepxICL359Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1yRK-002XLz-Tl; Fri, 09 Jul 2021 21:53:43 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1yRH-002XLc-Fh for linux-arm-kernel@lists.infradead.org; Fri, 09 Jul 2021 21:53:40 +0000 Received: by mail-pj1-x102f.google.com with SMTP id oj11-20020a17090b4d8bb029017338c124dcso3994093pjb.0 for ; Fri, 09 Jul 2021 14:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MZOA2XtQ30UKVk79SAgvpwg07B6ibw25WfTMs1wX3wg=; b=IHpJ/O/YNCyIx4/laDpAon1vX+8b5IFxxvglK8qpKhTPOdXtzVfowf6Gn/lj3L8b8G ZLdmYlc2pmGf7R7ikoL3oohwJdn/OZb3wEznR+VIu738fICua1/lPUkE+onuLQ+f2+51 ZfAVPWJwKXhqTB7+T4dvTXU1f1GV+C4573rQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MZOA2XtQ30UKVk79SAgvpwg07B6ibw25WfTMs1wX3wg=; b=aCKyCpEm/PMvXtWi8UD4+XgrIVaNoIZPNQ7FQYMTMVWFpiyj89P0nQSou6vQQq6lYH o2g4e1fHHqiFni+LwqSnfcj55fnuq5bV2gtN9cMFC2YB9/AVrDXRXkTWvcWogx1Cnq8A 8ouUpngx6/RCjXA75Lb4Nd/M8h5w+xjotXizUtMVR+kLhnpw6oecUtZGCy4BIhzQHlNS bB+IJR0cE+7h3rpP+ogKQNhxRgTulAZMq8+VrybINsLRbj4ubSNuX0giq4EHqUo82eFJ +6auuHpXv4m88OUXO2tPctxh0ELCbMYrozxMICmHaQ7MmnTWhTUwjFuXm1ezUNQ9CbAO dwBA== X-Gm-Message-State: AOAM532NW/H0euPYc6SYiFAtGWhDy7QrP4aGAEUpNy+ELyUmFqNHtziA LhZeKRPwOr/6etACSAct4IY43Q== X-Google-Smtp-Source: ABdhPJwIjvak1eY/U96Fw1Oiw9RnSDu8AcJfIY+8EEtq4BMJ3aC1wMo18+OQIYafwjiNiLBisKi3AQ== X-Received: by 2002:a17:90a:9a1:: with SMTP id 30mr40550193pjo.53.1625867615194; Fri, 09 Jul 2021 14:53:35 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:2538:c0b6:d152:9164]) by smtp.gmail.com with ESMTPSA id d129sm7222990pfd.218.2021.07.09.14.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 14:53:34 -0700 (PDT) Date: Sat, 10 Jul 2021 06:53:29 +0900 From: Sergey Senozhatsky To: Joel Fernandes Cc: Sergey Senozhatsky , Marc Zyngier , Will Deacon , Suleiman Souhlal , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCHv2 2/4] arm64: add guest pvstate support Message-ID: References: <20210709043713.887098-1-senozhatsky@chromium.org> <20210709043713.887098-3-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210709_145339_590009_E8DF9BBA X-CRM114-Status: GOOD ( 18.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Joel, On (21/07/09 14:58), Joel Fernandes wrote: [..] > > +struct vcpu_state { > > + bool preempted; > > + u8 reserved[63]; > > +}; > > + > > #ifdef CONFIG_PARAVIRT > > #include > > > > @@ -20,8 +25,22 @@ static inline u64 paravirt_steal_clock(int cpu) > > > > int __init pv_time_init(void); > > > > +bool dummy_vcpu_is_preempted(unsigned int cpu); > > + > > +extern struct static_key pv_vcpu_is_preempted_enabled;. > > pv_vcpu_is_preempted_enabled static_key is not used in any patch. > Maybe it is stale? Oh, it is, thanks. > > +DECLARE_STATIC_CALL(pv_vcpu_is_preempted, dummy_vcpu_is_preempted); > > + > > +static inline bool paravirt_vcpu_is_preempted(unsigned int cpu) > > +{ > > + return static_call(pv_vcpu_is_preempted)(cpu); > > +} > > + > > +int __init pv_vcpu_state_init(void); > > + > > #else > > > > +#define pv_vcpu_state_init() do {} while (0) > > + > > #define pv_time_init() do {} while (0) > > > > #endif // CONFIG_PARAVIRT > > diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c > > index 75fed4460407..d8fc46795d94 100644 > > --- a/arch/arm64/kernel/paravirt.c > > +++ b/arch/arm64/kernel/paravirt.c > > @@ -40,6 +40,11 @@ struct pv_time_stolen_time_region { > > > > static DEFINE_PER_CPU(struct pv_time_stolen_time_region, stolen_time_region); > > > > +static DEFINE_PER_CPU(struct vcpu_state, vcpus_states); > > +struct static_key pv_vcpu_is_preempted_enabled; > > + > > +DEFINE_STATIC_CALL(pv_vcpu_is_preempted, dummy_vcpu_is_preempted); > > Could we use DEFINE_STATIC_CALL_NULL and get rid of the dummy > function? I believe that makes the function trampoline as return > instruction, till it is updated. Is DEFINE_STATIC_CALL_NULL for cases when function returns void? We need something that returns `false` to vcpu_is_preempted() or per_cpu(vcpus_states) once pv vcpu-state is initialised. [..] > > +static bool __vcpu_is_preempted(unsigned int cpu) > > +{ > > + struct vcpu_state *st; > > + > > + st = &per_cpu(vcpus_states, cpu); > > + return READ_ONCE(st->preempted); > > I guess you could just do: > { > return READ_ONCE(per_cpu(vcpus_states, cpu).preempted); > } Ack. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel