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.6 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 6DECCC43331 for ; Wed, 1 Apr 2020 14:10:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 29AD8206F6 for ; Wed, 1 Apr 2020 14:10:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eP8YPqFm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29AD8206F6 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 CCC458E0007; Wed, 1 Apr 2020 10:10:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C578C8E0001; Wed, 1 Apr 2020 10:10:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFA108E0007; Wed, 1 Apr 2020 10:10:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 96BBF8E0001 for ; Wed, 1 Apr 2020 10:10:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 47EF8180AD802 for ; Wed, 1 Apr 2020 14:10:56 +0000 (UTC) X-FDA: 76659472512.14.crush61_253a3655c180d X-HE-Tag: crush61_253a3655c180d X-Filterd-Recvd-Size: 6508 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Apr 2020 14:10:55 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id o3so20204086ioh.2 for ; Wed, 01 Apr 2020 07:10:55 -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=ZUxB2y1F/uwIa0F7/L8+o+jKUigh0xUxeTQJ/UWTGkY=; b=eP8YPqFmRNew/Ulf6GlGny9EoQ38KmpTT4On7tNdvD6rcP0lbY9svhpxxSAtzrNveC jkyBO0VEwZpYQI7aA7DGuE9ekIOB9zHDJnF11FyMaDh8l/8nPa4fE7yIYTyri3+FCpsd GBYlH4pq6Cn0jNyEcIIfJDqFGwks0z2yNq4SE1Mb41hwU0A6wVsrvDhBeV7iIOco0AVj TSt36YZfRUdJdemkgUj05GAicLHl8+eMjdOSadUO1zeofdhfL+sSoW/x5ckhlfl1noRR KbYpriw0VNtQKLc5nGBsElkHFAdg8fR+xg4QLCk7ccSdbUeZL2Or+bp1V7ENFI8Ev1i3 1RNA== 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=ZUxB2y1F/uwIa0F7/L8+o+jKUigh0xUxeTQJ/UWTGkY=; b=Tr7gmQdb8Wre333i4JpGivopE+HSNmo45iYoXXdzNPBzyTkNBRKQeUT3GYL+fBATYB JHDvtahRGGtGKhjQ2g7ulgf3tIYifTu7ipzhcT6gnSHtdw3Xe8JLiq0Y0LxWU9EFp5u8 S4wWdSqm5hfp7QSMjU9E8auuLbZeGGxrwccRSP9gHbfoXNLW7yDGe21cjBl+l2Xr1nJL 5E0xrGzJU01lTihquM+4jzX/AXHO4A9LtYipdoHFbP2djzBJKAFp/lMzTDipRTYENtF6 l5ebmmevzYUlA1p2RHOKqWWAjBnuBY1KMA9zWM+FTaGGHAYhHkBG3iq1lXpJbxe7WcGh nTiA== X-Gm-Message-State: ANhLgQ3nlOjjzct5ZHAkCeGGgqzeyz3mBPP8lc7GnKBja0WqecQMFniI 8B9S3LXuM8crm3IYo06NDx2HSrFS2b9h+Rad/Q== X-Google-Smtp-Source: ADFU+vuyw/fN2VtdWCkSDTlUa5OcciGKkCB6CwIKXjMfNrNQk0LXkyTJaNKkHHrOIQtEQN6CHmISb8b4kyUISlNl7bs= X-Received: by 2002:a05:6638:a9b:: with SMTP id 27mr20981366jas.70.1585750255025; Wed, 01 Apr 2020 07:10:55 -0700 (PDT) MIME-Version: 1.0 References: <1584885427-4952-1-git-send-email-kernelfans@gmail.com> <20200323073408.GA7524@dhcp22.suse.cz> <20200324091453.GF19542@dhcp22.suse.cz> In-Reply-To: From: Pingfan Liu Date: Wed, 1 Apr 2020 22:10:43 +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 Wed, Mar 25, 2020 at 6:54 PM Pingfan Liu wrote: > > On Tue, Mar 24, 2020 at 5:14 PM Michal Hocko wrote: > > > > On Tue 24-03-20 11:47:20, Pingfan Liu wrote: > > > 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;}. > > > > OK, you made me look more closely. > > > > The lack of documentation and therefore the expected semantic doesn't > > really help. So we can only deduce from the existing code which is a > > recipe for cargo cult programming :/ > > > > The only difference betweena rmap_one returning true and false is that > > the VMA walk stops for the later and done() callback is not called. > > Does rmap_one success means the mapping for the vma has been torn down? > > No. As we can see for the munlock case which just shows hot vague the > > semantic of this callback might be. > > > > I believe the zone device path was just copying it. Is that wrong? > > Well, it is less optimal than necessary because the property we are > > checking is not VMA specific so all other VMAs (if there are any at all) > > will have the same to say. > > > > So the only last remaining point is the done() callback. That one is > > documented as a check. There is no note about potential side effects but > > the current implementation is really only a check so skipping it doesn't > > make any real difference. > > > > > > What is the real user visible problem here? > > > As explained, the original code happens to work, but it conflicts with > > > the logic. > > > > Your changelog should be explicit about this being a pure code > > refinement/cleanup without any functional changes. > OK, I will do that. It took me some time to make clear try_to_munlock(). And now I can make some notes. I will send out V2 soon. Thanks, Pingfan