From patchwork Fri Jan 28 04:54:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12727932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6508EC433EF for ; Fri, 28 Jan 2022 04:54:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADD746B0087; Thu, 27 Jan 2022 23:54:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A65126B008C; Thu, 27 Jan 2022 23:54:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DE196B0092; Thu, 27 Jan 2022 23:54:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 7BFAB6B0087 for ; Thu, 27 Jan 2022 23:54:28 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 293CC95260 for ; Fri, 28 Jan 2022 04:54:28 +0000 (UTC) X-FDA: 79078479816.21.B847171 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 9DC6BC0017 for ; Fri, 28 Jan 2022 04:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643345666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=resJk/tEdOzCb4HMrYNBbb0HwztWbu+r7ZIeropsSuw=; b=cPXPRSe5IbPGnDT0ROKoTPDHgo+w78iRFAkX25HO1ZVc5dt6IXq0Z5DwFsCjV1XrzMW9aA e8xjQQL2XNrKDRvKx45IzmZbAP75a5kgY4Ya1diOtlT771Yp7Xc3N/9CSPYgxSTAnsZHQt ws1nbVqRh9reZICW0iSBJ2RE9fD5+h0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-lzb_LFbUO2-32HDn42v6CA-1; Thu, 27 Jan 2022 23:54:25 -0500 X-MC-Unique: lzb_LFbUO2-32HDn42v6CA-1 Received: by mail-wm1-f69.google.com with SMTP id n7-20020a1c7207000000b0034ec3d8ce0aso2392394wmc.8 for ; Thu, 27 Jan 2022 20:54:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=resJk/tEdOzCb4HMrYNBbb0HwztWbu+r7ZIeropsSuw=; b=RM/X9lKX2OiKJOmT8D9gsFfx/LiOiptMcW/7tHb8dHG/S7NxpcxEsO7jBXUa3gfqEq P9NN3shgVK89OfHsvPqGd+WFVJ9cilvx6c7kpga8IzCgqToLcqmhfhfwbnwalAZXkioQ T8pEL4RbB2tp4h7udELPn6Av74J8V917BP03DLV79AEf/N0aRMVaSoZCQZcbEeHut6hG 52T+zGMghqEFwbQEt34wFM/IYRNwH1nhv0AmzYCZRar7+Iz/VkY2dzRQJCce2pDKEjZ5 h/9NAPPyJsuWlY8hSz8KJtakvLX4hLYb1Yv7jXObO2vzBj/cbhwzAV9jY/VBxuLfOsFp EJag== X-Gm-Message-State: AOAM530hk9KecZGePM9OJk1+0IBEBkQREiiwuGOnynKYtKsoaFe77p8D fmrl21b8c0fOnuumZa0tYHRMbr3pZ3HbfyvQYPy4k4ydGTxbmbFmN1VeKFRL4GnBvDtQNzVDXrL L4JDdp5ergLS0oYhHcz73exYidYJRexGPHpTU5P9RtrkLeltssVdFRZ65+YMJ X-Received: by 2002:a1c:a98f:: with SMTP id s137mr14457878wme.51.1643345664358; Thu, 27 Jan 2022 20:54:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/cbngk6JPIWe7eDn77j5uX7Q7CZTQwNG84coFmrPmCGvDYAJ1k7y6Mm20IH62h5mnyIOGoQ== X-Received: by 2002:a1c:a98f:: with SMTP id s137mr14457846wme.51.1643345663947; Thu, 27 Jan 2022 20:54:23 -0800 (PST) Received: from localhost.localdomain ([64.64.123.9]) by smtp.gmail.com with ESMTPSA id i13sm814014wrf.3.2022.01.27.20.54.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jan 2022 20:54:23 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Alistair Popple , Andrew Morton , Andrea Arcangeli , David Hildenbrand , Matthew Wilcox , John Hubbard , Hugh Dickins , Vlastimil Babka , Yang Shi , "Kirill A . Shutemov" Subject: [PATCH v3 0/4] mm: Rework zap ptes on swap entries Date: Fri, 28 Jan 2022 12:54:08 +0800 Message-Id: <20220128045412.18695-1-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cPXPRSe5; spf=none (imf28.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: nil X-Rspamd-Queue-Id: 9DC6BC0017 X-Stat-Signature: i75fu6k8e16x6gq1knudk1bx1f95nr8e X-Rspamd-Server: rspam12 X-HE-Tag: 1643345667-145750 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: v3: - Patch 1: - Fix !non_swap_entry() case and hwpoison case too [Hugh] - Added reproducer program in commit message - Introduced should_zap_cows() helper - Added patch 2, "mm: Rename zap_skip_check_mapping() to should_zap_page()" - Added patch 3, "mm: Change zap_details.zap_mapping into even_cows" RFC V2: https://lore.kernel.org/lkml/20211115134951.85286-1-peterx@redhat.com RFC V1: https://lore.kernel.org/lkml/20211110082952.19266-1-peterx@redhat.com Thanks to Hugh's help, we're pretty clear on the history of zap_details and swap skipping behavior, hence dropping the RFC tag. Patch 1 should fix a long standing bug for zap_pte_range() on zap_details usage. The risk is we could have some swap entries skipped while we should have zapped them. Migration entries are not the major concern because file backed memory always zap in the pattern that "first time without page lock, then re-zap with page lock" hence the 2nd zap will always make sure all migration entries are already recovered. However there can be issues with real swap entries got skipped errornoously. There's a reproducer provided in commit message of patch 1 for that. Patch 2-4 are cleanups that are based on patch 1. After the whole patchset applied, we should have a very clean view of zap_pte_range(). Only patch 1 needs to be backported to stable. Please review, thanks. Peter Xu (4): mm: Don't skip swap entry even if zap_details specified mm: Rename zap_skip_check_mapping() to should_zap_page() mm: Change zap_details.zap_mapping into even_cows mm: Rework swap handling of zap_pte_range mm/memory.c | 85 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 35 deletions(-)