Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1182011rwo; Wed, 2 Aug 2023 09:52:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHb6wUS4b9yNseWdzf3DOy9Vxc+BKcXqWJK+Q2o6bJ/pvpzb2LLN8nPrOlLxKqVnZkuBggS X-Received: by 2002:a17:907:760e:b0:987:47b3:6e34 with SMTP id jx14-20020a170907760e00b0098747b36e34mr5335217ejc.67.1690995164572; Wed, 02 Aug 2023 09:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690995164; cv=none; d=google.com; s=arc-20160816; b=JTXkUnZH2GK8aDK8hroiIgImICHtfcm578BrGiM+nJb80CyYwsI5KZqkTz1lfOJgee 6iTdX1aqfxEy6Tssz0FlXDVtGFTa0f+Kvl4yEcM+AuG6VmRbqBenvPXq5Y8KABLIK7zp jsEUCpIJHGbXLvKJqaUET6Tkn48lGwBwEL8zNKH8RJ438+ww/9OTJ7YnvucDA7hnicfp nKaNmE2q0MfsYTf2FI7h3B1Tmlz0wWNOvITL54H6wn95FtHeCjbl1xkZSm7YABcFu02e O7gXiKZw52VYhQ/HZ+TyC47fTBVaI9NU+v+1iInvx3tHhzCVLQ17+xpeRHOGs+m2wxmJ m6Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=BFrX2TWcBsNAzS89yEbXMhB7TcCvpaFVUFRIexqnHg0=; fh=K5NbtB26YhV+Mdx56/qT+0tOtX6B88Nxuz6hWFFdYLM=; b=vP1qG3NSk7Q1XBx75aCdpiNEQNf6P8fi4OMdJvQjeO9cnMwKIQexMPoGHFcV/TtdTJ Qcq+TLPqMavJ9ZeobeImBgQGKMBzkDyInHzeeuOF5pZpa8gqJQD53qolZrQO0q/w2x8C /5Yqc5UD5R77ua9Mm7K2/cl1Z/XVIAHFguenG0/s9Q1dE/r5EF6nAECNByHS5MPGS5BC oafVlG9y6yBaWU8qk7aIGH1lUUAQ6ez/xAigC5KsDAsTt9oVRfcCNKN6MciVj39VEtJR kFXOlbG4I8q5keemLO/7W+2DEvCVAghW9k4vWH7kkj2OTWmQLP/CxuxvVhMK/XFZRoqo 3dlQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq6-20020a170906d0c600b00992e0f4e861si10710232ejb.236.2023.08.02.09.52.19; Wed, 02 Aug 2023 09:52:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235129AbjHBPak (ORCPT + 99 others); Wed, 2 Aug 2023 11:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233127AbjHBPaZ (ORCPT ); Wed, 2 Aug 2023 11:30:25 -0400 Received: from outbound-smtp52.blacknight.com (outbound-smtp52.blacknight.com [46.22.136.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2ACFF for ; Wed, 2 Aug 2023 08:28:51 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp52.blacknight.com (Postfix) with ESMTPS id EF8A1FAE5C for ; Wed, 2 Aug 2023 16:28:49 +0100 (IST) Received: (qmail 12428 invoked from network); 2 Aug 2023 15:28:49 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.20.191]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 2 Aug 2023 15:28:49 -0000 Date: Wed, 2 Aug 2023 16:28:47 +0100 From: Mel Gorman To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrew Morton , Linus Torvalds , liubo , Peter Xu , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard , Mel Gorman , Shuah Khan , Paolo Bonzini Subject: Re: [PATCH v2 4/8] mm/gup: don't implicitly set FOLL_HONOR_NUMA_FAULT Message-ID: <20230802152847.c3pz5o4pfsmkuv3u@techsingularity.net> References: <20230801124844.278698-1-david@redhat.com> <20230801124844.278698-5-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230801124844.278698-5-david@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, Aug 01, 2023 at 02:48:40PM +0200, David Hildenbrand wrote: > Commit 0b9d705297b2 ("mm: numa: Support NUMA hinting page faults from > gup/gup_fast") from 2012 documented as the primary reason why we would want > to handle NUMA hinting faults from GUP: > > KVM secondary MMU page faults will trigger the NUMA hinting page > faults through gup_fast -> get_user_pages -> follow_page -> > handle_mm_fault. > > That is still the case today, and relevant KVM code has been converted to > manually set FOLL_HONOR_NUMA_FAULT. So let's stop setting > FOLL_HONOR_NUMA_FAULT for all GUP users and cross fingers that not that > many other ones that really require such handling for autonuma remain. > > Possible interaction with MMU notifiers: > > Assume a driver obtains a page using get_user_pages() to map it into > a secondary MMU, and uses the MMU notifier framework to get notified on > changes. > > Assume get_user_pages() succeeded on a PROT_NONE-mapped page (because > FOLL_HONOR_NUMA_FAULT is not set) in an accessible VMA and the page is > mapped into a secondary MMU. Once user space would turn that mapping > inaccessible using mprotect(PROT_NONE), the actual PTE in the page table > might not change. If the MMU notifier would be smart and optimize for that > case "why notify if the PTE didn't change", that could be problematic. > > At least change_pmd_range() with MMU_NOTIFY_PROTECTION_VMA for now does an > unconditional mmu_notifier_invalidate_range_start() -> > mmu_notifier_invalidate_range_end() and should be fine. > > Note that even if a PTE in an accessible VMA is pte_protnone(), the > underlying page might be accessed by a secondary MMU that does not set > FOLL_HONOR_NUMA_FAULT, and test_young() MMU notifiers would return "true". > > Signed-off-by: David Hildenbrand Also seems sane but a large portion of its correctness also depends on patch 3 being correct. -- Mel Gorman SUSE Labs