Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp474849rdb; Thu, 18 Jan 2024 08:57:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVRBsbyAc67xLOYI8FGkpOfPvh7yApyLBb3NhSCT+m16t+Iu2YRRHMPLQGf5BMjX7a2OnF X-Received: by 2002:a17:906:a099:b0:a2a:19d8:835b with SMTP id q25-20020a170906a09900b00a2a19d8835bmr636271ejy.88.1705597064002; Thu, 18 Jan 2024 08:57:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705597063; cv=pass; d=google.com; s=arc-20160816; b=yMVEQdMGXYK9yw+1HfTzzSN1RpcA6PXSD4ctqPfTr9YbmdqUcPOu3oM/nkIrt5hWzH 9AzJ+ESqN1fxyF/8ZSGh9AgxQvzr91XJr/UIDvN6wjsGoqXCV7vzZBUKmX77yQVwDKVd Oswdb++ZgfqFaBfIepOyvf0Gn5CRW4rmnrUiDyICvvMOgW1eS/IaaN5xOmljxWyaB7CE LjhhJAjepN9Ff+kl4y7TkI2u/RUzW5y65L3+dFruRy/xwm0KeZOD3fh+nUiGXnwNkQOB b3Ie31gIaS0LSqLwbsVRr3Zfwhi1sc3SHpXezEb4Hyrx3uLSJjPvoMLMa3tBnodbMRFX 5l+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=cmZn+BROv+sMREBkau20U4T/TQEgObsLAqinfuULAyg=; fh=e507D5NybQtyzIaj5zhT072in8erPlac1N89cnLCKzI=; b=fvEt3m98w7loSWtwI3erxkaD8BhHpOItF9e02jJBgxd5OZyr1t6Dz+8D3fh2KlkBQ7 jy2yY+A3XdwJps2geQxAfPI9/TXmKxis2LlXXA9/S0AWCBokhfEMnmJ/Q0bRQuo5BaNM 1jbaNIcLPr1swMdPPO0/KbAZb+OMO4kP8fAq5NOhM0Mj3asi48f8SqEoRx5PuNExq0n6 YOM/v9/b7VNM7T8Tg2ttf2I2WqzgwuqLaiBZeZ2q3Ur/jKuxZswiAW145k0UK1htG3xA RSECzpQTBmMKtJGJLcqhkzxNBk69IhaE/v6u8y6iCSxHR7h6q4b2eCukhjdv30EGYlMw DWLA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Qdf5Pmc2; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-30379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q16-20020a170906389000b00a2d50fcc5dbsi4752244ejd.87.2024.01.18.08.57.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 08:57:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Qdf5Pmc2; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-30379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C00C41F21332 for ; Thu, 18 Jan 2024 16:57:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E171E2C6BD; Thu, 18 Jan 2024 16:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Qdf5Pmc2" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDE9E2C6AB for ; Thu, 18 Jan 2024 16:57:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705597052; cv=none; b=UhiVplOEcdfk13ObFHbLxGuc8C0pnmTuYlDAKG9qCvjGkZrn9wWaB/7BF0qGTei72vCHyL0MSqVDR8EI2j5HODi1/Lb+4PiEc9xNZmPUkh5ukucq4iZ4j/NxNsSYd3mnsHFjkvuU0YBlnSJVQwOMg9g8Lij4qpvaVpqxhbR1ToY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705597052; c=relaxed/simple; bh=cmZn+BROv+sMREBkau20U4T/TQEgObsLAqinfuULAyg=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=U7H5biFI73EaTpHQj86pRh3L+b8OEjDExj0V3eHIoVyx0M2GhcykqC0KaW8eEW8tQCY4z3mtjsZLuvc0EXK8hUtSRm7vHtEE46jsVQuibDawebzvWeCu00DWO7MFfWn6DDyP4dFQIyEmQIx+nmXMB8Jp+OTk3fRPXJCPB1TYbkU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Qdf5Pmc2; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-dbedb1ee3e4so10623700276.3 for ; Thu, 18 Jan 2024 08:57:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705597049; x=1706201849; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cmZn+BROv+sMREBkau20U4T/TQEgObsLAqinfuULAyg=; b=Qdf5Pmc2E9Lqn0tozQlEd+MJF6I8HkxjgbELP5HQzYJyByJIDwRerqRpDZKSjbi1Xm 7NRpa7rRO87l/DR9gFXw7S/V+yhmiaCTUzlIzZC7h5rANmLgDIepigio3gUWYvVj/j/g uyr1KO5cMnMINt8PaB0/m/mneKHYI/YkEgKox+b6CeEz8h6KWtHz2QFAeWy6vKIQoyFg dNnyC9KEpUJ2N25XRyRTIifpgIZbD7mhLGdbrE5e88CGz2WABdg3hLi2THDiPSDbfL8q cgLdBqD/1kuMSEWyW60uR15aDeQHswAhqejXaOu4FcKYnhfumKNYs+hy8iXlHhcJd78Z HKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705597049; x=1706201849; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cmZn+BROv+sMREBkau20U4T/TQEgObsLAqinfuULAyg=; b=BopI9EVR3OWF4S0iZVSthSTmYdEWPYI9EzvfMIHxQQ2mnQoM7uHfehyycKA4JQI+Iu rpuBJXJziujrXvAKqi9q8d3GEtCgQVSexjtBoqx790f2FdIPupVRA7K5mkVBOO0x0zHB ID0+rZ+lxZ3m/icW1uiafm/WLdFo8QF760tbz90ETX5QZMoF5KBgAImEZTeVGkudg4tw 9x8RrAQJx70tofxjzYjF9qflwWHy1pvtq77pPy5khko/Q23tKG3CxrFo7XCDhM7j1/Zm SiTiXsmWYWSpfxagKVnj6oJ8lLF9eBRj6104tz6JMZ3hfOGoqRdY+ziAJ6PjzMlHnKk0 RYcg== X-Gm-Message-State: AOJu0Yzmqsptakc9l20sPzEXnP+dF1qEnvFiUyofaYx/aHL9Ja7IM06Q zY9OpjafAnSML7sZIfWEzmV7S2Ma7nC8mD2yS8QLR+9l0hnRT3PIc3PmKcRbTU3RVN1vhGb4W8L S+OlvnkNjuffx7XbWXgKytLBPZ7Tmumm4aKbB X-Received: by 2002:a25:748c:0:b0:dbd:7743:77cb with SMTP id p134-20020a25748c000000b00dbd774377cbmr856586ybc.128.1705597048380; Thu, 18 Jan 2024 08:57:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240117181141.286383-1-tjmercier@google.com> <20a68f86-27f0-48f4-a066-7dcf0092858e@amd.com> In-Reply-To: From: "T.J. Mercier" Date: Thu, 18 Jan 2024 08:57:16 -0800 Message-ID: Subject: Re: [PATCH] dma-buf: heaps: Don't track CMA dma-buf pages under RssFile To: =?UTF-8?Q?Christian_K=C3=B6nig?= , "T.J. Mercier" , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , Sandeep Patil , Laura Abbott , android-mm@google.com, minchan@google.com, John Stultz , Benjamin Gaignard , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Cc: daniel@ffwll.ch Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 18, 2024 at 6:49=E2=80=AFAM Daniel Vetter wro= te: > > On Thu, Jan 18, 2024 at 11:02:22AM +0100, Christian K=C3=B6nig wrote: > > Am 17.01.24 um 19:11 schrieb T.J. Mercier: > > > DMA buffers allocated from the CMA dma-buf heap get counted under > > > RssFile for processes that map them and trigger page faults. In > > > addition to the incorrect accounting reported to userspace, reclaim > > > behavior was influenced by the MM_FILEPAGES counter until linux 6.8, = but > > > this memory is not reclaimable. [1] Change the CMA dma-buf heap to se= t > > > VM_PFNMAP on the VMA so MM does not poke at the memory managed by thi= s > > > dma-buf heap, and use vmf_insert_pfn to correct the RSS accounting. > > > > > > The system dma-buf heap does not suffer from this issue since > > > remap_pfn_range is used during the mmap of the buffer, which also set= s > > > VM_PFNMAP on the VMA. > > > > Mhm, not an issue with this patch but Daniel wanted to add a check for > > VM_PFNMAP to dma_buf_mmap() which would have noted this earlier. > > > > I don't fully remember the discussion but for some reason that was neve= r > > committed. We should probably try that again. > > Iirc the issue is that dma_mmap is not guaranteed to give you a VM_SPECIA= L > mapping, at least on absolutely all architectures. That's why I defacto > dropped that idea, but it would indeed be really great if we could > resurrect it. I actually had it in my head that it was a BUG_ON check for VM_PFNMAP in dma_buf_mmap and it was merged, so I was surprised to discover that it wasn't set for these CMA buffers. > Maybe for x86 only? Or x86+armv8, I'm honestly not sure anymore which > exact cases ended up with a VM_NORMAL mapping ... Would need a pile of > digging. Looking back at the patch, the CI email at the end of the thread lists a bunch of now-broken links to DMESG-WARN test failures I assume pointed at a large chunk of them. https://lore.kernel.org/all/166919750173.15575.2864736980735346730@emeril.f= reedesktop.org/ > > > > > [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= /commit/mm/vmscan.c?id=3Dfb46e22a9e3863e08aef8815df9f17d0f4b9aede > > > > > > Fixes: b61614ec318a ("dma-buf: heaps: Add CMA heap to dmabuf heaps") > > > Signed-off-by: T.J. Mercier > > > > Acked-by: Christian K=C3=B6nig Thanks Christian.