Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1342364yba; Tue, 2 Apr 2019 07:12:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6Z6WFOmiRTMH0O1Ho8Og1fKyX0T74ugf0+gr5WVnPj3GG1EjYBdCywhL4hmuTbd9IhQFq X-Received: by 2002:aa7:9211:: with SMTP id 17mr68590087pfo.220.1554214323370; Tue, 02 Apr 2019 07:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554214323; cv=none; d=google.com; s=arc-20160816; b=sB9rqejE3QZCM7hYnoTC8hLhXi29VktJ05xdIJE0LJeyrM8O4xt6cZWN6/ONqMKqLS Z4tYC1OSd41gnLAOQYfOaUuUPtRukTyLDc66o8+g2iaZz7r4gMeq7d0pgMAWHWvUhUB1 vGsgIAtnAdFYCe1400qpaBrgEplTs4rMO170yJV9aX8irbprtAAMagjm5ixobdV6cgpI 0xvjhf2fkb8meDBQ5ajgvd6GM5EdU1fgsAkLYycIAKiEI2kcq9lxFaOk2m06+V7Wi1sF nZMyixCqQJplWjYc6x+YgKW1eolIc3679YkNIUOBoOjr/5nzZ8JccloBWi4SeMJdxQRS 1uCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yJAk7JBHZRxnc+86KWmwsxNa65Ai6RJsNUROoSDZXM8=; b=oGo+685tpDbOW2RjS59ibEZYVpvnW1HU6L5TN9zWlKwgU3RaJp0FEI9tReICzc/I3a vcg2oxp0VbRx99/JjKAnO8cGOVEl5UqG1iZJvPe0skdnFTN510kAzG2EytTLEkr0moRk PY+zJsXzbDm9n3W3n4O5DGBh52cWESQbeyTrjhxD+IHl0FrPQXt5X6KXuplQXZB4GnxS KaKtzYfAwak42/9bt4iZ2ZILPg3TMq1qMuBnHDyz9HQA8ilzuw0QMWgaOoJfoxPzKVHf w39/owKjh2v/WELTh1tVasnOKrfNrrk1o6x+p2paKGGbS/E8EMH9to9s5NmimUNCEbpw rAuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RIAfXofg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si11036701plt.141.2019.04.02.07.11.47; Tue, 02 Apr 2019 07:12:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RIAfXofg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbfDBOKo (ORCPT + 99 others); Tue, 2 Apr 2019 10:10:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:42100 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfDBOKo (ORCPT ); Tue, 2 Apr 2019 10:10:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yJAk7JBHZRxnc+86KWmwsxNa65Ai6RJsNUROoSDZXM8=; b=RIAfXofgI5AXMkmJK8jl1V8lt 1XNAJC+z8pYk6lpA22iStJgLlLs4bBogHezEOmO70VSMOS/+G6f3w6Sb58MoJIHScd1yItwYbYhqQ /mQuxMdd0L6jfHu4ngsiBSUURN/t3ghJjuukIOuGHNal5AFilhYkyl7N9YAYXecOlP59dCgTOks9D Xvrc/IPxnFoqDt1/+HtJd9rdrymV2bM82XZSsBwDhxzxNStLpSraHPKAEj0h8asN4ZBRVaLGySzP6 0rXi1QKpdtKnuGRsFh50RBIx6d+K3WI6T+l7uc2FoFwAWQ1NB2uhi5bWRvmhg2HLKRcEydUTm/2OE JDPPbHB0Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBK7d-0004gb-Jg; Tue, 02 Apr 2019 14:10:41 +0000 Date: Tue, 2 Apr 2019 07:10:41 -0700 From: Matthew Wilcox To: Qiang Yu Cc: Stephen Rothwell , Daniel Vetter , Intel Graphics , DRI , Linux Next Mailing List , Linux Kernel Mailing List , Eric Anholt Subject: Re: linux-next: build failure after merge of the drm-misc tree Message-ID: <20190402141041.GF22763@bombadil.infradead.org> References: <20190402105006.48f93e53@canb.auug.org.au> <20190402112656.GE22763@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 02, 2019 at 09:56:08PM +0800, Qiang Yu wrote: > On Tue, Apr 2, 2019 at 7:26 PM Matthew Wilcox wrote: > > > > On Tue, Apr 02, 2019 at 01:55:03PM +0800, Qiang Yu wrote: > > > Thanks, patch is: > > > Reviewed-by: Qiang Yu > > > > 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.