Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754480AbbGaPM4 (ORCPT ); Fri, 31 Jul 2015 11:12:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47205 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754441AbbGaPMx (ORCPT ); Fri, 31 Jul 2015 11:12:53 -0400 Message-ID: <55BB906F.5090802@redhat.com> Date: Fri, 31 Jul 2015 17:12:47 +0200 From: Jerome Marchand User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli , Hugh Dickins CC: Dave Hansen , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Sasha Levin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv9 31/36] thp, mm: split_huge_page(): caller need to lock page References: <1437402069-105900-1-git-send-email-kirill.shutemov@linux.intel.com> <1437402069-105900-32-git-send-email-kirill.shutemov@linux.intel.com> In-Reply-To: <1437402069-105900-32-git-send-email-kirill.shutemov@linux.intel.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="iHoBrwQPgn5DP9CdXDtGWHceFubJduJiN" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3681 Lines: 114 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --iHoBrwQPgn5DP9CdXDtGWHceFubJduJiN Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07/20/2015 04:21 PM, Kirill A. Shutemov wrote: > We're going to use migration entries instead of compound_lock() to > stabilize page refcounts. Setup and remove migration entries require > page to be locked. >=20 > Some of split_huge_page() callers already have the page locked. Let's > require everybody to lock the page before calling split_huge_page(). >=20 > Signed-off-by: Kirill A. Shutemov > Tested-by: Sasha Levin > Tested-by: Aneesh Kumar K.V > Acked-by: Vlastimil Babka Acked-by: Jerome Marchand > --- > mm/memory-failure.c | 10 ++++++++-- > mm/migrate.c | 8 ++++++-- > 2 files changed, 14 insertions(+), 4 deletions(-) >=20 > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index ef33ccf37224..f32a607d1aa3 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1143,15 +1143,18 @@ int memory_failure(unsigned long pfn, int trapn= o, int flags) > put_page(hpage); > return -EBUSY; > } > + lock_page(hpage); > if (unlikely(split_huge_page(hpage))) { > pr_err("MCE: %#lx: thp split failed\n", pfn); > if (TestClearPageHWPoison(p)) > atomic_long_sub(nr_pages, &num_poisoned_pages); > + unlock_page(hpage); > put_page(p); > if (p !=3D hpage) > put_page(hpage); > return -EBUSY; > } > + unlock_page(hpage); > VM_BUG_ON_PAGE(!page_count(p), p); > hpage =3D compound_head(p); > } > @@ -1714,10 +1717,13 @@ int soft_offline_page(struct page *page, int fl= ags) > return -EBUSY; > } > if (!PageHuge(page) && PageTransHuge(hpage)) { > - if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) { > + lock_page(page); > + ret =3D split_huge_page(hpage); > + unlock_page(page); > + if (unlikely(ret)) { > pr_info("soft offline: %#lx: failed to split THP\n", > pfn); > - return -EBUSY; > + return ret; > } > } > =20 > diff --git a/mm/migrate.c b/mm/migrate.c > index 67970faf544d..a9dbfd356e9d 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -933,9 +933,13 @@ static ICE_noinline int unmap_and_move(new_page_t = get_new_page, > goto out; > } > =20 > - if (unlikely(PageTransHuge(page))) > - if (unlikely(split_huge_page(page))) > + if (unlikely(PageTransHuge(page))) { > + lock_page(page); > + rc =3D split_huge_page(page); > + unlock_page(page); > + if (rc) > goto out; > + } > =20 > rc =3D __unmap_and_move(page, newpage, force, mode); > =20 >=20 --iHoBrwQPgn5DP9CdXDtGWHceFubJduJiN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJVu5BvAAoJEHTzHJCtsuoCtfEH/1x8vpClqOVzqOxPZubdr9+g AI8jcTEOd9Ei5wGna8GVB1bi0C1771hZCr8lFR/4AtxrHKrdo1/HQqW6ndIeW/Pb FdMA+xWTCQpVRmh6qO15JwiwpzHd2it+xyIlg2mvBSOhx0qQb7zG1EkxcDNGx0gM 95AXYyUMUQmpy8jEi+lDyTHeNb7xKZJAZujLcX1if7FmIhOyUjySwUw+zepSHxyN QuG3haPiwIpeHdSpXFO/4+ERNRVPCMR9P3pttfMurLRVqm9bQj69kAsK5cI/nG+v EK/yqnUOtMIlMKe64LWifgas9bvjaQeVyKz0CwJ9JGuyRZApc9LBiBSx1NkBrng= =wwS8 -----END PGP SIGNATURE----- --iHoBrwQPgn5DP9CdXDtGWHceFubJduJiN-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/