From patchwork Sun Jan 10 00:54:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 565295 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6650E1402BC for ; Sun, 10 Jan 2016 11:56:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=KTlpL849; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 401911A0D2D for ; Sun, 10 Jan 2016 11:56:20 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=KTlpL849; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com [IPv6:2607:f8b0:400e:c03::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 1A26E1A0908 for ; Sun, 10 Jan 2016 11:55:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=KTlpL849; dkim-atps=neutral Received: by mail-pa0-x234.google.com with SMTP id cy9so302320388pac.0 for ; Sat, 09 Jan 2016 16:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:user-agent:mime-version :content-type; bh=h+jCEKvjmSO7NtMrLME0xWnfe6inxRNqIqqktnVSdFI=; b=KTlpL849SXkCMCMRUWC4FI8ZiDP+dVUUtwCN25CBDjYekrGdOS0Ay/87XgF1nC+mkQ IXtNtJT+OQe/CVsMz/lC0Z/1bz6WYOa6NG8CaZQjpFZ8eAO3DlgevDjPWPx3sv0NsQs+ jCYa0qWOmT3KNNqJlwgj0614CYJ6Wvn69aFqyIv29AcZcT1WOW15x+LGa1dih8/k0mWY Ycj7Y1tofJ2/APMqVfLjzvJDsphGIeCo3qr9Pko/eWNKPgViohGcCqq+T6wOax9nijuj XB3h5ltX0NSWh1AYSiaA25fUkotUWTSYLOL0cT+amtcbNZYU9qbqc/5jkLNvsUXf/RX2 e+nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version:content-type; bh=h+jCEKvjmSO7NtMrLME0xWnfe6inxRNqIqqktnVSdFI=; b=iiz+Sft+aCZpa6H6bcmjasNdQU2ZA7Lo9nyKL1/vkHvjXz15R2vMWnJ3TQ5moOOvQt tpki37bPfk9c5+CbqXVl025c2dD+Rh+xmDGdmozg13dDcScacqzAA/2HrDcx3v96I++l qNEW7VKU77dQRkPyVX9AhO103t5eRzeHqH7358ZJZprj1vgEgJSGrls02Wtn3Iazheue EIeb56Ar5CP8jmm3JkVgul+pzQ3CTjiIyD3AcmqUlRFiTtIhip0WbSa74sq0s96t7HDO d0qlV8n3UzF2gPS8Kuh5D1BPaPyoRusqBGqv+CWvcIt2OnNNP01hIsQchfcohmE0MzRB jJbg== X-Gm-Message-State: ALoCoQmLp1eAzsrLafjiqmGL5gUmy9zJr2AdOhlONXbXyoTFGqfzQfJej6ma658m1sR2cI3SX7S8FSqywtkXxHkSh5CbYJOYAA== X-Received: by 10.67.6.1 with SMTP id cq1mr169140290pad.78.1452387302949; Sat, 09 Jan 2016 16:55:02 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id n84sm13744333pfa.45.2016.01.09.16.55.01 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 09 Jan 2016 16:55:02 -0800 (PST) Date: Sat, 9 Jan 2016 16:54:59 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Laurent Dufour Subject: [PATCH next] powerpc/mm: fix _PAGE_SWP_SOFT_DIRTY breaking swapoff Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cyrill Gorcunov , linux-mm@kvack.org, "Aneesh Kumar K.V" , Martin Schwidefsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Swapoff after swapping hangs on the G5, when CONFIG_CHECKPOINT_RESTORE=y but CONFIG_MEM_SOFT_DIRTY is not set. That's because the non-zero _PAGE_SWP_SOFT_DIRTY bit, added by CONFIG_HAVE_ARCH_SOFT_DIRTY=y, is not discounted when CONFIG_MEM_SOFT_DIRTY is not set: so swap ptes cannot be recognized. (I suspect that the peculiar dependence of HAVE_ARCH_SOFT_DIRTY on CHECKPOINT_RESTORE in arch/powerpc/Kconfig comes from an incomplete attempt to solve this problem.) It's true that the relationship between CONFIG_HAVE_ARCH_SOFT_DIRTY and and CONFIG_MEM_SOFT_DIRTY is too confusing, and it's true that swapoff should be made more robust; but nevertheless, fix up the powerpc ifdefs as x86_64 and s390 (which met the same problem) have them, defining the bits as 0 if CONFIG_MEM_SOFT_DIRTY is not set. Signed-off-by: Hugh Dickins Reviewed-by: Cyrill Gorcunov Acked-by: Laurent Dufour --- arch/powerpc/include/asm/book3s/64/hash.h | 5 +++++ arch/powerpc/include/asm/book3s/64/pgtable.h | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) --- 4.4-next/arch/powerpc/include/asm/book3s/64/hash.h 2016-01-06 11:54:01.377508976 -0800 +++ linux/arch/powerpc/include/asm/book3s/64/hash.h 2016-01-09 13:54:24.410893347 -0800 @@ -33,7 +33,12 @@ #define _PAGE_F_GIX_SHIFT 12 #define _PAGE_F_SECOND 0x08000 /* Whether to use secondary hash or not */ #define _PAGE_SPECIAL 0x10000 /* software: special page */ + +#ifdef CONFIG_MEM_SOFT_DIRTY #define _PAGE_SOFT_DIRTY 0x20000 /* software: software dirty tracking */ +#else +#define _PAGE_SOFT_DIRTY 0x00000 +#endif /* * We need to differentiate between explicit huge page and THP huge --- 4.4-next/arch/powerpc/include/asm/book3s/64/pgtable.h 2016-01-06 11:54:01.377508976 -0800 +++ linux/arch/powerpc/include/asm/book3s/64/pgtable.h 2016-01-09 13:54:24.410893347 -0800 @@ -162,8 +162,13 @@ static inline void pgd_set(pgd_t *pgdp, #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val((pte)) }) #define __swp_entry_to_pte(x) __pte((x).val) -#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY +#ifdef CONFIG_MEM_SOFT_DIRTY #define _PAGE_SWP_SOFT_DIRTY (1UL << (SWP_TYPE_BITS + _PAGE_BIT_SWAP_TYPE)) +#else +#define _PAGE_SWP_SOFT_DIRTY 0UL +#endif /* CONFIG_MEM_SOFT_DIRTY */ + +#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY static inline pte_t pte_swp_mksoft_dirty(pte_t pte) { return __pte(pte_val(pte) | _PAGE_SWP_SOFT_DIRTY); @@ -176,8 +181,6 @@ static inline pte_t pte_swp_clear_soft_d { return __pte(pte_val(pte) & ~_PAGE_SWP_SOFT_DIRTY); } -#else -#define _PAGE_SWP_SOFT_DIRTY 0 #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */ void pgtable_cache_add(unsigned shift, void (*ctor)(void *));