Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp944565pxb; Wed, 1 Sep 2021 13:21:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6K/aZOmuiekvqegd+zRGfi9+PIlXE4ugjtCq4vk4W0dXs5IXMhMN+uk1uOF2hWyTpkYQ1 X-Received: by 2002:a5d:8458:: with SMTP id w24mr1107978ior.168.1630527672086; Wed, 01 Sep 2021 13:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630527672; cv=none; d=google.com; s=arc-20160816; b=SGEsJwOn8c0L583SXVvMJ+jxi/4hdgPUD1lyJDBilOITSBmaEl4EvjS/J9XQcQHZXC 1sr+/8bynzXEYQ9QNCQdm+5mbMa46x4X8Ke5Co9ZtSK3Y/fn6xgIWa1CIWEjFoC2eZuY fIVj1BTFfd3lxFCYYzhCyaeyHkvQNoXXKN8KuHYSijL/ZzgaKXFM4/otgS8c6bqcxdoV kK2nzRFmBJl297OQsSdqd3RBLD+DhG87FDzdzw7AJF/BJVgsi5DabVgWWdX1SQZYpDE6 sKjprLy45s7/bP3wSVfRLM++f/sbfKR4TI+L/eYMSJRl6X67FZ3tUuF81Ax6jGatSKhV rpRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=i0smCMwmVwKCQLrLP9ThmbbkbGXWzmsdDycWPMRoaPI=; b=fmenJBk+Hn7G5t4YL64uucIpVhSxdSHqsmnKOe/ljCYX7yZ/wMZWw2P2n9qz9AzVHP f/mZJIOrqSj8Qh9UsrnBBGyUVqhso4McWAKsubfX7Vc+NEtRQhvRPjtHSs0cUShQ08MO 1AjsrzX/5Qvk43G3MPQx/zplW4RUwzOYdDIgQEd64PFdwRan2pEwNPhawQe1J1E5ok0I YzQ5VWNlKd7/S0ztlcFDiSSeLKYjAVVn/Fq20oQt4VyGw+MbIJ4vIRrKzgJrP0EDRWcs sd9fuBaoHlnQcfJJGfqT8IN4XIsiWniFmIsFw681lcKgWmEsL19gV6fCCg7NsAP9yQUv fcRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FqeA51nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si507180ioz.23.2021.09.01.13.21.00; Wed, 01 Sep 2021 13:21:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FqeA51nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231669AbhIAR7w (ORCPT + 99 others); Wed, 1 Sep 2021 13:59:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23735 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233691AbhIAR7v (ORCPT ); Wed, 1 Sep 2021 13:59:51 -0400 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-181-RvHv0luAMrSHHJ8-8JnbJQ-1; Wed, 01 Sep 2021 13:58:50 -0400 X-MC-Unique: RvHv0luAMrSHHJ8-8JnbJQ-1 Received: by mail-wm1-f71.google.com with SMTP id r4-20020a1c4404000000b002e728beb9fbso135945wma.9 for ; Wed, 01 Sep 2021 10:58:49 -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=aFNIhf3l5xq2OoYmKAbs9sy5CqoDzxqubol/6IgP3R6Y43sFGMRFBIlaH1Lw3jlocT 5VwALe+GigK40QdSBEhCj0YpTI1tJTZT59C01UD3uOTOI0yO0LZ4kDU2q/LjzLYo3zR6 zE1dfntsr6AztyFw1gkfLq7x678mcL63lE5THV8nqiyQ0hgctRhyfZoQPMnAWfvmxfQk wV+Ew9MmzadNeb8ai0viBaBY4sbwJp8HoPWugxi+XI3wuvrSiUyh4uqo5i0UNLpGEd+R a3N2uG6FBnIq9yv0+iAVw6qvs+LM/u9g/hnPBNGIoCVZrv6l6+XVpxlNFaSjiANSJ+5D XvFA== X-Gm-Message-State: AOAM530vwQX7cJn2CsDHpL3ySkDGsVu+GpKZ1F171mPGwYYcLbMGOu/F OdieKTCx1uS7LB82tyv9UN8UB/OUN0w7hz3Zmlg1fpGrDxVIfFK53yfXNzT3hqTAnbugspyCeYe 7N/9fjrrAtF/8IR7k+cnUBZW9 X-Received: by 2002:a1c:1904:: with SMTP id 4mr632316wmz.93.1630519129027; Wed, 01 Sep 2021 10:58:49 -0700 (PDT) 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> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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