From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 402EBC2BA19 for ; Sat, 18 Apr 2020 03:12:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 98E8B22201 for ; Sat, 18 Apr 2020 03:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TMQ0YEkK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98E8B22201 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 013118E0003; Fri, 17 Apr 2020 23:12:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F05FA8E0001; Fri, 17 Apr 2020 23:12:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1CB88E0003; Fri, 17 Apr 2020 23:12:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id C7EB68E0001 for ; Fri, 17 Apr 2020 23:12:11 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7AE1652CB for ; Sat, 18 Apr 2020 03:12:11 +0000 (UTC) X-FDA: 76719502062.21.pen41_4d4a5e4480400 X-HE-Tag: pen41_4d4a5e4480400 X-Filterd-Recvd-Size: 4895 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Sat, 18 Apr 2020 03:12:10 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id 7so2783715pjo.0 for ; Fri, 17 Apr 2020 20:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SVnIS7NUNuxx8XzJCvQXIR8PpNcdnQk4yL6GfXcB5IY=; b=TMQ0YEkKg3hT0LPllANSqL6Gj3pWRaENrlBuG1hXGqAzCOo8o8ugUIvfhZiF0zHxbX xw7qVkFvywnxePSrRkxB/dknATdKBpJxgJOky/Ikllh9DFmn5gSmEEP6TS8M8cMGj+4t pGSSLGxuMFVaOOxB6o9Vh+5hJc31fNZQVIuJvLrdE0tOzwbM8xeqf47Ma23UfwL7hUUc rTvibEjruaPqMqeZQJMN/qPDK8b7YxNu2ZWiz2myngXGD2V3s2JXcwv9wmF1hTUM7rUh PDCzvf3ut2O/uhPi3XDdaEKDBYlJu8llMmkY2FrTY5LaQkdIfhqAMDdWbXzAOSPbHSlE NV3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SVnIS7NUNuxx8XzJCvQXIR8PpNcdnQk4yL6GfXcB5IY=; b=qzBfmOkK6w6Ssiksg7SmJFk4kmOahA6TZ/na0wOPxV0RLd7vTmz5YWwOe2mQYfx5Z4 wbt8GbuNm1XIr0/QWsfRBd0cSHBOoK0++fDrtpamkpI0Gx8F4OJNbqf37EDATOKbSRQt FdLgHPCvUGsRYKCGFTbFzgN23H9TUxWhMBGsvZAHEEDPrT+htdRgab3foGYPJeggDoCS P5tPWpwPbX4E45JqPxOmtgITkjsoVtAmF4YogND6C+fi1EdRaxb3UN5PRnlv7megtfF6 E8wo3k8E0VgLMcvzk4KcjJX9AztO2XxEgvXwweGGSC2kbdpv6IOpvyP8lMSozUBoxhwC 5c0A== X-Gm-Message-State: AGi0PuaPkbTyCFPao8XOqwYg8xQIAEq3VmBFimoYPpW+uGvWcXdtuc3R l0aEIqco3cQmqbE03aX73bs= X-Google-Smtp-Source: APiQypLHMicqc6q6ziPZjTz+8upt1n/ioPyX1xsNcWW06CFhSw23MYBrLIZfk3wiDi7kfpbw05zItA== X-Received: by 2002:a17:902:b187:: with SMTP id s7mr6957664plr.0.1587179529972; Fri, 17 Apr 2020 20:12:09 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id w126sm11184008pfb.117.2020.04.17.20.12.08 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 17 Apr 2020 20:12:09 -0700 (PDT) Date: Sat, 18 Apr 2020 11:12:07 +0800 From: chenqiwu To: Michal Hocko Cc: akpm@linux-foundation.org, linux-mm@kvack.org, chenqiwu Subject: Re: [PATCH] mm/memory: add refcount for special mapping page in copy_one_pte() Message-ID: <20200418031207.GA9002@cqw-OptiPlex-7050> References: <1587119514-29679-1-git-send-email-qiwuchen55@gmail.com> <20200417114312.GM26707@dhcp22.suse.cz> <20200417142618.GA31882@cqw-OptiPlex-7050> <20200417152331.GP26707@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200417152331.GP26707@dhcp22.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) 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: On Fri, Apr 17, 2020 at 05:23:31PM +0200, Michal Hocko wrote: > On Fri 17-04-20 22:26:18, chenqiwu wrote: > > On Fri, Apr 17, 2020 at 01:43:12PM +0200, Michal Hocko wrote: > > > On Fri 17-04-20 18:31:54, qiwuchen55@gmail.com wrote: > > > > 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. > > > > > > From the changelog it is not clear what is the actual problem and how > > > the patch address it. Please be more verbose. > > > > > I don't find any actual problem, but I think there should be addressed > > to update the page refcount for special mappings include devmap and zero > > page instead of doing nothing else, since we copy the pte from one task > > to the other. > > As Matthew pointed out, zero pages are special. Just check how > vm_normal_page returns NULL (the same is the case for pte_devmap). This > means, among other things that zap_pte_range which is called during > munmap will only clear the pte but it doesn't operate on those pages so > there is no put_page for your get_page here. > > I do realize that this might be a subtle details that might be > confusing. On the other hand trying to formulate the specific problem > and add an explanation of the fix in the changelog could have revealed > this. It is really trivial to generate mappings backed by zero pages and > if the reference count was not handled properly then it would blow up > pretty quickly. > I agree. But I can't see where to put the normal page refcount back in zap_pte_range(), is there an imbalnace between copy_one_pte() and zap_pte_range()? BTW, I think the else if condition can be removed since we don't need to operate devmap pages.