All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Jia-Ju Bai <baijiaju1990@163.com>
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
	stephen@networkplumber.org, Neil Horman <nhorman@tuxdriver.com>
Subject: Re: Resource usages in Linux drivers
Date: Thu, 23 Apr 2015 13:37:04 +0300	[thread overview]
Message-ID: <5538CB50.3010601@cogentembedded.com> (raw)
In-Reply-To: <5538C4A3.6080302@163.com>

On 4/23/2015 1:08 PM, Jia-Ju Bai wrote:

>>>> I am very sorry to trouble you.

>>>> I find that resource management is error-prone when writing Linux drivers,
>>>> and
>>>> many problems may occur, such as resource leaks.
>>>> Meanwhile, I find that many applied patches in the kernel mailing list focus
>>>> on releasing allocated resources, especially in error-handling paths.

>>>> Therefore, I have a question: is it possible to automatically release
>>>> allocated resources in drivers before unloading and in error-handling paths?

>>>    Yes, there's managed device API, look for functions starting with devm_.
>>> There's one limitation though: it can be used only in the driver's probe()
>>> method, so can't be used when e.g. network device is being opened.

>> I think many APIs, such as kmalloc, can also be managed like garbage
>> collection in Java.
>> Maybe the performance is a matter.

>>>> I am looking forward to your reply, thanks!

>>>    Such questions should actually be asked on the mailing lists, not
>>> personally.

>> I am sorry for that, and I will cc to the mailing lists and other maintainers.

> I find that some common APIs are not managed, such as napi_enable and
> napi_start_queue. Is it possible to provide managed APIs for them?

    No, they're only called from ndo_open() method IIRC. The device managed 
APIs can only be called at the device probing time.

> I also find many drivers do not use these managed APIs, especially in ethernet
> card drivers (like e100, r8169). Is it possible to change them?

    Patches welcome. :-)

> Best wishes,
> Jia-Ju Bai

WBR, Sergei

  reply	other threads:[~2015-04-23 10:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5538950F.3040405@163.com>
     [not found] ` <5538B938.9060607@cogentembedded.com>
2015-04-23  9:29   ` Resource usages in Linux drivers Jia-Ju Bai
2015-04-23 10:08     ` Jia-Ju Bai
2015-04-23 10:37       ` Sergei Shtylyov [this message]
2015-04-23 23:19         ` Francois Romieu
2015-04-24  0:40           ` Florian Fainelli
2015-04-24  0:49             ` David Miller

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=5538CB50.3010601@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=baijiaju1990@163.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.