Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp767617pxb; Tue, 2 Feb 2021 18:05:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbYf9V/6GsP/nmYWf0sjj6izvmLZZxf/7C28JNhtnT3NmL5JLfq4qIQnKlV3DR2gogn/6P X-Received: by 2002:a17:906:3b8e:: with SMTP id u14mr871631ejf.179.1612317909193; Tue, 02 Feb 2021 18:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612317909; cv=none; d=google.com; s=arc-20160816; b=GBCEStlMBlA9XoL3EZuRLZuuk/E7QWEVCJrz0uaTh9+/uKM4toyY9lwZiEzRsvd0BU Jo1OIsas8TAp5EQtjAUeDn/FXbaCwik47kOVfiFfZaeS8Dp2ZCtQn4P3csKNTAGeZwLp 0D3D2VJb98IzETQH2Leb2LVRTvKSKFDhrbNH2uMrbyo6+rH6SGIwAKaps4sw/lD0FLGw uW6+dg3XifetFDjlKZyxmloF2BrLMaulK6jjzv9POQribEfZAIiOJRpe19YvIKUZVfem EudWyTZq+WfVAVmLNSJXwpCI2R/gcghr/jIYvoRu7Rr51wXThOcFQC87eeYctbYS/SsU IqSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=k1d6YTsPbefNP98n7kugOKyTm/5Jjwmgp6qDjgryobQ=; b=wRd6KCnAdPyhl3gumFlFOM90iQ/4+ZFuWi7H3QfkwlvoDPmETFUkW2NFYjsCQCJJW/ N6HK0FRLrFmOGwo2bPsSB/n5YnVO6VgE2qae7Xqi5XLBL6QKndDq+4Mwojdzr0e1pocR 3qa9ZHFjyUKGDnOyMHjy2ii7DaAqin2akdBbuzqTu52PNX+Bnr90sPp9zjJ62EhCEyIt 7wwk7b+IMxge6UvFKDzjuFw5jChMa4i+p89KVKRoWM8995jDXn9oj4TgxzL3qy2Miwth QY9p6TeCahaFI9/eIzdQRsw/hkMCpJBkUnAgvhvOpwVe/vdaSschzzBZp04xSGLbLDYW 8vxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YTpxuQQ5; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a27si449120ejc.18.2021.02.02.18.04.44; Tue, 02 Feb 2021 18:05:09 -0800 (PST) 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=@google.com header.s=20161025 header.b=YTpxuQQ5; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbhBCCDB (ORCPT + 99 others); Tue, 2 Feb 2021 21:03:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbhBCCCz (ORCPT ); Tue, 2 Feb 2021 21:02:55 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D661DC06174A for ; Tue, 2 Feb 2021 18:02:14 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id a1so22450733wrq.6 for ; Tue, 02 Feb 2021 18:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k1d6YTsPbefNP98n7kugOKyTm/5Jjwmgp6qDjgryobQ=; b=YTpxuQQ56VEKPyP5QRwFOXD5rzq90h+zb0bL5zaHyoZAGpubAhVDWr6tVquoLfUHXY 8Bgskv29OXx/jlR9EGtJIj2o0B36+WZncwc30a96duFnTOR6NIS20pOkUXRH1YLOzXjx rd796bWXm93rjoNLs5XewciYkKHyTn0eFOpN5IkEe8j0OFbNs/YrOetNsTJ6nmGccTFF ppqnrLaeHkAtN+jfTW3sILXbMs+y+eKWJtYUCP90lE6ejamVvj0wYtOVvAMo/jMCTtxl VNobZKCa1yOaQeNS8a2B0xxWxeuJgYXvbwrr101FjA/2VRquOyZZ58akT0yeyVEGoY5c ac0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k1d6YTsPbefNP98n7kugOKyTm/5Jjwmgp6qDjgryobQ=; b=eskwViIfk1bejKqwZNaZSUmxqWoQZEnGATbRYJJO/WkEsWpJjZIc3vItmq6OzfHvaz tBa+/aTdE3SEpPvGhvPbb6BwkZjDmPGntLIIYDMdqntu5q+3NRyc3Cw5e4uHFovO6Esp SclbAwylizVIRjWVC5cvk4Qkr1iuHt6Th8iD3vN2yn+76Tn8MtFXP1eW/BoVO1JLV17W hbwZtYrlLwIAL34Ogezd1UcsuHMsFFTi2LPOBfcyAFbJzyyzM6oITU801Kr74aQDemj7 lK3XXZERMn/MlqHzhlTCl3XUKCMq+As8G9Gi5UShLkS9N8pxGjLu0sAe6c9uzFRDbQyW Yo+g== X-Gm-Message-State: AOAM530e+1laYWj7ofuJBOyp0/QXz7RjxRdKBzgcNVGckPJSteV4HqYl BTYzPLzshOqM/nRJkS/Jr3tadjg/W1119Y/6qYTAqw== X-Received: by 2002:adf:e50e:: with SMTP id j14mr860530wrm.162.1612317733369; Tue, 02 Feb 2021 18:02:13 -0800 (PST) MIME-Version: 1.0 References: <20210203003134.2422308-1-surenb@google.com> <20210203003134.2422308-2-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 2 Feb 2021 18:02:01 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] dma-buf: heaps: Map system heap pages as managed by linux vm To: Minchan Kim Cc: Sumit Semwal , Andrew Morton , Christoph Hellwig , Liam Mark , labbott@redhat.com, Brian Starkey , John Stultz , =?UTF-8?Q?Christian_K=C3=B6nig?= , Chris Goldsworthy , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , James Jones , Hridya Valsaraju , Sandeep Patil , linux-media , DRI mailing list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , linux-mm , LKML , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 2, 2021 at 5:39 PM Minchan Kim wrote: > > On Tue, Feb 02, 2021 at 04:31:34PM -0800, Suren Baghdasaryan wrote: > > Currently system heap maps its buffers with VM_PFNMAP flag using > > remap_pfn_range. This results in such buffers not being accounted > > for in PSS calculations because vm treats this memory as having no > > page structs. Without page structs there are no counters representing > > how many processes are mapping a page and therefore PSS calculation > > is impossible. > > Historically, ION driver used to map its buffers as VM_PFNMAP areas > > due to memory carveouts that did not have page structs [1]. That > > is not the case anymore and it seems there was desire to move away > > from remap_pfn_range [2]. > > Dmabuf system heap design inherits this ION behavior and maps its > > pages using remap_pfn_range even though allocated pages are backed > > by page structs. > > Replace remap_pfn_range with vm_insert_page, following Laura's suggestion > > in [1]. This would allow correct PSS calculation for dmabufs. > > > > [1] https://driverdev-devel.linuxdriverproject.narkive.com/v0fJGpaD/using-ion-memory-for-direct-io > > [2] http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-October/127519.html > > (sorry, could not find lore links for these discussions) > > > > Suggested-by: Laura Abbott > > Signed-off-by: Suren Baghdasaryan > Reviewed-by: Minchan Kim > > A note: This patch makes dmabuf system heap accounted as PSS so > if someone has relies on the size, they will see the bloat. > IIRC, there was some debate whether PSS accounting for their > buffer is correct or not. If it'd be a problem, we need to > discuss how to solve it(maybe, vma->vm_flags and reintroduce > remap_pfn_range for them to be respected). I did not see debates about not including *mapped* dmabufs into PSS calculation. I remember people were discussing how to account dmabufs referred only by the FD but that is a different discussion. If the buffer is mapped into the address space of a process then IMHO including it into PSS of that process is not controversial.