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 641D0C2D0E2 for ; Tue, 22 Sep 2020 15:36:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D35362220D for ; Tue, 22 Sep 2020 15:36:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PN/9wieG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D35362220D 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 6B268900018; Tue, 22 Sep 2020 11:36:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6619690000A; Tue, 22 Sep 2020 11:36:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50276900018; Tue, 22 Sep 2020 11:36:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 31E5990000A for ; Tue, 22 Sep 2020 11:36:21 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E0AE2180AD802 for ; Tue, 22 Sep 2020 15:36:20 +0000 (UTC) X-FDA: 77291098920.09.class67_0d0f1012714e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id C46DE180AD804 for ; Tue, 22 Sep 2020 15:36:20 +0000 (UTC) X-HE-Tag: class67_0d0f1012714e X-Filterd-Recvd-Size: 5555 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 15:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600788979; 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=9qUAnZcDPIOTE8chUJkXUfmB3Qkup6kzfAgtjloNLEI=; b=PN/9wieGMrWf1DzRAge5ksj8oyQxBgLj/F7ATFjp9basBbApqg8IJ8qdxQrsqtCxHGxCNi KLFes/fuasWeay0SkcmUeQ+jYEjO8PbuFmxxhk5xs76+/rGvm3Ju3pV9dgatH9EMnQG5mm FLj6pZr+36F9YILvZBxpWab3v5eYbNY= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-IGSd5WR6NS-ZU2qa_oaetg-1; Tue, 22 Sep 2020 11:36:16 -0400 X-MC-Unique: IGSd5WR6NS-ZU2qa_oaetg-1 Received: by mail-qt1-f199.google.com with SMTP id f5so16232785qtk.11 for ; Tue, 22 Sep 2020 08:36:15 -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=9qUAnZcDPIOTE8chUJkXUfmB3Qkup6kzfAgtjloNLEI=; b=rPI8cAoDXak3VjR0QaCty5F4hmoUXJi1aDCQzs4U+/3dzga20VtbvrnMw7b4HEBcND q+wgStPFf4lci4aS5VD2FrJ7Kbfa3qF6AK8GtjQHhOnYuYK7+M1CaqCrCDHhtJeV1clk PHJfPxY+j8PJJVmj4cOjU9du3EkocFUUBT6HT/X31CfBvSfrr78W/LPu3NbI5HCPiGRZ y3D31hIuTRn4jUd8MdWmDk4Cx6FcIeBfFo6VfbgRAThZYWtd2dMrK4/CXmO0jXLIUFwL 0DQIIGIkRwpcn7M1gJz3Y7bGrsYnp8kTig10/BZ44YHtjqgaHh3s4SDZGz3VUEUhhW4n Degw== X-Gm-Message-State: AOAM530HzuQaPggwi0qpwHGF2/xSZXV+Qh5C+3e6WdCEVBXVysTpixVm KHNcEV8Vx0h8X9hA/H6nIlOUR+MyGwOOGCSlE2uxO+77m4SO44+4Pt/4hwokw37Bd3b0+bbKL1f ArgPhKtSRafA= X-Received: by 2002:a37:8883:: with SMTP id k125mr5113333qkd.387.1600788975028; Tue, 22 Sep 2020 08:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3nN2tbkiA28XqYXkWFBSdDPKBDK4RDcM0qhYUN5Ac6FIwGRsUoFXx4b9P9kPZ3JzBgvSuyw== X-Received: by 2002:a37:8883:: with SMTP id k125mr5113311qkd.387.1600788974750; Tue, 22 Sep 2020 08:36:14 -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 v16sm11433232qkg.37.2020.09.22.08.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 08:36:14 -0700 (PDT) Date: Tue, 22 Sep 2020 11:36:12 -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: <20200922153612.GF19098@xz-x1> References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-4-peterx@redhat.com> <20200922100840.GA11679@redhat.com> <20200922101815.GB11679@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200922101815.GB11679@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 12:18:16PM +0200, Oleg Nesterov wrote: > On 09/22, Oleg Nesterov wrote: > > > > On 09/21, Peter Xu wrote: > > > > > > @@ -866,13 +877,18 @@ static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, > > > pte_unmap_unlock(orig_dst_pte, dst_ptl); > > > cond_resched(); > > > > > > - if (entry.val) { > > > - if (add_swap_count_continuation(entry, GFP_KERNEL) < 0) > > > + switch (copy_ret) { > > > + case COPY_MM_SWAP_CONT: > > > + if (add_swap_count_continuation(data.entry, GFP_KERNEL) < 0) > > > return -ENOMEM; > > > - progress = 0; > > > + break; > > > > Note that you didn't clear copy_ret, it is still COPY_MM_SWAP_CONT, > > > > > + default: > > > + break; > > > } > > > + > > > if (addr != end) > > > goto again; > > > > After that the main loop can stop again because of need_resched(), and > > in this case add_swap_count_continuation(data.entry) will be called again? > > No, this is not possible, copy_one_pte() should be called at least once, > progress = 0 before restart. Sorry for noise. Oh wait, I think you're right... when we get a COPY_MM_SWAP_CONT, goto "again", then if there're 32 pte_none() ptes _plus_ an need_resched(), then we might reach again at the same add_swap_count_continuation() with the same swp entry. 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. Thanks, -- Peter Xu