netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Oeser <netdev@axxeo.de>
To: Valentine Barshak <vbarshak@ru.mvista.com>
Cc: netdev@vger.kernel.org, Oliver Neukum <oliver@neukum.org>,
	linux-usb-devel@lists.sourceforge.net
Subject: Re: [PATCH] USB: net: Fix asix read transfer buffer allocations.
Date: Tue, 23 Oct 2007 19:00:14 +0200	[thread overview]
Message-ID: <200710231900.14696.netdev@axxeo.de> (raw)
In-Reply-To: <471CF893.3050605@ru.mvista.com>

Valentine Barshak schrieb:
> Oliver Neukum wrote:
> > Am Montag 22 Oktober 2007 schrieb Valentine Barshak:
> >>  static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
> >>  {
> >>         struct usbnet *dev = netdev_priv(netdev);
> >> +       void *buf;
> >>         u16 res;
> >>  
> >>         mutex_lock(&dev->phy_mutex);
> >>         asix_set_sw_mii(dev);
> >> +
> >> +       buf = kmalloc(2, GFP_KERNEL);
> > 
> > This is done under lock. Can you allocate the buffer once and reuse it?
> I think we can use 2 bytes of the usbnet data buffer for this.
> I'll submit a new patch soon.

If this cannot be done for some reason, then you can at least kmalloc() before
you do "mutex_lock(&dev->phy_mutex);" and kfree() after you did 
"mutex_unlock(&dev->phy_mutex);"

The reason to can do this, is that "buf" has a life time limited to this function.

The reason you should do this, is that kmalloc(, GFP_KERNEL) is allowed to sleep,
which will block the mutex for that time. While this is technically ok, 
since mutexes can sleep, it is not desireable, since other users of that mutex
are blocked until the allocation is done.

If you are able to implement the "2 bytes of  usbnet data buffer" version,
please ignore that mail :-)


Best Regards

Ingo Oeser

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

  reply	other threads:[~2007-10-23 17:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-22 15:50 [PATCH] USB: net: Fix asix read transfer buffer allocations Valentine Barshak
2007-10-22 17:29 ` Oliver Neukum
2007-10-22 19:22   ` Valentine Barshak
2007-10-23 17:00     ` Ingo Oeser [this message]
2007-10-23 17:20       ` Valentine Barshak
2007-10-23 17:40         ` Valentine Barshak
2007-10-23 20:00           ` David Brownell
2007-10-24 11:24             ` Valentine Barshak
2007-10-24 11:33               ` Valentine Barshak
2007-10-24 11:33             ` Valentine Barshak
2007-10-24 11:59               ` David Hollis

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=200710231900.14696.netdev@axxeo.de \
    --to=netdev@axxeo.de \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=netdev@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=vbarshak@ru.mvista.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).