linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: linux-wireless@vger.kernel.org, Felix Fietkau <nbd@nbd.name>
Subject: Re: [RFC 11/12] mt76usb: allocate urb and sg as linear data
Date: Tue, 12 Mar 2019 17:34:32 +0100	[thread overview]
Message-ID: <20190312163431.GF2611@localhost.localdomain> (raw)
In-Reply-To: <1552403166-3821-12-git-send-email-sgruszka@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

> Alloc sg table at the end of urb structure. This will increase
> cache usage.
> 

I am curious, have you observed any performance improvement doing so?

> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/usb.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> index 0b9f0b5fd37d..dd487f65f44e 100644
> --- a/drivers/net/wireless/mediatek/mt76/usb.c
> +++ b/drivers/net/wireless/mediatek/mt76/usb.c
> @@ -336,19 +336,19 @@ static bool mt76u_check_sg(struct mt76_dev *dev)
>  static int
>  mt76u_urb_alloc(struct mt76_dev *dev, struct mt76_queue_entry *e)
>  {
> -	struct urb *urb;
> +	unsigned int size = sizeof(struct urb);
> +
> +	if (dev->usb.sg_en)
> +		size += MT_SG_MAX_SIZE * sizeof(struct scatterlist);
>  
> -	urb = usb_alloc_urb(0, GFP_KERNEL);
> -	if (!urb)
> +	e->urb = kzalloc(size, GFP_KERNEL);
> +	if (!e->urb)
>  		return -ENOMEM;
> -	e->urb = urb;
>  
> -	if (dev->usb.sg_en) {
> -		urb->sg = devm_kcalloc(dev->dev, MT_SG_MAX_SIZE,
> -				       sizeof(urb->sg), GFP_KERNEL);
> -		if (!urb->sg)
> -			return -ENOMEM;
> -	}
> +	usb_init_urb(e->urb);
> +
> +	if (dev->usb.sg_en)
> +		e->urb->sg = (struct scatterlist *)((u8 *)e->urb + sizeof(struct urb));

You can avoid u8 cast doing:
(struct scatterlist *)(e->urb + 1)

Regards,
Lorenzo

>  
>  	return 0;
>  }
> -- 
> 1.9.3
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2019-03-12 16:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-12 15:05 [RFC 00/12] mt76usb: some cleanups and optimizations Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 01/12] mt76usb: change mt76u_submit_buf Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 02/12] mt76: remove rx_page_lock Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 03/12] mt76usb: change mt76u_fill_rx_sg arguments Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 04/12] mt76usb: use usb_dev private data Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 05/12] mt76usb: remove mt76u_buf redundant fileds Stanislaw Gruszka
2019-03-12 16:25   ` Lorenzo Bianconi
2019-03-13 12:53     ` Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 06/12] mt76usb: move mt76u_buf->done to queue entry Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 07/12] mt76usb: remove mt76u_buf and use urb directly Stanislaw Gruszka
2019-03-12 16:27   ` Lorenzo Bianconi
2019-03-13 12:53     ` Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 08/12] mt76usb: remove MT_RXQ_MAIN queue from mt76u_urb_alloc Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 09/12] mt76usb: resue mt76u_urb_alloc for tx Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 10/12] mt76usb: remove unneded sg_init_table Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 11/12] mt76usb: allocate urb and sg as linear data Stanislaw Gruszka
2019-03-12 16:34   ` Lorenzo Bianconi [this message]
2019-03-13 12:59     ` Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 12/12] mt76usb: remove queue variable from rx_tasklet Stanislaw Gruszka

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=20190312163431.GF2611@localhost.localdomain \
    --to=lorenzo.bianconi@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=sgruszka@redhat.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).