From patchwork Thu Jul 15 20:16:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12380977 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 692FCC636C9 for ; Thu, 15 Jul 2021 20:17:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 18AC3613CF for ; Thu, 15 Jul 2021 20:17:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18AC3613CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D27B8D0107; Thu, 15 Jul 2021 16:17:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45C9A8D00FC; Thu, 15 Jul 2021 16:17:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 288AE8D0107; Thu, 15 Jul 2021 16:17:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id 0067A8D00FC for ; Thu, 15 Jul 2021 16:17:09 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CED4918598407 for ; Thu, 15 Jul 2021 20:17:08 +0000 (UTC) X-FDA: 78365931336.29.F1F0390 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 80D291904 for ; Thu, 15 Jul 2021 20:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626380227; 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: in-reply-to:in-reply-to:references:references; bh=d+qr2gkGCf8UGCRyFBArhsHy6tP5+E2Jys4dwvbHGGg=; b=ICQDb+YB+4ro/88IJRhTQXzLG6p87N5qKekLbt+jP/B+QSw5hQWtMq4WVkSAYl5VVAv6rR P4B/g04mhqf78BoJhtVx8PKPRNQOqdKRrhGYT/Jl1WAGL0WA2ZYbeoIshI/YWbx8TIXitn zX7LB39ZXQMPD/VnMmFfCOkXBg8DFgY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-tM2uevL2Mkel44nAwOxUrg-1; Thu, 15 Jul 2021 16:16:55 -0400 X-MC-Unique: tM2uevL2Mkel44nAwOxUrg-1 Received: by mail-qk1-f200.google.com with SMTP id 81-20020a370b540000b02903b854c43335so4656073qkl.21 for ; Thu, 15 Jul 2021 13:16:55 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=d+qr2gkGCf8UGCRyFBArhsHy6tP5+E2Jys4dwvbHGGg=; b=pc/w2RaeO8H5NfbclDB3rbHLGV57AeyF78wQuF3ufO9HpCeniEecqm6BpEHWrZCTGl nsV0wszaNN6MOKXoEhvupggP9T+9Q0xwwbm0fJ1aHTSYbk2SaxydkFTWx1nF6S9tkJDB tLRLlVW6s8K773ksemv85M1KJqLRj6zRLBvwTJrSAm+Aa11SYwccD4ktKdsZicqlHVZ8 XcdIZI5igaE0J4bJk+lMeKG/1jxYTqTufzq9x1d4ZVfoE+oTZJfPljQfQGqJtHAj3xQw cINDPjxhHezUS7aqCcSFWeN7ykcLEF4T3j5U6btdxgbn8/Ici0gNi8eRvK+Rf9zc/LKJ NY/A== X-Gm-Message-State: AOAM5314U9Ud9DYLWN5h8J45VylL3gu5/nGDjzQN2MgvPN375Oe5ARpU yH/c1czFdIRCwn8KHL4J8vaSNv9mFb1vlf6ZGCN/H6u0lvf1ZxDSm4+Vr4RH/GvtbT0GWHFEkkb 65o7W6uZtTkA= X-Received: by 2002:ac8:7690:: with SMTP id g16mr5672222qtr.221.1626380215107; Thu, 15 Jul 2021 13:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3n2A17eCVd0ShKH2hDWtxhMPVbHnKs9Bym1cK2+XbUnXj4wDOYY9VEDs7W8nbrHHR4ZqZjA== X-Received: by 2002:ac8:7690:: with SMTP id g16mr5672205qtr.221.1626380214903; Thu, 15 Jul 2021 13:16:54 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id w185sm2965820qkd.30.2021.07.15.13.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 13:16:54 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Nadav Amit , Jerome Glisse , "Kirill A . Shutemov" , Jason Gunthorpe , Alistair Popple , Andrew Morton , David Hildenbrand , peterx@redhat.com, Andrea Arcangeli , Matthew Wilcox , Mike Kravetz , Tiberiu Georgescu , Hugh Dickins , Miaohe Lin , Mike Rapoport Subject: [PATCH v5 24/26] mm/pagemap: Recognize uffd-wp bit for shmem/hugetlbfs Date: Thu, 15 Jul 2021 16:16:51 -0400 Message-Id: <20210715201651.212134-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715201422.211004-1-peterx@redhat.com> References: <20210715201422.211004-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ICQDb+YB; spf=none (imf22.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: rspam05 X-Stat-Signature: 9y4cjdcapb5gcji6cfwnwy3ehf3y788x X-Rspamd-Queue-Id: 80D291904 X-HE-Tag: 1626380228-925258 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: This requires the pagemap code to be able to recognize the newly introduced swap special pte for uffd-wp, meanwhile the general case for hugetlb that we recently start to support. It should make pagemap uffd-wp support complete. Signed-off-by: Peter Xu --- fs/proc/task_mmu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 9c5af77b5290..988e29fa1f00 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1389,6 +1389,8 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm, flags |= PM_SWAP; if (is_pfn_swap_entry(entry)) page = pfn_swap_entry_to_page(entry); + } else if (pte_swp_uffd_wp_special(pte)) { + flags |= PM_UFFD_WP; } if (page && !PageAnon(page)) @@ -1522,10 +1524,15 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask, if (page_mapcount(page) == 1) flags |= PM_MMAP_EXCLUSIVE; + if (huge_pte_uffd_wp(pte)) + flags |= PM_UFFD_WP; + flags |= PM_PRESENT; if (pm->show_pfn) frame = pte_pfn(pte) + ((addr & ~hmask) >> PAGE_SHIFT); + } else if (pte_swp_uffd_wp_special(pte)) { + flags |= PM_UFFD_WP; } for (; addr != end; addr += PAGE_SIZE) {