From patchwork Fri Apr 17 10:31:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11494691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 270AD912 for ; Fri, 17 Apr 2020 10:32:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E7FBF21D95 for ; Fri, 17 Apr 2020 10:32:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uQv0m/pp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7FBF21D95 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F21C8E0008; Fri, 17 Apr 2020 06:32:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2F08E0001; Fri, 17 Apr 2020 06:32:02 -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 042E58E0008; Fri, 17 Apr 2020 06:32:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id DAAB98E0001 for ; Fri, 17 Apr 2020 06:32:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 795CC180AD81D for ; Fri, 17 Apr 2020 10:32:01 +0000 (UTC) X-FDA: 76716981642.04.root81_4bd62f9349749 X-Spam-Summary: 2,0,0,e5bf24b9a3acea72,d41d8cd98f00b204,qiwuchen55@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1539:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3350:3865:3872:5007:6261:6653:7576:9413:10004:11026:11658:11914:12297:12517:12519:12555:12679:12895:13069:13311:13357:14181:14384:14394:14721:21080:21444:21451:21611:21627:21666:30054,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: root81_4bd62f9349749 X-Filterd-Recvd-Size: 3304 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Apr 2020 10:32:01 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id t4so811031plq.12 for ; Fri, 17 Apr 2020 03:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lBs7XJjdW6ybVsxQ1bUex8OGCP5715A0ilIyUoP2WqM=; b=uQv0m/ppzmvrXp3SlavP+Gz+33S92uHGslSklWCF6dWdusgjAjMRwicz08wy9BL8oq ExSQoN2yCLCOwnxV9MaXR+C87iHjI0pRpVNLZJ9XtFxhG20eajQ0I+aHkOnBHx1I5qtl J4/AJxTHBGjCkHYfhYiaLu+zZWc9KpOPb6AW9EFHYiC0ux+Xe9jZAFUL3zcvVhFzY+qk ikAzWOf23r6bohXLAZbTbC5Gy33uup6I7UAtOEAzgDKULFCd8hH0zZhjR3McN4iC+VET HJuJX3mROmQovh3tdD8y/+v7vNyEfreEA7iZ120hBkJRv9xPO0wKCMb1HXvWHdQAHlQ4 2fKA== 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; bh=lBs7XJjdW6ybVsxQ1bUex8OGCP5715A0ilIyUoP2WqM=; b=l6QfuI3CzDV2E0AvpYAc2KW7mmhzgTeRnBolwbw8Bkr5buSDwF+37mntFWXkhBLFQr Xhz+4F8o545F1lPQhY9f246GqAP5JEip3FIueJVrD07fG2hN80WauBWdr3sK4eXPYgzv 9pmYzqd4M1uRdJU1Y+vDM+MEu+JsJjXKXPQJrdghrfCHUNQ1NDJ0Ty4MZZ42DBhDDWmP nHgI+pJZk934YCOY7y9psEqe3LhIOrCLj5zyV2P8K+kCZicsv3egVclvRzbOoTY1I+gi 92qZkgfmXpn0YzncaqJYLbX6OnkqBUn1FrLH/bax85vHx2FcQNUBQHhiZMRYiPDMzH9n FIKQ== X-Gm-Message-State: AGi0Puap4yC5zt3v+sLEynVScv+bTqESrx6aQWb1Yw9v0kaxW2y5jIXz pzAbumBRVFdmMU4cC8VqKGM= X-Google-Smtp-Source: APiQypIzCbaw46a6YNYIAKtmsKQ4tV2vgRbbrKr6/fImlbSu0YJEEjQU4cxBJcS2NWBQf2ouP0bk5w== X-Received: by 2002:a17:902:cb97:: with SMTP id d23mr2852586ply.232.1587119520084; Fri, 17 Apr 2020 03:32:00 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id f9sm5280922pjt.45.2020.04.17.03.31.58 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 17 Apr 2020 03:31:59 -0700 (PDT) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, chenqiwu Subject: [PATCH] mm/memory: add refcount for special mapping page in copy_one_pte() Date: Fri, 17 Apr 2020 18:31:54 +0800 Message-Id: <1587119514-29679-1-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000840, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: chenqiwu If we get a special mapping page like device mapping page or zero page when copy_one_pte, it's necessary add the page refcount count. Signed-off-by: chenqiwu --- mm/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index f703fe8..a57975a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -802,8 +802,9 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, get_page(page); page_dup_rmap(page, false); rss[mm_counter(page)]++; - } else if (pte_devmap(pte)) { + } else if (pte_devmap(pte) || is_zero_pfn(pte_pfn(pte))) { page = pte_page(pte); + get_page(page); } out_set_pte: