netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: Helge Deller <deller@gmx.de>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	linux-parisc@vger.kernel.org,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	John David Anglin <dave.anglin@bell.net>
Cc: Tom Herbert <therbert@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: CONFIG_XPS depends on L1_CACHE_BYTES being greater than sizeof(struct xps_map)
Date: Fri, 23 Oct 2015 15:00:37 -0700	[thread overview]
Message-ID: <562AAE05.5020300@gmail.com> (raw)
In-Reply-To: <20151023210810.GA1969@ls3530.box>

On 10/23/2015 02:08 PM, Helge Deller wrote:
> * Eric Dumazet <eric.dumazet@gmail.com>:
>> On Fri, 2015-10-23 at 21:25 +0200, Helge Deller wrote:
>>
>>> Then, how about simply changing it to twice of L1_CACHE_BYTES ?
>>>
>>> #define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES * 2 - sizeof(struct xps_map)) / sizeof(u16))
>>
>>
>> Seems good to me.
>
> Great!
>
> Can you then maybe give me an Acked-by or signed-off for the patch below?
> It further adds a compile-time check to avoid that XPS_MIN_MAP_ALLOC
> gets calculated to zero on any architecture - otherwise no queues would
> be allocated.
>
> In addition I would like to push it for v4.3 then through my parisc-tree
> (after keeping it in for-next for 1-2 days), together with the patch
> which reduces L1_CACHE_BYTES to 16 on parisc.
> Would that be OK too?
>
> Thanks!
> Helge
>
>
> [PATCH] net/xps: Increase initial number of xps queues
>
> Increase the number of initial allocated xps queues, so that the initial record
> allocates twice the size of L1_CACHE_BYTES bytes.
>
> This change is needed to copy with architectures where L1_CACHE_BYTES is
> defined to equal or less than 16 bytes.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 2d15e38..d152788 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -718,7 +718,7 @@ struct xps_map {
>   	u16 queues[0];
>   };
>   #define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + ((_num) * sizeof(u16)))
> -#define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map))	\
> +#define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES * 2 - sizeof(struct xps_map)) \
>       / sizeof(u16))
>
>   /*
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 6bb6470..f6d6dd1 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1972,6 +1972,8 @@ static struct xps_map *expand_xps_map(struct xps_map *map,
>   	int alloc_len = XPS_MIN_MAP_ALLOC;
>   	int i, pos;
>
> +	BUILD_BUG_ON(XPS_MIN_MAP_ALLOC == 0);
> +
>   	for (pos = 0; map && pos < map->len; pos++) {
>   		if (map->queues[pos] != index)
>   			continue;
>
>

Rather then leaving a potential bug you could probably rewrite the macro 
so that it will give you at least 1.

All you need to do is something like the following
#define XPS_MIN_MAP_ALLOC \
	((L1_CACHE_ALIGN(offsetof(struct xps_map, queue[1])) - \
	  sizeof(struct xps_map)) / sizeof(u16))

That should give you at least an XPS_MIN_MAP_ALLOC of 1.

- Alex

  parent reply	other threads:[~2015-10-23 22:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <42430464-867C-4E0B-8E95-C6CDB6D8A0B2@bell.net>
     [not found] ` <32A3BF6F-B243-4AD4-9AE9-A5F9DAE0270A@bell.net>
     [not found]   ` <B8E85737-5ECD-4CBE-8730-886B098C5FA4@bell.net>
     [not found]     ` <trinity-eda7d55d-7234-4b29-a15c-955f8ba0c95e-1445513884942@3capp-gmx-bs32>
     [not found]       ` <trinity-8980ad10-b889-45cf-8f37-a33ba9cf99ef-1445514797080@3capp-gmx-bs32>
     [not found]         ` <1445524549.2207.1.camel@HansenPartnership.com>
     [not found]           ` <5628F868.3040105@bell.net>
2015-10-22 20:00             ` CONFIG_XPS depends on L1_CACHE_BYTES being greater than sizeof(struct xps_map) Helge Deller
2015-10-22 21:37               ` Tom Herbert
2015-10-23 19:21                 ` Helge Deller
2015-10-23 22:16                   ` Tom Herbert
2015-10-22 21:50               ` Eric Dumazet
2015-10-23 19:25                 ` Helge Deller
2015-10-23 20:03                   ` Eric Dumazet
2015-10-23 21:08                     ` Helge Deller
2015-10-23 21:09                       ` Helge Deller
2015-10-23 21:38                       ` Eric Dumazet
2015-10-23 22:00                       ` Alexander Duyck [this message]
2015-10-23 22:17                         ` Helge Deller
2015-10-23 22:40                           ` Alexander Duyck
2015-10-24 14:43                             ` Helge Deller
2015-10-25  5:41                               ` Alexander Duyck

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=562AAE05.5020300@gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dave.anglin@bell.net \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-parisc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=therbert@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).