Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp690354imm; Thu, 5 Jul 2018 07:20:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5kvKJDVjU2CMRd0ypl6Lg6IcphBHiZdJ/X6BP2imUXH30qeI+O91NlrI+rcCEDyPQfto8 X-Received: by 2002:a62:15c8:: with SMTP id 191-v6mr5340741pfv.194.1530800444479; Thu, 05 Jul 2018 07:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530800444; cv=none; d=google.com; s=arc-20160816; b=pYHGUfopvVaDA50ASw6a0e6l6YMgCpr9MjCXgGkXQeuJHUND/osTLWsAEot2oZtMKp OLcidMLvppxGBEoLT4k03AnCdq4xPLRy1jQkkrKCN08iOAEGwOq6nxwhcqLIkueyKOve XxKfwU89or9U0cE3zRCrtmtzjCERVMQsnBe0HlYKxkjNBZ5SGgaIzC2NplSiOBWY8bpL UqQvuBYEjSj+TI1vSRYLjxMyIHgNC/jbkQTx2j+kP//gCZl4KhCnFVjhDdBxDHH48sGW HwmedyRyj5Zad0gSkQLqmUpWTHPFRP+PCzJoH9WSPp50Q0BEPexOZ8eIxfzr48pKw7d2 7IGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=K9PH+/K89pRAdEgmI3fx7ERZ/RnQIWTYCAT/5katZ6Y=; b=NWVsCLIIFfPFNmwrTpn98aU+TLxttKU7c8gzpFnKGD0ZLAne+0eSQ6tsBnnbsHikh5 dE6WzX94JwhQ6MzaoH+hTBGVlv10D/IVz2VDXvpviDKFBACtL2OXoG7w3ZghAcA/vpCh AhZ/VMLl40wTME/cd6xtRoNWyieGhdq5JIVQOqKRie8trmqFnOg3JDaSEhfM3orjM6Ti NGdWiG/45Rkyhlk2KTvEjSOYWmcCSbmb4F7AZ/PdKIJXv7DztFlXGQefkt5gwqOXQSbb Nj/TWCjZHTygHMiJVTgtgFjGfH3kne5kR9jNF+q2Jfy55/Xyr20kxuoLgunwKuWB2Lys JYfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=gurrF9p8; 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 32-v6si6176159ple.447.2018.07.05.07.19.51; Thu, 05 Jul 2018 07:20:44 -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=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=gurrF9p8; 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 S1753828AbeGEORW (ORCPT + 99 others); Thu, 5 Jul 2018 10:17:22 -0400 Received: from a9-114.smtp-out.amazonses.com ([54.240.9.114]:38118 "EHLO a9-114.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753606AbeGEORU (ORCPT ); Thu, 5 Jul 2018 10:17:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1530800239; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=K9PH+/K89pRAdEgmI3fx7ERZ/RnQIWTYCAT/5katZ6Y=; b=gurrF9p8EF+ztjS5akguIPvrbpwmJoGltGOvXF05khbLUoV6QKjCo8/CbgFRX3LA rLK9+P2t9xeqZs88x7iGjBQ+V+afeAQgDlskNXSXATk/dCWNzOJs0nXT+Tt57SWkDC+ Y3XQ0UVrPOU1DMY1B1sBMbzjlBOlyRwzsqov2AT8= Date: Thu, 5 Jul 2018 14:17:19 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Jan Kara cc: John Hubbard , john.hubbard@gmail.com, Matthew Wilcox , Michal Hocko , Jason Gunthorpe , Dan Williams , linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 5/6] mm: track gup pages with page->dma_pinned_* fields In-Reply-To: <20180704104318.f5pnqtnn3unkwauw@quack2.suse.cz> Message-ID: <010001646acdf1d8-0460be04-cc74-4a2d-be89-a337461bd485-000000@email.amazonses.com> References: <20180702005654.20369-1-jhubbard@nvidia.com> <20180702005654.20369-6-jhubbard@nvidia.com> <20180702095331.n5zfz35d3invl5al@quack2.suse.cz> <010001645d77ee2c-de7fedbd-f52d-4b74-9388-e6435973792b-000000@email.amazonses.com> <01000164611dacae-5ac25e48-b845-43ef-9992-fc1047d8e0a0-000000@email.amazonses.com> <3c71556f-1d71-873a-6f74-121865568bf7@nvidia.com> <20180704104318.f5pnqtnn3unkwauw@quack2.suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2018.07.05-54.240.9.114 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Jul 2018, Jan Kara wrote: > > So this seems unsolvable without having the caller specify that it knows the > > page type, and that it is therefore safe to decrement page->dma_pinned_count. > > I was hoping I'd found a way, but clearly I haven't. :) > > Well, I think the misconception is that "pinned" is a fundamental property > of a page. It is not. "pinned" is a property of a page reference (i.e., a > kind of reference that can be used for DMA access) and page gets into > "pinned" state if it has any reference of "pinned" type. And when you > realize this, it is obvious that you just have to have a special api for > getting and dropping references of this "pinned" type. For getting we > already have get_user_pages(), for putting we have to create the api... Maybe we can do something by creating a special "pinned" bit in the pte? If it is a RDMA reference then set that pinned bit there. Thus any of the references could cause a pin. Since the page struct does not contain that information we therefore have to scan through the ptes to figure out if a page is pinned? If so then we would not need a special function for dropping the reference. References to a page can also be created from devices mmu. Maybe we could at some point start to manage them in a similar way to the page tables of the processor? The mmu notifiers are a bit awkward if we need closer mm integration.