From patchwork Thu Sep 2 20:17:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12472433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18D59C433EF for ; Thu, 2 Sep 2021 20:17:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9813C61131 for ; Thu, 2 Sep 2021 20:17:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9813C61131 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 085F86B0071; Thu, 2 Sep 2021 16:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 036196B0072; Thu, 2 Sep 2021 16:17:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E18746B0073; Thu, 2 Sep 2021 16:17:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id D07556B0071 for ; Thu, 2 Sep 2021 16:17:26 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 886548169F80 for ; Thu, 2 Sep 2021 20:17:26 +0000 (UTC) X-FDA: 78543743292.30.414B79D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 096E3D00009A for ; Thu, 2 Sep 2021 20:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630613845; 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=cD1W3dntLgg1x3vkXVCT9JGKq3SQlkeHYUmqX0fImm4=; b=Ar5X45d9UPWK1VBEFq7oD6rOUK6Nv1a05LNAyynB+0DXb1s0wZApRWq/O9uSm747L2IjB3 9Zvi3iG5tbN8MchpkmN2GDuBjd6pmJssNEkuFfnqeqIM3XqUs2PMwXAeCtfI5GOeD7N/Td 3GxUCEdNVS02fTRYZDlSf0zB81b3fiI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-a5AcboOlOB-WoFcUtXHisA-1; Thu, 02 Sep 2021 16:17:24 -0400 X-MC-Unique: a5AcboOlOB-WoFcUtXHisA-1 Received: by mail-qt1-f199.google.com with SMTP id u16-20020a05622a199000b0029f37b5c4f4so2783094qtc.17 for ; Thu, 02 Sep 2021 13:17:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cD1W3dntLgg1x3vkXVCT9JGKq3SQlkeHYUmqX0fImm4=; b=GeKNLAeEw6WdRPGfyKe/LShgpBY8s8GySfDF6tbGZN9aVu8RLNmwFYTggFY/rK8PNu xD0XeE8uP7y1TYBGuYj1l7+DRWBOKcxJcgOdqPr0A+AF78hXK+AljkAzFw3LuHLeBHaO J5Oe/GAvYZb8xi7L0XksMQunUkxTpIU9nbcoBuGJCfSEJcDoQVhQ7p6q1Q+RpB//CYol ThcJx8Ho+BIvYJgNBLXznkDVfGUwSOnlOXYgG5x61QGow+wK8Ie144IBhAnHCylit7Co ZElTEOWjcDqoai7DmzKe61KJ+UzLiH4sgKEkbgM5PwYnHYaYAcDFYyJ46QAzBa8Tr0Im O2zg== X-Gm-Message-State: AOAM532B5uwKIQb0rxOvVxkOxCgCnO4fvFp32mEoMqQkScSDxwKw6rzg zKd5mLnq0QWEdKdZjEOZLlU0/DFEcLY2zljo/Q6/PJIj7VeQRQ87s2qRK3LqBifXMpYjrJwahmE 8bxlJmRxW5JU= X-Received: by 2002:ac8:a0a:: with SMTP id b10mr167534qti.164.1630613843926; Thu, 02 Sep 2021 13:17:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/2PxgUG48VI5CyWpSrsgmcN4+bm4tOjKozx0or1bv7gKrDgWp7u41BOWsDuMOfcRu4ITTeA== X-Received: by 2002:ac8:a0a:: with SMTP id b10mr167496qti.164.1630613843647; Thu, 02 Sep 2021 13:17:23 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a3:500::ad7f]) by smtp.gmail.com with ESMTPSA id m8sm2219962qkk.130.2021.09.02.13.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 13:17:23 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , linux-mm@kvack.org Cc: Andrea Arcangeli , Yang Shi , Matthew Wilcox , peterx@redhat.com, Jerome Glisse , Mike Rapoport , "Kirill A . Shutemov" , Miaohe Lin , David Hildenbrand , Alistair Popple Subject: [PATCH v2 0/5] mm: A few cleanup patches around zap, shmem and uffd Date: Thu, 2 Sep 2021 16:17:16 -0400 Message-Id: <20210902201721.52796-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ar5X45d9; spf=none (imf15.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 096E3D00009A X-Stat-Signature: z6k4qgbsdo59ngphyf7ybn9m5t5dxhod X-HE-Tag: 1630613845-321308 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: [Based on tag v5.14, but it should still apply to -mm too. If not, I can repost anytime] Hugh, So I found one thing that I feel like a bug of commit 22061a1ffabdb9c3, but I'm not sure. If that's the case, patch 5 of this series may be the fix for it. The problem is unmap_mapping_page() in current tree is calling unmap_mapping_range_tree() with a details pointer, while by default when detail pointer is specified, it means "we want to skip zapping swap entries". I didn't mention this in v1 simply because I thought it was fine, e.g., swap entry won't be kept in shmem ptes so skipped is okay (it is never okay with shmem uffd-wp but uffd-wp code is not landed yet). However I just remembered there could also be e.g. shmem migration entries if I'm not wrong. From that pov, skipping swap entries for unmap_mapping_page() seems wrong. Would you please help check? It'll be great if you can comment on patch 1 too, to see whether that's okay and what I could have been missing there (e.g., if you have other concern on breaking stuff, I'll be happy to test). v2: - Patch "mm: Clear vmf->pte after pte_unmap_same() returns" - Remove one comment [David] - Collect r-b for patch 2/3 - Rewrite the last two patches to drop ZAP_FLAG_CHECK_MAPPING, dropping Alistair's r-b on patch 5 because it changed [David, Matthew] ===== v1 cover letter ===== I picked up these patches from uffd-wp v5 series here: https://lore.kernel.org/lkml/20210715201422.211004-1-peterx@redhat.com/ IMHO all of them are very nice cleanups to existing code already, they're all small and self-contained. They'll be needed by uffd-wp coming series. I would appreciate if they can be accepted earlier, so as to not carry them over always with the uffd-wp series. I removed some CC from the uffd-wp v5 series to reduce the noise, and added a few more into it. Reviews are greatly welcomed, thanks. Peter Xu (5): mm/shmem: Unconditionally set pte dirty in mfill_atomic_install_pte mm: Clear vmf->pte after pte_unmap_same() returns mm: Drop first_index/last_index in zap_details mm: Add zap_skip_check_mapping() helper mm: Add ZAP_FLAG_SKIP_SWAP and zap_flags include/linux/mm.h | 33 ++++++++++++++++++-- mm/memory.c | 76 +++++++++++++++++++--------------------------- mm/shmem.c | 1 - mm/userfaultfd.c | 3 +- 4 files changed, 62 insertions(+), 51 deletions(-)