Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4148533pxk; Tue, 22 Sep 2020 11:27:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySs/IRp+tz8EWKSYWRax2MXy/aRiHKtbOpjDBGS/UgW3OlnTzKtM/DY6MJhHAJuT9H1ZHQ X-Received: by 2002:a05:6402:d3:: with SMTP id i19mr5501218edu.320.1600799275617; Tue, 22 Sep 2020 11:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600799275; cv=none; d=google.com; s=arc-20160816; b=h0MfiRO9hhJTy4KHT7ffm6MiT2NraF/LHLE/gGmLdCGVnoSTpX6EsO5xtsSD9YapqR XrNIoLoyP/RLa08Lm+n5+flb2qHwhVBQg38QM4sbZ/L8f0Dk803JmW0caGGxCDdmUT8F jBPU+CxTptYZ+GgkyVthtZziRMG3Y15TISNtJLNnJ3vDUUSOrXiTCZC8KdfkSVczDRAl 2ZUkM1Pxz+lHtgHLlnDfpbpudWHKM4/ylsFFgsE+AxJbCI4hgLUZa3P3Cw3tQliD+WAH 6WWQ47lP0JHIAyUjKO4ZWwzJzhhs8JNdWZ5GTbGp1wPUCfMaftu+7DRpdojpUiWE5xTz psPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ovmZrpAC+T2YMt44GFu5rQZOQ7iR8zuXRD3rJJbHavM=; b=PI0Qag3YNbYd1MI2SR3VyvmD2wUOBmpUsl//WE5CMoUmtNmRFgtK/mUB8o9qZMdjwX +iOoei0DwU/V+XWaN7m0FZ+TV6VPbtA2qN4vmEKR+fXhhPNAFl3chcix4jJfZJ8CTvdl sdD/30sXEVpMpgFxkBJ4oYocROP8Ixhl8PUFmkupAWyE2/U4GHkfKp/IoezM0GjUH+1v 93ifnTSDqtVuhAwInV/PCOsTglmMmu/ltKHdR5z9ULAYAtvXoV4jNtYJeGjltptNEjTS +/NyKxnX7ndAFiK9l38gCm5l1PnAmhkpuZpQ6qU3GJ5qqyWTFHljuhb+GjbSyFAjqcN+ dFsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=huc+kdq8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lt3si11376783ejb.687.2020.09.22.11.27.29; Tue, 22 Sep 2020 11:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=huc+kdq8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbgIVSXc (ORCPT + 99 others); Tue, 22 Sep 2020 14:23:32 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48322 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726526AbgIVSXb (ORCPT ); Tue, 22 Sep 2020 14:23:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600799010; 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=ovmZrpAC+T2YMt44GFu5rQZOQ7iR8zuXRD3rJJbHavM=; b=huc+kdq8/cuJ6B+rCJPEvg+QX2b3ijR3oQ22Z1lXBPFNlRUPaYIoYg4b+CHE/WD3BLIwBL 2rtrohi/GMyK/sUduclbABwlx2luzgH1V5jMd0lBiVVIAeJt2GdO7Mum7WxCVy8DoIbks6 A6SzEizFFHSmC63m/HKlKypevkUc1sA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-DIMrhNbONEK1AjdJmpafsw-1; Tue, 22 Sep 2020 14:23:28 -0400 X-MC-Unique: DIMrhNbONEK1AjdJmpafsw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6DA31801ABB; Tue, 22 Sep 2020 18:23:26 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.146]) by smtp.corp.redhat.com (Postfix) with SMTP id 9CAF45DE19; Tue, 22 Sep 2020 18:23:19 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 22 Sep 2020 20:23:26 +0200 (CEST) Date: Tue, 22 Sep 2020 20:23:18 +0200 From: Oleg Nesterov To: Peter Xu 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: <20200922182317.GH11679@redhat.com> 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> <20200922181306.GJ19098@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922181306.GJ19098@xz-x1> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/22, Peter Xu wrote: > > 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(), This is clear. But I still think that !pte_none() -> pte_none() transition is not possible under mmap_write_lock()... OK, let me repeat I don't understans these code paths enough, let me reword: I don't see how this transition is possible. Oleg.