From patchwork Wed Feb 16 09:48:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12748343 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 A7B2CC433F5 for ; Wed, 16 Feb 2022 09:48:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF0366B0078; Wed, 16 Feb 2022 04:48:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA0806B007B; Wed, 16 Feb 2022 04:48:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D67FF6B007D; Wed, 16 Feb 2022 04:48:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id C86A96B0078 for ; Wed, 16 Feb 2022 04:48:39 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 699068249980 for ; Wed, 16 Feb 2022 09:48:39 +0000 (UTC) X-FDA: 79148168358.07.53236FF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id BB6EF1A0005 for ; Wed, 16 Feb 2022 09:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645004918; 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=R0KDZgp75NCn3GqeaHfIg3tMwSJcRByZ3Og05yrSr6w=; b=epWtiju5ATkegh4LUwVN34bfNn/voqYbOZUZE5EbBv/5wtnm0Y33RZRHyOWXKfwYoeKH8D rdljAbYoyeIJ/PIbYtTk6XpkUKIr3P3FED8NE32QL0hAtruHwFdcczDlQz8DEknHienL1k AfUNDzWQNeKH5QIbwv4Xe88pMyp14NE= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-nXESVS4yOFa2XCTx_k99LQ-1; Wed, 16 Feb 2022 04:48:37 -0500 X-MC-Unique: nXESVS4yOFa2XCTx_k99LQ-1 Received: by mail-pj1-f70.google.com with SMTP id md16-20020a17090b23d000b001b8bd5e35e2so1119240pjb.0 for ; Wed, 16 Feb 2022 01:48:37 -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=R0KDZgp75NCn3GqeaHfIg3tMwSJcRByZ3Og05yrSr6w=; b=bCH5uofbVa5mzS8Aayjt7vcraO6z11eNEL2PFE1oosdfaIstEjZ4k4U1OIKiERj+2E EGkucnjZnZEeSLORzCiLXagfr75WEf6DZJx9eLI4hEsaaWlfLUlgGZgzV92tdqE6iNDZ kyTXxP4CUQAT9d4DKDcxNEej8wHyZ1nNUK51+YJmF9Ik2+7XKed3CG8SUU5PVYxiWH1F me8aqVptOx3OGubE11xQqS+3lGpMfJUlQ/I8Gj/Wr/H9J58F7JhRP7fBZostOL+AMKaZ jrXdB4161ZhT5MU5GsdA0QGYlfrG1IaeQGpSfaPRt603v6N1enY86JO3MSywCScWTZCS 4VRw== X-Gm-Message-State: AOAM530xRXMj7p7GKOSFZo59rH+HaCpTNSWRr4WH4zBF0l9ZOtkAbNFf 7ByP5lA/0xEGe2a16giNubHmhzgMK4l4bHJcO1azwQIYWDeGDILmEBkIPTKAsulBzDanSoLHUy3 0H87peufAhOQ= X-Received: by 2002:a17:90b:104:b0:1b8:d212:9b8e with SMTP id p4-20020a17090b010400b001b8d2129b8emr766268pjz.11.1645004916015; Wed, 16 Feb 2022 01:48:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJybAQIc6R/6zMXRczxvOWvn4bCG50xP5kjea3OzmnTzEPRiCP3Sdss04dZKrFD0kiE1paUwyA== X-Received: by 2002:a17:90b:104:b0:1b8:d212:9b8e with SMTP id p4-20020a17090b010400b001b8d2129b8emr766237pjz.11.1645004915681; Wed, 16 Feb 2022 01:48:35 -0800 (PST) Received: from localhost.localdomain ([64.64.123.81]) by smtp.gmail.com with ESMTPSA id qe7sm11567835pjb.25.2022.02.16.01.48.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 16 Feb 2022 01:48:35 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , "Kirill A . Shutemov" , Matthew Wilcox , Yang Shi , Andrea Arcangeli , peterx@redhat.com, John Hubbard , Alistair Popple , David Hildenbrand , Vlastimil Babka , Hugh Dickins Subject: [PATCH v4 0/4] mm: Rework zap ptes on swap entries Date: Wed, 16 Feb 2022 17:48:06 +0800 Message-Id: <20220216094810.60572-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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BB6EF1A0005 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=epWtiju5; spf=none (imf19.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-Stat-Signature: wac58k71yq8weoiraennbi6ntthnbhr4 X-HE-Tag: 1645004918-880020 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: v4: - Rebase to v5.17-rc4 - Add r-b, and suggested-by on patch 2 [David] - Fix spelling (s/Quotting/Quoting/) [David] RFC V1: https://lore.kernel.org/lkml/20211110082952.19266-1-peterx@redhat.com RFC V2: https://lore.kernel.org/lkml/20211115134951.85286-1-peterx@redhat.com V3: https://lore.kernel.org/lkml/20220128045412.18695-1-peterx@redhat.com 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 if necessary. 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(-)