Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4209218ybi; Fri, 19 Jul 2019 17:34:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqweylWwVcRRwI+m4eErcWtEpksMl/VXRhLny8B4QyPhz9kAoury3LrSlekeeK5ehL0QSIgK X-Received: by 2002:a17:902:ba96:: with SMTP id k22mr61335382pls.44.1563582890429; Fri, 19 Jul 2019 17:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563582890; cv=none; d=google.com; s=arc-20160816; b=z3EWP4E/cUsrjBhMSIP7Ay9N1IrQurN7SMFgLm0mu7e8xcIEoF/IsRmhubo5ApT6NX 6cvHjJ8n3PUhDGsvQcZlq4I9ogxKapfWZ7S+Lf35qnereK2QCBVX8puOXJKjW509yKvn zVymw+uNcGt7LwXvxHGzWTDnwZMXqUF3gKlxx2jqjYtDeFdoVEeFRkn7K/z/2LLoroNg XVFhkS+VpwzaOtaEHE76Xfsn3Z9Nz56fbZHofP3U0Y+UY1fTeWNC/SrVuDH7xuKP/yYH zTNqaMNvTbp98PvK29j1dthKK0K1bTQfxOZgGPpjxmsT0bOL6XQ2M0dQzK8EsCT86GRJ PqKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=k+MfdY4VFZ+1G6NydT7z1KYzEUKt/3lM29KKNcFF7DE=; b=EcKuR1ZwzOewtZ2cSFrkH8HAzkFHr/e7Jrrev2CBQT9XM5O35d3jffUjafwDl97+m8 cuDOsFJwR8HDW66TcMWNmlkxjqZFqaV4LOLjyCpsPAIchf37NxDYNdOgRjK60GjqqkHF YRND0vN0ibrqDqeAGl2u/NAW+OuV2ssZtoYzVJ0VBqgvxuxPcVqqh4uzoOxhxcn0KbBM dakfB8sbhdkuQO9jn6bioG5tWLyCHjZ5juX3MPAuIQuQqRRCuqPIuJvET2+WNZrU7pXR YjY24efwp1ucEt7plVMB25UCyNWDi2Ghh6ojx+FEE35iTKJIYoIATdVd5m/52E6UWLXl GtGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=S4D0txoX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y21si1393712plp.332.2019.07.19.17.34.35; Fri, 19 Jul 2019 17:34:50 -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=@nvidia.com header.s=n1 header.b=S4D0txoX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731019AbfGSVnW (ORCPT + 99 others); Fri, 19 Jul 2019 17:43:22 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:14072 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728564AbfGSVnV (ORCPT ); Fri, 19 Jul 2019 17:43:21 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 19 Jul 2019 14:43:18 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 19 Jul 2019 14:43:20 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 19 Jul 2019 14:43:20 -0700 Received: from [10.110.48.28] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Jul 2019 21:43:18 +0000 Subject: Re: [PATCH v2 1/3] mm: document zone device struct page field usage To: Ralph Campbell , CC: , Matthew Wilcox , Vlastimil Babka , Christoph Lameter , "Dave Hansen" , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "Kirill A . Shutemov" , Lai Jiangshan , Martin Schwidefsky , Pekka Enberg , Randy Dunlap , Andrey Ryabinin , Christoph Hellwig , Jason Gunthorpe , Andrew Morton , Linus Torvalds References: <20190719192955.30462-1-rcampbell@nvidia.com> <20190719192955.30462-2-rcampbell@nvidia.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Fri, 19 Jul 2019 14:43:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190719192955.30462-2-rcampbell@nvidia.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1563572598; bh=k+MfdY4VFZ+1G6NydT7z1KYzEUKt/3lM29KKNcFF7DE=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=S4D0txoXh5ZlUY37eQf+2R6xEnAxjq7ugYhSFhHNeaZJc9gzt9AFqSTcqwxgF4ipI OaPooSm3TY1Y/tCOgH4IQijSLZMX2+/CTLTxxnYrYVCT1Yd9vvXnBokWprsQCA0SBu hFaFsXxrQ2orwUntRfq0/vwbW9AZnv6tZl6Z/QKbtny+xYzOMoTlK/jNOafxR/RuuN OkUICjRl6gUjlig8xvZ/FwUkCxVyAe7+S9G64st1c0V2EQVHSwmZllERNtNjB8ynC0 +uZq4tzbY321dByCbFHF3UhYBdZPsV93HdC7nag52tX1rzhZGjdAo3WLONbyYZ5Bdy Af+qRnzn1qvRw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/19/19 12:29 PM, Ralph Campbell wrote: > Struct page for ZONE_DEVICE private pages uses the page->mapping and > and page->index fields while the source anonymous pages are migrated to > device private memory. This is so rmap_walk() can find the page when > migrating the ZONE_DEVICE private page back to system memory. > ZONE_DEVICE pmem backed fsdax pages also use the page->mapping and > page->index fields when files are mapped into a process address space. >=20 > Restructure struct page and add comments to make this more clear. >=20 > Signed-off-by: Ralph Campbell > Reviewed-by: John Hubbard > Cc: Matthew Wilcox > Cc: Vlastimil Babka > Cc: Christoph Lameter > Cc: Dave Hansen > Cc: J=C3=A9r=C3=B4me Glisse > Cc: "Kirill A . Shutemov" > Cc: Lai Jiangshan > Cc: Martin Schwidefsky > Cc: Pekka Enberg > Cc: Randy Dunlap > Cc: Andrey Ryabinin > Cc: Christoph Hellwig > Cc: Jason Gunthorpe > Cc: Andrew Morton > Cc: Linus Torvalds > --- > include/linux/mm_types.h | 42 +++++++++++++++++++++++++++------------- > 1 file changed, 29 insertions(+), 13 deletions(-) >=20 > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 3a37a89eb7a7..f6c52e44d40c 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -76,13 +76,35 @@ struct page { > * avoid collision and false-positive PageTail(). > */ > union { > - struct { /* Page cache and anonymous pages */ > - /** > - * @lru: Pageout list, eg. active_list protected by > - * pgdat->lru_lock. Sometimes used as a generic list > - * by the page owner. > - */ > - struct list_head lru; > + struct { /* Page cache, anonymous, ZONE_DEVICE pages */ > + union { > + /** > + * @lru: Pageout list, e.g., active_list > + * protected by pgdat->lru_lock. Sometimes > + * used as a generic list by the page owner. > + */ > + struct list_head lru; > + /** > + * ZONE_DEVICE pages are never on the lru > + * list so they reuse the list space. > + * ZONE_DEVICE private pages are counted as > + * being mapped so the @mapping and @index > + * fields are used while the page is migrated > + * to device private memory. > + * ZONE_DEVICE MEMORY_DEVICE_FS_DAX pages also > + * use the @mapping and @index fields when pmem > + * backed DAX files are mapped. > + */ > + struct { > + /** > + * @pgmap: Points to the hosting > + * device page map. > + */ > + struct dev_pagemap *pgmap; > + /** @zone_device_data: opaque data. */ This is nice, and I think it's a solid step forward in documentation via clearer code. I recall a number of email, and even face to face discussions= , in which the statement kept coming up: "remember, the ZONE_DEVICE pages use mapping and index, too. Actually, that reminds me: page->private is often in use in that case, too, so ZONE_DEVICE couldn't use that, either. I don't think we need to explicitly say that, though, with this new layout. nit: the above comment can be deleted, because it merely echoes the actual code that directly follows it. Either way, you can add: Reviewed-by: John Hubbard thanks, --=20 John Hubbard NVIDIA > + void *zone_device_data; > + }; > + }; > /* See page-flags.h for PAGE_MAPPING_FLAGS */ > struct address_space *mapping; > pgoff_t index; /* Our offset within mapping. */ > @@ -155,12 +177,6 @@ struct page { > spinlock_t ptl; > #endif > }; > - struct { /* ZONE_DEVICE pages */ > - /** @pgmap: Points to the hosting device page map. */ > - struct dev_pagemap *pgmap; > - void *zone_device_data; > - unsigned long _zd_pad_1; /* uses mapping */ > - }; > =20 > /** @rcu_head: You can use this to free a page by RCU. */ > struct rcu_head rcu_head; >=20