All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin@oracle.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	riel@redhat.com, hannes@cmpxchg.org, peterz@infradead.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm: initialize variable for mem_cgroup_end_page_stat
Date: Thu, 30 Oct 2014 09:32:14 -0400	[thread overview]
Message-ID: <54523DDE.9000904@oracle.com> (raw)
In-Reply-To: <20141030082712.GB4664@dhcp22.suse.cz>

On 10/30/2014 04:27 AM, Michal Hocko wrote:
> On Wed 29-10-14 21:44:24, Sasha Levin wrote:
>> > Commit "mm: memcontrol: fix missed end-writeback page accounting" has changed
>> > the behaviour of mem_cgroup_begin_page_stat() to not always set the "locked"
>> > parameter.
>> > 
>> > We should initialize it at the callers to prevent garbage being used in a
>> > later call to mem_cgroup_end_page_stat().
> The contract is that if the returned memcg is non-NULL then the locked
> is always initialized. Nobody but mem_cgroup_end_page_stat should touch
> this variable and this function makes sure it uses it properly. Similar
> applies to flags which is initialized only if we really take the slow
> path (has a meaning only if locked == true).
> 
> So this is not really needed. Was this triggered by a compiler warning?

The problem is that you are attempting to read 'locked' when you call
mem_cgroup_end_page_stat(), so it gets used even before you enter the
function - and using uninitialized variables is undefined.

Yes, it's a compiler warning.


Thanks,
Sasha

--
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: Sasha Levin <sasha.levin@oracle.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	riel@redhat.com, hannes@cmpxchg.org, peterz@infradead.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm: initialize variable for mem_cgroup_end_page_stat
Date: Thu, 30 Oct 2014 09:32:14 -0400	[thread overview]
Message-ID: <54523DDE.9000904@oracle.com> (raw)
In-Reply-To: <20141030082712.GB4664@dhcp22.suse.cz>

On 10/30/2014 04:27 AM, Michal Hocko wrote:
> On Wed 29-10-14 21:44:24, Sasha Levin wrote:
>> > Commit "mm: memcontrol: fix missed end-writeback page accounting" has changed
>> > the behaviour of mem_cgroup_begin_page_stat() to not always set the "locked"
>> > parameter.
>> > 
>> > We should initialize it at the callers to prevent garbage being used in a
>> > later call to mem_cgroup_end_page_stat().
> The contract is that if the returned memcg is non-NULL then the locked
> is always initialized. Nobody but mem_cgroup_end_page_stat should touch
> this variable and this function makes sure it uses it properly. Similar
> applies to flags which is initialized only if we really take the slow
> path (has a meaning only if locked == true).
> 
> So this is not really needed. Was this triggered by a compiler warning?

The problem is that you are attempting to read 'locked' when you call
mem_cgroup_end_page_stat(), so it gets used even before you enter the
function - and using uninitialized variables is undefined.

Yes, it's a compiler warning.


Thanks,
Sasha


  reply	other threads:[~2014-10-30 13:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-30  1:44 [PATCH] mm: initialize variable for mem_cgroup_end_page_stat Sasha Levin
2014-10-30  1:44 ` Sasha Levin
2014-10-30  8:27 ` Michal Hocko
2014-10-30  8:27   ` Michal Hocko
2014-10-30 13:32   ` Sasha Levin [this message]
2014-10-30 13:32     ` Sasha Levin
2014-10-30 14:14     ` Johannes Weiner
2014-10-30 14:14       ` Johannes Weiner
2014-10-30 14:24       ` Sasha Levin
2014-10-30 14:24         ` Sasha Levin
2014-10-30 15:06         ` Johannes Weiner
2014-10-30 15:06           ` Johannes Weiner
2014-10-30 16:02           ` Sasha Levin
2014-10-30 16:02             ` Sasha Levin
2014-10-30 15:31         ` Michal Hocko
2014-10-30 15:31           ` Michal Hocko
2014-10-30 17:26           ` Johannes Weiner
2014-10-30 17:26             ` Johannes Weiner
2014-10-30 17:42             ` Michal Hocko
2014-10-30 17:42               ` Michal Hocko
2014-10-30 19:30               ` Peter Zijlstra
2014-10-30 19:30                 ` Peter Zijlstra
2014-10-31 18:17               ` Johannes Weiner
2014-10-31 18:17                 ` Johannes Weiner

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=54523DDE.9000904@oracle.com \
    --to=sasha.levin@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.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.