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=-19.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 E5FCFC433F5 for ; Tue, 7 Sep 2021 13:09:58 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 9B01E61052 for ; Tue, 7 Sep 2021 13:09:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B01E61052 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=apertussolutions.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.181027.327980 (Exim 4.92) (envelope-from ) id 1mNarD-00060a-6O; Tue, 07 Sep 2021 13:09:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 181027.327980; Tue, 07 Sep 2021 13:09:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNarD-00060T-3J; Tue, 07 Sep 2021 13:09:47 +0000 Received: by outflank-mailman (input) for mailman id 181027; Tue, 07 Sep 2021 13:09:46 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNarC-00060N-41 for xen-devel@lists.xenproject.org; Tue, 07 Sep 2021 13:09:46 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6c39c5b0-5c72-4792-bbfc-2b90ee5247fc; Tue, 07 Sep 2021 13:09:44 +0000 (UTC) Received: from [10.10.1.146] (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631020175056268.27192467139764; Tue, 7 Sep 2021 06:09:35 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6c39c5b0-5c72-4792-bbfc-2b90ee5247fc ARC-Seal: i=1; a=rsa-sha256; t=1631020180; cv=none; d=zohomail.com; s=zohoarc; b=Bpqq9silydKZDS3unZW4woy8Lpxr6mBVys9wZHwLDmGkSFBvcuz26I72Qa5w45tC2IbZ676RjubXimUoLx+0k9RS6xpUySVwtIKJwfklno6c+4AVRBEs38tKlS+Aj3ga1PX0JERzJBDyvhQT/ye1KjeIksyipXXARdYmYmo1kp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631020180; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=D/hKG9aSJpSBbbyNnfJLMboaDfUK/6nKEu6OPyO+A24=; b=IJklqAFis6wcZh2pny0SbFa7MHqePfvYMUHMa2KxPZF7cQYguPbHcb+gsuviFx7PBg/6dPVxN1eHwQZS2VdPgsRdPQVcoFsGHitXKo9MsnFremxjfqEDUdSJF2NcnnOE5HilbVjDwBf4ktlY71ZrO3IWV1G0aUoFBD8+8xo/prw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631020180; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=D/hKG9aSJpSBbbyNnfJLMboaDfUK/6nKEu6OPyO+A24=; b=kNCDrjwqigiY0hOgCyTNR7okXsPNdvhQ1HLl4oaSyZDed8X7D/1TjQIgKpLyis8P syoixqwlifuPMOaA7SJZ7u59+ZxZFro3ykKzc/JTd9Qi226kSxHGwpLE9wFF+wksekS cPmFSB0CHYUILPVxxOv59D5r6eW37NJ2FlXr1apA= Subject: Re: [PATCH v4 01/11] xen: Implement xen/alternative-call.h for use in common code To: Jan Beulich , Andrew Cooper Cc: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bob Eshleman , Alistair Francis , Connor Davis , George Dunlap , Ian Jackson , Wei Liu , xen-devel@lists.xenproject.org References: <20210903190629.11917-1-dpsmith@apertussolutions.com> <20210903190629.11917-2-dpsmith@apertussolutions.com> <3a91e4ad-50c4-205f-3d90-f23c996b2938@suse.com> <8c3dfbf5-5c98-c923-ca81-28af3d13c4a4@citrix.com> <7e71ce74-dd81-21c3-db78-c37d95d5b239@suse.com> From: "Daniel P. Smith" Message-ID: Date: Tue, 7 Sep 2021 09:07:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <7e71ce74-dd81-21c3-db78-c37d95d5b239@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ZohoMailClient: External On 9/7/21 2:00 AM, Jan Beulich wrote: > On 06.09.2021 18:22, Andrew Cooper wrote: >> On 06/09/2021 16:52, Jan Beulich wrote: >>> On 03.09.2021 21:06, Daniel P. Smith wrote: >>>> --- /dev/null >>>> +++ b/xen/include/xen/alternative-call.h >>>> @@ -0,0 +1,63 @@ >>>> +/* SPDX-License-Identifier: GPL-2.0 */ >>>> +#ifndef XEN_ALTERNATIVE_CALL >>>> +#define XEN_ALTERNATIVE_CALL >>>> + >>>> +/* >>>> + * Some subsystems in Xen may have multiple implementions, which can be >>>> + * resolved to a single implementation at boot time. By default, this will >>>> + * result in the use of function pointers. >>>> + * >>>> + * Some architectures may have mechanisms for dynamically modifying .text. >>>> + * Using this mechnaism, function pointers can be converted to direct calls >>>> + * which are typically more efficient at runtime. >>>> + * >>>> + * For architectures to support: >>>> + * >>>> + * - Implement alternative_{,v}call() in asm/alternative.h. Code generation >>>> + * requirements are to emit a function pointer call at build time, and stash >>>> + * enough metadata to simplify the call at boot once the implementation has >>>> + * been resolved. >>>> + * - Select ALTERNATIVE_CALL in Kconfig. >>>> + * >>>> + * To use: >>>> + * >>>> + * Consider the following simplified example. >>>> + * >>>> + * 1) struct foo_ops __alt_call_maybe_initdata ops; >>>> + * >>>> + * 2) const struct foo_ops __initconst foo_a_ops = { ... }; >>>> + * const struct foo_ops __initconst foo_b_ops = { ... }; >>>> + * >>>> + * void foo_init(void) >>>> + * { >>>> + * ... >>>> + * if ( use_impl_a ) >>>> + * ops = *foo_a_ops; >>>> + * else if ( use_impl_b ) >>>> + * ops = *foo_b_ops; >>>> + * ... >>>> + * } >>>> + * >>>> + * 3) alternative_call(ops.bar, ...); >>>> + * >>>> + * There needs to a single ops object (1) which will eventually contain the >>>> + * function pointers. This should be populated in foo's init() function (2) >>>> + * by one of the available implementations. To call functions, use >>>> + * alternative_{,v}call() referencing the main ops object (3). >>>> + */ >>>> + >>>> +#ifdef CONFIG_ALTERNATIVE_CALL >>>> + >>>> +#include >>>> + >>>> +#define __alt_call_maybe_initdata __initdata >>> My v3 comment here was: >>> >>> "I think it wants (needs) clarifying that this may only be used if >>> the ops object is used exclusively in alternative_{,v}call() >>> instances (besides the original assignments to it, of course)." >>> >>> I realize this was slightly too strict, as other uses from .init.* >>> are of course also okay, but I continue to think that - in >>> particular with the example using it - there should be a warning >>> about this possible pitfall. Or am I merely unable to spot the >>> wording change somewhere in the comment? >> >> Such a comment is utterly pointless.  initdata has a well known meaning, >> and a comment warning about the effects of it is just teaching >> developers to suck eggs[1] > > Well, okay then - at least the definition of __alt_call_maybe_initdata > isn't far away from the comment. (What I'm not convinced of is that > people knowing __initdata's meaning necessarily need to correctly > infer __alt_call_maybe_initdata's.) > > Two other observations about the comment though, which I'd like to be > taken care of (perhaps while committing): > > - __initconst wants to become __initconstrel. > - foo_init(), seeing that there are section annotations elsewhere, > wants to be marked __init. > > Then > Acked-by: Jan Beulich > > Daniel, you having made changes (even if just minor ones) imo requires > you S-o-b on the patch alongside Andrew's. Ack, I realized after sending I didn't SoB it, my apologies on that. v/r, dps