[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 01/11] xen: Implement xen/alternative-call.h for use in common code


  • To: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 6 Sep 2021 17:52:10 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=L7UKcM4S9tKAzyGGYNFS3Wo9PSeC76IYZoeIv6naCYk=; b=jkg7Kywyvh3UFDR37yqIl2Z/sJVA21A9MSr4GIA7cmvuhFAV0UHen3NjKkr9ZCy4isqyfyCh9P7EVP5ew7eWfbkEnnykkfpUIpKyp5HuTrjsCSn20uuGQDfZz1DfeE6REZ+3/Gx1el437aaTwoOPf8snj7vmf4dxns6xflKNphUDuxL1MRsuHjrEY4pPFmP6RwylFY8WDQrp2e/AjIRXKePaby6SF2UwV1mjacCLPL1KpFGkyEuMUQDcPQ9u4+e5izcjcS9ouZDeVTF5eNa7utuvBEht3/TKVFnD//Z+/562JmvD75sbnUX1krWdq46upc6YofmGf2nVdiZgRAFoQA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eqCdVsoSwNMZymkJeu6shrlDE7askClulZsXxw6Dr03LBi9DhUNYfy1fWuopynjT20WVdRvju2qHrvvI5zwY7H9sNQamNBQRCD1u8UXPaihz9ymBvoMM/iMLzbgEHIxg+QxJt6D2RAnYGmW2iZ/KXe8a0mSpIMOmd9nPz0G0/zM5iwgTFgqG6l32K6u9Ar63MNYCeELtS9gQAxYhoXZxn15Fm6IZ3kruE6u2+i38Mzs1RrbWOGryS6dtuRZKLRoy7W+6ySZ9Aly4bSG3COP2xoWdgF4A9HNFmXP7I5rZgzNvEazHIEi+UVMRjIkz5A76EwROn+OLfnLB5rYADNLZfw==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 06 Sep 2021 15:52:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 <asm/alternative.h>
> +
> +#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?

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.