Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752158AbcDPXdM (ORCPT ); Sat, 16 Apr 2016 19:33:12 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34126 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751823AbcDPXdL (ORCPT ); Sat, 16 Apr 2016 19:33:11 -0400 Date: Sat, 16 Apr 2016 16:33:07 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: "Kirill A. Shutemov" , Andrea Arcangeli , Andres Lagar-Cavilla , Yang Shi , Ning Qu , Stephen Rothwell , Mika Penttila , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH mmotm 3/5] huge tmpfs recovery: tweak shmem_getpage_gfp to fill team fix In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 986 Lines: 27 Please add this fix after my 27/31, your huge-tmpfs-recovery-tweak-shmem_getpage_gfp-to-fill-team.patch for later merging into it. Great catch by Mika Penttila, a bug which prevented some unusual cases from being recovered into huge pages as intended: an initially sparse head would be set PageTeam only after this check. But the check is guarding against a racing disband, which cannot happen before the head is published as PageTeam, plus we have an additional reference on the head which keeps it safe throughout: so very easily fixed. Reported-by: Mika Penttila Signed-off-by: Hugh Dickins --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2938,7 +2938,7 @@ repeat: page = *pagep; lock_page(page); head = page - (index & (HPAGE_PMD_NR-1)); - if (!PageTeam(head)) { + if (!PageTeam(head) && page != head) { error = -ENOENT; goto decused; }