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=-0.8 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 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 1176DC10DCE for ; Tue, 24 Mar 2020 03:47:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9FFB5206F8 for ; Tue, 24 Mar 2020 03:47:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NzhvF6IX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FFB5206F8 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 EA7E96B00C0; Mon, 23 Mar 2020 23:47:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E58B76B00C1; Mon, 23 Mar 2020 23:47:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E046B00C2; Mon, 23 Mar 2020 23:47:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id BD0706B00C0 for ; Mon, 23 Mar 2020 23:47:33 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BD80EB933D for ; Tue, 24 Mar 2020 03:47:33 +0000 (UTC) X-FDA: 76628871186.11.waves31_5f15b12448039 X-HE-Tag: waves31_5f15b12448039 X-Filterd-Recvd-Size: 4515 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Mar 2020 03:47:33 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id a20so9451769ioo.13 for ; Mon, 23 Mar 2020 20:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sCw5/OsOFGYYbSSXjAUBWBtDOYWzYVSLdBpgDtD1qNY=; b=NzhvF6IXtSoKFlm+xj4OLYUyDbc9BUPugyOwWJRuuMJ475uwIOxCUeZiunCFqiItf0 tifZspG92hPZSv3T9L01I7HY+lGzQFyG/kCJCRoF5fyXygB3EhJrD1XFw+uBnBI57a39 y6Vb9pvFxrFnRaTGp1dBgg+6j8CXOxAnBQv8pwIonVgl9Z8niNQkHMNr1f5azr+KZSAy Lyt57QPLPfgieeA5/lG4HGeSJGyLOofDH3xmt+U5dFIW58v260LyfUx6RdVFykdchIL1 cUJKAVlVgPKdwUH2etwmzLWclLkw3Ld9i9sm1ZdxSMgJ9Aue5n60mRgP2Z3LOE44bkgD RM/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sCw5/OsOFGYYbSSXjAUBWBtDOYWzYVSLdBpgDtD1qNY=; b=rONH6+YdDHH8LHP0dfcjapvXf9xscXZ7qbyGvb/NPNTb8nmDwweSMlV75SRLyI4XX5 OYix26OyKnMzq6A20bFnHwC+LEa7YotxZllcf5PH9nlax3CB9NmEsfl7FvHxuOlH+WDU VoOARXR/N3C09prFGpRxkDf0+GozJgsOnzZ/BVcfp4NOc0IxIf+8v+GvjQy47CoHOW5/ 6IPedbHg5mMfIgWtiRu0UocCM7RJ0GLV4wCPzSRhVzp6RgqOMoudyzTFW+RT5GGtKnhS qevFY12AipigNXQDG8Og3kW1GCvGmpd/WZahrrR9d5P91y2kccY7HRYYx5IFldkwIYYE aRHA== X-Gm-Message-State: ANhLgQ2pSK/793+mTgjR9LSkJEHdKsy9pf31XT1QneCUD6nXO3evxiZq I3Szjnq6nxgV0Pcuefe7vpbuI0qop8dnHW4nuA== X-Google-Smtp-Source: ADFU+vvvtkPCSxSOX+n+o9RirQ988GiJ59eevqf8UTWxe++iJ0+G8/rVII/EXDhzdWRTiFnJXsSdjTyorZXjREPn/Lo= X-Received: by 2002:a5e:d512:: with SMTP id e18mr22721035iom.209.1585021651966; Mon, 23 Mar 2020 20:47:31 -0700 (PDT) MIME-Version: 1.0 References: <1584885427-4952-1-git-send-email-kernelfans@gmail.com> <20200323073408.GA7524@dhcp22.suse.cz> In-Reply-To: <20200323073408.GA7524@dhcp22.suse.cz> From: Pingfan Liu Date: Tue, 24 Mar 2020 11:47:20 +0800 Message-ID: Subject: Re: [PATCH] mm/rmap: fix the handling of device private page in try_to_unmap_one() To: Michal Hocko Cc: Linux-MM , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , John Hubbard , "Kirill A . Shutemov" , Aneesh Kumar , Andrew Morton Content-Type: text/plain; charset="UTF-8" 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 Mon, Mar 23, 2020 at 3:34 PM Michal Hocko wrote: > > On Sun 22-03-20 21:57:07, Pingfan Liu wrote: > > For zone_device, migration can only happen on is_device_private_page(page). > > Correct the logic in try_to_unmap_one(). > > Maybe it is just me lacking knowledge in the zone_device ZOO. But > this really deserves a much more detailed explanation IMHO. It seems > a5430dda8a3a ("mm/migrate: support un-addressable ZONE_DEVICE page in > migration") deliberately made the decision to allow unmapping these > pages? Is the check just wrong, inncomplete? Why? I am not quite sure about zone_device, but I will try to explain it later. But first of all, I think the code conflicts with the logic behind it. If try_to_unmap_one() success to unmap a page, then it should kill the pte, and return true. But the original code return true before the code like "ptep_clear_flush()" Now, I try to say about !device_private zone device. (Please pardon and correct me if I make a mistake) memmap_init_zone_device() raises an extra _refcount on all zone device. And private-device should lifts the count later, otherwise it can not migrate. But I did not find the exact place yet. While this extra _refcount will block migration, it is not the whole reason if a zone device page is mapped. If a zone device page is mapped, then I think the original code happen to work due to it skip the call of page_remove_rmap(), and in try_to_unmap(){ return !page_mapcount(page) ? true : false;}. > > What is the real user visible problem here? As explained, the original code happens to work, but it conflicts with the logic. Thanks, Pingfan