netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@163.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.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 18:08:35 +0800	[thread overview]
Message-ID: <5538C4A3.6080302@163.com> (raw)
In-Reply-To: <5538BB61.30907@163.com>

On 04/23/2015 05:29 PM, Jia-Ju Bai wrote:
> Thank you!
>
> On 04/23/2015 05:19 PM, Sergei Shtylyov wrote:
>> Hello.
>>
>> On 4/23/2015 9:45 AM, Jia-Ju Bai wrote:
>>
>>> Dear Sir,
>>
>>> 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?
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?


Best wishes,
Jia-Ju Bai

  reply	other threads:[~2015-04-23 10:09 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 [this message]
2015-04-23 10:37       ` Sergei Shtylyov
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=5538C4A3.6080302@163.com \
    --to=baijiaju1990@163.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=sergei.shtylyov@cogentembedded.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 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).