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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 E0169C433E2 for ; Mon, 22 Mar 2021 11:39:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8F1361998 for ; Mon, 22 Mar 2021 11:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbhCVLjQ (ORCPT ); Mon, 22 Mar 2021 07:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhCVLio (ORCPT ); Mon, 22 Mar 2021 07:38:44 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B1CC061762 for ; Mon, 22 Mar 2021 04:38:43 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id r20so20614439ljk.4 for ; Mon, 22 Mar 2021 04:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QYQGe8GavJNNQqRVgKmXAqfd/LyDn5OkU3yK0hg/4Ds=; b=Mv8hzSF9y/WlPpAJoV0/oEmocDMZi3VCHHD1hVvUTkZJ7qEWAWnJxRXeCr+OHb5HNn eY7Dxmno2nebZDo/jr3ffQqERrasGX324IDrbmh0YqW/3M2iAwCjalyN9DiG94jWvfVl 9ECZZ+H87jPB+Lzt9FBAgBuOBOeWOpNtrNjoB/ndPCLCB/+LtjgU5jQgaqHqZzEBVp4e +4IMIPORukxDUlKUYmQDQmEjR/9dHQxDGo45e4Fv2aa0hU8ukxyzogwyd3XzjwG40e+L OmuBlsWP+kqDFGWSPQiPxCfGDa8GllhzwiSc54smaN2fCDEIT01/8DwkN0yBOBbP2jL7 sBvg== 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=QYQGe8GavJNNQqRVgKmXAqfd/LyDn5OkU3yK0hg/4Ds=; b=oLEOT3JTBig9W0IbIvCEio0gYy1JyOnQrlPxkEZo7qtd8UY25MD9JgW8CCMKiwqdJW tPRiczjv+RFs2qD/nYwynTByYQDLkTvMmEGVZeuAbW9WXBo+lMCmTJ7PlHl1QBvph9mD +tvzIq7QbJ0ZR5axfU9D25MNr44xb/Wl2NgfBnSDc83D/TgrWQ+3S8zlMcO3MlwuinhF AahxuSGmLh9PxjxnC3ZfKyhI1TL6MkAZCXwt/jnj8rSrZ7or4QV+DmJQftvLZvvBXp61 VpfQGE2w1bG7a1+EZ2gbtDWA/YNe45Tv1fjxtHCaYQ4aK1qWGAXS7UiuhNYkRR+KZoD7 2iRA== X-Gm-Message-State: AOAM532HNjQI+Q0jz8NoNTnqAy5zhe4YJj8T/J91ktGMAZapyv3vpToJ w3at/zNZ4yz3QE3KfSluTkj9IQ== X-Google-Smtp-Source: ABdhPJypWrQG3ZuDSQnHHtofx4HFDssoJDVyC/HSlMvOsjsQ3kQJLqjwWXFFLw5UM6XnXEB17KFpUQ== X-Received: by 2002:a05:651c:2c6:: with SMTP id f6mr9499521ljo.279.1616413122447; Mon, 22 Mar 2021 04:38:42 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id l12sm1912343ljg.39.2021.03.22.04.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 04:38:41 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 5BE39101DEB; Mon, 22 Mar 2021 14:38:49 +0300 (+03) Date: Mon, 22 Mar 2021 14:38:49 +0300 From: "Kirill A. Shutemov" To: Peter Zijlstra Cc: Yu-cheng Yu , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Subject: Re: [PATCH v23 12/28] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW Message-ID: <20210322113849.snfoxcijpwoks4go@box> References: <20210316151054.5405-1-yu-cheng.yu@intel.com> <20210316151054.5405-13-yu-cheng.yu@intel.com> <20210322101502.b5hdy3qgyh6hf3sr@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 22, 2021 at 11:46:21AM +0100, Peter Zijlstra wrote: > On Mon, Mar 22, 2021 at 01:15:02PM +0300, Kirill A. Shutemov wrote: > > On Tue, Mar 16, 2021 at 08:10:38AM -0700, Yu-cheng Yu wrote: > > > > + pte_t old_pte, new_pte; > > > + > > > + old_pte = READ_ONCE(*ptep); > > > + do { > > > + new_pte = pte_wrprotect(old_pte); > > > + } while (!try_cmpxchg(&ptep->pte, &old_pte.pte, new_pte.pte)); > > > > I think this is wrong. You need to update old_pte on every loop iteration, > > otherwise you can get in to endless loop. > > It is correct, please consider why the old argument is a pointer. Ah, right. Sorry for the noise. -- Kirill A. Shutemov