From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E11E5C433DF for ; Wed, 24 Jun 2020 14:26:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9DE132072E for ; Wed, 24 Jun 2020 14:26:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="dymmndgS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DE132072E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 40F706B0006; Wed, 24 Jun 2020 10:26:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C0276B0007; Wed, 24 Jun 2020 10:26:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AE9A6B0008; Wed, 24 Jun 2020 10:26:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 144706B0006 for ; Wed, 24 Jun 2020 10:26:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A52CF181ABE86 for ; Wed, 24 Jun 2020 14:25:59 +0000 (UTC) X-FDA: 76964329638.04.hall62_4604e6b26e44 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 76D04801145B for ; Wed, 24 Jun 2020 14:25:46 +0000 (UTC) X-HE-Tag: hall62_4604e6b26e44 X-Filterd-Recvd-Size: 5935 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 14:25:45 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id a14so1107440qvq.6 for ; Wed, 24 Jun 2020 07:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g4v52LhelGRWHo4E060iGv80Sg40kHoTOkJNdHp0l7w=; b=dymmndgStUdd0/3lQSMwLo/eL/Xa3bVbecbtngR0j1pxAmzSD5u+QfdVyDmEO/fuZp JXgn1eXUASD81w6G1vkwKVkFQSX/9453QuyJaGmfHKnkwmuol91YRWbAyPJvnfFK2D2X QmdM1pPzYdNMSwYTMDoQg+jvYCBbFuorT7eEhlbwU2C1KteUBgPKbe2uvnGvWq9DPbhA 5/vIBvShOiYPV+UjYaPM+RkV0i3tcd/gXDVeiOjCVR8odXU6mHuoS+W23dXp6pYzL2pH BQZL8PsbGAqJcYviefOYG67H27DU3lPtFOkasDcQo5vVcL1n57Ateh7s8DnMFZp5YH/4 xkrg== 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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g4v52LhelGRWHo4E060iGv80Sg40kHoTOkJNdHp0l7w=; b=dpa5tnG2Tc4cmrelf7BqVXwt8DMRPsbBG38QU4q2pQPKAWZXspqT/Dms9KLX90JElR xmQqnuzqT3bfWXM68qvWSUBjBZuUzm9AaMs9ISYDiv0WdbM9KMJibHry8RIuQxgUd3O+ 0Wj/rVArSJpZoiSeZCYUhFhPhDKnSrdbpFDRXGSYTjGBA9EBZxbldSOZ6bE/p9/dT0Mf Yogkos8CEqBiwEdXvkVHYC/dMPN6eWQD5HGs9MGUrPk2ff0CWUz+TLeYQwPGGoubh9SP m6iMWbVl8PEy0BmHyT5Zdgt+exIKqOOWzYaNhf34FLAFpx9+vMw7xTxarLa0VrhwMD7w lkMQ== X-Gm-Message-State: AOAM533q3vQLGps5HK4Fn8u72s8tkIGu0zJJgdZQkMffO3BmJ+dsf4Oi h7Z0Thh35+5zMU1dScPPCDd90g== X-Google-Smtp-Source: ABdhPJytdlYpgwrNlGYx3gebaoAxruYw79+A/Wp3ekG9B4Rc2tCTzSijdNEjaSUxVqjMevqv+3UZPA== X-Received: by 2002:a05:6214:b23:: with SMTP id w3mr31814976qvj.63.1593008745274; Wed, 24 Jun 2020 07:25:45 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id w28sm1408065qkw.92.2020.06.24.07.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:25:44 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.93) (envelope-from ) id 1jo6LQ-00DVtv-C2; Wed, 24 Jun 2020 11:25:44 -0300 Date: Wed, 24 Jun 2020 11:25:44 -0300 From: Jason Gunthorpe To: Chris Wilson Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Andrew Morton Subject: Re: [PATCH 1/2] mm/mmu_notifier: Mark up direct reclaim paths with MAYFAIL Message-ID: <20200624142544.GI6578@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> <159300796224.4527.2014771396582759689@build.alporthouse.com> <20200624141604.GH6578@ziepe.ca> <159300850942.4527.8335506003268197914@build.alporthouse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <159300850942.4527.8335506003268197914@build.alporthouse.com> X-Rspamd-Queue-Id: 76D04801145B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jun 24, 2020 at 03:21:49PM +0100, Chris Wilson wrote: > Quoting Jason Gunthorpe (2020-06-24 15:16:04) > > On Wed, Jun 24, 2020 at 03:12:42PM +0100, Chris Wilson wrote: > > > 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". > > > > Maybe I'm unclear what this series is actually trying to fix? > > > > You said "avoiding a recursive wait" which sounds like some locking > > deadlock to me. > > It's the shrinker being called while we are allocating for/on behalf of > the object. As we are actively using the object, we don't want to free > it -- the partial object allocation being the clearest, if the object > consists of 2 pages, trying to free page 0 in order to allocate page 1 > has to fail (and the shrinker should find another candidate to reclaim, > or fail the allocation). mmu notifiers are not for influencing policy of the mm. Jason