From patchwork Wed Apr 6 22:51:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 8766681 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7AF509F36E for ; Wed, 6 Apr 2016 22:55:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2D0B20160 for ; Wed, 6 Apr 2016 22:55:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0C7A20131 for ; Wed, 6 Apr 2016 22:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754918AbcDFWxo (ORCPT ); Wed, 6 Apr 2016 18:53:44 -0400 Received: from mga04.intel.com ([192.55.52.120]:44498 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754632AbcDFWvl (ORCPT ); Wed, 6 Apr 2016 18:51:41 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 06 Apr 2016 15:51:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,448,1455004800"; d="scan'208";a="80454653" Received: from black.fi.intel.com ([10.237.72.93]) by fmsmga004.fm.intel.com with ESMTP; 06 Apr 2016 15:51:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 3328B54B; Thu, 7 Apr 2016 01:51:22 +0300 (EEST) From: "Kirill A. Shutemov" To: Hugh Dickins , Andrea Arcangeli , Andrew Morton Cc: Dave Hansen , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Jerome Marchand , Yang Shi , Sasha Levin , Andres Lagar-Cavilla , Ning Qu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv6 11/30] thp: handle file pages in mremap() Date: Thu, 7 Apr 2016 01:51:01 +0300 Message-Id: <1459983080-106718-12-git-send-email-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1459983080-106718-1-git-send-email-kirill.shutemov@linux.intel.com> References: <1459983080-106718-1-git-send-email-kirill.shutemov@linux.intel.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to mirror logic in move_ptes() wrt need_rmap_locks to get proper serialization file THP. Signed-off-by: Kirill A. Shutemov --- mm/mremap.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mm/mremap.c b/mm/mremap.c index 3fa0a467df66..88fa7ab1a8ce 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -192,17 +192,27 @@ unsigned long move_page_tables(struct vm_area_struct *vma, break; if (pmd_trans_huge(*old_pmd)) { if (extent == HPAGE_PMD_SIZE) { + struct address_space *mapping = NULL; + struct anon_vma *anon_vma = NULL; bool moved; - VM_BUG_ON_VMA(vma->vm_file || !vma->anon_vma, - vma); /* See comment in move_ptes() */ - if (need_rmap_locks) - anon_vma_lock_write(vma->anon_vma); + if (need_rmap_locks) { + if (vma->vm_file) { + mapping = vma->vm_file->f_mapping; + i_mmap_lock_write(mapping); + } + if (vma->anon_vma) { + anon_vma = vma->anon_vma; + anon_vma_lock_write(anon_vma); + } + } moved = move_huge_pmd(vma, new_vma, old_addr, new_addr, old_end, old_pmd, new_pmd); - if (need_rmap_locks) - anon_vma_unlock_write(vma->anon_vma); + if (anon_vma) + anon_vma_unlock_write(anon_vma); + if (mapping) + i_mmap_unlock_write(mapping); if (moved) { need_flush = true; continue;