Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1462033ybt; Thu, 25 Jun 2020 06:44:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjje+zG0jvm7gmd1A3jt3zPiOkYmzSCk5AFl0Ub1zOvgUuAps+vNQWSITG4etm16zv9oCr X-Received: by 2002:a17:906:191a:: with SMTP id a26mr20254682eje.315.1593092687989; Thu, 25 Jun 2020 06:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593092687; cv=none; d=google.com; s=arc-20160816; b=uVXFkY+RxYUuNWuflgKPGS38BdLCqXSvSyAg0CGzZZosT6QGdi3xD10N19TZlv6uLo zkLi0ErcI1TdD0JkpEv+jLn0Td0KHL6tThDxK6S02KuA4l+vqpoNMXwJ1TVSMSto31AI bLKa8mHnKPoa7CYJT520SEdLfaiiuys2LFMD/THs0EwLcmIvKKJAwCizY9qBwqnFImyW zYgZBdDJ8sB+fzfxl5QEdGEpwbTSEt+ALWK2TyjRiK/7wsaKJYS4YIbh6Dzjau1wf+5E AY5lizyfvIgJ6LxDnLhSAqbEJLFFNI7v9Zp9vEWNZaDU0gNmksuzU5zVI/jvqe0WmoWt gHiA== 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:cc :to:from:date; bh=SM7Ydl584lMyYn6vwVNkeBpDub5lnuQlUURLr5vP+js=; b=Uz0VcpdEBmeeYwc7vQuUiZ6ATMiBhu4c1h9ExT6bZpxdiwPUI4Ai9xu7pWMk5OQCFx MHkbflQIpI/FAXDGdwM7BPpjXwMr2GjrKjal4lZds9Cy6HTzWvZnm4zDu9aWsg6fvBEh RVxSDO8ZdofZ+64Rmbuklo5Hw7Q+n1vGhuaqF+WDRTVSZLp2wvgRXBPAPGMwVVBD3b9V MSYYwTuMAfMq5VQmm/pQZA9Rp5FecYDioJtcAPKDaQ4P1d8OGKWoNEZgtvFivTLIN8uK ljIsMd4QsjQ408s3b4X21JCIiCJ01QrUdheOdj6v1rlGBzeu26ohMWzfqs/OrzfcrnfF 2KXw== 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 hh22si15013857ejb.85.2020.06.25.06.44.24; Thu, 25 Jun 2020 06:44:47 -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 S2404987AbgFYNkr (ORCPT + 99 others); Thu, 25 Jun 2020 09:40:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:55220 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404966AbgFYNkq (ORCPT ); Thu, 25 Jun 2020 09:40:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E9490AEDD; Thu, 25 Jun 2020 13:40:44 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id E966C1E1274; Thu, 25 Jun 2020 15:40:44 +0200 (CEST) Date: Thu, 25 Jun 2020 15:40:44 +0200 From: Jan Kara To: Matthew Wilcox Cc: Chris Wilson , linux-mm@kvack.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Andrew Morton , Jan Kara , =?iso-8859-1?B?Suly9G1l?= Glisse , John Hubbard , Claudio Imbrenda , "Kirill A . Shutemov" , Jason Gunthorpe Subject: Re: [PATCH] mm: Skip opportunistic reclaim for dma pinned pages Message-ID: <20200625134044.GD17788@quack2.suse.cz> References: <20200624191417.16735-1-chris@chris-wilson.co.uk> <20200625114209.GA7703@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625114209.GA7703@casper.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 25-06-20 12:42:09, Matthew Wilcox wrote: > On Wed, Jun 24, 2020 at 08:14:17PM +0100, Chris Wilson wrote: > > A side effect of the LRU shrinker not being dma aware is that we will > > often attempt to perform direct reclaim on the persistent group of dma > > pages while continuing to use the dma HW (an issue as the HW may already > > be actively waiting for the next user request), and even attempt to > > reclaim a partially allocated dma object in order to satisfy pinning > > the next user page for that object. > > > > It is to be expected that such pages are made available for reclaim at > > the end of the dma operation [unpin_user_pages()], and for truly > > longterm pins to be proactively recovered via device specific shrinkers > > [i.e. stop the HW, allow the pages to be returned to the system, and > > then compete again for the memory]. > > Why are DMA pinned pages still on the LRU list at all? I never got an > answer to this that made sense to me. By definition, a page which is > pinned for DMA is being accessed, and needs to at the very least change > position on the LRU list, so just take it off the list when DMA-pinned > and put it back on the list when DMA-unpinned. Well, we do mark_page_accessed() when pinning in GUP. This is not perfect but it's as good as it gets with CPU having no control when the page is actually accessed. Also taking the page off and then back to LRU list would increase the contention on the LRU list locks and generally cost performance so for short term pins it is not desirable... Otherwise I agree that conceptually it would make some sence although I'm not sure some places wouldn't get confused by e.g. page cache pages not being on LRU list. Honza -- Jan Kara SUSE Labs, CR