Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5786521rwb; Tue, 1 Aug 2023 07:58:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlGRkXHEyKqanKkDVsDwchhgNeZt13xDnEc5ug0muMMBzc4jwtt6m8jg8SsPmBLacyCmX7wx X-Received: by 2002:a17:90a:3b0b:b0:263:4157:66de with SMTP id d11-20020a17090a3b0b00b00263415766demr10037631pjc.42.1690901883868; Tue, 01 Aug 2023 07:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690901883; cv=none; d=google.com; s=arc-20160816; b=GKBSyAd61YB8S3PoClNyfFSBBTtDrTcPVp2QdXgmXuEr0NGhTIedq12Lv8U5oGuclD ksj2+9AA0aTy5YPywvi5ZJrX6HHor5JlyLAaQ6ryfmuG2kkCeK4uBeI3WTwDU9TD+Weo zX6WB9TEt72JI+FLZPB9lzpVEHydv6BrD3GdA1HH7jKiLbirI2R2aLGXvkCS1gtDT4cJ B65GPb6JnfU/V4cpdZ4z/dSiY+YBPFB1lu+HaRDAeFKtfqOJnkZsEZcrWmbM+wTTXlcB qBB/2Sr/CH8WYVNTy779F6Rjm/ZgpsuEkYaNe7OWYLMwvSBQ72gHEbmhor5pZeIgweXV wukw== 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=RHFvfXcP0yrcIaYOdQEvaIRqqVbMZney2Vh1PcaD7Io=; fh=i3gLtdu9xSzQPPVTj+9s6FBK2YcuZWkS7XUWqyPqS+g=; b=AZZ0fapr2M+DAnGU9o5nFGrIftjMgHJfoiW0tW1lrg44mg/oSBDOqW/0nOvsawHlY1 MOOKotC7ysVHpFSxqm9WPwQDR8lCVwiAWY+FNQnaB+esLqXX7ilgsoIDKAECdYMiK+Xk JJ/4DHfgTdrDDQOZQruPCP2wzSr/oKPo8+/velEu/PRBpN4B4EHrMk6/UZ9JfMFgtucA wmmmYS1Qhl9pbZdUeh07hV4uMl5sA3DKtTVGvoGlTt8RTssqeuB0JE9Xee5ednUoWnT4 w0Imnw/bqyIEnG3PRAIetTmBaYbO+Kd2ka7EO5WZVQLPMEbhpZsOWX7eIWrBBRk4lrFS FpZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W3mkAxeZ; 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 s10-20020a17090aad8a00b0025945de4165si92612pjq.141.2023.08.01.07.57.47; Tue, 01 Aug 2023 07:58:03 -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=W3mkAxeZ; 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 S232430AbjHAMtn (ORCPT + 99 others); Tue, 1 Aug 2023 08:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232396AbjHAMtk (ORCPT ); Tue, 1 Aug 2023 08:49:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF8C1FD0 for ; Tue, 1 Aug 2023 05:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690894134; 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=RHFvfXcP0yrcIaYOdQEvaIRqqVbMZney2Vh1PcaD7Io=; b=W3mkAxeZWOeZ3UlklGmbIDgoiXzjwmb9GKjN3dkT/bMUROwk//mtdNSoP6gWsLGd9Vk8qj GFbcFAPyv1ypl+UFJI1qMxZmzz/AFHJ5fhyorjGh4HzS1O4QFCOJk9HUVc10ZrmKNkqM4L 9XRWd/ony4A37gsX7IL7Kpxu/0oIEO0= 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-46-92PRgIToNqSHCN5sbvkKmg-1; Tue, 01 Aug 2023 08:48:50 -0400 X-MC-Unique: 92PRgIToNqSHCN5sbvkKmg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8876C3C14AA4; Tue, 1 Aug 2023 12:48:49 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7B1EC585A0; Tue, 1 Aug 2023 12:48:45 +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 v2 0/8] smaps / mm/gup: fix gup_can_follow_protnone fallout Date: Tue, 1 Aug 2023 14:48:36 +0200 Message-ID: <20230801124844.278698-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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_BLOCKED,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 #7 and #8 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. Next attempt 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. 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 and patch #6 cleanup some comments. Patch #7 improves the KVM functional tests such that patch #8 can actually check for one of the known issues: KSM no longer working on PROT_NONE mappings on x86-64 with CONFIG_NUMA_BALANCING. 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 (8): 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 mm/huge_memory: remove stale NUMA hinting comment from follow_trans_huge_pmd() 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/mm.h | 21 +++- include/linux/mm_types.h | 9 ++ include/linux/pgtable.h | 16 ++- mm/gup.c | 23 +++- mm/huge_memory.c | 3 +- .../selftests/mm/ksm_functional_tests.c | 106 ++++++++++++++++-- virt/kvm/kvm_main.c | 13 ++- 8 files changed, 164 insertions(+), 30 deletions(-) -- 2.41.0