Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp719818ybl; Sat, 17 Aug 2019 09:11:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJIWrlOTwI/fJ79ERRNoGF2Xn3zwTGWm2LLbbLkF2CXhPzv7nfls6VfUpZV8Yr1ocwmv88 X-Received: by 2002:a17:902:b48c:: with SMTP id y12mr1057270plr.202.1566058280064; Sat, 17 Aug 2019 09:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566058280; cv=none; d=google.com; s=arc-20160816; b=MzlT+QjHqGfaWmu+yaxxsPNYF3vgG5rmnP2UWi5hXn9idjFRi0jJsFJLugZIcYOPFx Ksdsxd6xQxgeNzYAhz4b53Yaf1X66DZ6UmZ+UC0Mhi9qPTnbxgCi0S80nsGJE9keYmZJ 09SI7egTwTIKdDYHwfUfK4HYvPXAGolukSy/N7412+8wWNA7bChTxPe/8oy9qEsC7xXq 5szh0s+6NJWjnww/CYODy599ZgFDuIunhDy1fHKf9pBxFEnuWhFLnNQF9ZKWHY44I7GM dsfU4o3sqh7uKL9ciIrhM5CKeJhI4l470vrUUzygS3lQ2GTIaNZqy55rsdLulOs6RSEU pVIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/dLbDP+XbKcJMYntrsaFKnZVTIgZ0VHyMdGQlHN9qFU=; b=MxM5Gf32sBT9CW9ibW0HGvtdXAG5E8AHr8/DlGI9lxauTdCQFwZN0GWKpCs+heth9k EtN49nmkEjouhXDZF5D3/iC3iU6vZMKPd+agiEglmIzhqpRA1vqshIuh/vq8HtXIEGDO 0+0NHca7Iga23Ul1q9Q1lJWx72tmArUVuHioyivkeVESrCALgzmOj5opN8SDa7SCOzEO EBsJhgMwxJ3KJwQt8hpAyYGWPvZHX61FuTMp1hoC2JXWTaeQ87a6xDnOykbNB9Et2KGS 9UtypsokxezIdVzpY0zftCLw8Mmdso7HdY/mBe4ovBU6sSAtRVswzIVIuQXLx7OWoDW+ zrNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=B5UOJokG; 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 n9si6070679pgq.240.2019.08.17.09.11.04; Sat, 17 Aug 2019 09:11:20 -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=pass header.i=@ffwll.ch header.s=google header.b=B5UOJokG; 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 S1726046AbfHQQKH (ORCPT + 99 others); Sat, 17 Aug 2019 12:10:07 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:43261 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfHQQKG (ORCPT ); Sat, 17 Aug 2019 12:10:06 -0400 Received: by mail-ot1-f65.google.com with SMTP id e12so12284614otp.10 for ; Sat, 17 Aug 2019 09:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/dLbDP+XbKcJMYntrsaFKnZVTIgZ0VHyMdGQlHN9qFU=; b=B5UOJokGjOlBPz4rMQ3Si/DpHraMyEYjQZnsGkf6QDVaPp5z9cpjK1+gkfiq/zazff NL4cuOvDdj2IcVJLJ9P5XOOuwMQ+B+/YrCGP3oe4dPerl/SOJztR2seJqY/t5jIW2guZ 0vUMVsA5mwUX/XZfEdCbwGtfe9HGRKda6wKfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/dLbDP+XbKcJMYntrsaFKnZVTIgZ0VHyMdGQlHN9qFU=; b=TqltgKmmGlRvTi4F2Y2Nmqi+FYXP36NzPOQLv/ql+d6aJTblyBhfdykyVCPAYGGFDf c26iVtRH1j+JwlDK15QhOVfnbV3gEnS/UDAndrOAXFhQcjdlaYaJyhGTdHNLT4zOZO83 OYPZ71O10CWLgbEJBAfsiFldKruz4oBUdG53r6DpvkryYq1grfpYCLUexsWH5RWlFE0L Vcpr+qla80/bPcCUPc1R7mmrltbwOW5DiUAwD8vQEZhmUT+D/xcB8AfTLue3RUpKFfcg gHWeQ5CYveQZuj0qsrF9HPoM7sKojqs2ykhCSMMJ6bLZNET3I5FeffRBc1fqP7QHnnp+ VsVA== X-Gm-Message-State: APjAAAWxAIebhni2Kh3LPdigObfdFo9/bReKj25soJ2Q/N0O8/EXnflz eJgyxzrkEoDtj9ps2SRBl8B3K4SZYCC9Gh2ex3Wqcg== X-Received: by 2002:a9d:590d:: with SMTP id t13mr660910oth.281.1566058205676; Sat, 17 Aug 2019 09:10:05 -0700 (PDT) MIME-Version: 1.0 References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-4-daniel.vetter@ffwll.ch> <20190815000029.GC11200@ziepe.ca> <20190815070249.GB7444@phenom.ffwll.local> <20190815123556.GB21596@ziepe.ca> In-Reply-To: <20190815123556.GB21596@ziepe.ca> From: Daniel Vetter Date: Sat, 17 Aug 2019 18:09:54 +0200 Message-ID: Subject: Re: [PATCH 3/5] mm, notifier: Catch sleeping/blocking for !blockable To: Jason Gunthorpe Cc: LKML , Linux MM , DRI Development , Intel Graphics Development , Andrew Morton , Michal Hocko , David Rientjes , =?UTF-8?Q?Christian_K=C3=B6nig?= , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 17, 2019 at 5:26 PM Jason Gunthorpe wrote: > > On Thu, Aug 15, 2019 at 09:02:49AM +0200, Daniel Vetter wrote: > > On Wed, Aug 14, 2019 at 09:00:29PM -0300, Jason Gunthorpe wrote: > > > On Wed, Aug 14, 2019 at 10:20:25PM +0200, Daniel Vetter wrote: > > > > We need to make sure implementations don't cheat and don't have a > > > > possible schedule/blocking point deeply burried where review can't > > > > catch it. > > > > > > > > I'm not sure whether this is the best way to make sure all the > > > > might_sleep() callsites trigger, and it's a bit ugly in the code flow. > > > > But it gets the job done. > > > > > > > > Inspired by an i915 patch series which did exactly that, because the > > > > rules haven't been entirely clear to us. > > > > > > I thought lockdep already was able to detect: > > > > > > spin_lock() > > > might_sleep(); > > > spin_unlock() > > > > > > Am I mistaken? If yes, couldn't this patch just inject a dummy lockdep > > > spinlock? > > > > Hm ... assuming I didn't get lost in the maze I think might_sleep (well > > ___might_sleep) doesn't do any lockdep checking at all. And we want > > might_sleep, since that catches a lot more than lockdep. > > Don't know how it works, but it sure looks like it does: > > This: > spin_lock(&file->uobjects_lock); > down_read(&file->hw_destroy_rwsem); > up_read(&file->hw_destroy_rwsem); > spin_unlock(&file->uobjects_lock); > > Causes: > > [ 33.324729] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1444 > [ 33.325599] in_atomic(): 1, irqs_disabled(): 0, pid: 247, name: ibv_devinfo > [ 33.326115] 3 locks held by ibv_devinfo/247: > [ 33.326556] #0: 000000009edf8379 (&uverbs_dev->disassociate_srcu){....}, at: ib_uverbs_open+0xff/0x5f0 [ib_uverbs] > [ 33.327657] #1: 000000005e0eddf1 (&uverbs_dev->lists_mutex){+.+.}, at: ib_uverbs_open+0x16c/0x5f0 [ib_uverbs] > [ 33.328682] #2: 00000000505f509e (&(&file->uobjects_lock)->rlock){+.+.}, at: ib_uverbs_open+0x31a/0x5f0 [ib_uverbs] > > And this: > > spin_lock(&file->uobjects_lock); > might_sleep(); > spin_unlock(&file->uobjects_lock); > > Causes: > > [ 16.867211] BUG: sleeping function called from invalid context at drivers/infiniband/core/uverbs_main.c:1095 > [ 16.867776] in_atomic(): 1, irqs_disabled(): 0, pid: 245, name: ibv_devinfo > [ 16.868098] 3 locks held by ibv_devinfo/245: > [ 16.868383] #0: 000000004c5954ff (&uverbs_dev->disassociate_srcu){....}, at: ib_uverbs_open+0xf8/0x600 [ib_uverbs] > [ 16.868938] #1: 0000000020a6fae2 (&uverbs_dev->lists_mutex){+.+.}, at: ib_uverbs_open+0x16c/0x600 [ib_uverbs] > [ 16.869568] #2: 00000000036e6a97 (&(&file->uobjects_lock)->rlock){+.+.}, at: ib_uverbs_open+0x317/0x600 [ib_uverbs] > > I think this is done in some very expensive way, so it probably only > works when lockdep is enabled.. This is the might_sleep debug infrastructure (both of them), not lockdep. Disable CONFIG_PROVE_LOCKING and you should still get these. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch