Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2078533ybl; Thu, 15 Aug 2019 06:15:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJSI/W7H+knckLUqblr3Ex3FyTqqfBCiQB6CqATvrO4QzsKeb0VkP05++T5LJfhVy5Jwob X-Received: by 2002:a17:90a:26ac:: with SMTP id m41mr2200218pje.59.1565874921982; Thu, 15 Aug 2019 06:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565874921; cv=none; d=google.com; s=arc-20160816; b=GmGn8EW+aKQASrVNoWNQ1DcpAnnQvNXFuUyq/qd0Ut7B74l07HnW8zW3GuRupfomdP XLGoRdf+BbfAA0P/NLCR5WP57rGy7aP3GqlpdMH/KcuNz6pvq9NhvlIOjy2LEXrJdy+z pdODXPUfoSd6UGSekiz9T+ISF4XKDz/sTCq/q1hIXiZEjPbXCDbqlX9vFDm7mCULc3Yf 4wDJyzmXdjHQpQHjxnlgWnTYw8DAJ4Rb5CuHQ5m0+eOW6IJ8bHJgCBP2xRfqO5r8Z9vE e2Vb//491D+MlSLvNy32SMQRrfkNA085MAzkN+LWGsaohABu2Bl7VwyxSoWXW/K0vAHZ biyw== 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=nLAvE7lDJNY/2hXIcylLI9QM83e4RDXFU2y4iIE01K4=; b=G0Kardc9Q+7RVwqO6F7mbiycOPoPTIfyvCEIUbtNvAxu0DKJwyh1A/MiCtg0lYXwd1 drCq1lB9s8zqI1w0f19leLeWNpKlgfPL4oPKJ0unyJC4VFzdcttXUVdcoM2QFoBoSfiC Y6Z2PU+DOEBdL/vrm00zgBgh+KYwaP+Q1kmbLL+N1I+PHpbAKPU+ibjViLgzsHxtzdf5 I9Z75KryzZWnRhQjAtpT3XaWnFb6i5uFjCiyAmzFem7+21zK5C576BzZimoHRDZkbEnk gMeeLBvEOd/YZNLTAzPtJfbHc7xeShha0Ped6jpAsdnkv9o8A3GXxnozNxwRYZZnO6p2 12dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Za9fYZAv; 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 d13si2020271pfo.33.2019.08.15.06.15.05; Thu, 15 Aug 2019 06:15:21 -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=Za9fYZAv; 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 S1732173AbfHONM2 (ORCPT + 99 others); Thu, 15 Aug 2019 09:12:28 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46787 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731840AbfHONM2 (ORCPT ); Thu, 15 Aug 2019 09:12:28 -0400 Received: by mail-ot1-f68.google.com with SMTP id z17so5603172otk.13 for ; Thu, 15 Aug 2019 06:12:27 -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=nLAvE7lDJNY/2hXIcylLI9QM83e4RDXFU2y4iIE01K4=; b=Za9fYZAvz38c7q5/yD99Bw30IvGPgKhHThVM4vKevIWU3/BW35bi+F3ppSbkTaFkbT fo2CpvHM7cVjqc50yRgI9kWHHLUpxwV9lKj2e5yAkPWwg/XLsgOFJ9+5aRlUooRkXMat 8A59WCTr5lrTYXQcbNjUgSTq+i4lJG3Axdh94= 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=nLAvE7lDJNY/2hXIcylLI9QM83e4RDXFU2y4iIE01K4=; b=QFt5DEp446KNuxL+oFtMeJZ2TebTj87CiXVZ2N21usCSBGSyqj8/pVZ7tybjdnzLw6 z6YfKo0yaE7LhHxk0IPpehYxxaOlQ1py4GaRvIoJi4yMA/cdMS4bhsrgzh+0NVF9h6qH azuGRqApDB7e7fZs/lRiEMHnamzut3SqNKZoIt6ZBr12J4+yu6u6VniBfzXjpmG/ovQd SrxTZHwbQveUGH2oTdkqMf+mDM7Shn/c3OQ0NaYXaAydEk2TTYifnwVTMxcNdHLRth5X m/amtK0kl1u0f1giKsItrZ7ExcK5DqMwqzXdqwbEv/xCpsLAFsnKF4Yuqo4I/cJjm3Hs JWWg== X-Gm-Message-State: APjAAAVbVGmq2bSfIsE/Z5fL4I4yiguaijeUTRJkU/7Bcmw56SxGRZR3 7ir32HujB/PIQOeYETaevF6fLXK2u5i1gL7FAzdnCQ== X-Received: by 2002:a9d:7cc9:: with SMTP id r9mr3688645otn.188.1565874747163; Thu, 15 Aug 2019 06:12:27 -0700 (PDT) MIME-Version: 1.0 References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-3-daniel.vetter@ffwll.ch> <20190814134558.fe659b1a9a169c0150c3e57c@linux-foundation.org> <20190815084429.GE9477@dhcp22.suse.cz> <20190815130415.GD21596@ziepe.ca> In-Reply-To: <20190815130415.GD21596@ziepe.ca> From: Daniel Vetter Date: Thu, 15 Aug 2019 15:12:11 +0200 Message-ID: Subject: Re: [PATCH 2/5] kernel.h: Add non_block_start/end() To: Jason Gunthorpe Cc: Michal Hocko , Andrew Morton , LKML , Linux MM , DRI Development , Intel Graphics Development , Peter Zijlstra , Ingo Molnar , David Rientjes , =?UTF-8?Q?Christian_K=C3=B6nig?= , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , 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 Thu, Aug 15, 2019 at 3:04 PM Jason Gunthorpe wrote: > > On Thu, Aug 15, 2019 at 10:44:29AM +0200, Michal Hocko wrote: > > > As the oom reaper is the primary guarantee of the oom handling forward > > progress it cannot be blocked on anything that might depend on blockable > > memory allocations. These are not really easy to track because they > > might be indirect - e.g. notifier blocks on a lock which other context > > holds while allocating memory or waiting for a flusher that needs memory > > to perform its work. > > But lockdep *does* track all this and fs_reclaim_acquire() was created > to solve exactly this problem. > > fs_reclaim is a lock and it flows through all the usual lockdep > schemes like any other lock. Any time the page allocator wants to do > something the would deadlock with reclaim it takes the lock. > > Failure is expressed by a deadlock cycle in the lockdep map, and > lockdep can handle arbitary complexity through layers of locks, work > queues, threads, etc. > > What is missing? Lockdep doens't seen everything by far. E.g. a wait_event will be caught by the annotations here, but not by lockdep. Plus lockdep does not see through the wait_event, and doesn't realize if e.g. that event will never signal because the worker is part of the deadlock loop. cross-release was supposed to fix that, but seems like that will never land. And since we're talking about mmu notifiers here and gpus/dma engines. We have dma_fence_wait, which can wait for any hw/driver in the system that takes part in shared/zero-copy buffer processing. Which at least on the graphics side is everything. This pulls in enormous amounts of deadlock potential that lockdep simply is blind about and will never see. Arming might_sleep catches them all. Cheers, Daniel PS: Don't ask me about why we need these semantics for oom_reaper, like I said just trying to follow the rules. -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch