From: Ryosuke Yasuoka <ryasuoka@redhat.com>
To: Jocelyn Falempe <jfalempe@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
kraxel@redhat.com, gurchetansingh@chromium.org,
olvaffe@gmail.com, akpm@linux-foundation.org, urezki@gmail.com,
hch@infradead.org, dmitry.osipenko@collabora.com,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH drm-next 1/2] vmalloc: Add atomic_vmap
Date: Sun, 9 Mar 2025 17:07:59 +0900 [thread overview]
Message-ID: <CAHpthZqn7ZZW1ekFQe7nN0+xfsNvMQMKhjMNcB3EyQ18yfQhiA@mail.gmail.com> (raw)
In-Reply-To: <51c11147-4927-4ebc-9737-fd1eebe4e0bd@redhat.com>
On Fri, Mar 7, 2025 at 4:55 PM Jocelyn Falempe <jfalempe@redhat.com> wrote:
>
> On 06/03/2025 16:52, Simona Vetter wrote:
> > On Thu, Mar 06, 2025 at 02:24:51PM +0100, Jocelyn Falempe wrote:
> >> On 06/03/2025 05:52, Matthew Wilcox wrote:
> >>> On Thu, Mar 06, 2025 at 12:25:53AM +0900, Ryosuke Yasuoka wrote:
> >>>> Some drivers can use vmap in drm_panic, however, vmap is sleepable and
> >>>> takes locks. Since drm_panic will vmap in panic handler, atomic_vmap
> >>>> requests pages with GFP_ATOMIC and maps KVA without locks and sleep.
> >>>
> >>> In addition to the implicit GFP_KERNEL allocations Vlad mentioned, how
> >>> is this supposed to work?
> >>>
> >>>> + vn = addr_to_node(va->va_start);
> >>>> +
> >>>> + insert_vmap_area(va, &vn->busy.root, &vn->busy.head);
> >>>
> >>> If someone else is holding the vn->busy.lock because they're modifying the
> >>> busy tree, you'll corrupt the tree. You can't just say "I can't take a
> >>> lock here, so I won't bother". You need to figure out how to do something
> >>> safe without taking the lock. For example, you could preallocate the
> >>> page tables and reserve a vmap area when the driver loads that would
> >>> then be usable for the panic situation. I don't know that we have APIs
> >>> to let you do that today, but it's something that could be added.
> >>>
> >> Regarding the lock, it should be possible to use the trylock() variant, and
> >> fail if the lock is already taken. (In the panic handler, only 1 CPU remain
> >> active, so it's unlikely the lock would be released anyway).
> >>
> >> If we need to pre-allocate the page table and reserve the vmap area, maybe
> >> it would be easier to just always vmap() the primary framebuffer, so it can
> >> be used in the panic handler?
> >
> > Yeah I really don't like the idea of creating some really brittle one-off
> > core mm code just so we don't have to vmap a buffer unconditionally. I
> > think even better would be if drm_panic can cope with non-linear buffers,
> > it's entirely fine if the drawing function absolutely crawls and sets each
> > individual byte ...
>
> It already supports some non-linear buffer, like Nvidia block-linear:
> https://elixir.bootlin.com/linux/v6.13.5/source/drivers/gpu/drm/nouveau/dispnv50/wndw.c#L606
>
> And I've also sent some patches to support Intel's 4-tile and Y-tile format:
> https://patchwork.freedesktop.org/patch/637200/?series=141936&rev=5
> https://patchwork.freedesktop.org/patch/637202/?series=141936&rev=5
>
> Hopefully Color Compression can be disabled on intel's GPU, otherwise
> that would be a bit harder to implement than tiling.
>
> >
> > The only thing you're allowed to do in panic is try_lock on a raw spinlock
> > (plus some really scare lockless tricks), imposing that on core mm sounds
> > like a non-starter to me.
> >
> > Cheers, Sima
>
Thank you all for your comments.
I understand adding atomic_vmap is not possible as vmalloc is not compatible
with GFP_ATOMIC. I'll re-implement this by pre-allocating the page table and
reserve the vmap area while the kernel is alive. It'll might be
allocated in driver
codes so maybe I don't need to add any features in core mm code.
Best regards,
Ryosuke
next prev parent reply other threads:[~2025-03-09 8:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 15:25 [PATCH drm-next 0/2] Enhance drm_panic Support for Virtio-GPU Ryosuke Yasuoka
2025-03-05 15:25 ` [PATCH drm-next 1/2] vmalloc: Add atomic_vmap Ryosuke Yasuoka
2025-03-05 17:08 ` Markus Elfring
2025-03-05 17:27 ` Uladzislau Rezki
2025-03-06 4:52 ` Matthew Wilcox
2025-03-06 13:24 ` Jocelyn Falempe
2025-03-06 14:04 ` Uladzislau Rezki
2025-03-06 15:52 ` Simona Vetter
2025-03-07 7:54 ` Jocelyn Falempe
2025-03-09 8:07 ` Ryosuke Yasuoka [this message]
2025-03-10 10:23 ` Jocelyn Falempe
2025-03-05 15:25 ` [PATCH drm-next 2/2] drm/virtio: Use atomic_vmap to work drm_panic in GUI Ryosuke Yasuoka
2025-03-06 23:56 ` kernel test robot
2025-03-07 3:07 ` kernel test robot
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=CAHpthZqn7ZZW1ekFQe7nN0+xfsNvMQMKhjMNcB3EyQ18yfQhiA@mail.gmail.com \
--to=ryasuoka@redhat.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=hch@infradead.org \
--cc=jfalempe@redhat.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=urezki@gmail.com \
--cc=virtualization@lists.linux.dev \
--cc=willy@infradead.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