Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp956509pxb; Wed, 3 Mar 2021 22:27:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwH78WEfdgIR+jg92FlqZ0Gp9lbTCmN0cPdZDB91JOiVvLwC9QpoApRMUnh10M4TALw2+K0 X-Received: by 2002:a17:907:119b:: with SMTP id uz27mr2525748ejb.464.1614839255350; Wed, 03 Mar 2021 22:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614839255; cv=none; d=google.com; s=arc-20160816; b=wL8XME14ForDs9erXDIkpXbqfmNeUNtaC+PzeseABW7geDRII/7HKz+F7tfCFLX3Iq r3ZAy02UG4kV8X+STFU1IBNc10MqBdkZBFK4njhrHUXefgLnZSdackd104PzSNubVdX8 3jk1ADrYo3FyEghKZjM27gI/Hj29xFigYeehavXlaE3cLwykcLldcZLXHYgAIfrhp26Z 1jjjzGvul3N0wbuL9cF6FRBeLQHOQpgoxOn47zfoXJcx1Uh9ycID3PjuqMym1Q6AnYxX n2O7AsUBKczRnqkbU4Z5ZjXC86gu6+UvERxR6EFV+OudX3/+k27p42fkjcjlKSvwhGzW xo6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ZdRgbB/+xhU+BLrEYW5FodZNgcXrZTzEEyZSROXdiNs=; b=NSAbk2gaEi9kPf8ItETlymfslK+7Yc5Z3WZtWdtsAFIxvOrl464/hChny3tO4xKkOT C+TUjwGvP/8BLYylarZPEu3DZpqBmhx7OZdRl8LEArdSfaAT6nzPEXgqihP0+4TxJBbD G1DENoFWT57a1nuaagmwcXdf/EWygipXLJDJn2Cd5dw1dmok5q4tTVr2NdiIOjAvTfl9 6yWOWYlQfkaXv3FNAU7OPTdxJYsadY5ejsbStdh6jTmG+tpGA6clfW0xbeqfV+2Wp700 JAcKU7CE+eH6kJJFavSumfGZ18smRb7FirEKDUyMPFKbu1FEmgGyLpob03MHHE2j9WEG ur7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AYlTlq4u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si16805229ejk.360.2021.03.03.22.27.10; Wed, 03 Mar 2021 22:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AYlTlq4u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1838984AbhCBPzq (ORCPT + 99 others); Tue, 2 Mar 2021 10:55:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351191AbhCBNfM (ORCPT ); Tue, 2 Mar 2021 08:35:12 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C41C061756 for ; Tue, 2 Mar 2021 05:34:16 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id m1so2762955wml.2 for ; Tue, 02 Mar 2021 05:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ZdRgbB/+xhU+BLrEYW5FodZNgcXrZTzEEyZSROXdiNs=; b=AYlTlq4uW3iRg29N/HN0EX4sWg7+Le02hNVo3M/Yt9O05X/IY8T6751/c1wmEoCY0L biLdWKDhwHXiyra5neWncvah9XDw0cZFZJYMMmR2gsOLFy14QaWJtQ2kIHUgb8mfRkSx /6LKYUXahNk7VB85kjvAsvXfx364A2h5uMQWfrZ6YMhc35f0NceLI5S+fQ1oG2z19JHa O9v7dj6PPis7ILJNbQNLncYb9BLabzUFOYX1exg4oixDpugNo8v9EqICPC1JiRgX2+JI VRU8jezhLwGk8aPjOVf05vtVleyBrItTHD93svBy/b403AaUGdbqIfMBVCDNNC9s8I/Q 3q2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ZdRgbB/+xhU+BLrEYW5FodZNgcXrZTzEEyZSROXdiNs=; b=m49ZWTn+IyWIEDHSoaKrOv1HOkPLhUXAdFZ5Qcxm2AdnDAFKTTVEuBu5EjW1hGmplg s4fvod6bc+xzAkvPgS43c4fEQiefc/KFNsdge45NcLemx1Dw6NZ5L4VvDnsXrsR9QVXQ LP5u9LLIKP3c5u/aKEU1hfBv1d4dLg2bmaEv6z9o2tEbkHIU8t6Tiy6fD2eY2hMu25EO FENcRPe5re+JM/bEYmVg0WcTIjIvWJQoicblzt30oSDWk9UbGhE8TI69VmgmIOwYYx8G rWCbTUe9B4KjxRkVMwhH9LGlqs9bPIbB6vHDypMWoFU8dc7NglHIHT+TF/DlcYXj5MjQ esvA== X-Gm-Message-State: AOAM532Davwt1O8ue4GyXVIfno7eL8aek187KlivX1nDgcPzFlOUEdmL rXUcoo8fuj2u4Cuqm9E5oAo2Ug== X-Received: by 2002:a7b:cb05:: with SMTP id u5mr4092039wmj.46.1614692054679; Tue, 02 Mar 2021 05:34:14 -0800 (PST) Received: from [192.168.0.41] (lns-bzn-59-82-252-144-192.adsl.proxad.net. [82.252.144.192]) by smtp.googlemail.com with ESMTPSA id w18sm2428636wrr.7.2021.03.02.05.34.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Mar 2021 05:34:14 -0800 (PST) Subject: Re: [PATCH v2 08/10] clocksource/drivers/hyper-v: Handle sched_clock differences inline To: Michael Kelley , Stephen Hemminger , KY Srinivasan , "wei.liu@kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" , "arnd@arndb.de" , "linux-hyperv@vger.kernel.org" Cc: "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-arch@vger.kernel.org" References: <1614561332-2523-1-git-send-email-mikelley@microsoft.com> <1614561332-2523-9-git-send-email-mikelley@microsoft.com> <2c320759-4e0e-752f-f3e8-7594cc1d544f@linaro.org> From: Daniel Lezcano Message-ID: <6c0b3487-5f99-764c-6dc7-70454916cd57@linaro.org> Date: Tue, 2 Mar 2021 14:34:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/2021 02:38, Michael Kelley wrote: > From: Daniel Lezcano Sent: Monday, March 1, 2021 6:25 AM >> >> On 01/03/2021 02:15, Michael Kelley wrote: >>> While the Hyper-V Reference TSC code is architecture neutral, the >>> pv_ops.time.sched_clock() function is implemented for x86/x64, but not >>> for ARM64. Current code calls a utility function under arch/x86 (and >>> coming, under arch/arm64) to handle the difference. >>> >>> Change this approach to handle the difference inline based on whether >>> GENERIC_SCHED_CLOCK is present. The new approach removes code under >>> arch/* since the difference is tied more to the specifics of the Linux >>> implementation than to the architecture. >>> >>> No functional change. >>> >>> Signed-off-by: Michael Kelley >>> Reviewed-by: Boqun Feng >>> --- >> >> [ ... ] >> >>> +/* >>> + * Reference to pv_ops must be inline so objtool >>> + * detection of noinstr violations can work correctly. >>> + */ >>> +static __always_inline void hv_setup_sched_clock(void *sched_clock) >>> +{ >>> +#ifdef CONFIG_GENERIC_SCHED_CLOCK >>> + /* >>> + * We're on an architecture with generic sched clock (not x86/x64). >>> + * The Hyper-V sched clock read function returns nanoseconds, not >>> + * the normal 100ns units of the Hyper-V synthetic clock. >>> + */ >>> + sched_clock_register(sched_clock, 64, NSEC_PER_SEC); >>> +#else >>> +#ifdef CONFIG_PARAVIRT >>> + /* We're on x86/x64 *and* using PV ops */ >>> + pv_ops.time.sched_clock = sched_clock; >>> +#endif >>> +#endif >>> +} >> Please refer to: >> >> Documentation/process/coding-style.rst >> >> Section 21) >> >> [ ... ] >> >> Prefer to compile out entire functions, rather than portions of >> functions or portions of expressions. >> >> [ ... ] >> > > OK. I'll rework the #ifdef in v3 of the patch set. Is the following > the preferred approach? Yes but with an indentation and comment to describe the section end. eg. #ifdef A #else # ifdef B ... # else # endif /* B */ #endif /* A */ > #ifdef CONFIG_GENERIC_SCHED_CLOCK > static __always_inline void hv_setup_sched_clock(void *sched_clock) > { > sched_clock_register(sched_clock, 64 NSEC_PER_SEC); > } > #else > #ifdef CONFIG_PARAVIRT > static __always_inline void hv_setup_sched_clock(void *sched_clock) > { > pv_ops.time.sched_clock = sched_clock: > } > #else > static __always_inline void hv_setup_sched_clock(void *sched_clock) {} > #endif > #endif Or #ifdef CONFIG_GENERIC_SCHED_CLOCK ... #elif defined CONFIG_PARAVIRT ... #else /* !CONFIG_GENERIC_SCHED_CLOCK && !CONFIG_PARAVIRT */ ... #endif /* CONFIG_GENERIC_SCHED_CLOCK */ -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog