Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2395008rwo; Thu, 3 Aug 2023 08:46:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOqZGXxLcEiJvfzVmye219NbNpl+vOgGn1T54scYo0wuuzCuYl7Zfrsv7/FzCqmthxihLq X-Received: by 2002:a50:ee95:0:b0:523:102f:3ce0 with SMTP id f21-20020a50ee95000000b00523102f3ce0mr1432522edr.21.1691077611816; Thu, 03 Aug 2023 08:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691077611; cv=none; d=google.com; s=arc-20160816; b=u8fPv+tjWMYRpFk189wuQ/1XcudfzWg8IL0cuKNNVSe7WEVFHk4QCPOF8YVxI5A9OM CYKubwmRjyT/tl4RzsohkhFf2i+vyOuQFRiYHUo8Z9urbbXqxFTXXpQtM/4gDPXidBGX ofHg2Jcc0w5pT8uXsztwp2waU2uk6hC3JE7jxrT1sG+jyOgwxKPvAfrUpRYFerm/IR9G Upj7tBerS5LiuxC4/4vD2KX43AOFLrU+1Kl2ZZ8frnJRkp5DGNPd9Aro2Mra5rCA71Yi seL981fdWNvtMmDbypHC5hf2uoB/R8A/82QIQCAX+jiS4bdzB5uIIbVHwjMDwSOY1GT5 D1tA== 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=5fvDz/G2oKfYF1lRg/Bv4LyzGTOydxYCnQFLIhcefpU=; fh=i3gLtdu9xSzQPPVTj+9s6FBK2YcuZWkS7XUWqyPqS+g=; b=RfTx7GMwAJZho31RDHGvIs9u+DqXOuvsF83as3r98GVJ+kItfHsFhDn6yWvjzLth87 e5wayNAkKq/Sh+KIEgZ5CedU3fzijz4isw3Gj9ifgyjuPWICCNiRDpLm3fboC4/f8/eU 3N4f+5T9IrUKyqFkj7Ezd1uQKoQoUdjq0J2zrS9nje21XYO7WdF2tjYKlweywgo7VXDY BHGjg+QjCx7y28b/G2ge97N1DVFMHy3bb4pqYJZryvNdUbx4JtcKUreEkC+1dFCn75g8 5YSrLQveQVnTVyuPdTEMtm2pScKgdKYrXvUl7X5GsrO4g0AFGPJ80TcRk8MZ2UwCUS5s zpTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LTpUagoM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a50fb09000000b005222bc367e1si2789924edq.98.2023.08.03.08.46.25; Thu, 03 Aug 2023 08:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LTpUagoM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232883AbjHCOdF (ORCPT + 99 others); Thu, 3 Aug 2023 10:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236310AbjHCOdA (ORCPT ); Thu, 3 Aug 2023 10:33:00 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD741728 for ; Thu, 3 Aug 2023 07:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691073137; 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=5fvDz/G2oKfYF1lRg/Bv4LyzGTOydxYCnQFLIhcefpU=; b=LTpUagoMS/Hp0z4tQw7HRYnWFjsp1N7FaUBioeiStUOK2RjuLDwUhol/RnE8yClpAbMAs9 TUbpuMFUOmu1Q+iaX0e4z6OJBDfjwIjiwDrdj156DuJwgT58MCZyn7kMZ3i/yzhyECm9fE s+8nIs1ynpO3NT79locI0XICSfgtgu4= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-223-I45NiEcYM16tOhTdMPGmWQ-1; Thu, 03 Aug 2023 10:32:13 -0400 X-MC-Unique: I45NiEcYM16tOhTdMPGmWQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F8FB3C025BA; Thu, 3 Aug 2023 14:32:13 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6067200B66C; Thu, 3 Aug 2023 14:32:09 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Linus Torvalds , liubo , Peter Xu , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard , Mel Gorman , Shuah Khan , Paolo Bonzini Subject: [PATCH v3 0/7] smaps / mm/gup: fix gup_can_follow_protnone fallout Date: Thu, 3 Aug 2023 16:32:01 +0200 Message-ID: <20230803143208.383663-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 This is agains mm/mm-unstable, but everything except patch #6 and #7 should apply on current master. Especially patch #1 and #2 should go upstream first, so we can let the other stuff mature a bit longer. 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. Patch #1 fixes the known issues by reintroducing FOLL_NUMA as FOLL_HONOR_NUMA_FAULT and decoupling it from FOLL_FORCE. Patch #2 is a cleanup that I think actually fixes some corner cases, so I added a Fixes: tag. Patch #3 makes KVM explicitly set FOLL_HONOR_NUMA_FAULT in the single case where it is required, and documents the situation. Patch #4 then stops implicitly setting FOLL_HONOR_NUMA_FAULT. But note that for FOLL_WRITE we always implicitly honor NUMA hinting faults. Patch #5 cleans up a comments. Patch #6 improves the KVM functional tests such that patch #7 can actually check for one of the known issues: KSM no longer working on PROT_NONE mappings on x86-64 with CONFIG_NUMA_BALANCING. v2 -> V3: * "mm/gup: reintroduce FOLL_NUMA as FOLL_HONOR_NUMA_FAULT" -> Squash one comment removal -> Adjust the KSM comment * smaps: use vm_normal_page_pmd() instead of follow_trans_huge_pmd() -> Move follow_trans_huge_pmd() to mm/internal.h Cc: Andrew Morton Cc: Linus Torvalds Cc: liubo Cc: Peter Xu Cc: Matthew Wilcox Cc: Hugh Dickins Cc: Jason Gunthorpe Cc: John Hubbard Cc: Mel Gorman Cc: Shuah Khan Cc: Paolo Bonzini David Hildenbrand (7): mm/gup: reintroduce FOLL_NUMA as FOLL_HONOR_NUMA_FAULT smaps: use vm_normal_page_pmd() instead of follow_trans_huge_pmd() kvm: explicitly set FOLL_HONOR_NUMA_FAULT in hva_to_pfn_slow() mm/gup: don't implicitly set FOLL_HONOR_NUMA_FAULT pgtable: improve pte_protnone() comment selftest/mm: ksm_functional_tests: test in mmap_and_merge_range() if anything got merged selftest/mm: ksm_functional_tests: Add PROT_NONE test fs/proc/task_mmu.c | 3 +- include/linux/huge_mm.h | 3 - include/linux/mm.h | 21 +++- include/linux/mm_types.h | 9 ++ include/linux/pgtable.h | 16 ++- mm/gup.c | 23 +++- mm/huge_memory.c | 3 +- mm/internal.h | 7 ++ .../selftests/mm/ksm_functional_tests.c | 106 ++++++++++++++++-- virt/kvm/kvm_main.c | 13 ++- 10 files changed, 171 insertions(+), 33 deletions(-) -- 2.41.0