From patchwork Thu Feb 17 06:07:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12749418 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 8E703C433F5 for ; Thu, 17 Feb 2022 06:08:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01E186B0074; Thu, 17 Feb 2022 01:08:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE8896B0075; Thu, 17 Feb 2022 01:07:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D608E6B0078; Thu, 17 Feb 2022 01:07:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id C176C6B0074 for ; Thu, 17 Feb 2022 01:07:59 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 765238249980 for ; Thu, 17 Feb 2022 06:07:59 +0000 (UTC) X-FDA: 79151241078.22.B69C6B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id CA07040002 for ; Thu, 17 Feb 2022 06:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645078078; 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=58IcYQPt3ZhNcNyChh1IrLVEmd4Lcb+cUPGc2UbHCU0=; b=iAv7kGkJxf6Se9c3Sfp5VbhxdVOxA0xIGqXvR3Q/QvtLXc5HUVsu2M0za6NbRPx9lyXlSR 3JpO9wcfjNBMyfhrFjI8Q7iaGU0lS5jBzzF61cbinHmJdiExvDMiH+6JRno5yXlu+skK0D VCe8SpjEc31VqsffSrP6rVmNiZ8kuEU= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-5tjVgFxoMAm1D0EAQwvOQA-1; Thu, 17 Feb 2022 01:07:57 -0500 X-MC-Unique: 5tjVgFxoMAm1D0EAQwvOQA-1 Received: by mail-pf1-f198.google.com with SMTP id f128-20020a623886000000b004e152a2c149so2686061pfa.5 for ; Wed, 16 Feb 2022 22:07:56 -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=58IcYQPt3ZhNcNyChh1IrLVEmd4Lcb+cUPGc2UbHCU0=; b=jCEI9JovxDd7ZL9c2lS4GvHPzZ/KzQKl4TOuw0u1v9kjz2nGyXaJlqWeiXm0fI6CIu T2tC26lnm4FLaqcRFuuvSEiwF3y/2SsQ6ANqCrfN0qPg1M5NbUlv4+UXK7mug6aIP849 wM4U9T2SRBLuXa2pvR6Kju9ihM0ni+b61azxJShQBMjUYE//jf4bRep70N5by26rwS2B WB6lquJy0u3UopwHbTM8hiEWYTK8raYrLfR7p+jrN3Gd37WD0i8QDhjSMRCqh45txjGd 6034XrZZMAyBFKhSTZINOeVr3KQ4Eytz/VMjEkhxpIRCYNdv6KwUuyMjBLB/K46q1o/N SoSA== X-Gm-Message-State: AOAM531f+juiTeQlYVlLPSE+567/9X+yzP9KlNoS11mpqJqGswcQuYan dk5obsyZ+cQ9mFThHwSNQ5NcKCVG5Po2HO6GKpwIaHmrvui2J8ca5bapglvxMZICBr41UdX7ICw QId8VAxje2aCohLQ3obXnFVm86qX7N2TElDX+8fPSWVtvpH6p14zgduIL/p6s X-Received: by 2002:a17:902:fe83:b0:14d:6e55:eea3 with SMTP id x3-20020a170902fe8300b0014d6e55eea3mr1415414plm.104.1645078075687; Wed, 16 Feb 2022 22:07:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzKtPr2kwyIYGum1Q09mgsPZ2ioQRfmHyRjvcp1K2tM0GogiQwyeAoUhJIKwFJRBmXDX8QrQ== X-Received: by 2002:a17:902:fe83:b0:14d:6e55:eea3 with SMTP id x3-20020a170902fe8300b0014d6e55eea3mr1415382plm.104.1645078075270; Wed, 16 Feb 2022 22:07:55 -0800 (PST) Received: from localhost.localdomain ([94.177.118.126]) by smtp.gmail.com with ESMTPSA id j8sm224230pjc.11.2022.02.16.22.07.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 16 Feb 2022 22:07:55 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Alistair Popple , Matthew Wilcox , peterx@redhat.com, David Hildenbrand , Andrea Arcangeli , Hugh Dickins , Yang Shi , Vlastimil Babka , John Hubbard , Andrew Morton , "Kirill A . Shutemov" Subject: [PATCH v5 0/4] mm: Rework zap ptes on swap entries Date: Thu, 17 Feb 2022 14:07:42 +0800 Message-Id: <20220217060746.71256-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: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iAv7kGkJ; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf17.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: CA07040002 X-Stat-Signature: y1qcek6rnzs37o1iuojp83w1bo7uhcaf X-HE-Tag: 1645078078-47170 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: v5: - Patch 1: - A few comment fixups in patch 1 [John] - Tweak commit message (s/user/caller/) [Andrew] - Add r-bs for John - Reindent commit messages to 75 columns [John] 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 V4: https://lore.kernel.org/lkml/20220216094810.60572-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 | 80 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 35 deletions(-)