Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752219AbdFNNwe (ORCPT ); Wed, 14 Jun 2017 09:52:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:19740 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750728AbdFNNwc (ORCPT ); Wed, 14 Jun 2017 09:52:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,340,1493708400"; d="scan'208";a="99402077" From: "Kirill A. Shutemov" To: Andrew Morton , Vlastimil Babka , Vineet Gupta , Russell King , Will Deacon , Catalin Marinas , Ralf Baechle , "David S. Miller" , Heiko Carstens Cc: "Aneesh Kumar K . V" , Martin Schwidefsky , Andrea Arcangeli , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 2/3] mm: Do not loose dirty and access bits in pmdp_invalidate() Date: Wed, 14 Jun 2017 16:51:42 +0300 Message-Id: <20170614135143.25068-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170614135143.25068-1-kirill.shutemov@linux.intel.com> References: <20170614135143.25068-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1279 Lines: 37 Vlastimil noted that pmdp_invalidate() is not atomic and we can loose dirty and access bits if CPU sets them after pmdp dereference, but before set_pmd_at(). The bug doesn't lead to user-visible misbehaviour in current kernel. Loosing access bit can lead to sub-optimal reclaim behaviour for THP, but nothing destructive. Loosing dirty bit is not a big deal too: we would make page dirty unconditionally on splitting huge page. The fix is critical for future work on THP: both huge-ext4 and THP swap out rely on proper dirty tracking. Signed-off-by: Kirill A. Shutemov Reported-by: Vlastimil Babka --- mm/pgtable-generic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index c99d9512a45b..68094fa190d1 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -182,8 +182,7 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - pmd_t entry = *pmdp; - set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry)); + pmdp_mknotpresent(pmdp); flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); } #endif -- 2.11.0