Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4910731imm; Tue, 16 Oct 2018 01:57:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV6078jFnSG5S3L6/l0vFrmg3sTrWjkRN06IHRGfe8RP8oWbI/JxOvA3boEcQQ4pr63MVTzr4 X-Received: by 2002:a63:1066:: with SMTP id 38-v6mr19619498pgq.254.1539680262823; Tue, 16 Oct 2018 01:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539680262; cv=none; d=google.com; s=arc-20160816; b=AmhTNfXXE/YHag6wxVM0S/Si5P3FaUSN+MxIIGlEy0VJgagFi6Y6TNlVOYzeJONi08 3R0kuhgNYvFJMGOgw8Sek5KgK0PUGSiSXtk9eI64PO0/bDbZ4A6Kn2b8EZbNJw7pZa1x W7pwNRL71M9H622/shnhj3/XIXtpL+UaiUMeV/ubKNOYVZHZq9TxDkBw07LYmc1gtvye yWJEcbFpomUYIstZM2RJh0L4aQsP0EXhVzQ35J4Ya6DdOPBELsH2gwNONTQbZruG3x5e BFN1KKrXLtXqBbqzJxpHJObSnQnc1NIzvv+OwjgtlZfr7918+t0YV1yMRzXAOj5jTtaK WUvg== 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=eXscdt9XxnBwsz9jKHyeAr5udDoGHBy1R8whaIn8PY0=; b=GZJgaRwjvHCuoGF8HAXzvOLr0LBmEOexiecutT8BvOf2L6y0PzNnstsLyAZZLNfP5w IX02dL7v4uwAGSWZiqiM3mHR0FLDFxKJH17FljSxwuu2a8Pb3GVUbeOaXeXGn563A2M3 zfAu7LGZEseypPv78vaMF/RBQhjT+upxvvpHNDfyy+xT0sYJgS0Z9jiFijXJd5nwnX5l cbrfDmgp2QvyZSTRgx0Roo3Liy6JgKYciYYW2d7QUs1PWdpbP+B7v8kCYKAAbLgDj6tc UAZ7dmLnMXFanwpCioQxPymaiI8pFFWb7bDvxj95e/ZLL3CLD5Exr8z8v7pGlwqKiSdA NF8g== ARC-Authentication-Results: i=1; mx.google.com; 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 y190-v6si13464472pfy.147.2018.10.16.01.57.25; Tue, 16 Oct 2018 01:57:42 -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; 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 S1727384AbeJPQkn (ORCPT + 99 others); Tue, 16 Oct 2018 12:40:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:39980 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726541AbeJPQkm (ORCPT ); Tue, 16 Oct 2018 12:40:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 63DB6B08B; Tue, 16 Oct 2018 08:51:03 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id ADB0F1E088D; Tue, 16 Oct 2018 10:51:02 +0200 (CEST) Date: Tue, 16 Oct 2018 10:51:02 +0200 From: Jan Kara To: Dave Chinner Cc: John Hubbard , Matthew Wilcox , Michal Hocko , Christopher Lameter , Jason Gunthorpe , Dan Williams , Jan Kara , linux-mm@kvack.org, Andrew Morton , LKML , linux-rdma , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 4/6] mm: introduce page->dma_pinned_flags, _count Message-ID: <20181016085102.GB18918@quack2.suse.cz> References: <20181012060014.10242-1-jhubbard@nvidia.com> <20181012060014.10242-5-jhubbard@nvidia.com> <20181013035516.GA18822@dastard> <7c2e3b54-0b1d-6726-a508-804ef8620cfd@nvidia.com> <20181013230124.GB18822@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181013230124.GB18822@dastard> 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 Sun 14-10-18 10:01:24, Dave Chinner wrote: > On Sat, Oct 13, 2018 at 12:34:12AM -0700, John Hubbard wrote: > > On 10/12/18 8:55 PM, Dave Chinner wrote: > > > On Thu, Oct 11, 2018 at 11:00:12PM -0700, john.hubbard@gmail.com wrote: > > >> From: John Hubbard > > [...] > > >> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > >> index 5ed8f6292a53..017ab82e36ca 100644 > > >> --- a/include/linux/mm_types.h > > >> +++ b/include/linux/mm_types.h > > >> @@ -78,12 +78,22 @@ struct page { > > >> */ > > >> union { > > >> struct { /* Page cache and anonymous pages */ > > >> - /** > > >> - * @lru: Pageout list, eg. active_list protected by > > >> - * zone_lru_lock. Sometimes used as a generic list > > >> - * by the page owner. > > >> - */ > > >> - struct list_head lru; > > >> + union { > > >> + /** > > >> + * @lru: Pageout list, eg. active_list protected > > >> + * by zone_lru_lock. Sometimes used as a > > >> + * generic list by the page owner. > > >> + */ > > >> + struct list_head lru; > > >> + /* Used by get_user_pages*(). Pages may not be > > >> + * on an LRU while these dma_pinned_* fields > > >> + * are in use. > > >> + */ > > >> + struct { > > >> + unsigned long dma_pinned_flags; > > >> + atomic_t dma_pinned_count; > > >> + }; > > >> + }; > > > > > > Isn't this broken for mapped file-backed pages? i.e. they may be > > > passed as the user buffer to read/write direct IO and so the pages > > > passed to gup will be on the active/inactive LRUs. hence I can't see > > > how you can have dual use of the LRU list head like this.... > > > > > > What am I missing here? > > > > Hi Dave, > > > > In patch 6/6, pin_page_for_dma(), which is called at the end of get_user_pages(), > > unceremoniously rips the pages out of the LRU, as a prerequisite to using > > either of the page->dma_pinned_* fields. > > How is that safe? If you've ripped the page out of the LRU, it's no > longer being tracked by the page cache aging and reclaim algorithms. > Patch 6 doesn't appear to put these pages back in the LRU, either, > so it looks to me like this just dumps them on the ground after the > gup reference is dropped. How do we reclaim these page cache pages > when there is memory pressure if they aren't in the LRU? Yeah, that's a bug in patch 6/6 (possibly in ClearPageDmaPinned). It should return the page to the LRU from put_user_page(). Honza -- Jan Kara SUSE Labs, CR