Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752811AbdFOOxK (ORCPT ); Thu, 15 Jun 2017 10:53:10 -0400 Received: from mga04.intel.com ([192.55.52.120]:17168 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338AbdFOOxJ (ORCPT ); Thu, 15 Jun 2017 10:53:09 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,343,1493708400"; d="scan'208";a="1141593450" From: "Kirill A. Shutemov" To: Andrew Morton , Vlastimil Babka , Vineet Gupta , Russell King , Will Deacon , Catalin Marinas , Ralf Baechle , "David S. Miller" , "Aneesh Kumar K . V" , Martin Schwidefsky , Heiko Carstens , Andrea Arcangeli Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [HELP-NEEDED, PATCHv2 0/3] Do not loose dirty bit on THP pages Date: Thu, 15 Jun 2017 17:52:21 +0300 Message-Id: <20170615145224.66200-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1602 Lines: 50 Hi, 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, but fixing this would be critical for future work on THP: both huge-ext4 and THP swap out rely on proper dirty tracking. Unfortunately, there's no way to address the issue in a generic way. We need to fix all architectures that support THP one-by-one. All architectures that have THP supported have to provide atomic pmdp_invalidate() that returns previous value. If generic implementation of pmdp_invalidate() is used, architecture needs to provide atomic pmdp_estabish(). pmdp_estabish() is not used out-side generic implementation of pmdp_invalidate() so far, but I think this can change in the future. I've fixed the issue for x86, but I need help with the rest. So far THP is supported on 7 architectures, beyond x86: - arc; - arm; - arm64; - mips; - power; - s390; - sparc; Please, help me with them. v2: - Introduce pmdp_estabish(), instead of pmdp_mknonpresent(); - Change pmdp_invalidate() to return previous value of the pmd; arch/x86/include/asm/pgtable-3level.h | 18 ++++++++++++++++++ arch/x86/include/asm/pgtable.h | 14 ++++++++++++++ fs/proc/task_mmu.c | 8 ++++---- include/asm-generic/pgtable.h | 2 +- mm/huge_memory.c | 29 ++++++++++++----------------- mm/pgtable-generic.c | 9 +++++---- 6 files changed, 54 insertions(+), 26 deletions(-) -- 2.11.0