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=-8.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 C20D7C432BE for ; Wed, 1 Sep 2021 17:58:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 64E5260F23 for ; Wed, 1 Sep 2021 17:58:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 64E5260F23 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 E07BE8D0002; Wed, 1 Sep 2021 13:58:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB6F58D0001; Wed, 1 Sep 2021 13:58:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7E5A8D0002; Wed, 1 Sep 2021 13:58:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id B55428D0001 for ; Wed, 1 Sep 2021 13:58:52 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 67BF1181CC1C1 for ; Wed, 1 Sep 2021 17:58:52 +0000 (UTC) X-FDA: 78539765304.31.1420754 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 0D550B0000A3 for ; Wed, 1 Sep 2021 17:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630519131; 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=i0smCMwmVwKCQLrLP9ThmbbkbGXWzmsdDycWPMRoaPI=; b=FqeA51nNxEr45U1Hodx0kjGDpjN84euYLpZkB/Olc6ERQETkVDdUyvNFdNrUMINXfpDjx2 jD3q8IGyqDA7ctFe1YpIY195KoviQ+hA+yoqp5Vw9gYzfjwXybt3GFW8a2p9a9Lla8JeBK nLUF8H90m04e8i111DlOWekTLQZ6Djw= 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-204-EFmF58EIOQCAiFBBmz81CA-1; Wed, 01 Sep 2021 13:58:50 -0400 X-MC-Unique: EFmF58EIOQCAiFBBmz81CA-1 Received: by mail-wm1-f71.google.com with SMTP id u14-20020a7bcb0e0000b0290248831d46e4so115027wmj.6 for ; Wed, 01 Sep 2021 10:58:50 -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=i0smCMwmVwKCQLrLP9ThmbbkbGXWzmsdDycWPMRoaPI=; b=iBkTSbzR7X/leO1/Yof1LHq6wAfW+YEfHU8AWHpByGbYCeLnB8t6sjnKhbFkSqg4Jw 8VU9vZ2P9KzuzvHiSUxuJF3+3205Ka0gS/q+pkEJd+sO3t1pDCj7ichPmVFNz83bWl1r Mf/8In98I97CCZKDyPTfjnzkqH8+6JMiEccD82p/Qm25IkEndAPhIrLSs2bUHMizjwKu ksFgOVVBLM+e44Csw4LyBtJoOowUhsObUcGqUah8L6sPCdtQxqn6NXLstgDbtLfgZNE9 PMSFTSlUzUy/UYWjH6ORbp3SE99dxgr0tx+kvUKMutLVPmi4XBLP1yzx43gfzMzVvqxN cESQ== X-Gm-Message-State: AOAM532PrH3bY+zAcMPEy5WoLcsCpQiuSrY//ohsPq6VXg+gyLt0sLuJ I4RZA6UEZqd3wZfRnLYo0zWM8XCF1Ck77Ko1n1tOgMfNI6KxC/irc/0bLeV5nRGSKi0jJKAnr/R oKu5HHSQZNeQ= X-Received: by 2002:a1c:1904:: with SMTP id 4mr632347wmz.93.1630519129469; Wed, 01 Sep 2021 10:58:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznn407qu+Ost99CYfe2lcliOS2h2St5mYG0lHHVc+4MOX4G0xXAv7RYLIHHtKhlQzOV2LngA== X-Received: by 2002:a1c:1904:: with SMTP id 4mr632301wmz.93.1630519128815; Wed, 01 Sep 2021 10:58:48 -0700 (PDT) Received: from [192.168.3.132] (p4ff23f71.dip0.t-ipconnect.de. [79.242.63.113]) by smtp.gmail.com with ESMTPSA id t14sm224966wmi.12.2021.09.01.10.58.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 10:58:48 -0700 (PDT) Subject: Re: [PATCH v2 6/9] mm: free user PTE page table pages To: Jason Gunthorpe Cc: Qi Zheng , 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> <0c9766c9-6e8b-5445-83dc-9f2b71a76b4f@redhat.com> <20210901153247.GJ1721383@nvidia.com> <7789261d-6a64-c47b-be6c-c9be680e5d33@redhat.com> <20210901161613.GN1721383@nvidia.com> <20210901171039.GO1721383@nvidia.com> <20210901175547.GP1721383@nvidia.com> From: David Hildenbrand Organization: Red Hat Message-ID: <52ba8125-0382-3270-a958-ed113ae1db2a@redhat.com> Date: Wed, 1 Sep 2021 19:58:47 +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: <20210901175547.GP1721383@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: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FqeA51nN; spf=none (imf19.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: 0D550B0000A3 X-Stat-Signature: imqhiawwqu6ggxdoursc17bo51zss53u X-HE-Tag: 1630519131-538392 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 19:55, Jason Gunthorpe wrote: > On Wed, Sep 01, 2021 at 07:49:23PM +0200, David Hildenbrand wrote: >> On 01.09.21 19:10, Jason Gunthorpe wrote: >>> On Wed, Sep 01, 2021 at 06:19:03PM +0200, David Hildenbrand wrote: >>> >>>>> I wouldn't think it works everywhere, bit it works in a lot of places, >>>>> and it is a heck of a lot better than what is proposed here. I'd >>>>> rather see the places that can use it be moved, and the few places >>>>> that can't be opencoded. >>>> >>>> Well, I used ptep_get_map_lock() and friends. But hacking directly into >>>> ptep_map_lock() and friends wasn't possible due to all the corner cases. >>> >>> Sure, I'm not surprised you can't get every single case, but that just >>> suggest we need two API families, today's to support the special cases >>> and a different one for the other regular simple cases. >>> >>> A new function family pte_try_map/_locked() and paired unmap that can >>> internally do the recounting and THP trickery and convert the easy >>> callsites. >>> >>> Very rough counting suggest at least half of the pte_offset_map_lock() >>> call sites can trivially use the simpler API. >>> >>> The other cases can stay as is and get open coded refcounts, or maybe >>> someone will have a better idea once they are more clearly identified. >>> >>> But I don't think we should take a performance hit of additional >>> atomics in cases like GUP where this is trivially delt with by using a >>> better API. >> >> Right, but as I said in the cover letter, we can happily optimize once we >> have the basic infrastructure in place and properly reviewed. Getting rid of >> some unnecessary atomics by introducing additional fancy helpers falls under >> that category. > > I'm not sure I agree given how big and wide this patch series is. It > would be easier to review if it was touching less places. The helpers > are not fancy, it is a logical re-arrangement of existing code that > shrinks the LOC of this series and makes it more reviewable. You'll most likely have to touch each and every place either way, for example when suddenly returning "null" instead of a pte. It's just a matter of making this easier to review and the changes as minimal and as clear as possible. > > Or stated another way, a niche feature like this try much harder not > to add more complexity everywhere. I fully agree. -- Thanks, David / dhildenb