Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp618398ybt; Wed, 24 Jun 2020 07:15:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCmTdDv+X0cQOC6iS0bQKJVQ1ZpAt2lN2WLTcxUbN/Gq5wW+Zd6UdBy6VZn4sPNwY6iFAZ X-Received: by 2002:a17:906:1102:: with SMTP id h2mr24260625eja.356.1593008143213; Wed, 24 Jun 2020 07:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593008143; cv=none; d=google.com; s=arc-20160816; b=dMVBBbZ5kDyPNEshUi41G1NzgBJ11tXvOsIfe3aGCGi7P4Q/o/Heqm5/1i6tCOJ1fl RQAy8C4CfDS4CR6Q2vD2jBitSdyfa0igcszmzn7PGlWpwKdFpupiorvzmo3hifIuPyvs BMg3KLL7scgUYafAEcNo1UbxjLCUWw0tsLsRlgYAJvtFaQ8TKL02DL41xRTGXuv9w5/r 18z1RqcqHnylonR1s0YSWdXWzfgkwkTnv+uTkR2ZPjCsVb/smpBbMuKe9T0O16RPZA26 eDErWZ3TEakbLfnwRZwItSk7CJujSwXK14r0H7vPYvi1xH1OTTvSPDnJSvDR5wggfHce j9Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:message-id:cc:to:subject :from:references:in-reply-to:content-transfer-encoding:mime-version; bh=v2wV7W5fxxSP8BlnaMThkBszjeizKs0/MN3N+Hw2p2o=; b=A4vPOU+RaHHC1B4rBqyLIYXVNzIiRahlWbDNTNOwtqD2ttRZKzdrz+DPds0WG9D7S4 ehRv2LQtaGeabINr0qjHG8/cIAheUV2Emno+3NX1LNeD2W1FdD/NuDj7vuuns/a9YzdS fghF4wyTK9bdOh8mU2R/+ESaUQgkvo7b/fkj2be7xqAsUgF8/Ap3f3I4enmUFiF0UmWr VuEAc16Zfif7e26EGNVD+iLA8mV6NU1M/g39C9CeEHsT6uB6E+yQ+sUolw2oZn5s+0G4 hWIfidGu4+uosOD+pcxwdwHeONE211iPa2k4wx8HHnL3fbhn/tPZgMnkhc8InT4dn+Nt R3+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si12681533ejr.363.2020.06.24.07.15.19; Wed, 24 Jun 2020 07:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391062AbgFXOMw convert rfc822-to-8bit (ORCPT + 99 others); Wed, 24 Jun 2020 10:12:52 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:58921 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388395AbgFXOMv (ORCPT ); Wed, 24 Jun 2020 10:12:51 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 21603647-1500050 for multiple; Wed, 24 Jun 2020 15:12:46 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT In-Reply-To: <20200624123910.GA3178169@ziepe.ca> References: <20200624080248.3701-1-chris@chris-wilson.co.uk> <20200624121053.GD6578@ziepe.ca> <159300126338.4527.3968787379471939056@build.alporthouse.com> <20200624123910.GA3178169@ziepe.ca> From: Chris Wilson Subject: Re: [PATCH 1/2] mm/mmu_notifier: Mark up direct reclaim paths with MAYFAIL To: Jason Gunthorpe Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Andrew Morton Message-ID: <159300796224.4527.2014771396582759689@build.alporthouse.com> User-Agent: alot/0.8.1 Date: Wed, 24 Jun 2020 15:12:42 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Jason Gunthorpe (2020-06-24 13:39:10) > On Wed, Jun 24, 2020 at 01:21:03PM +0100, Chris Wilson wrote: > > Quoting Jason Gunthorpe (2020-06-24 13:10:53) > > > On Wed, Jun 24, 2020 at 09:02:47AM +0100, Chris Wilson wrote: > > > > When direct reclaim enters the shrinker and tries to reclaim pages, it > > > > has to opportunitically unmap them [try_to_unmap_one]. For direct > > > > reclaim, the calling context is unknown and may include attempts to > > > > unmap one page of a dma object while attempting to allocate more pages > > > > for that object. Pass the information along that we are inside an > > > > opportunistic unmap that can allow that page to remain referenced and > > > > mapped, and let the callback opt in to avoiding a recursive wait. > > > > > > i915 should already not be holding locks shared with the notifiers > > > across allocations that can trigger reclaim. This is already required > > > to use notifiers correctly anyhow - why do we need something in the > > > notifiers? > > > > for (n = 0; n < num_pages; n++) > > pin_user_page() > > > > may call try_to_unmap_page from the lru shrinker for [0, n-1]. > > Yes, of course you can't hold any locks that intersect with notifiers > across pin_user_page()/get_user_page() What lock though? It's just the page refcount, shrinker asks us to drop it [via mmu], we reply we would like to keep using that page as freeing it for the current allocation is "robbing Peter to pay Paul". -Chris