All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: yalin wang <yalin.wang2010@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	mgorman@techsingularity.net, mhocko@suse.com,
	David Rientjes <rientjes@google.com>,
	js1304@gmail.com,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	hannes@cmpxchg.org, alexander.h.duyck@redhat.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] mm: fix a BUG, the page is allocated 2 times
Date: Mon, 12 Oct 2015 13:05:14 +0300	[thread overview]
Message-ID: <20151012100514.GA2544@node> (raw)
In-Reply-To: <4D925B19-2187-4892-A99A-E59D575C2147@gmail.com>

On Mon, Oct 12, 2015 at 03:58:51PM +0800, yalin wang wrote:
> 
> > On Oct 12, 2015, at 15:38, Vlastimil Babka <vbabka@suse.cz> wrote:
> > 
> > On 10/12/2015 04:40 AM, yalin wang wrote:
> >> Remove unlikely(order), because we are sure order is not zero if
> >> code reach here, also add if (page == NULL), only allocate page again if
> >> __rmqueue_smallest() failed or alloc_flags & ALLOC_HARDER == 0
> > 
> > The second mentioned change is actually more important as it removes a memory leak! Thanks for catching this. The problem is in patch mm-page_alloc-reserve-pageblocks-for-high-order-atomic-allocations-on-demand.patch and seems to have been due to a change in the last submitted version to make sure the tracepoint is called.
> > 
> >> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
> >> ---
> >>  mm/page_alloc.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >> 
> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >> index 0d6f540..de82e2c 100644
> >> --- a/mm/page_alloc.c
> >> +++ b/mm/page_alloc.c
> >> @@ -2241,13 +2241,13 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
> >>  		spin_lock_irqsave(&zone->lock, flags);
> >> 
> >>  		page = NULL;
> >> -		if (unlikely(order) && (alloc_flags & ALLOC_HARDER)) {
> >> +		if (alloc_flags & ALLOC_HARDER) {
> >>  			page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC);
> >>  			if (page)
> >>  				trace_mm_page_alloc_zone_locked(page, order, migratetype);
> >>  		}
> >> -
> >> -		page = __rmqueue(zone, order, migratetype, gfp_flags);
> >> +		if (page == NULL)
> > 
> > "if (!page)" is more common and already used below.
> > We could skip the check for !page in case we don't go through the ALLOC_HARDER branch, but I guess it's not worth the goto, and hopefully the compiler is smart enough anywaya?|
> agree with your comments,
> do i need send a new patch for this ?

Looks like a two patches to me: memory leak and removing always-true part
of condifition.

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: yalin wang <yalin.wang2010@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	mgorman@techsingularity.net, mhocko@suse.com,
	David Rientjes <rientjes@google.com>,
	js1304@gmail.com,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	hannes@cmpxchg.org, alexander.h.duyck@redhat.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] mm: fix a BUG, the page is allocated 2 times
Date: Mon, 12 Oct 2015 13:05:14 +0300	[thread overview]
Message-ID: <20151012100514.GA2544@node> (raw)
In-Reply-To: <4D925B19-2187-4892-A99A-E59D575C2147@gmail.com>

On Mon, Oct 12, 2015 at 03:58:51PM +0800, yalin wang wrote:
> 
> > On Oct 12, 2015, at 15:38, Vlastimil Babka <vbabka@suse.cz> wrote:
> > 
> > On 10/12/2015 04:40 AM, yalin wang wrote:
> >> Remove unlikely(order), because we are sure order is not zero if
> >> code reach here, also add if (page == NULL), only allocate page again if
> >> __rmqueue_smallest() failed or alloc_flags & ALLOC_HARDER == 0
> > 
> > The second mentioned change is actually more important as it removes a memory leak! Thanks for catching this. The problem is in patch mm-page_alloc-reserve-pageblocks-for-high-order-atomic-allocations-on-demand.patch and seems to have been due to a change in the last submitted version to make sure the tracepoint is called.
> > 
> >> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
> >> ---
> >>  mm/page_alloc.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >> 
> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >> index 0d6f540..de82e2c 100644
> >> --- a/mm/page_alloc.c
> >> +++ b/mm/page_alloc.c
> >> @@ -2241,13 +2241,13 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
> >>  		spin_lock_irqsave(&zone->lock, flags);
> >> 
> >>  		page = NULL;
> >> -		if (unlikely(order) && (alloc_flags & ALLOC_HARDER)) {
> >> +		if (alloc_flags & ALLOC_HARDER) {
> >>  			page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC);
> >>  			if (page)
> >>  				trace_mm_page_alloc_zone_locked(page, order, migratetype);
> >>  		}
> >> -
> >> -		page = __rmqueue(zone, order, migratetype, gfp_flags);
> >> +		if (page == NULL)
> > 
> > "if (!page)" is more common and already used below.
> > We could skip the check for !page in case we don't go through the ALLOC_HARDER branch, but I guess it's not worth the goto, and hopefully the compiler is smart enough anyway…
> agree with your comments,
> do i need send a new patch for this ?

Looks like a two patches to me: memory leak and removing always-true part
of condifition.

-- 
 Kirill A. Shutemov

  reply	other threads:[~2015-10-12 10:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12  2:40 [RFC] mm: fix a BUG, the page is allocated 2 times yalin wang
2015-10-12  2:40 ` yalin wang
2015-10-12  7:38 ` Vlastimil Babka
2015-10-12  7:38   ` Vlastimil Babka
2015-10-12  7:58   ` yalin wang
2015-10-12  7:58     ` yalin wang
2015-10-12 10:05     ` Kirill A. Shutemov [this message]
2015-10-12 10:05       ` Kirill A. Shutemov
2015-10-12 11:22       ` Vlastimil Babka
2015-10-12 11:22         ` Vlastimil Babka
2015-10-12 13:52 ` Mel Gorman
2015-10-12 13:52   ` Mel Gorman
2015-10-13  1:43   ` yalin wang
2015-10-13  1:43     ` yalin wang

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=20151012100514.GA2544@node \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.h.duyck@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=js1304@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    --cc=yalin.wang2010@gmail.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 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.