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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 3765AC38A2C for ; Fri, 17 Apr 2020 15:23:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0407920644 for ; Fri, 17 Apr 2020 15:23:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0407920644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8DE188E002D; Fri, 17 Apr 2020 11:23:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88DAF8E0023; Fri, 17 Apr 2020 11:23:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A2718E002D; Fri, 17 Apr 2020 11:23:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id 60FED8E0023 for ; Fri, 17 Apr 2020 11:23:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1345968BE for ; Fri, 17 Apr 2020 15:23:35 +0000 (UTC) X-FDA: 76717716390.26.magic20_228b637b3c58 X-HE-Tag: magic20_228b637b3c58 X-Filterd-Recvd-Size: 3809 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Apr 2020 15:23:34 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id f13so3454926wrm.13 for ; Fri, 17 Apr 2020 08:23:34 -0700 (PDT) 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; bh=MJpZan09FViBVnO9BmC+DYH+BWKMRHgrAuxH1+HdPZ4=; b=GYEF8tWbvVbpbyEU63bRnYWA2mIU7ITSQZbOxXyG4ZhRRveIcLQ7RnItV0qxnida3C WSr9Rh02jf0eRbP/v+OLKkSjuJAzuoZ1wCgh58RF2bz5rAu5MWdnKYn8vWC2kQgg6OrK Buqjbyw85R+D2dqFBn91xF2JIciihq86UsAYARrO3vqW8Jdj2xfA7b5IA4rPi6cy7Jg2 xUPUfmhL3rlcu/mxbB/1RwzJeVesnDiYWPlPe/fzDC9HZrILTLg0BJvMLsveeCyWvkcm KSkqk1g85Ecb0jW/o0N0Bxd1YCEMVRqv2FFxnc58l3m9N2gSheEO/eI5uqpipAC2RAVr M+vg== X-Gm-Message-State: AGi0PuZb3WIJouWc7ojTS2VAa4FbwnP3an+kJW92ocm6PP8HCwNhiCDf AGYyiFAdYcxR04Xsh5Dp6Uc= X-Google-Smtp-Source: APiQypJTfg+QejO80SrLOg1Qwn/WjufP5YHufrAmedXZuRLjU2VtygRVfmGSn+07G7ASApjBhbL5Hw== X-Received: by 2002:adf:f1c5:: with SMTP id z5mr4448862wro.100.1587137013621; Fri, 17 Apr 2020 08:23:33 -0700 (PDT) Received: from localhost (ip-37-188-130-62.eurotel.cz. [37.188.130.62]) by smtp.gmail.com with ESMTPSA id d7sm32111489wrr.77.2020.04.17.08.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2020 08:23:32 -0700 (PDT) Date: Fri, 17 Apr 2020 17:23:31 +0200 From: Michal Hocko To: chenqiwu 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: <20200417152331.GP26707@dhcp22.suse.cz> References: <1587119514-29679-1-git-send-email-qiwuchen55@gmail.com> <20200417114312.GM26707@dhcp22.suse.cz> <20200417142618.GA31882@cqw-OptiPlex-7050> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200417142618.GA31882@cqw-OptiPlex-7050> 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 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. -- Michal Hocko SUSE Labs