Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1422961imm; Tue, 3 Jul 2018 10:50:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI+yzwoQvlt8XA5pGSL7Ytx6gxPXiRhG2gZmtJ6o0WlnYsC0lSvGI1EQh0MOKL0dwLTWeFP X-Received: by 2002:a63:7847:: with SMTP id t68-v6mr26259362pgc.329.1530640213641; Tue, 03 Jul 2018 10:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530640213; cv=none; d=google.com; s=arc-20160816; b=rdd40bwNw7ap9y5unS4ewi0nSWrfa5cnXKgIR7k2HhPvNzN37gVAFS+7xlr/krEOoP ZZPU8PbZArzhpwbx8dTqJcbno5aw/MksuFRbbqEbkJZlvZClrq1kAGHQcoTnLu7er0Cy e9FD3NHVPgcxa6qOTKoePWwmq3oIPJWJyhXjTwNDLiBQA+VuBPwQE0UyuHB+goCToYpE BECvQaPdimt/t7vFVrK6srLdMzQ1AGvTXsWu95dtksEJRK2ABnqFgZvMNcQhT/qPGXJl FHDcLqxlXyYL8wMZJlOsKpBk/eq04NXvTft18EovmTfMIuL+0raBwTOZ9jtIfPa3nJHg yVyg== 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=7D7XxG5OB9QArfEn8E2UV611MMRJaNLaSvgIspa3Hb4=; b=eb+zl40NoZfkRnrJNhwYk1zoLfUhvOm0CO8doXh2F8y00hWSQC95ikpUZ+axgbeJpq G3QQq/ePKDo8QwSQxwe4TFl5D8aN+URn7n2o7SyldY3AL+IdeQrrlLYiyqP+8qRc8Op+ 6hm6pbVSR0P/Jx3+cgSCHZlOdBfNib8NG+/te2IajzZRkWnENtoRFo/7dp/BztfNlAUx SPOVc3t3vpzFUGorr/NT28OGhf/zz+bfz0y4KXh7fTJr9qb/GthJq4m8eB9cD35oJFxP NEtrFWO5bYc6RXxKRpzdHXqha7dzNePJA78quWmzif3F7G6HEtCI61C8SNDcN3wbPpNq Sttg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=PPY5TrI7; 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 v4-v6si1463839pgf.488.2018.07.03.10.49.58; Tue, 03 Jul 2018 10:50: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=PPY5TrI7; 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 S934400AbeGCRsQ (ORCPT + 99 others); Tue, 3 Jul 2018 13:48:16 -0400 Received: from a9-114.smtp-out.amazonses.com ([54.240.9.114]:35332 "EHLO a9-114.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934194AbeGCRsO (ORCPT ); Tue, 3 Jul 2018 13:48:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1530640093; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=aXbYaSd3EQ3yZCupU/c+djTDBfDgvkfq9r7D/H9Z44M=; b=PPY5TrI7v1CmLCdVsJELPVPYBud7VqDslZc/l9Mab3FTJb/mtDXNAqQJR9JYRwpm 5vlEilrMqHUuel0sOof6jDV33DuqINBPQnoxeQsReFJ2onAvTyHzAW7rqnpk4fpvkpc B1Wb/mGQUlgOgzSBz4lEBQXPT7lT9rJTQYZedZks= Date: Tue, 3 Jul 2018 17:48:13 +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: <3c71556f-1d71-873a-6f74-121865568bf7@nvidia.com> Message-ID: <0100016461425062-724aa9d3-d7c1-4fa2-a87b-dc59cc5f7800-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> 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.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 Tue, 3 Jul 2018, John Hubbard wrote: > The page->_refcount field is used normally, in addition to the dma_pinned_count. > But the problem is that, unless the caller knows what kind of page it is, > the page->dma_pinned_count cannot be looked at, because it is unioned with > page->lru.prev. page->dma_pinned_flags, at least starting at bit 1, are > safe to look at due to pointer alignment, but now you cannot atomically > count... > > 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. :) Try to find some way to indicate that the page is pinned by using some of the existing page flags? There is already an MLOCK flag. Maybe some creativity with that can lead to something (but then the MLOCKed pages are on the unevictable LRU....). cgroups used to have something called struct page_ext. Oh its there in linux/mm/page_ext.c.