All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>,
	"Daniel P. Smith" <dpsmith@apertussolutions.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org, "Wei Liu" <wl@xen.org>
Subject: Re: [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code
Date: Tue, 13 Jul 2021 09:36:58 +0100	[thread overview]
Message-ID: <a95650ec-1bd0-d36d-8a76-43c315fb620e@citrix.com> (raw)
In-Reply-To: <4a55dc14-5d02-2594-38e8-f732ead164a6@suse.com>

On 13/07/2021 07:28, Jan Beulich wrote:
> On 13.07.2021 01:48, Andrew Cooper wrote:
>> On 12/07/2021 21:32, Daniel P. Smith wrote:
>>> diff --git a/xen/include/xen/alternative-call.h b/xen/include/xen/alternative-call.h
>>> new file mode 100644
>>> index 0000000000..11d1c26068
>>> --- /dev/null
>>> +++ b/xen/include/xen/alternative-call.h
>>> @@ -0,0 +1,65 @@
>>> +/* 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) struct foo_ops __alt_call_maybe_initconst foo_a_ops = { ... };
>>> + *     struct foo_ops __alt_call_maybe_initconst foo_b_ops = { ... };
>> It occurs to me after reviewing patch 2 that these want to be const
>> struct foo_ops __initconst ...,
> __initconstrel then, I suppose.
>
>> and there is no need for
>> __alt_call_maybe_initconst at all.
>>
>> The only thing wanting a conditional annotation like this is the single
>> ops object, and it needs to be initdata (or hopefully ro_after_init in
>> the future).
> ro_after_init and initdata can't be alternatives of one another; ops
> (until be gain ro_after_init) need to remain in .bss (or .data).

Once alternatives have run, the ops structure is no longer referenced by
anything at runtime, and can be reclaimed.

All the x86 examples are weird because we've either got extra data
fields which are referenced at runtime, or we've not accelerated all
function pointers.

In neither case does modifying an accelerated function pointer after the
fact do what the programmer expected, and conditionally initdata makes
this far more obvious.

~Andrew



  reply	other threads:[~2021-07-13  8:37 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 20:32 [PATCH v2 00/10] xsm: refactoring xsm hooks Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code Daniel P. Smith
2021-07-12 23:48   ` Andrew Cooper
2021-07-13  6:28     ` Jan Beulich
2021-07-13  8:36       ` Andrew Cooper [this message]
2021-07-13  8:53         ` Jan Beulich
2021-07-14 15:35   ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 02/10] xsm: refactor xsm_ops handling Daniel P. Smith
2021-07-12 23:39   ` Andrew Cooper
2021-07-14 15:54     ` Jan Beulich
2021-07-15 17:16     ` Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 03/10] xsm: remove the ability to disable flask Daniel P. Smith
2021-07-12 23:22   ` Andrew Cooper
2021-07-15 17:17     ` Daniel P. Smith
2021-07-14 15:58   ` Jan Beulich
2021-07-15 17:19     ` Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 04/10] xsm: convert xsm_ops hook calls to alternative call Daniel P. Smith
2021-07-12 23:44   ` Andrew Cooper
2021-07-15 17:20     ` Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 05/10] xsm: decouple xsm header inclusion selection Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 06/10] xsm: enable xsm to always be included Daniel P. Smith
2021-07-19 10:24   ` Jan Beulich
2021-07-25 20:47     ` Daniel P. Smith
2021-08-03  7:08       ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 07/10] xsm: drop generic event channel labeling Daniel P. Smith
2021-07-12 23:52   ` Andrew Cooper
2021-07-15 17:26     ` Daniel P. Smith
2021-07-16  7:03   ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions Daniel P. Smith
2021-07-16  7:23   ` Jan Beulich
2021-07-16 14:15     ` Andrew Cooper
2021-07-16 14:55       ` Jan Beulich
2021-07-16  7:37   ` Jan Beulich
2021-07-27 13:39   ` Ian Jackson
2021-08-06 21:41     ` Daniel P. Smith
2021-08-10  8:39       ` Jan Beulich
2021-08-26  9:42       ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 09/10] xsm: expand the function related macros in dummy.h Daniel P. Smith
2021-07-16  7:34   ` Jan Beulich
2021-07-24 20:07     ` Daniel P. Smith
2021-07-24 20:43       ` Daniel P. Smith
2021-08-03  7:23       ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 10/10] xsm: removing the XSM_ASSERT_ACTION macro Daniel P. Smith
2021-07-12 23:12 ` [PATCH v2 00/10] xsm: refactoring xsm hooks Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a95650ec-1bd0-d36d-8a76-43c315fb620e@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=dpsmith@apertussolutions.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.