Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp680028pxb; Wed, 16 Feb 2022 01:50:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe/E6EkpKqGyAeiEJQSupN9RFIZtMBMCsKvhSmLvMZjK+Hzwjn54Mfx9MWyrdpdsKYnpmI X-Received: by 2002:a63:5557:0:b0:370:60a8:c1da with SMTP id f23-20020a635557000000b0037060a8c1damr1613431pgm.278.1645005032031; Wed, 16 Feb 2022 01:50:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645005032; cv=none; d=google.com; s=arc-20160816; b=cLA6RK2GF9M4g8E2P/T0eu+7h8GB5qdZFKmZmTvho2a3kNoDOfLtmL5Y3ouKNPVK+s 3JRPY3x8mlG86V7RObnzB6xMXDO2KdaCD9vvUyjf74jEHNop8aJ2ucTKUc5Xn6za7ODM ogQT6BpCHzQzEaDy7kwQGrduYTZ+H/Rr8t/H7dko1+CuibX9aa3qF6oKIfiq9VLjhRmZ NeJIOYDDZVNT/lZgNkLYxuUzrpyjvBTVGuVMZz/BsrUFcbYlnpzSuRxdLb09ifUkIEyu BaRhaAubTPpAEuM5wXCc85XzavQUV362WX7Ml83SsgOJQWbf90tEaSi3nY+5OjAk2h3V J7ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=R0KDZgp75NCn3GqeaHfIg3tMwSJcRByZ3Og05yrSr6w=; b=P8j5vOBloOP6O52quTYGYhyPE/eslnZNzjkcdxoJvC/LCLL4OiGkOwFUt0rBrif7CV jRc5kvCFQVNsZ3jnJz4JDmr1mUZbnAh8CGXvDlwT8u5tIaXHIZN/JbtofgWMC/rLKmDy dQ0kkPI3CpBpBulMi2lZuS747KoKduFFdnPGuZvmLtJ+NPwrYxA23yHUxNIB3XUfFl7m RZJPIDXTwQLNWGfciFta/1RH59FrkiGK2h7pa2SuCb1Ck1UF6Vmbk+uqIv9MbUwoHCE1 FjeDuA+rRzY2jJBL6DmUxoYjwK1TL757J235KfuQVnQCoSe2aypuy6XgYfezUhnOjC1x HLlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=epWtiju5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mq12si6579805pjb.189.2022.02.16.01.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 01:50:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=epWtiju5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 747D6105A9D; Wed, 16 Feb 2022 01:48:47 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232421AbiBPJsw (ORCPT + 99 others); Wed, 16 Feb 2022 04:48:52 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232408AbiBPJsv (ORCPT ); Wed, 16 Feb 2022 04:48:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B83B105A9D for ; Wed, 16 Feb 2022 01:48:39 -0800 (PST) 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-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-264-3TK9wRSQMTOFZFeLPFg2Ug-1; Wed, 16 Feb 2022 04:48:37 -0500 X-MC-Unique: 3TK9wRSQMTOFZFeLPFg2Ug-1 Received: by mail-pg1-f197.google.com with SMTP id k6-20020a63d846000000b00365088c8f6aso995440pgj.6 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=eZd6DTLT8tS5q1brpLYQAlSYzTj4j9HRJHtS+nCm5KY9jm4zPmI8gWP01dNarMqsUd 9HO9JwLd1RFVYoeEtSFnFC5D3HJIGVsg9yJVrbwQmG5i2tpzv6w/nU6pK1YbsdHJkkOt 2koaF2cwDiTpHOb8e26uFo4u6iyZzZASS1Uy6tcav/rILJqXKOc8Cno6NC01o0r59vgw cdkEBZqg5l6wmRbk2zowqQ1TS35s7iBEQ5q8mmkMoHbaFdpsfEgFYwIoTw3rmmhYsEkF 1H0NMtspFaMOXuhhuNQquhhImfCuHMCuUFeuSotsGvU4Wsv24rf2BSVu2/K2XUEaFapt N1LQ== X-Gm-Message-State: AOAM5338OZsM3lcCpOIm7Md2V3EbiHVXWYTxsqcSZI8gH30HK4A+JDBF a3nr5UXi0WQ2A6URGoKr76cLtdSrQc7siKxjgXyfEed0bL+wNprHgxNfdXBL/ezhOha9tT3OcnO wVkqz1i9mOVvH89a+qaXM3UPI2GzRwfbNgliLatl7Kwm67HvDtUDYcvNLlzItNOAnWsQUaLI+Hg == X-Received: by 2002:a17:90b:104:b0:1b8:d212:9b8e with SMTP id p4-20020a17090b010400b001b8d2129b8emr766283pjz.11.1645004916198; Wed, 16 Feb 2022 01:48:36 -0800 (PST) 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 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.32.0