lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190402141041.GF22763@bombadil.infradead.org>
Date:   Tue, 2 Apr 2019 07:10:41 -0700
From:   Matthew Wilcox <willy@...radead.org>
To:     Qiang Yu <yuq825@...il.com>
Cc:     Stephen Rothwell <sfr@...b.auug.org.au>,
        Daniel Vetter <daniel.vetter@...ll.ch>,
        Intel Graphics <intel-gfx@...ts.freedesktop.org>,
        DRI <dri-devel@...ts.freedesktop.org>,
        Linux Next Mailing List <linux-next@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Eric Anholt <eric@...olt.net>
Subject: Re: linux-next: build failure after merge of the drm-misc tree

On Tue, Apr 02, 2019 at 09:56:08PM +0800, Qiang Yu wrote:
> On Tue, Apr 2, 2019 at 7:26 PM Matthew Wilcox <willy@...radead.org> wrote:
> >
> > On Tue, Apr 02, 2019 at 01:55:03PM +0800, Qiang Yu wrote:
> > > Thanks, patch is:
> > > Reviewed-by: Qiang Yu <yuq825@...il.com>
> >
> > This looks like a fairly naive conversion from the old IDR API to the
> > XArray API.  You should be able to remove mgr->lock entirely, relying on
> > the xa_lock for synchronising free and get.
> 
> I'm afraid the a little complex free path may involve some might sleep
> functions so use a mutex lock instead of spinlock.

Ah, good call ...

+       mutex_lock(&mgr->lock);
+       ctx = xa_erase(&mgr->handles, id);
+       if (ctx)
+               kref_put(&ctx->refcnt, lima_ctx_do_release);
+       else
+               ret = -EINVAL;
+       mutex_unlock(&mgr->lock);

+static void lima_ctx_do_release(struct kref *ref)
+{
+       struct lima_ctx *ctx = container_of(ref, struct lima_ctx, refcnt);
+       int i;
+
+       for (i = 0; i < lima_pipe_num; i++)
+               lima_sched_context_fini(ctx->dev->pipe + i, ctx->context + i);
+       kfree(ctx);
+}

+void lima_sched_context_fini(struct lima_sched_pipe *pipe,
+                            struct lima_sched_context *context)
+{
+       drm_sched_entity_fini(&context->base);
+}

and drm_sched_entity_fini() can call kthread_park(), which does sleep.

> > If you think it's worth it,
> > you could even use kfree_rcu() to free the ctx and kref_get_unless_zero()
> > and then your get path would be lock-free.
> 
> I can take a look this way, thanks.

I think that's the only way you can get rid of the mutex, given the
sleeping functions called in the free path.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ