linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
To: David Hildenbrand <david@redhat.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Hugh Dickins <hughd@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	"Kim, Dongwon" <dongwon.kim@intel.com>,
	"Chang, Junxiao" <junxiao.chang@intel.com>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"Hocko, Michal" <mhocko@suse.com>,
	"jmarchan@redhat.com" <jmarchan@redhat.com>,
	"muchun.song@linux.dev" <muchun.song@linux.dev>,
	James Houghton <jthoughton@google.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] udmabuf: revert 'Add support for mapping hugepages (v4)'
Date: Tue, 13 Jun 2023 08:26:13 +0000	[thread overview]
Message-ID: <IA0PR11MB71852D6B27C83658670CBFBDF855A@IA0PR11MB7185.namprd11.prod.outlook.com> (raw)
In-Reply-To: <281caf4f-25da-3a73-554b-4fb252963035@redhat.com>

Hi David,

> 
> On 12.06.23 09:10, Kasireddy, Vivek wrote:
> > Hi Mike,
> 
> Hi Vivek,
> 
> >
> > Sorry for the late reply; I just got back from vacation.
> > If it is unsafe to directly use the subpages of a hugetlb page, then reverting
> > this patch seems like the only option for addressing this issue immediately.
> > So, this patch is
> > Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> >
> > As far as the use-case is concerned, there are two main users of the
> udmabuf
> > driver: Qemu and CrosVM VMMs. However, it appears Qemu is the only
> one
> > that uses hugetlb pages (when hugetlb=on is set) as the backing store for
> > Guest (Linux, Android and Windows) system memory. The main goal is to
> > share the pages associated with the Guest allocated framebuffer (FB) with
> > the Host GPU driver and other components in a zero-copy way. To that
> end,
> > the guest GPU driver (virtio-gpu) allocates 4k size pages (associated with
> > the FB) and pins them before sharing the (guest) physical (or dma)
> addresses
> > (and lengths) with Qemu. Qemu then translates the addresses into file
> > offsets and shares these offsets with udmabuf.
> 
> Is my understanding correct, that we can effectively long-term pin
> (worse than mlock) 64 MiB per UDMABUF_CREATE, allowing eventually !root
The 64 MiB limit is the theoretical upper bound that we have not seen hit in 
practice. Typically, for a 1920x1080 resolution (commonly used in Guests),
the size of the FB is ~8 MB (1920x1080x4). And, most modern Graphics
compositors flip between two FBs.

> users
> 
> ll /dev/udmabuf
> crw-rw---- 1 root kvm 10, 125 12. Jun 08:12 /dev/udmabuf
> 
> to bypass there effective MEMLOCK limit, fragmenting physical memory and
> breaking swap?
Right, it does not look like the mlock limits are honored.

> 
> Regarding the udmabuf_vm_fault(), I assume we're mapping pages we
> obtained from the memfd ourselves into a special VMA (mmap() of the
mmap operation is really needed only if any component on the Host needs
CPU access to the buffer. But in most scenarios, we try to ensure direct GPU
access (h/w acceleration via gl) to these pages.

> udmabuf). I'm not sure how well shmem pages are prepared for getting
> mapped by someone else into an arbitrary VMA (page->index?).
Most drm/gpu drivers use shmem pages as the backing store for FBs and
other buffers and also provide mmap capability. What concerns do you see
with this approach?

> 
> ... also, just imagine someone doing FALLOC_FL_PUNCH_HOLE / ftruncate()
> on the memfd. What's mapped into the memfd no longer corresponds to
> what's pinned / mapped into the VMA.
IIUC, making use of the DMA_BUF_IOCTL_SYNC ioctl would help with any
coherency issues:
https://www.kernel.org/doc/html/v6.2/driver-api/dma-buf.html#c.dma_buf_sync

> 
> 
> Was linux-mm (and especially shmem maintainers, ccing Hugh) involved in
> the upstreaming of udmabuf?
It does not appear so from the link below although other key lists were cc'd:
https://patchwork.freedesktop.org/patch/246100/?series=39879&rev=7

Thanks,
Vivek
> 
> --
> Cheers,
> 
> David / dhildenb


  reply	other threads:[~2023-06-13  8:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 20:49 [PATCH] udmabuf: revert 'Add support for mapping hugepages (v4)' Mike Kravetz
2023-06-09  6:09 ` Greg Kroah-Hartman
2023-06-12  7:10 ` Kasireddy, Vivek
2023-06-12  7:46   ` David Hildenbrand
2023-06-13  8:26     ` Kasireddy, Vivek [this message]
2023-06-13 12:25       ` David Laight
2023-06-13 17:51       ` David Hildenbrand
2023-06-14  3:40         ` Hugh Dickins
2023-06-14  7:51         ` Kasireddy, Vivek
2023-06-15  9:48           ` David Hildenbrand
2023-06-19 12:35 ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=IA0PR11MB71852D6B27C83658670CBFBDF855A@IA0PR11MB7185.namprd11.prod.outlook.com \
    --to=vivek.kasireddy@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=dongwon.kim@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hughd@google.com \
    --cc=jmarchan@redhat.com \
    --cc=jthoughton@google.com \
    --cc=junxiao.chang@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=muchun.song@linux.dev \
    --cc=qemu-devel@nongnu.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).