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=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 E088FC4363D for ; Tue, 22 Sep 2020 18:13:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3481D238D7 for ; Tue, 22 Sep 2020 18:13:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WRGxW7o9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3481D238D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 655768E0001; Tue, 22 Sep 2020 14:13:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 606926B0037; Tue, 22 Sep 2020 14:13:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F6C28E0001; Tue, 22 Sep 2020 14:13:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 38ADD6B0003 for ; Tue, 22 Sep 2020 14:13:14 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E920E180AD801 for ; Tue, 22 Sep 2020 18:13:13 +0000 (UTC) X-FDA: 77291494266.25.chain80_560a5d32714f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id BC88D1804E3A1 for ; Tue, 22 Sep 2020 18:13:13 +0000 (UTC) X-HE-Tag: chain80_560a5d32714f X-Filterd-Recvd-Size: 5327 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 18:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600798392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=71Fdmnk5+zjGGKXcJZwLvS205zm9cv4AZ4wruSNhUcM=; b=WRGxW7o9uJ7iSqpaNNn+OMCVHO66pNfuuN6J4Ln/N1bS7TprlIqtj+LwCe1F3R1RLy7vY/ 5V9vfaw6efCSACiDWm5OOaAIxX/IJKVUOxPyH+wLC9L+JlpklnAHY9+0DyjTJ4KaiyODBc wH9oButkV7Orqqj8WD+yf4d2wZ5hTAg= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-Kd0mswuHOtSD2Jt1WEEt-Q-1; Tue, 22 Sep 2020 14:13:09 -0400 X-MC-Unique: Kd0mswuHOtSD2Jt1WEEt-Q-1 Received: by mail-qk1-f199.google.com with SMTP id y17so14424702qkf.15 for ; Tue, 22 Sep 2020 11:13:09 -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=71Fdmnk5+zjGGKXcJZwLvS205zm9cv4AZ4wruSNhUcM=; b=GZamejb3BNjSpF8zApCPG/p5gzbPQoTsG0PCkDVBuaWTkxO6/JusMk5juCQyjawXLE A3TeiXygITE6iYcgwNLv6eKHAoVUxwBGlWyK/hScaVxWBW9kzUiXY+D6uw78OmH8Lpxs EwIS/fsxhl5aYUeE5wOoZMzgjw0LABDjkSNtnL+mkNluklrUKVw+q19LdO0RPny++NHG eXWw4FozDzIKyp5fjkB0aFaB0TV2u0m+ZrsalF8gyZINNn2CuxszXv+PKU0KMdIepCxy NsrcjrXV+pqbwluCX0gpAv2ithxpqbXRXXsWsBo+AwfE3lK0+OBZX3NoB8H3Cs3BJY3o 6nnw== X-Gm-Message-State: AOAM5316LgE97nvbZpojk6mWk0Z2BNLr5T28Z9Uke8PvPvtDW+SQX2pb aZMwz7MtmD6WwLRvwoJ3WLkL0tjKLxQye14Hlx0t74CmOQcfIkqd3wr1Ny+103i2I5HdWJhjXNz xZI4BNkH5fco= X-Received: by 2002:ac8:4059:: with SMTP id j25mr6042664qtl.155.1600798389098; Tue, 22 Sep 2020 11:13:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfvmGh7iELa5nbikWtKbuG7m8huILlGOMffTQ2A5cRtCL5n4tlxPOqOgSKoAAjJj4AgN1MAw== X-Received: by 2002:ac8:4059:: with SMTP id j25mr6042636qtl.155.1600798388868; Tue, 22 Sep 2020 11:13:08 -0700 (PDT) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id h18sm11699096qkl.12.2020.09.22.11.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 11:13:08 -0700 (PDT) Date: Tue, 22 Sep 2020 14:13:06 -0400 From: Peter Xu To: Oleg Nesterov Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jason Gunthorpe , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , John Hubbard , Leon Romanovsky , Linus Torvalds , Jann Horn Subject: Re: [PATCH 3/5] mm: Rework return value for copy_one_pte() Message-ID: <20200922181306.GJ19098@xz-x1> References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-4-peterx@redhat.com> <20200922100840.GA11679@redhat.com> <20200922101815.GB11679@redhat.com> <20200922153612.GF19098@xz-x1> <20200922154845.GE11679@redhat.com> <20200922160330.GH19098@xz-x1> <20200922165354.GG11679@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200922165354.GG11679@redhat.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 Tue, Sep 22, 2020 at 06:53:55PM +0200, Oleg Nesterov wrote: > On 09/22, Peter Xu wrote: > > > > On Tue, Sep 22, 2020 at 05:48:46PM +0200, Oleg Nesterov wrote: > > > > However since I didn't change this logic in this patch, it probably means this > > > > bug is also in the original code before this series... I'm thinking maybe I > > > > should prepare a standalone patch to clear the swp_entry_t and cc stable. > > > > > > Well, if copy_one_pte(src_pte) hits a swap entry and returns entry.val != 0, then > > > pte_none(*src_pte) is not possible after restart? This means that copy_one_pte() > > > will be called at least once. > > > > Note that we've released the page table locks, so afaict the old swp entry can > > be gone under us when we go back to the "do" loop... :) > > But how? > > I am just curious, I don't understand this code enough. Me neither. The point is I think we can't assume *src_pte will read the same if we have released the src_ptl in copy_pte_range(), because imho the src_ptl is the only thing to protect it. Or to be more explicit, we need pte_alloc_map_lock() to read a stable pmd/pte or before update (since src_ptl itself could change too). Thanks, -- Peter Xu