Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1590032rwb; Fri, 28 Jul 2023 11:39:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGlR0NdUnHZs3dvBzspybVVtt0qU8e9VrBJLnaClIWZ9NLuA5Okwyfc+KIx6vNXkOy3T4GY X-Received: by 2002:a2e:854d:0:b0:2b6:d89e:74e2 with SMTP id u13-20020a2e854d000000b002b6d89e74e2mr2275461ljj.7.1690569570416; Fri, 28 Jul 2023 11:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690569570; cv=none; d=google.com; s=arc-20160816; b=MzqAz+BIoWskYCjpGPP/r6nbIHQN5gtQM3YqwkGoNcNlVL0ad2Im0FlhS2mpE993pc jL6vy1vK9ckn5uIguAHO86jL2P0q4/Wny4tNyUNJ32oTdzaRPqPmqwGYP9xuLqFsX3Dy sJkdwu85aWW00dd/JBxFwphvP3A5Ndy4LBxTptgw+d+ti338JCp8h7xXkfgcDfHhmPci 4dLIAiit7Iy/moAO1WtIc+zWMejooM86xiZlcuxf0qtaNJfeAqaJp+SpPwMATuBd98Zv QDYv6xd9ZxC269QIMdCr5pSdcdlPCBUxj5t6te16nBu9Q5hzbQqzfhmNwj4Bot4LynmR B6UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=Z5BKzqiVvDxpi79QFmZnEbX/IsAn0VcOVhbxmE8BoKs=; fh=swwBzVQEc4y2COoGcDxLnjg722uebS+qqffxeHzXKV0=; b=zA25JWABPbojWNKhGMWbU9IbQIzBu6tezzA8Jl6r4+bsGXc3FgJ0lKSaWTHXeUaAo1 q85cWn6heH24+nOSCrZ84CB0oJcVJyNgsw8OWIDoNkwkYTI80OdF+JLF68oXlgS8B26P K2dkKFpehkH0E5XSZL2VuTig2RIHHJav8OgGFJ7OAt1sgilDfLcez/E9n+dw0tM4p6lX HWlC0+QpwZ4lmBh21F+lWmV+X5MvpiDSc2sEoOuV/P0+jIjrkjSOjCUFLoOvxYBIvZBe 6SS+aYxxdSh6LoxkIxdM3ZL2KiR/6MNPjQChLEZL/3MyEe7KT/nPFICjtGsMue2sMGyI eg5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mgr42134; 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 w23-20020a1709061f1700b0098e78ff1a8fsi3187932ejj.358.2023.07.28.11.39.05; Fri, 28 Jul 2023 11:39:30 -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=Mgr42134; 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 S233478AbjG1Rz5 (ORCPT + 99 others); Fri, 28 Jul 2023 13:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232346AbjG1Rzt (ORCPT ); Fri, 28 Jul 2023 13:55:49 -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 32BD410CB for ; Fri, 28 Jul 2023 10:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690566899; 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=Z5BKzqiVvDxpi79QFmZnEbX/IsAn0VcOVhbxmE8BoKs=; b=Mgr42134k7//Fz4TY5OJV5SMK70WnwtrAcSW9xoR97WffnTYaSG+NWSX5n8sqvNKBogowr 0A07ZaIfoqmutHFCLDsx/dW6U7cwaltlkNSkXGJpTI5OppSUNid94uCIRiCq/fItG5RrZj D1xDmvbh7D+GhrxGE+HtI87h5P0kza8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-R7tNtWu2N0Wax3teaPI3rw-1; Fri, 28 Jul 2023 13:54:57 -0400 X-MC-Unique: R7tNtWu2N0Wax3teaPI3rw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f42bcef2acso12849185e9.2 for ; Fri, 28 Jul 2023 10:54:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690566896; x=1691171696; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z5BKzqiVvDxpi79QFmZnEbX/IsAn0VcOVhbxmE8BoKs=; b=MdfgAvs5MGqj9GNtuaxyeukRXYJJf8TAWpcJ5Y+xy7WmiayfZ8h4qq2Gg+uHG6QO0F AKyMLi3DQrcmi9Gd+xc8aV4FjYs97lU3d+yC7djIGopN3cUBZEq+Te/EWnn4jbl5FeHG qvuQVN1zZXamu5V39ZvpdCbPg77I6IXtauLhHvvYS9POpS9S2rmN48HB6NPLrbQewIs5 nYRgYylM2Zz6+pRgh7fg0ul3YDLEWIQcihi5PpoArFe64aDAl3dsftok5NvQMLDoi6CC TN837x2XiT9SYcr3ftInftQwybKZ3TwA/6nH+Dq13OFKnqdlH3LiVa75FWhXN7wm4q53 Ezkg== X-Gm-Message-State: ABy/qLZC5Pzk1j6LyOvYzsJEZGqyQsfGubF6Z8/ccO9JotkQayOXIErk cOuFq4Ah2pbLCB0vfAlAbmMLDzlosby9dzsqwDRS0jnjqficMMjg5lytS4FykwoW1QcCvItBtaf 4noLHQ7taEfFjMupTrc33APuQ X-Received: by 2002:a7b:cd8c:0:b0:3fb:fa9f:5292 with SMTP id y12-20020a7bcd8c000000b003fbfa9f5292mr2354778wmj.25.1690566896496; Fri, 28 Jul 2023 10:54:56 -0700 (PDT) X-Received: by 2002:a7b:cd8c:0:b0:3fb:fa9f:5292 with SMTP id y12-20020a7bcd8c000000b003fbfa9f5292mr2354756wmj.25.1690566896027; Fri, 28 Jul 2023 10:54:56 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:6b00:bf49:f14b:380d:f871? (p200300cbc7066b00bf49f14b380df871.dip0.t-ipconnect.de. [2003:cb:c706:6b00:bf49:f14b:380d:f871]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c029100b003f9bd9e3226sm4760553wmk.7.2023.07.28.10.54.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jul 2023 10:54:55 -0700 (PDT) Message-ID: <29a7a660-ea24-abcd-ba7a-beef9c074340@redhat.com> Date: Fri, 28 Jul 2023 19:54:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 0/4] smaps / mm/gup: fix gup_can_follow_protnone fallout Content-Language: en-US From: David Hildenbrand To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Andrew Morton , liubo , Peter Xu , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard , Mel Gorman References: <20230727212845.135673-1-david@redhat.com> Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 [...] > > There was the case for "FOLL_PIN represents application behavior and > should trigger NUMA faults", but I guess that can be ignored. > > But it would be much better to just remove all that if we can. > > Let me look into some details. I just stumbled over the comment from Mel in follow_trans_huge_pmd(): /* Full NUMA hinting faults to serialise migration in fault paths */ It dates back to commit 2b4847e73004c10ae6666c2e27b5c5430aed8698 Author: Mel Gorman Date: Wed Dec 18 17:08:32 2013 -0800 mm: numa: serialise parallel get_user_page against THP migration Base pages are unmapped and flushed from cache and TLB during normal page migration and replaced with a migration entry that causes any parallel NUMA hinting fault or gup to block until migration completes. THP does not unmap pages due to a lack of support for migration entries at a PMD level. This allows races with get_user_pages and get_user_pages_fast which commit 3f926ab945b6 ("mm: Close races between THP migration and PMD numa clearing") made worse by introducing a pmd_clear_flush(). This patch forces get_user_page (fast and normal) on a pmd_numa page to go through the slow get_user_page path where it will serialise against THP migration and properly account for the NUMA hinting fault. On the migration side the page table lock is taken for each PTE update. We nowadays do have migration entries at PMD level -- and setting FOLL_FORCE could similarly trigger such a race. So I suspect we're good. -- Cheers, David / dhildenb