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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 49420C04FF3 for ; Mon, 24 May 2021 17:17:36 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 726576109F for ; Mon, 24 May 2021 17:17:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 726576109F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FpkRf0W06z3071 for ; Tue, 25 May 2021 03:17:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=google header.b=cV5W3NmA; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=2a00:1450:4864:20::12e; helo=mail-lf1-x12e.google.com; envelope-from=torvalds@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=google header.b=cV5W3NmA; dkim-atps=neutral Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FpkR775Xkz2yXq for ; Tue, 25 May 2021 03:17:05 +1000 (AEST) Received: by mail-lf1-x12e.google.com with SMTP id q3so11553716lfu.2 for ; Mon, 24 May 2021 10:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nc7F/YNBdgjDdP/qhNEAcnLGrc409bn4ko9tRV0fC6M=; b=cV5W3NmA+15ESzIpW1CgdKehYcwWRodRFr3vjpfRjFT8a+bfb2OoW/+ozwXcJM2vZk EkmxyfR93ogCNbdLjQkSlu6ERD8y88l2JWxB0oFlpPWzohFsqjfyKPd+UF0Dp8McMiXR FTxNo2yJHgOX+UVUeX5DA3/5hjjkm0pe43ZKw= 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=nc7F/YNBdgjDdP/qhNEAcnLGrc409bn4ko9tRV0fC6M=; b=pZiiHTLW9SsEekhV5Tksl80fI+WGifpSWhJ+1Ngv4S0UlVfmavVWtRHJVdSP0SWlpP tqcMMCYN37yQd2F60Myq8s/tlq4sYseAHDW9CAr9+guu4wm/dctmKoxObASsxRdtRCLz VWGyb6GWzT8fH6WALOolu5q3hA8uCAsu1WX+w+1kkCaPnamYtcSnAo72DDMxYHPxLwqX upM2A05+xU+RU3Q6MFGB1vz3mnRopqCzZHXTtfYA+KgTxOKroGWbVlmhFdv/jwj+rhIE NF1zwYfq7TqD2WTCvCzfc4Re0Vtsm6q27d6xIgJep2wdh4eIoY252JlnG9rE47MOdrO0 icRQ== X-Gm-Message-State: AOAM530jS3lUgN7rTwjfJU41SYmqtvI26O+MWQPr0vnP3G+negDVYvOG Q41XA+ntx3q7ljhUv8hX1bEbxtjeB+zIxXUoKS4= X-Google-Smtp-Source: ABdhPJxX/TamrpFkD+Vvglu6R7ViRYwRbPTLEce8ZQk16dW6lKjprwEwB71ZJf+oe19wp2ovoTkicw== X-Received: by 2002:ac2:43ce:: with SMTP id u14mr11133478lfl.662.1621876620029; Mon, 24 May 2021 10:17:00 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id u3sm1828332ljg.78.2021.05.24.10.16.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 10:16:59 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id w15so34567713ljo.10 for ; Mon, 24 May 2021 10:16:59 -0700 (PDT) X-Received: by 2002:a2e:968e:: with SMTP id q14mr17720803lji.507.1621876618963; Mon, 24 May 2021 10:16:58 -0700 (PDT) MIME-Version: 1.0 References: <20210524133818.84955-1-aneesh.kumar@linux.ibm.com> In-Reply-To: <20210524133818.84955-1-aneesh.kumar@linux.ibm.com> From: Linus Torvalds Date: Mon, 24 May 2021 07:16:43 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 updated 9/11] mm/mremap: Fix race between mremap and pageout To: "Aneesh Kumar K.V" Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Piggin , Linux-MM , Kalesh Singh , Joel Fernandes , Andrew Morton , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, May 24, 2021 at 3:38 AM Aneesh Kumar K.V wrote: > > Avoid the above race with MOVE_PMD by holding pte ptl in mremap and waiting for > parallel pagetable walk to finish operating on pte before updating new_pmd Ack on the concept. However, not so much on the patch. Odd whitespace change: > @@ -254,6 +254,7 @@ static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long old_addr, > if (WARN_ON_ONCE(!pmd_none(*new_pmd))) > return false; > > + > /* > * We don't have to worry about the ordering of src and dst > * ptlocks because exclusive mmap_lock prevents deadlock. And new optimization for empty pmd, which seems unrelated to the change and should presumably be separate: > @@ -263,6 +264,10 @@ static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long old_addr, > if (new_ptl != old_ptl) > spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING); > > + if (pmd_none(*old_pmd)) > + goto unlock_out; > + > + pte_ptl = pte_lockptr(mm, old_pmd); > /* Clear the pmd */ > pmd = *old_pmd; > pmd_clear(old_pmd); And also, why does the above assign 'pte_ptl' without using it, when the actual use is ten lines further down? So I think this patch needs some cleanup. Linus