public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Bryan O'Sullivan" <bos@pathscale.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Andrew Morton <akpm@osdl.org>,
	rdreier@cisco.com, torvalds@osdl.org, hch@infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 10 of 20] ipath - support for userspace apps using core driver
Date: Tue, 21 Mar 2006 12:52:27 -0800	[thread overview]
Message-ID: <1142974347.29199.87.camel@serpentine.pathscale.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0603162003140.25033@goblin.wat.veritas.com>

On Thu, 2006-03-16 at 20:10 +0000, Hugh Dickins wrote:

> You wisely remarked earlier that you'd not yet checked for memory leaks:
> that is of course the complementary, less obvious, error to the troubles
> you've been having so far: and I wish you luck when you come to check,
> hoping that I haven't merely misled you from one side to the other!

Well, as it turns out, we're not out of the woods.

The memory that we allocate with dma_alloc_coherent is indeed being
handed back to us as compound pages, but something horrible is happening
after that.

Our nopage handler does an unconditional get_page on every page that it
gets handed, but nothing seems to ever call put_page on those pages.  At
least, I infer this to be the case, because the page counts look all
wrong when I free them.  The kernel thinks I leak 4.5MB of memory every
time I run "hello, world" (~1300 allocations of 4K).

If you recall, we have three different areas of memory that userspace
can mmap.  Two of these (rcvhdrq and pioavailregs) are allocated at
driver init time, and freed when the driver exits.  The third (egrbufs)
is allocated when the process opens the char device, and closed when the
char device's release method is called.

I've instrumented my calls to dma_alloc_coherent and dma_free_coherent,
and they are getting called when they should be.  However, on each
successive run of "hello, world", the page counts on the rcvhdrq and
pioavailregs pages (the ones allocated at driver start) increase,
without ever decreasing.  And for the egrbufs pages, the page counts go
up to 8 (I'm allocating 32K at a time, so get_page is called 8 times per
compound page), but I never get handed the same struct page on two
successive runs, so I conclude that the struct pages are leaking.

So my belief is that I am freeing the memory behind the struct pages,
but the struct pages themselves stay stuck with a permanently elevated
count.  This is obviously not a winning strategy.

On 2.6.15, this all "works", but I have the poor kernel thinking it
loses 4.5MB of memory on every run.  On 2.6.16-rc6, I get a BUG.  I'll
have to do a bit of work to reproduce it, so I can't paste it here yet.

So my quandary is thus: what am I doing wrong?  It seems that my calls
to get_page are more or less correct, but should I be doing a put_page
somewhere, too, such as when the char dev's release method is called,
prior to calling dma_free_coherent?

	<b


  parent reply	other threads:[~2006-03-21 20:52 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <71644dd19420ddb07a75.1141922823@localhost.localdomain>
2006-03-09 23:28 ` [PATCH 10 of 20] ipath - support for userspace apps using core driver Roland Dreier
2006-03-09 23:55   ` Bryan O'Sullivan
2006-03-10  0:01     ` Roland Dreier
2006-03-10  0:07       ` Bryan O'Sullivan
2006-03-10  0:32         ` Roland Dreier
2006-03-10  0:36           ` Bryan O'Sullivan
2006-03-10  0:37         ` Andrew Morton
2006-03-10  0:50           ` Bryan O'Sullivan
2006-03-16  0:56           ` Bryan O'Sullivan
2006-03-16  1:51             ` Roland Dreier
2006-03-16  2:11               ` Bryan O'Sullivan
2006-03-16  2:37                 ` Roland Dreier
2006-03-16  2:52                   ` Bryan O'Sullivan
2006-03-16  2:56                     ` Bryan O'Sullivan
2006-03-16  3:28                     ` Andrew Morton
2006-03-16  4:58                       ` Bryan O'Sullivan
2006-03-16  5:38                         ` Andrew Morton
2006-03-16  5:54                           ` Roland Dreier
2006-03-16  6:17                             ` Andrew Morton
2006-03-16  6:44                               ` Nick Piggin
2006-03-16  9:39                                 ` Andrew Morton
2006-03-16 10:00                                   ` Nick Piggin
2006-03-16  7:25                               ` Roland Dreier
2006-03-16 16:46                                 ` Linus Torvalds
2006-03-16 14:57                               ` Hugh Dickins
2006-03-16  6:31                             ` Nick Piggin
2006-03-16 14:34                               ` Hugh Dickins
2006-03-17  0:37                                 ` Nick Piggin
2006-03-17  1:09                                   ` Roland Dreier
2006-03-17 15:27                                   ` Hugh Dickins
2006-03-17 22:21                                     ` Nick Piggin
2006-03-17 16:11                                   ` Bryan O'Sullivan
2006-03-17 16:28                                     ` Linus Torvalds
2006-03-17 16:40                                       ` Bryan O'Sullivan
2006-03-17 22:28                                         ` Nick Piggin
2006-03-17 22:14                                     ` Nick Piggin
2006-03-16 15:12                             ` Bryan O'Sullivan
2006-03-16 17:08                               ` Linus Torvalds
2006-03-16 17:46                               ` Hugh Dickins
2006-03-16 17:53                                 ` Bryan O'Sullivan
2006-03-16 14:24                           ` Hugh Dickins
2006-03-16 15:33                             ` Bryan O'Sullivan
2006-03-16 17:23                               ` Hugh Dickins
2006-03-16 17:40                                 ` Bryan O'Sullivan
2006-03-16 19:52                                 ` Bryan O'Sullivan
2006-03-16 20:10                                   ` Hugh Dickins
2006-03-16 20:35                                     ` Linus Torvalds
2006-03-16 20:43                                       ` Bryan O'Sullivan
2006-03-21 20:52                                     ` Bryan O'Sullivan [this message]
2006-03-21 23:20                                       ` Hugh Dickins
2006-03-22 15:58                                         ` Bryan O'Sullivan
2006-03-22 16:19                                           ` Linus Torvalds
2006-03-22 16:43                                             ` Bryan O'Sullivan
2006-03-22 17:46                                           ` Hugh Dickins
2006-03-22 17:53                                             ` Bryan O'Sullivan
2006-03-16 23:37                             ` Roland Dreier
2006-03-16 23:51                             ` Remapping pages mapped to userspace (was: [PATCH 10 of 20] ipath - support for userspace apps using core driver) Roland Dreier
2006-03-16 23:56                               ` Bryan O'Sullivan
2006-03-17  1:10                                 ` Remapping pages mapped to userspace Roland Dreier
2006-03-17  1:12                                 ` Roland Dreier
2006-03-17  1:28                                   ` Alan Cox
2006-03-17  2:16                                     ` Roland Dreier
2006-03-17 17:13                               ` Remapping pages mapped to userspace (was: [PATCH 10 of 20] ipath - support for userspace apps using core driver) Hugh Dickins
2006-03-17 17:17                                 ` Bryan O'Sullivan
2006-03-17 17:30                                   ` Linus Torvalds
2006-03-17 18:20                                     ` Hugh Dickins
2006-03-17 22:58                                     ` Remapping pages mapped to userspace Roland Dreier
2006-03-16 15:08                           ` [PATCH 10 of 20] ipath - support for userspace apps using core driver Bryan O'Sullivan
2006-03-16 17:27                             ` Hugh Dickins
2006-03-16 17:44                               ` Bryan O'Sullivan
2006-03-16 16:52                           ` Bryan O'Sullivan
2006-03-16  3:58                     ` Linus Torvalds
2006-03-16  4:53                     ` Roland Dreier
2006-03-16  2:28             ` Linus Torvalds
2006-03-09 23:33 ` Roland Dreier
2006-03-09 23:56   ` Bryan O'Sullivan
2006-03-10  0:35 [PATCH 0 of 20] [RFC] ipath driver - another round for review Bryan O'Sullivan
2006-03-10  0:35 ` [PATCH 10 of 20] ipath - support for userspace apps using core driver Bryan O'Sullivan

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=1142974347.29199.87.camel@serpentine.pathscale.com \
    --to=bos@pathscale.com \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.com \
    --cc=torvalds@osdl.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