Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2051324ybl; Thu, 15 Aug 2019 05:51:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWA6hHCzRgVAHw+zI5uPiyu8sfcDBM5yarzgC9gJUfw3armSmomKkXL+eL7hZEL5woNPQS X-Received: by 2002:a17:902:6b06:: with SMTP id o6mr4110054plk.33.1565873517730; Thu, 15 Aug 2019 05:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565873517; cv=none; d=google.com; s=arc-20160816; b=olL9kdJ00VFf1xWcxaqSGJchbbryKbtoEqznCCEKxIdpAdgatQAMsl6wiPPKkyCklC exOZvjMI6y631JHeIzZQ11DkW+L5UmjqZHcc8rf1nlIh0CFcgv3YrgYvkwa3xzsUKo3D +H7KoH1CEPiS4CIUZ4rGRXRY2ksL4uEULJtgJqhlL7y9wOSOLFqJ7+Y8B+ZDsz3FznAw 2nMSRYYSA0+1frJ3CSJWXIhZaHbEy53dIOwEFT1WZIlVuP998JYYprBQ1xoMO04ru3+/ /rf7I7bLFaCnvvJCu0geqfRVdLD6XbE7fz+ZbHvD/+SYy2nFmhHYI/CP+eC79VYbx5jM IijQ== 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:to :from:date:dkim-signature; bh=dMM4Yh2lSK206Ipl1C50HgHP0mjyxRSuLJo2cy44isg=; b=yvNDzI9h0w35pb1nWqepSzL+Jux9ngZ3f1+b8+9pecCf4/piF7T473cABLOci51A82 VegDGnnqYQ9/GtZyk5Vr1iqicKqReDDwctVcxHxr/bMv7NWUQ2LS7jUpX1Tn09CGAKxU pJxMNTq82UbWNqsgigr1PfjQI6iSJiEqjGsAvOH+8ZZYQMYgmoVJrE2hN/bT2lbvqH02 7IA2CBCew8AR0lMhtjj3EQYE5Vhou//y5hl/ltoR1f6oazB+kt/hPfBWTNUyAUqeF7Lb ZooFRp4lL3x0FSuRX0Op7Y7HAXYv95OdG/eWT3CAdk8LVfffSLF0/dBospgD2o+7WP3U Quzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=LcThbfWl; 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 200si2035944pfy.246.2019.08.15.05.51.42; Thu, 15 Aug 2019 05:51:57 -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=@ziepe.ca header.s=google header.b=LcThbfWl; 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 S1731454AbfHOMf6 (ORCPT + 99 others); Thu, 15 Aug 2019 08:35:58 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:46203 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbfHOMf6 (ORCPT ); Thu, 15 Aug 2019 08:35:58 -0400 Received: by mail-qk1-f195.google.com with SMTP id p13so1607005qkg.13 for ; Thu, 15 Aug 2019 05:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dMM4Yh2lSK206Ipl1C50HgHP0mjyxRSuLJo2cy44isg=; b=LcThbfWlDi/1kO+hot7trp2RyPL/m8trA/zLWvD92LpYSw9yeBGasQ9R8EuhQAD4Bt bKTs6mxBzCYP5bxVj7suBbpQpwPmyVk9+ValBigp6E3/dN66mhkX8Njt4ppVEZtvDs7I pFV8ElSL59gPu/AJrf/nBtVrnXSJNWNiktqRsXie0F6agJz4BKwmgdVzNu8UCtVSZyjt 8Wo1tUaZ7v0gu4catDl7h/ooM4QQ31MZD++g646hqe9H7YlNvUSIJCxR7iEcgQ6UNJ9L 6M/IYIm3vG+ItNPPGAvXI3A8PLTW1EGMyGgSG4iOIgZ0ADxVFk0nYIVgDLqPrtq/MGRs HJ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dMM4Yh2lSK206Ipl1C50HgHP0mjyxRSuLJo2cy44isg=; b=ubhrthV8M4eCxqOK67zH20qKiOG5HfydXIXcksBy8T29TMyb9ehTUW+giecH3qmuvE hUJHbuZ4MnjX8g72BosYIqTlXpaKucxrinChsXTdotCwghH1v+Lhzg1/JR60BlkOYxAH zCBFVPGWFkR0UCDvQE4TxTmdA2CVOAAB8OD18tmNGnO57hj3GWCzO5Aba9bDB0CBM4gw CEw7UYvVpgUooUuR9yTPuFtvDtPQN8YxS84iFIlWqHK4A57iN83m651OMJ61QpAFjFZq +qRZ9eSxTSz2VdPN9BgAPOnix8H03KB4eyUp48xJ1RqrtKj2L4m1MXIQJCwf3LzULghn C0wQ== X-Gm-Message-State: APjAAAUHIcLVTpvhIZOnPIjuFmaSeQy0cM4AvTb2c/oiMJi6NZOHmMPA L0JACeTmbmDsStOUgfIQZakavLx+TZw= X-Received: by 2002:a37:96c7:: with SMTP id y190mr3700663qkd.111.1565872557356; Thu, 15 Aug 2019 05:35:57 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id w10sm1320862qts.37.2019.08.15.05.35.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Aug 2019 05:35:56 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hyEyy-00043M-ES; Thu, 15 Aug 2019 09:35:56 -0300 Date: Thu, 15 Aug 2019 09:35:56 -0300 From: Jason Gunthorpe To: LKML , linux-mm@kvack.org, DRI Development , Intel Graphics Development , Andrew Morton , Michal Hocko , David Rientjes , Christian =?utf-8?B?S8O2bmln?= , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Daniel Vetter Subject: Re: [PATCH 3/5] mm, notifier: Catch sleeping/blocking for !blockable Message-ID: <20190815123556.GB21596@ziepe.ca> References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-4-daniel.vetter@ffwll.ch> <20190815000029.GC11200@ziepe.ca> <20190815070249.GB7444@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190815070249.GB7444@phenom.ffwll.local> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.. Jason