[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: Jan Beulich <jbeulich@xxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 6 Sep 2021 17:22:58 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=NAWywoEhPXo8wkSkHOONStkbpBdXvcsyCBc2lneyBb8=; b=JY9L4atVHGv4TcCF0173og2a5Jt4HI92+8mWy+xYjUxC6tp5MH/2COBVn63AVApXqr49LmtG+UBjJMN7npXtIl08eoCLjnQ6CziWiubRy2kG7cIIMtvwsNCFGHm/7noK4v1VDK7Dz45qICgD4yoz07TmrqRJICc1hHz0e4lTTNvBKxqgi1KDvxnGFG8cf2VaprdTDRwlrfVJWtSAUczNBucP9JBbEeKdvxON0gh4XuZX63p/hgZ9fvBj3WAYcGabMMDx6jifPoRnGkC//uODfk4gMmdJCRgHy3GJwVQGG8Pb0RAS61tM1Y5lJS1P2txSZtiKgReLjEjmBCIQkFRpBA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KOO1SQlkNfM4CFHZATNIChtWTYk0nmSUW/JPaop/kFLLa3t8LA03ZmrL06/alYXUrmgoiOZlPgValUNeyagmNkDnLrzAd4pcxEerdJ7NGyj2oK6FrLBVUkiG9/4pIJJu3z+YZIar57IvP0009aBjOf7e+OqHOctWTW8hbSVhNnhzjTfHp1szmO3Yw7KkU1zkQOjWvCKghGcgElGfL3/EvhAYTaFwpML0KgDvtZUjUaUecQnGFvr5CD8sIsXNVqU4rYK2NblAKKr5nkcS94G3PC8dRvacbGSxJJ672c1GWBcxxDOJq8/FznaG+hgJ8X7UnMzfqcvEKVYVOQXIjQKtZg==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.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: Mon, 06 Sep 2021 16:23:18 +0000
  • Ironport-hdrordr: A9a23:zXrAXKx/Q+h0wKGZ1WfOKrPxu+skLtp133Aq2lEZdPULSKOlfp GV8MjziyWYtN9wYhAdcdDpAtjkfZquz+8L3WB3B8bfYOCGghrUEGgG1+XfKlLbalXDH4JmpM Bdmu1FeafN5DtB/LbHCWuDYq8dKbC8mcjC74eurAYfcegpUdAF0+4QMHfrLqQcfnghOXNWLu v/2iMKnUvaRZxBBf7LeEXtEtKz6+HjpdbDW1orFhQn4A6BgXeB76P7KQGR2lM7XylUybkv3G DZm0ihj5/T/c2T+1v57Sv+/p5WkNzuxp9qA9GNsNEcLnHJhhyzbIpsdrWetHQeof2p6nwtjN 7Qyi1QcPhb2jf0RCWYsBHt0w7v3HIH7GLj80aRhT/ZrcnwVFsBeoF8rLMcViGcx1srvdl63q 4O9XmerYBrARTJmzm4z8TUVjlx/3DE4kYKoKo2tThyQIEeYLheocg050VOCqoNGyr89cQODP RuNsfB//xbGGnqL0wxhlMfheBEY05DWitvGiM5y4uoOnlt7TFEJnIjtY4idixqzuN6d3FGj9 60epiA2os+F/P/wMpGdZA8qPCMexnwqCT3QSuvyGTcZdM60k322urKCZUOlauXkc8zvdYPcK qoaiIviYd1QTO3NfGz
  • Ironport-sdr: aITdVDxBJwvPSCi6ug98L7fiFhUqZAEmE49LuZRb8tAR+VQHXlYJYu6vDfuMmiDcdZxk7S2VWY 1l6zwaYvqJlHhUOb/8BX9AaRxvZHvSdlZWAyXaNGnTLP/59iSbaB6oQR04NbQJUkMX+g58peyN jIPD8T9zJLxCAjtgSqEPLKuK4lDj+wjb7e2DWVl0MrjATjWYMlXxT102P/DqGcPyNuk60xSGXJ TVGNBm73WHkwzeNY1KkrNreOGkmLc3BZ13QK2AaOhxoGQw/Tho1qzul7gpxLVllFtSZwL47sCm 2ZuJWT1uuiWLInjdkfKuYXjY
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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]

~Andrew

[1] For the non-english speakers,
https://en.wikipedia.org/wiki/Teaching_grandmother_to_suck_eggs




 


Rackspace

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