From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19402C432BE for ; Wed, 1 Sep 2021 13:57:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A3F2261026 for ; Wed, 1 Sep 2021 13:57:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A3F2261026 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0488A6B006C; Wed, 1 Sep 2021 09:57:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F398C6B0071; Wed, 1 Sep 2021 09:57:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE5256B0072; Wed, 1 Sep 2021 09:57:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id CB9DA6B006C for ; Wed, 1 Sep 2021 09:57:14 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7D1111822BC54 for ; Wed, 1 Sep 2021 13:57:14 +0000 (UTC) X-FDA: 78539156388.17.AC82634 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 1704D3000108 for ; Wed, 1 Sep 2021 13:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630504633; 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=AtcCp/E1mJH1qo6IRVdtwg5GdGZiUHZsdrfrSmluGPA=; b=VuPqDJv8AFrvgzkai9909dFiMxU5ZVEWTKtmvpn/6eRbw51WjVjJDsZLXZ6zC4GN5ZssKe dduJsHLf163L1Uo+hOmnqydSrj04lZIMg+k6gEP/F4qH3JHa8yzwBAXWqI6W0VL1c2G0U4 dG1kLjFn5MMv4BsY8D7GU/Kj6xOQJxM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-gku6C1amOVuVaJLESg7oaw-1; Wed, 01 Sep 2021 09:57:12 -0400 X-MC-Unique: gku6C1amOVuVaJLESg7oaw-1 Received: by mail-wm1-f71.google.com with SMTP id y188-20020a1c7dc5000000b002e80e0b2f87so2878322wmc.1 for ; Wed, 01 Sep 2021 06:57:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=AtcCp/E1mJH1qo6IRVdtwg5GdGZiUHZsdrfrSmluGPA=; b=BEkHGxqgMmi4Cq4yd/Bb8Bz0cpVBwiSeBXwhCl3xn68Ux/nJKPVACAaUETZ4uQvYCk bh4ihrCU+pBeChbf53uMT9lxZsz3/sCahfP2cBdpDuzQvfqn3B7fOCQH0KmNx8Nq1mps KJMVbJqysPr3psbBDBIlbNfbwmAqihuazpEQGRVtjuNLJJbNPhgt8ntXBdseMKFzF9Qb 3SGz8/CciV8bZbv9wqGFKrlL2tqGY9QSxV5lUyPZhfboN+fK8Op6WMVtIce38vQpXll0 ODnx0V8YDQdudT4hK4O1or3k8F7vqiUMLRHwH9n/QLwZV0g3bm8XehTK8BolY+sUG5ZT uMKw== X-Gm-Message-State: AOAM531vc5r/zDPFSvobh1sb6JuPg9ld5O612C80dyIXFgqnNFkyySNG ICpxttKsCBHJnyzS0GoUKj7qn37G+WG9EmD30JoJu3LYGbTK3dxugPW6EY0Wl1+taL7n+07xu7F jwrbr/ODORwY= X-Received: by 2002:adf:f403:: with SMTP id g3mr36321531wro.206.1630504631367; Wed, 01 Sep 2021 06:57:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8AAzCiaIzpXWN507TidFNNd5TOET80fPvXM2IZjrsm98BojK/EWo12Z9GfuLAARluEbknaA== X-Received: by 2002:adf:f403:: with SMTP id g3mr36321499wro.206.1630504631115; Wed, 01 Sep 2021 06:57:11 -0700 (PDT) Received: from [192.168.3.132] (p4ff23f71.dip0.t-ipconnect.de. [79.242.63.113]) by smtp.gmail.com with ESMTPSA id u16sm5978489wmc.41.2021.09.01.06.57.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 06:57:10 -0700 (PDT) Subject: Re: [PATCH v2 6/9] mm: free user PTE page table pages To: Jason Gunthorpe , Qi Zheng Cc: akpm@linux-foundation.org, tglx@linutronix.de, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com References: <20210819031858.98043-1-zhengqi.arch@bytedance.com> <20210819031858.98043-7-zhengqi.arch@bytedance.com> <20210901135314.GA1859446@nvidia.com> From: David Hildenbrand Organization: Red Hat Message-ID: <0c9766c9-6e8b-5445-83dc-9f2b71a76b4f@redhat.com> Date: Wed, 1 Sep 2021 15:57:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210901135314.GA1859446@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VuPqDJv8; spf=none (imf09.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1704D3000108 X-Stat-Signature: 49amfyuh4bob4s75iutdyd841x586srf X-HE-Tag: 1630504633-587058 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: On 01.09.21 15:53, Jason Gunthorpe wrote: > On Thu, Aug 19, 2021 at 11:18:55AM +0800, Qi Zheng wrote: > >> diff --git a/mm/gup.c b/mm/gup.c >> index 2630ed1bb4f4..30757f3b176c 100644 >> +++ b/mm/gup.c >> @@ -500,6 +500,9 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, >> if (unlikely(pmd_bad(*pmd))) >> return no_page_table(vma, flags); >> >> + if (!pte_try_get(mm, pmd)) >> + return no_page_table(vma, flags); >> + >> ptep = pte_offset_map_lock(mm, pmd, address, &ptl); > > This is not good on a performance path, the pte_try_get() is > locking/locking the same lock that pte_offset_map_lock() is getting. Yes, and we really need patch #8, anything else is just confusing reviewers. > > This would be much better if the map_lock infra could manage the > refcount itself. > > I'm also not really keen on adding ptl level locking to all the > currently no-lock paths. If we are doing that then the no-lock paths > should rely on the ptl for alot more of their operations and avoid the > complicatred no-lock data access we have. eg 'pte_try_get()' should > also copy the pte_t under the lock. > > Also, I don't really understand how this scheme works with > get_user_pages_fast. With the RCU change it in #8 it should work just fine, because RCU synchronize has to wait either until all other CPUs have left the RCU read section, or re-enabled interrupts. -- Thanks, David / dhildenb