mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Ying Huang <ying.huang@intel.com>,
	Wenwei Tao <wenwei.tww@alibaba-inc.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Minchan Kim <minchan@kernel.org>, Rik van Riel <riel@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Hillf Danton <hillf.zj@alibaba-inc.com>
Subject: Re: [PATCH 1/2] mm/swap: Fix race conditions in swap_slots cache init
Date: Tue, 3 Oct 2017 15:27:37 -0700	[thread overview]
Message-ID: <20171003152737.c955053c04ee6ad9f70dc5eb@linux-foundation.org> (raw)
In-Reply-To: <65a9d0f133f63e66bba37b53b2fd0464b7cae771.1500677066.git.tim.c.chen@linux.intel.com>

On Fri, 21 Jul 2017 15:45:00 -0700 Tim Chen <tim.c.chen@linux.intel.com> wrote:

> Memory allocations can happen before the swap_slots cache initialization
> is completed during cpu bring up.  If we are low on memory, we could call
> get_swap_page and access swap_slots_cache before it is fully initialized.
> 
> Add a check in get_swap_page for initialized swap_slots_cache
> to prevent this condition.  Similar check already exists in
> free_swap_slot.  Also annotate the checks to indicate the likely
> condition.
> 
> We also added a memory barrier to make sure that the locks
> initialization are done before the assignment of cache->slots
> and cache->slots_ret pointers. This ensures the assumption
> that it is safe to acquire the slots cache locks and use the slots
> cache when the corresponding cache->slots or cache->slots_ret
> pointers are non null.

I guess that the user-visible effect is "crash on boot on large
machine".  Or something.  Please don't make me guess!

Which kernel version(s) do you believe need this patch, and why?

      parent reply	other threads:[~2017-10-03 22:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21 22:45 Tim Chen
2017-07-21 22:45 ` [PATCH 2/2] mm/swap: Remove lock_initialized flag from swap_slots_cache Tim Chen
2017-07-24  2:15   ` Huang, Ying
2017-07-24 16:54     ` Tim Chen
2017-10-03 22:27 ` Andrew Morton [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=20171003152737.c955053c04ee6ad9f70dc5eb@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aarcange@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=wenwei.tww@alibaba-inc.com \
    --cc=ying.huang@intel.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

Powered by JetHome