mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Brenden Blanco <bblanco@plumgrid.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Vladimir Davydov <vdavydov@virtuozzo.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>
Subject: Re: uprobes: memory leak in enable/disable loop
Date: Tue, 16 Aug 2016 16:37:10 +0200	[thread overview]
Message-ID: <20160816143710.GG17417@dhcp22.suse.cz> (raw)
In-Reply-To: <20160816142511.GB17006@redhat.com>

On Tue 16-08-16 16:25:12, Oleg Nesterov wrote:
> On 08/16, Oleg Nesterov wrote:
> >
> > On 08/15, Brenden Blanco wrote:
> > >
> > > Hi folks,
> > >
> > > I think I have come across a memory leak in uprobes, which is fairly easy to
> > > reproduce.
> >
> > At first glance this looks as a problem in memcg, add CC's...
> >
> > put_page(old_page) looks properly balanced, and I assume we do not need
> > the additional "uncharge", we can rely on __page_cache_release().
> >
> > And I do not see any leak if I try to reproduce with CONFIG_MEMCG=n.
> 
> Heh. it seems that mem_cgroup_*() logic was always wrong in __replace_page().

Yes this seems broken since 00501b531c47 ("mm: memcontrol: rewrite
charge API")

> Could you try the patch below?

The patch looks good to me. Thanks!

> Oleg.
> ---
> 
> --- x/kernel/events/uprobes.c
> +++ x/kernel/events/uprobes.c
> @@ -200,7 +200,8 @@ static int __replace_page(struct vm_area
>  
>  	err = 0;
>   unlock:
> -	mem_cgroup_cancel_charge(kpage, memcg, false);
> + 	if (err)
> +		mem_cgroup_cancel_charge(kpage, memcg, false);
>  	mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
>  	unlock_page(page);
>  	return err;

-- 
Michal Hocko
SUSE Labs

      parent reply	other threads:[~2016-08-16 14:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-15 20:58 Brenden Blanco
2016-08-16 14:13 ` Oleg Nesterov
2016-08-16 14:25   ` Oleg Nesterov
2016-08-16 14:34     ` Oleg Nesterov
2016-08-16 16:55       ` Brenden Blanco
2016-08-17 15:36         ` [PATCH 0/2] " Oleg Nesterov
2016-08-17 15:36           ` [PATCH 1/2] uprobes: fix the memcg accounting Oleg Nesterov
2016-08-18  8:07             ` [tip:perf/urgent] uprobes: Fix " tip-bot for Oleg Nesterov
2016-08-17 15:37           ` [PATCH 2/2] uprobes: rename the "struct page *" args of __replace_page() Oleg Nesterov
2016-08-18 10:49             ` [tip:perf/core] uprobes: Rename " tip-bot for Oleg Nesterov
2016-08-16 17:36       ` uprobes: memory leak in enable/disable loop Johannes Weiner
2016-08-16 14:37     ` Michal Hocko [this message]

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=20160816143710.GG17417@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bblanco@plumgrid.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vdavydov@virtuozzo.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

all inboxes | Powered by JetHome®