This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


RE: [Xen-devel][Pv-ops][PATCH 0/3 v3] Netback multiple threads support

>>> "Xu, Dongxiao" <dongxiao.xu@xxxxxxxxx> 04.05.10 13:36 >>>
>Jan Beulich wrote:
>>>>> "Xu, Dongxiao" <dongxiao.xu@xxxxxxxxx> 04.05.10 03:52 >>>
>>> 1. Merge "group" and "idx" into "netif->mapping", therefore
>>> page_ext is not used now.
>> Open coding this seems very fragile (and even more using literal
>> constants in those code fragments).
>> I'm also not convinced restricting either part to 16 bits is a good
>> thing (particularly on 64-bits, where you could easily have each part
>> use 32 bits).
>Do you have any suggestion on how to embed the data into

Here is how I implemented this in our version of those patches:

/* extra field used in struct page */
union page_ext {
        struct {
#if BITS_PER_LONG < 64
#define MAX_GROUPS ((1U << GROUP_WIDTH) - 1)
                unsigned int grp:GROUP_WIDTH;
                unsigned int idx:CONFIG_XEN_NETDEV_TX_SHIFT;
                unsigned int grp, idx;
        } e;
        void *mapping;

static inline void netif_set_page_ext(struct page *pg, unsigned int group,
                                      unsigned int idx)
        union page_ext ext = { .e = { .grp = group + 1, .idx = idx } };

        BUILD_BUG_ON(sizeof(ext) > sizeof(ext.mapping));
        pg->mapping = ext.mapping;

static inline unsigned int netif_page_group(const struct page *pg)
        union page_ext ext = { .mapping = pg->mapping };

        return ext.e.grp - 1;

static inline unsigned int netif_page_index(const struct page *pg)
        union page_ext ext = { .mapping = pg->mapping };

        return ext.e.idx;

CONFIG_XEN_NETDEV_TX_SHIFT is something an earlier patch of
ours introduces (range limited to 5...16; certainly pv-ops could
benefit from having such too), so you will need to replace this
with a literal constant 8 for the time being.


Xen-devel mailing list

<Prev in Thread] Current Thread [Next in Thread>