From patchwork Fri Jul 19 19:06:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ralph Campbell X-Patchwork-Id: 11050523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE570112C for ; Fri, 19 Jul 2019 19:07:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2097288FC for ; Fri, 19 Jul 2019 19:07:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5C312893A; Fri, 19 Jul 2019 19:07:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00715288FC for ; Fri, 19 Jul 2019 19:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A0216B0006; Fri, 19 Jul 2019 15:07:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 350FC8E0003; Fri, 19 Jul 2019 15:07:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2669D8E0001; Fri, 19 Jul 2019 15:07:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id 00DFC6B0006 for ; Fri, 19 Jul 2019 15:07:06 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id 75so24429328ywb.3 for ; Fri, 19 Jul 2019 12:07:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding:dkim-signature; bh=n97TMr2JNhrSZ7vCgIqLLYdPmnZDRy5pEGPbgjYfhkI=; b=uQg97wJ7Z4h2QrO+XJ1bDXdibKxwvANtde46rhrAMyUku0bkadO6nojthd2QEt1I43 IN0kel8l5t26olLTk2Bb7/OtPZA3Uz6+ZfurcqYCBwdxOy8yE1nVrxsve4C8BKgLFU0A LfAbpaUAGBNp/8/UL4npG9HYAsfbt0Int5jqdPMWinIq5vmt//kMvVO1FLMhDhrkRq3E GndbChoZu1YgFYr37ImT+lCzzGFyeq/76SOOst2Qf6q4O9a904KKMy4na9jY6uyq8Yie DrXpQJclv/gr3d0ZpUaUzWz0Uha6O7E3T4cPL2NwQYVxtg6hZPQnMeCFMxUZ1L7cbjF/ UxSA== X-Gm-Message-State: APjAAAX6C9CR2ylpnue/nfbWwU6qj44HpGsGW1aJ9Go4bZSTkQpymjat tJDfGGgw2TasBz5PaDMhLf5scAfy17iSfDybI1900tMBCtCT6HVQP54qyOun+C/jVreWlBLbfwm jSwnVe1z2M7auPAEHgUMm1IQ5/aNSeEGPIUKhNU90XIFB5BYIayI6azrW2R9JcAlJ+A== X-Received: by 2002:a25:5f48:: with SMTP id h8mr31072935ybm.231.1563563225713; Fri, 19 Jul 2019 12:07:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqz+JaVeFfwFYAacs4HDRqHDcXGW2suzG77yaxtKXss8rXNJp51LdmFZm0cBnIpbaGEEP8 X-Received: by 2002:a25:5f48:: with SMTP id h8mr31072891ybm.231.1563563224924; Fri, 19 Jul 2019 12:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563563224; cv=none; d=google.com; s=arc-20160816; b=Ix3Cr1vS4tdJ6U5jctNGU+GsRN/yxFZYOLoZvvkgo7z4p7asQv+r0NyyWRz90Ze4rF uw9DjrKGEB5oR1bGf3zVHO2GWptrcQzMoi2TQ3ucDgZerVhUBgXAKxNaLNUaxc6CgU8C QDKqL68MGMNS11xMj3oDCct8Lgv1v9YuNjOXTvDC/hziwCIhHq+mtSoFcRz+n9k6jEPR Vyo+LfyPISpqgGBHzzvOhP02UMA16OQNhY/pf/SpjQFXO9lkIWgt2C3dGU+QB/T3KxNS zvVEZAEWeOM3Ai74Lp12LFT+LGUd5RsDmiYsZVH/yFRBufQmNYrNaDMhKT4DFmm+Ki63 jgMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=n97TMr2JNhrSZ7vCgIqLLYdPmnZDRy5pEGPbgjYfhkI=; b=jGWKl54Kil2HMzgxZ+Lz4cPrygRr4IY2BkwkqZdjge3M2mDDDkpJnHfDWdKSFD1PFY 7wZLnfP+Kk9LKqluZb5Wmr4zK2SLDwYNPDnC4HyAYe04hygZSVqddmfXiLSEBafdpCWE i13L1AxXrN0jprpQpBQWz6+eI3gaRFvpRtcMbDusMNdSVM8iXGgo6oGWDbAp67RgvJ6x CA4FJCAl0B0kcmhxkXTePZyA2EUR3YTv6w5sDZW8OG9oy4bP3Dqnh9ug8QlbTQcUlIne mpWQt3mw5NY3B9vlfv0yZBGtQj2uL5ExWH4ihBj2UHok/7uICV/l5CNIDJWrTSt09nDL DmEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=XEXD8+Mp; spf=pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.143 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from hqemgate14.nvidia.com (hqemgate14.nvidia.com. [216.228.121.143]) by mx.google.com with ESMTPS id k128si13078839ybk.341.2019.07.19.12.07.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jul 2019 12:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.143 as permitted sender) client-ip=216.228.121.143; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=XEXD8+Mp; spf=pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.143 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 19 Jul 2019 12:07:04 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 19 Jul 2019 12:07:03 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 19 Jul 2019 12:07:03 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Jul 2019 19:07:03 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Jul 2019 19:07:00 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 19 Jul 2019 19:07:00 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 19 Jul 2019 12:07:00 -0700 From: Ralph Campbell To: CC: , Ralph Campbell , 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 Subject: [PATCH 1/3] mm: document zone device struct page reserved fields Date: Fri, 19 Jul 2019 12:06:47 -0700 Message-ID: <20190719190649.30096-2-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719190649.30096-1-rcampbell@nvidia.com> References: <20190719190649.30096-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1563563224; bh=n97TMr2JNhrSZ7vCgIqLLYdPmnZDRy5pEGPbgjYfhkI=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Type:Content-Transfer-Encoding; b=XEXD8+MpeZa8W8p+pE1zOfZ44fRxNZfhiDWMcWxGdu0UuRY6HiaEZ343XnQhe8G9l plFxe13YRg7+09Pz3X/2r5ztqQ7vDggzGl7dYEf2qZhHAFEEIdiXXDfJIM11GZaBXD 8Sn/eycEEMOXvMVmcYByNs3x4Hgc294+XGXs2WN7VREX6SoSERQlIZ2kWAFpsBezK1 2qPKW/Tai815rjsLCrsQlfRNce4ANwWohy9W95HfonwFgt6rH/hFQ5j/SDdTFdiNVN fyGTBqmwrAFuong+CNyxx6UPxHoDak9BCXrLSaPipZ+8bknLhdkw5Dh6BPDewv6qoB LscjOGnASY84g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Struct page for ZONE_DEVICE private pages uses the reserved fields when anonymous pages are migrated to device private memory. This is so the page->mapping and page->index fields are preserved and the page can be migrated back to system memory. Document this in comments so it is more clear. Signed-off-by: Ralph Campbell Cc: Matthew Wilcox Cc: Vlastimil Babka Cc: Christoph Lameter Cc: Dave Hansen Cc: Jérôme 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 3a37a89eb7a7..d6ea74e20306 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -159,7 +159,14 @@ struct page { /** @pgmap: Points to the hosting device page map. */ struct dev_pagemap *pgmap; void *zone_device_data; - unsigned long _zd_pad_1; /* uses mapping */ + /* + * The following fields are used to hold the source + * page anonymous mapping information while it is + * migrated to device memory. See migrate_page(). + */ + unsigned long _zd_pad_1; /* aliases mapping */ + unsigned long _zd_pad_2; /* aliases index */ + unsigned long _zd_pad_3; /* aliases private */ }; /** @rcu_head: You can use this to free a page by RCU. */ From patchwork Fri Jul 19 19:06:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ralph Campbell X-Patchwork-Id: 11050525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A3B01510 for ; Fri, 19 Jul 2019 19:07:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E1E0288FC for ; Fri, 19 Jul 2019 19:07:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 613C42893A; Fri, 19 Jul 2019 19:07:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B23228936 for ; Fri, 19 Jul 2019 19:07:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 462C46B0007; Fri, 19 Jul 2019 15:07:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 414388E0003; Fri, 19 Jul 2019 15:07:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DAD28E0001; Fri, 19 Jul 2019 15:07:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id 0B6A76B0007 for ; Fri, 19 Jul 2019 15:07:10 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id t18so25276879ybp.13 for ; Fri, 19 Jul 2019 12:07:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding:dkim-signature; bh=xvR8iX2outgELqejVmTcMhX9RlYLy+wU1js0WKyDum8=; b=VeVFJlFNlA0a/L/WMWSl8pWZ763KHXNDN/D4ylkRP+6BYtDYrZd74f6rboCtJ/jp03 5wJZXXGKQNaDjEI2QefybiY8rl+r6f53Yje4ribFSHFkTMWPC4eMAeKVy8jAfGH9xSa9 dHSEIa0DJnoabTQYx3TiKu9J2hH2EW6mo0+3XIKJfk5k2B1MPV4LA/dVZHYXzD9X5/Zf 4muVhvR5t8UhpWG5ARcl44O0Cb6E0tY7DS2XypQHH6rncwTDXOV/BbYWsh6IF13J/3Ah g7aiYZr/+VxPG5kXmiE1NYWzyRkt21PzvZEAGcihe07OuO8OJFOajJryPoHJJhfDfqtW n7gw== X-Gm-Message-State: APjAAAUz6y1yiUInXkIW4WR+7NTcA6MPSQxC4MzEhHTtDeaII9ZsfQLg SsOvLjGjSYOPxy/Cx785kklh6j53/h4i9hz3Fef9AR0JVMQejAGRJ6OUKczxjVZXxobJEOEJJ7x 92M8Xyojrjj7UgIZI4P+axfCCiEonooApkSqKdvE4AJiYrP+K+NNg4Y4PBWxvcaL9Sg== X-Received: by 2002:a81:494f:: with SMTP id w76mr31517836ywa.21.1563563229817; Fri, 19 Jul 2019 12:07:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIQE25zpOaI2NCzJVw2bYOmYYOUwqjF7jDMH1p5LGwPcEFOt/j7tsnRER8ANLpovEe31xo X-Received: by 2002:a81:494f:: with SMTP id w76mr31517779ywa.21.1563563228864; Fri, 19 Jul 2019 12:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563563228; cv=none; d=google.com; s=arc-20160816; b=K0EM4rGyy00PDH43lKjyov8COnSUMk+VCRZ9+u7m8KjQzo/Ap9kxzKyxjOH/uVPrux qMvepriTal62iZ5x0syQVa7EYEryDnahLLhncH1LKcb8nfSaEqC6ul04txWrHZ+xongh nZ+WHXnu7i3OBLvJIAbsAdz/oieaYpg3eDFTFLzXl8D+8rv0XFI2xkvYP7Bolu03GrNR +FNuEyuJiIruWTZiunxLNHDfB/PN45gzAP0yVgscB0NsH3chL9/IyymzacvBojDMxuFd 90mcjiYrrrknT5BxEoRYr8gD3Y+xjLWotwJzBRQNlyj0FGqNS6EDnY3sKDHCkH1+4TnU fXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=xvR8iX2outgELqejVmTcMhX9RlYLy+wU1js0WKyDum8=; b=weM64Nl5l53zqSmvRtJiQG8Sb22/Fm/L+LXLgYEtF9v0b8EUt1gxA120lmlFPfFDvR 9KT6UFHmFazeBPz7/2iXa9Ybwdls+KpmGrK7393rxfKoupTpWUWsSSkLxO5UbyiJgUjY 4SDjL4c2irobBgch7GrURQL7Q0h1DZ1eytUdqbDV5tlf+FrLo/0KYLGLP+8RHz3fWp5i j10zLs0Wn0I+iDCveCbZFzNEZL228DSNgeSQQUabaxzVycQl1JWTVmAQb5tBYNgWlWC2 g3jGF4TrV8M7mkSWsKSUfXWQnjinyPnM1Cm/kU8A+8To4x28MIl8xy/06G0M/Ps3M8/7 t1PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=OKZvq3+z; spf=pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.65 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from hqemgate16.nvidia.com (hqemgate16.nvidia.com. [216.228.121.65]) by mx.google.com with ESMTPS id k188si6359068yba.293.2019.07.19.12.07.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jul 2019 12:07:08 -0700 (PDT) Received-SPF: pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.65 as permitted sender) client-ip=216.228.121.65; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=OKZvq3+z; spf=pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.65 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 19 Jul 2019 12:07:04 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 19 Jul 2019 12:07:06 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 19 Jul 2019 12:07:06 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Jul 2019 19:07:06 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Jul 2019 19:07:02 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 19 Jul 2019 19:07:02 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 19 Jul 2019 12:07:02 -0700 From: Ralph Campbell To: CC: , Ralph Campbell , , Christoph Hellwig , Dan Williams , Andrew Morton , "Jason Gunthorpe" , Logan Gunthorpe , "Ira Weiny" , Matthew Wilcox , "Mel Gorman" , Jan Kara , "Kirill A. Shutemov" , Michal Hocko , Andrea Arcangeli , Mike Kravetz , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= Subject: [PATCH 2/3] mm/hmm: fix ZONE_DEVICE anon page mapping reuse Date: Fri, 19 Jul 2019 12:06:48 -0700 Message-ID: <20190719190649.30096-3-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719190649.30096-1-rcampbell@nvidia.com> References: <20190719190649.30096-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1563563224; bh=xvR8iX2outgELqejVmTcMhX9RlYLy+wU1js0WKyDum8=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Type:Content-Transfer-Encoding; b=OKZvq3+z673WKe9ZxHHENZNaFNaPQZoxO8AM7Y6bFKGbam/hN8xmfqFwVzF/1F1Y0 UcnRMsDU67Z51I9cCja1HqAyybrks1U6IV32zBohgz0b+bAkYuAPGZeU4bl49NjQY+ oSgVVuKMaEJ9+usmKExyucb5HPeidwazzVoZM/YEk5eWYU9GEVacTlZdhbiM8F4FYO kTGHcZCLoO2BnoiEjtVY9PoQ05yzaVRFVKbdyj5yNjiVu5piwj6VwAqAvnrT/iU14z ovFCHJs05zX1f6DQI1ic67Zpb+D9KoDGQXGOJbW/SsAnUJVXx0VoaJoAgnvWvg7gvh xrPQ4Hwllt9fA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When a ZONE_DEVICE private page is freed, the page->mapping field can be set. If this page is reused as an anonymous page, the previous value can prevent the page from being inserted into the CPU's anon rmap table. For example, when migrating a pte_none() page to device memory: migrate_vma(ops, vma, start, end, src, dst, private) migrate_vma_collect() src[] = MIGRATE_PFN_MIGRATE migrate_vma_prepare() /* no page to lock or isolate so OK */ migrate_vma_unmap() /* no page to unmap so OK */ ops->alloc_and_copy() /* driver allocates ZONE_DEVICE page for dst[] */ migrate_vma_pages() migrate_vma_insert_page() page_add_new_anon_rmap() __page_set_anon_rmap() /* This check sees the page's stale mapping field */ if (PageAnon(page)) return /* page->mapping is not updated */ The result is that the migration appears to succeed but a subsequent CPU fault will be unable to migrate the page back to system memory or worse. Clear the page->mapping field when freeing the ZONE_DEVICE page so stale pointer data doesn't affect future page use. Fixes: b7a523109fb5c9d2d6dd ("mm: don't clear ->mapping in hmm_devmem_free") Cc: stable@vger.kernel.org Signed-off-by: Ralph Campbell Cc: Christoph Hellwig Cc: Dan Williams Cc: Andrew Morton Cc: Jason Gunthorpe Cc: Logan Gunthorpe Cc: Ira Weiny Cc: Matthew Wilcox Cc: Mel Gorman Cc: Jan Kara Cc: "Kirill A. Shutemov" Cc: Michal Hocko Cc: Andrea Arcangeli Cc: Mike Kravetz Cc: "Jérôme Glisse" --- kernel/memremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/memremap.c b/kernel/memremap.c index bea6f887adad..238ae5d0ae8a 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -408,6 +408,10 @@ void __put_devmap_managed_page(struct page *page) mem_cgroup_uncharge(page); + /* Clear anonymous page mapping to prevent stale pointers */ + if (is_device_private_page(page)) + page->mapping = NULL; + page->pgmap->ops->page_free(page); } else if (!count) __put_page(page); From patchwork Fri Jul 19 19:06:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ralph Campbell X-Patchwork-Id: 11050527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 774E1746 for ; Fri, 19 Jul 2019 19:07:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B325288FC for ; Fri, 19 Jul 2019 19:07:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EFBA2893A; Fri, 19 Jul 2019 19:07:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D472F288FC for ; Fri, 19 Jul 2019 19:07:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BC996B0008; Fri, 19 Jul 2019 15:07:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 943598E0003; Fri, 19 Jul 2019 15:07:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80DC38E0001; Fri, 19 Jul 2019 15:07:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 5FD4D6B0008 for ; Fri, 19 Jul 2019 15:07:11 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id v17so7271004ybq.0 for ; Fri, 19 Jul 2019 12:07:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding:dkim-signature; bh=U0IXy/zKKcejMP4DQKHZ57GJs0lTlzQ4MYtXzCim3fk=; b=h3VV2+noqSVxzu5+wMJDoNpZooAVnB3qT2idmdQ6asmIygnQOBD5UJzEgIfbxQ5hf/ ytHSJhkJKa/y6yrwGGpWpYvcrep/QGtaIabJrrT56s/P5kbcN4Bbo1UOIzLQRvLkw4Gt 5XSajSR66Sp0GYjfT8l2a5/XmuMMVfN4pZPLOPbeXlRYRd8W09PhFnDZIyJa9KAU2wJH cx8Z6uDWNGT4DJAX5lPDPvLjNjFKk5hvk+OYf6haQiBru6wUUkUpIf3naFXr7nXo8LzH RymvbzmLWrFI2S1ZHgZnJAil1qG0Izr2ViTMRIMQCz8WRwsDrQoD0Tz0zwYFlsmayV7B l5bA== X-Gm-Message-State: APjAAAUZ5rJZ2eAbdGZKUQ++D22qc/dazqNGg+NeyFm6S4UFcBB2qo7B a+pqMItb0nX+yatKDNLA8Ry5Ea2aAY+hjqLTp6HopJfBbh2mwaozA8ggZvRqTraJfISSbhJUnSo mfzVlz8AkH7j5Y0aWCpZChQnyJQmV0A0GzoQBjohKwzeKrnNruByVdVC7s95iTIrsdA== X-Received: by 2002:a81:3b8e:: with SMTP id i136mr32212531ywa.493.1563563231111; Fri, 19 Jul 2019 12:07:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWydyrb+9EmJp+fNeHMlTDYYPvl3jtDWlEv/lCKL1KljFM0QrMEJz/4QSptxJDcGh8wQDR X-Received: by 2002:a81:3b8e:: with SMTP id i136mr32212474ywa.493.1563563230151; Fri, 19 Jul 2019 12:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563563230; cv=none; d=google.com; s=arc-20160816; b=YHlFISfQEdv2GRK/WOVZKg99tIyift7Q+wJfyDh1KY9EreuD6m0HjIhm+y0xAe3zC3 eSe+KM6XZRs6brV5LlIMZDspy4fbMuaLh0JlLYD5PXTVkPHxZaNQhMT+I5IXEinRb8hl fcCVjGIuRRM7wbHQ5aVJI8EMS4hEVxTPpxR5tgSH8iA4PB50bi12SNaYnvcTuR/DDYe2 uw8VGE8ehxjdekHVXmuTZSeijt2S364dNBW9Hk9oHM1ElD9coqb26joMt2BrrO0g3j2v ieMjSl9lv69iwRo85qWXzbGoNUpcdE9Lw5M70hsKLBgGKvYAw1PIE/dexuwYB3zU13e9 VK0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=U0IXy/zKKcejMP4DQKHZ57GJs0lTlzQ4MYtXzCim3fk=; b=vJhAtpt99DGrVXLjdJ05zSaU9ASBC56DcX+oqmA/09dBwjr7HaK4Nstl2FsNRS/zc8 IyK5D4gYcUkYRxFk8+DcgBvG2TBrIl4zdFLCxjipY7+veBfSoxJTPmwxVVWDn6g3Li8+ pZFwH9S0O+qv6lfO3t8HGKv/feiSS8etvGY9tTTb3cp3NA/lsNBsFB9vQSOn69M/30TS 2b0FvhBPAP1VEjNGuDYj2++okt9x0P4OpjlIOn6vcFfRERN3UHUn6eEngxlZV6DD7T8Q hGQ4X966AkgIg3MOCfjhFHHIR34eJCW/N2GTkc0LNyUKJ09sfEhEoJfb5cSUtrcXR9mN AuOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=o+RBABok; spf=pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.143 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from hqemgate14.nvidia.com (hqemgate14.nvidia.com. [216.228.121.143]) by mx.google.com with ESMTPS id c9si4728987ywa.216.2019.07.19.12.07.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jul 2019 12:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.143 as permitted sender) client-ip=216.228.121.143; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=o+RBABok; spf=pass (google.com: domain of rcampbell@nvidia.com designates 216.228.121.143 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 19 Jul 2019 12:07:09 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 19 Jul 2019 12:07:09 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 19 Jul 2019 12:07:09 -0700 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Jul 2019 19:07:04 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 19 Jul 2019 19:07:05 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 19 Jul 2019 12:07:04 -0700 From: Ralph Campbell To: CC: , Ralph Campbell , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "Kirill A. Shutemov" , Mike Kravetz , Christoph Hellwig , Jason Gunthorpe , John Hubbard , , Andrew Morton Subject: [PATCH 3/3] mm/hmm: Fix bad subpage pointer in try_to_unmap_one Date: Fri, 19 Jul 2019 12:06:49 -0700 Message-ID: <20190719190649.30096-4-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719190649.30096-1-rcampbell@nvidia.com> References: <20190719190649.30096-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1563563229; bh=U0IXy/zKKcejMP4DQKHZ57GJs0lTlzQ4MYtXzCim3fk=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Type:Content-Transfer-Encoding; b=o+RBABok9q175TIaACbH78zORn0X6HKDRIaL7qVbx6i1lTfFIvWnzJW+4vNL6sV6b ZKgT8U/FylXyFeAAKUtwBA/FkfEIAamghIZKdkVrDQ5M71n4NK6qlF4EKNxv4IL4eG +muFf+zUoAUwJ+7LK/tHizAsQdE0USzc+yeNNAo+BhVqKHOsE2Pc3X9dhUdgl61mgH F95OPZNtDZ+Hw34YccLNzh4c/8BUxt3ybbT6oi2KcaW8mcQG/dCe872irjZnjQI/eM pN1XUWI2MkJJS0eZpCAGD73t9t7AvrexWZ6dujBLVTspyk/N1JQL1I0qnp79R8szhm 24nbXQtuN0hkw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When migrating an anonymous private page to a ZONE_DEVICE private page, the source page->mapping and page->index fields are copied to the destination ZONE_DEVICE struct page and the page_mapcount() is increased. This is so rmap_walk() can be used to unmap and migrate the page back to system memory. However, try_to_unmap_one() computes the subpage pointer from a swap pte which computes an invalid page pointer and a kernel panic results such as: BUG: unable to handle page fault for address: ffffea1fffffffc8 Currently, only single pages can be migrated to device private memory so no subpage computation is needed and it can be set to "page". Fixes: a5430dda8a3a1c ("mm/migrate: support un-addressable ZONE_DEVICE page in migration") Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse" Cc: "Kirill A. Shutemov" Cc: Mike Kravetz Cc: Christoph Hellwig Cc: Jason Gunthorpe Cc: John Hubbard Cc: Signed-off-by: Andrew Morton --- mm/rmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/rmap.c b/mm/rmap.c index e5dfe2ae6b0d..ec1af8b60423 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1476,6 +1476,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, * No need to invalidate here it will synchronize on * against the special swap migration pte. */ + subpage = page; goto discard; }