From: Michal Hocko <mhocko@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Rik van Riel <riel@redhat.com>,
stable@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [patch] mm, writeback: prevent race when calculating dirty limits
Date: Fri, 18 Jul 2014 08:54:44 +0200 [thread overview]
Message-ID: <20140718065444.GA21453@dhcp22.suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.02.1407161733200.23892@chino.kir.corp.google.com>
On Wed 16-07-14 17:36:49, David Rientjes wrote:
> Setting vm_dirty_bytes and dirty_background_bytes is not protected by any
> serialization.
>
> Therefore, it's possible for either variable to change value after the
> test in global_dirty_limits() to determine whether available_memory needs
> to be initialized or not.
>
> Always ensure that available_memory is properly initialized.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: David Rientjes <rientjes@google.com>
Makes sense to me
Acked-by: Michal Hocko <mhocko@suse.cz>
> ---
> mm/page-writeback.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -261,14 +261,11 @@ static unsigned long global_dirtyable_memory(void)
> */
> void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
> {
> + const unsigned long available_memory = global_dirtyable_memory();
> unsigned long background;
> unsigned long dirty;
> - unsigned long uninitialized_var(available_memory);
> struct task_struct *tsk;
>
> - if (!vm_dirty_bytes || !dirty_background_bytes)
> - available_memory = global_dirtyable_memory();
> -
> if (vm_dirty_bytes)
> dirty = DIV_ROUND_UP(vm_dirty_bytes, PAGE_SIZE);
> else
--
Michal Hocko
SUSE Labs
--
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>
prev parent reply other threads:[~2014-07-18 6:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 0:36 [patch] mm, writeback: prevent race when calculating dirty limits David Rientjes
2014-07-17 3:57 ` Johannes Weiner
2014-07-18 6:54 ` 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=20140718065444.GA21453@dhcp22.suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
--cc=stable@vger.kernel.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).