Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1384092imm; Tue, 3 Jul 2018 10:09:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdCwzRPVE/WsO+yaw02cA0va3T8FkWWf2tPprunekFyOga3WZ+T2EBlXvBAhKiCWOMG8/UP X-Received: by 2002:a62:8a83:: with SMTP id o3-v6mr30751423pfk.12.1530637753984; Tue, 03 Jul 2018 10:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530637753; cv=none; d=google.com; s=arc-20160816; b=ADIP7uN1I0a1vzPJ+lqaDRXSyrIkc+c9B1B8Dz9V/vD53hGQn8d4k3wved21A6tTz3 qmKl/HCCdfB35Q5CRIQETlW59yizz4EY6wk84XEIK7h58TQBhxu+X6lN/ijLbQxnCQn5 ACKqZa8XWoeXzCVXZiIeG0IPkbaxYIXWlqQHiHBYhhnbWKXTEhqGfDOBHYhg/Rbwaa3n 1GDc6lq3EBGD9ahC6OdsSjDO+vKhtU8B8LmEUSYkWMnIQTOD6pw1GdZyY8WrUSP6VDVh Zf5nyyc7ZAQ0ZPtTluBT+LydtmPlihB+nLmjUTdqgAu1Mh7sKI9979am/qvX/TNk+XfM Ldpw== 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=PlNvGt4Niu1GplK8wDH7AqVGgfaOe8vRNAjVsCWVWIY=; b=tf87TsCQUDMZyeBcdzrWgAwMIw1jcWfcf23NEB/tFAREYK7kwblGl8zypAQUJ2HwuC RAQe+92IBKjTCTNrRLWnMgkj+E9DCh7DlRK9Wci7cYD3pwZAq24FNY9YzWCggYSaSYhQ OJCYLPtPK6AfQjBuRFGDRLcagU7RtB0oowxt6VpoB5/l+pCQzlAYeSLK0IfXpEj5eUuU XqxgmzBVzav604wGf0Dh4lZ0NekP4EWXZ28Z5XGDRorcldLmcwopdhE1/yfFpKrYxJt6 4EcMNxDtLjhIOYaaOdlr9upxhhtD77uXBzh0XEI0K6tGtkveR+JyuhNpWga+BBLmRrDR 1DaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=MXYx+ZNh; 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 a7-v6si1568745pfg.200.2018.07.03.10.08.59; Tue, 03 Jul 2018 10:09:13 -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=MXYx+ZNh; 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 S933677AbeGCRIR (ORCPT + 99 others); Tue, 3 Jul 2018 13:08:17 -0400 Received: from a9-112.smtp-out.amazonses.com ([54.240.9.112]:58602 "EHLO a9-112.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933860AbeGCRIN (ORCPT ); Tue, 3 Jul 2018 13:08:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1530637692; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=PlNvGt4Niu1GplK8wDH7AqVGgfaOe8vRNAjVsCWVWIY=; b=MXYx+ZNhw/Fq5P0Dsgku8oNfTWT2I6kLWXiAWkILf30UmrxjIhOyNEFSuoLTV75F G9yEos2Ps3bbsAHRH4r+6NJH77rP7qWmyQQcICVxOZxpK0fhuB9FiOPbLtxRmLHZXnZ +NuftoYn591eC9HTlCW13P63ZY7gimFZAZmuaGuc= Date: Tue, 3 Jul 2018 17:08:12 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: John Hubbard cc: Jan Kara , 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: Message-ID: <01000164611dacae-5ac25e48-b845-43ef-9992-fc1047d8e0a0-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> 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.03-54.240.9.112 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 Mon, 2 Jul 2018, John Hubbard wrote: > > If you establish a reference to a page then increase the page count. If > > the reference is a dma pin action also then increase the pinned count. > > > > That way you know how many of the references to the page are dma > > pins and you can correctly manage the state of the page if the dma pins go > > away. > > > > I think this sounds like what this patch already does, right? See: > __put_page_for_pinned_dma(), __get_page_for_pinned_dma(), and > pin_page_for_dma(). The locking seems correct to me, but I suspect it's > too heavyweight for such a hot path. But without adding a new put_user_page() > call, that was the best I could come up with. When I saw the patch it looked like you were avoiding to increment the page->count field. > What I'm hearing now from Jan and Michal is that the desired end result is > a separate API call, put_user_pages(), so that we can explicitly manage > these pinned pages. Certainly a good approach.