[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 7 Sep 2021 08:00:02 +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=wdBhc89sJrcmeLMeJkCx0mR3ZXIDHKOAM3UfkYNp9/0=; b=KbkZAH9+YVhOQBmnTvrJSjk+KaLrQZ03RXMP8rwCxnic11rb0VvCx0JNBCISGW/K5Y+35omo8fqPcY3ke9T1arYCwzfuixqa13miilNGqw+s/21s0uQBzEWpgqUTIdB2cmoi4FT/DLzb1KKmYlSYe6KsIu9MoB77D9hBuIVs0gaKLJq6poc3FHLAMcDkQvUE8CmG5zrcbGVAyWVwOdWerqE1KIM/mYpem92zBrrN9Ppo0MBdu6W3Zu2A15frNZySgW1HG/V9/XF2dh836LSlcSB6KDttTi2iVAy6hcr1SXnCzroQ4ldnq//gcbhNsC2cxtAg2khOk+G+QO1xgZEotA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lmsgw4LESNtND2ApvG38Km/fbF2zJCXhgiwJnvUBl5P4TbT4lEzJCD4tMl3j5bySPBXHrJpSDHX49l9MzgGb+MTPX1o4NMfQutgSFllTlH0GoroZVHoQBYD+6CcwDicSCUkrTbmh/hg3AuNgyFfaVfTFKT65/Xg6kRB9U1Q+5VdqgB2CGkj2YPgVr6u4TsfbIVD1ao+TI5z8xBnBn1lPTPHhIdv7PghiQUUFcdtuHMnMGjODr7W6ikDUXjWcW3hHklRF5OxcP91sXJCe9WPYyDDA6NVDDyTPlI1f4aQXje9HpFAf0t0KqoiJVKDASxwa6uVau6Pl9AvvpJwH1eicnA==
  • 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: 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: Tue, 07 Sep 2021 06:00:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 <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?
> 
> 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 <jbeulich@xxxxxxxx>

Daniel, you having made changes (even if just minor ones) imo requires
you S-o-b on the patch alongside Andrew's.

Jan




 


Rackspace

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