From patchwork Thu Jul 27 21:28:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13330785 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 99E95EB64DD for ; Thu, 27 Jul 2023 21:28:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15A106B0075; Thu, 27 Jul 2023 17:28:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10AA96B0078; Thu, 27 Jul 2023 17:28:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F13EC6B007D; Thu, 27 Jul 2023 17:28:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E20966B0075 for ; Thu, 27 Jul 2023 17:28:56 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8F0F78031D for ; Thu, 27 Jul 2023 21:28:56 +0000 (UTC) X-FDA: 81058681872.26.4E08025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id D92B880019 for ; Thu, 27 Jul 2023 21:28:54 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V1sPIIzf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690493335; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=MHtDEcJmjYkfEI+Ix28zkYwSjHjzxbeRw7Afa8s+sDk=; b=l8RdkkBJ6GANTGBhIplnnjuQJa0H2jXOlm5MncKJnW2hlGgfF5scIcQHFpOkjOFtW3Nb+S 3T89VDHzAwiA6Yg2R6S1bBfbwN6SuYiltsXeC6OG/tvbiDFrJPJaU7rJpTRhJwRyNFR14O nQuBc26FC/mJKs8RwVd74cu6TxuY6vI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V1sPIIzf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690493335; a=rsa-sha256; cv=none; b=0oPyv6a3FNwKSgwxYAlk6wzh4WGBVxb/F2s3gRVISjsj4ctI8NRKEIfh5fGFCx7zmpb+ZM idQ1ltGlyUBK4wqtg72PAuxj+vlIklj1hhtieCSR8VJCI91gsSRZWr1br3Zd5OkKwYHe4Q 5ut1hFffchmvJlL6U/lKK//KAvkBuv0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690493334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MHtDEcJmjYkfEI+Ix28zkYwSjHjzxbeRw7Afa8s+sDk=; b=V1sPIIzftjOYK8qE/VqLnjqIpKJnj11YlUdStCrSUt7UBjpMY9UhO6zdOiX6r+yBS8nj9E dBjU2JvKSH7djaxsYA9xlpFWSHIQtR58gNC4cUr+E0egLqvgsZ6MukU4vHwQTaaArRQ5yN HE/x+SK4Atayv19HiJiF9StfvYrjJPc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-477-SSSPx73SMmCaNq4xHLAjEw-1; Thu, 27 Jul 2023 17:28:50 -0400 X-MC-Unique: SSSPx73SMmCaNq4xHLAjEw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D69AE101A54E; Thu, 27 Jul 2023 21:28:49 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C073D40C2063; Thu, 27 Jul 2023 21:28:46 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Linus Torvalds , liubo , Peter Xu , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard Subject: [PATCH v1 0/4] smaps / mm/gup: fix gup_can_follow_protnone fallout Date: Thu, 27 Jul 2023 23:28:41 +0200 Message-ID: <20230727212845.135673-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: D92B880019 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: w84zt8ksouipmggzt6fxs9k5jggqek1x X-HE-Tag: 1690493334-806534 X-HE-Meta: U2FsdGVkX1+fvePLCPEuJw6vDqS7HygnA/e1OX3HOR7Jyb6o8q78XmuH+zSu5JUqbR5rxrF3i46rzM6cyE+cfvyQr/2B8hvUeU21Ah8iqr3TCHrVAMGDLIKJVwcJbFpYQY6v1QNv2laY9183mJlLk5UedN4WzqgTM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DlT+MCrS8H/86qeE2/LBDJsId9JYiI5zyORrSsE7nHHLb3DAltv5xBNKhDSLRSgGwdz9FawK8xxBU+5maX2RFH+xpbQUNe03VJ5nZl45TBvy89i92ZZMzYKZIwRCz7ytgE3zolg24ZbV1vWPkv49g0fCKHrNEyN9jp9J5EGdXVXRy1rfjAEHRtgul7Nm2uA9OOdafZhx3jV7QIxPM2tyKMcGCcjboHk5pL2cB+2DMaQl84oejiX2V6voDfsw7f/9nOS8D1MaSk9+5dBxpoFE8qei9eGsAZI+KGEA== 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 is my proposal on how to handle the fallout of 474098edac26 ("mm/gup: replace FOLL_NUMA by gup_can_follow_protnone()") where I accidentially missed that follow_page() and smaps implicitly kept the FOLL_NUMA flag clear by *not* setting it if FOLL_FORCE is absent, to not trigger faults on PROT_NONE-mapped PTEs. (maybe it's just me who considers that confusing) Patch #1 is the original fix proposal, which patch #3 cleans up. Patch #2 is another fix for the issue on the follow_page() level pointed out by Peter. Patch #4 documents the FOLL_FORCE situation. Peter prefers a revert of that commit [1], I disagree and am still happy to see FOLL_NUMA gone that implicitly relied on FOLL_FORCE. An alternative might be to use an internal FOLL_PROTNONE or FOLL_NO_PROTNONE flag in patch #3, not so sure about that. Did a quick sanity test, will do more testing tomorrow. [1] https://lkml.kernel.org/r/ZMK+jSDgOmJKySTr@x1n Cc: Andrew Morton Cc: Linus Torvalds Cc: liubo Cc: Peter Xu Cc: Matthew Wilcox Cc: Hugh Dickins Cc: Jason Gunthorpe Cc: John Hubbard David Hildenbrand (3): mm/gup: Make follow_page() succeed again on PROT_NONE PTEs/PMDs smaps: use vm_normal_page_pmd() instead of follow_trans_huge_pmd() mm/gup: document FOLL_FORCE behavior liubo (1): smaps: Fix the abnormal memory statistics obtained through /proc/pid/smaps fs/proc/task_mmu.c | 3 +-- include/linux/mm_types.h | 25 ++++++++++++++++++++++++- mm/gup.c | 10 +++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) Reported-by: liubo Reported-by: Peter Xu Signed-off-by: David Hildenbrand