Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2991363pxk; Mon, 28 Sep 2020 05:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH6pJeAtImQeyl/IBx+ypGSt3i5eYzB5EAjWanw5PbKiJHp1FkmaxWsIHVV9s+VT2vDX5d X-Received: by 2002:a50:fc0b:: with SMTP id i11mr1548445edr.164.1601297482607; Mon, 28 Sep 2020 05:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601297482; cv=none; d=google.com; s=arc-20160816; b=0vp++WIqp/+hSWsql+Mg4SOYNqPR1JOmwr//CJ0oc9ELpS98lyrXeZrzAEgciqGLAA zwV9xFZ1qJ6mlv2tvvFvXhLhvyIcfG23YORNzK+6dCx/spVrqBgzUSR3wVH49fxNAHkv +u0ghFe8lhDp/O2fJ95Es2LVb4WWPq6r9ugJswFDxex6XtOtLjqTDvh5chAPuX6P4jS4 EA3h2+qcnDZQJF4wSfoAmm6Pa2IaxOQpsWFesLPFqfGS24hwsN8nJfM491BRDqIF/TSm jqDA7gzelJSoLpEgpnZSKDqqiRlGlwa++xnYxtGKA1Zmrq4Vx3x/koC1OmYTt8WRdwKZ sOzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C7pLuM6q9GITD003wal8FUvMqWiJb4o3xG/3xTeMIHw=; b=ecLH/UuACHqVbdd3Gjupy7U+UJTsw6+7/LpEVEaSt430d4smEp5fk970DzJ62WTFZy rZlDhi3T0xzlBRIV1yi8GmGXB2eE3CNOyCcUBzD9iT5kKBp32TlpsIGsO9PdJlpL1Tkl GZbyc7etktI7i+rVK6aAOeBH8DTUb02tnMciLacmMz4ojPUAC99TowjL+0fVnH67QNnC b/tqvpEfoL12NeLLPWLSzKmh7JtTfJ0LI0t3tekyenLtA2j+hIkA/nZN7nXPSbupu1KU 0xzaizeP/I44Z1GTou0xeSf3anJq60bF/CQ5JihvYVD/sQjzHiB+11/Lnmt75IRXnRh3 q9UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=f9lb2tgP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu20si551547edb.311.2020.09.28.05.50.59; Mon, 28 Sep 2020 05:51:22 -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=@ziepe.ca header.s=google header.b=f9lb2tgP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgI1Mtk (ORCPT + 99 others); Mon, 28 Sep 2020 08:49:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgI1Mtj (ORCPT ); Mon, 28 Sep 2020 08:49:39 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9850AC061755 for ; Mon, 28 Sep 2020 05:49:39 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id o21so591993qtp.2 for ; Mon, 28 Sep 2020 05:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=C7pLuM6q9GITD003wal8FUvMqWiJb4o3xG/3xTeMIHw=; b=f9lb2tgPovyEXgA0Z4FOMgi3I5WM4fBlC3HOpM70LPWDcNTyUIrsetkEgxSbET6gAK 3nKGSJc6Ub1KXYMckQVyXMumjmiBV4aEkPHu0vd33RSDrVhtFcOPjmx2R9RWDfoGSUF9 WoK4s1dUzp5TRfJcyPWmkbAPdi/wMVzJf4V+S4eRYobTP9huYHbVRPyBLVb5yD8wNMxx Xz+rB/6VCcuNtjmYfQfJBfHnO7i0LEXvIwBrkzAc7KySYSwf4EgQ0JVLaTy/0P5QMCmX JSO4/vjoDkbffgbtEEU5bc9jR3Y6HY8/zAEtSRvZ53rivyLk2Zm8zuyZIJQT6qlcFPlq APsw== 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=C7pLuM6q9GITD003wal8FUvMqWiJb4o3xG/3xTeMIHw=; b=OkSMg8f3AF63X7iSmHqnlMiQXOVPVGEPApMhrdJbUDGsM3V20i0sghbCnqDw1k/nn4 CWA67Of1Ff5AYkC0u6X+WovIb+DnNmKuvsljGX+J0xDUAC38tLFGmbGcTxAa3mS6sx5F NJbT8rb43oooAk/u6CbcMbYZS4wwV+tEpSrK46mtNqMowQvjeHHnEtR5Qkl942rrQOM0 vf7FOH9RJQJaHk1XGfiqgPG6j0TAUz0EG4//v3QqkvwPY6f+Zt7WXDniKXT/1+mFwwgu 2M0/7pe/+4sZ1yptrLnOVorSkPGNwYaxDtDqnAVRMFpmuXHLydTbgA6NnlMy8oEeA90M HTHg== X-Gm-Message-State: AOAM530yq1xmynh89XmBBywhwD541ByyAuEh04MgTIoxS9Yzu30EmP/Z CJFJRO4gNwT/BeEPZBsEz5D46g== X-Received: by 2002:ac8:4d07:: with SMTP id w7mr1338294qtv.243.1601297378789; Mon, 28 Sep 2020 05:49:38 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id e24sm826203qka.76.2020.09.28.05.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 05:49:37 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kMsb3-001ueb-Ap; Mon, 28 Sep 2020 09:49:37 -0300 Date: Mon, 28 Sep 2020 09:49:37 -0300 From: Jason Gunthorpe To: Linus Torvalds Cc: Leon Romanovsky , Peter Xu , John Hubbard , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Jann Horn Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned Message-ID: <20200928124937.GN9916@ziepe.ca> References: <20200924183953.GG9916@ziepe.ca> <20200924213010.GL79898@xz-x1> <20200926004136.GJ9916@ziepe.ca> <20200927062337.GE2280698@unreal> 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 Sun, Sep 27, 2020 at 11:45:30AM -0700, Linus Torvalds wrote: > On Sun, Sep 27, 2020 at 11:16 AM Linus Torvalds > wrote: > > > > Btw, I'm not convinced about the whole "turn the pte read-only and > > then back". If the fork races with another thread doing a pinning > > fast-GUP on another CPU, there are memory ordering issues etc too. > > That's not necessarily visible on x86 (the "turn read-only being a > > locked op will force serialization), but it all looks dodgy as heck. Oh. Yes, looking again the atomics in the final arrangement of copy_present_page() aren't going to be strong enough to order this. Sorry for missing, wasn't able to look very deeply during the weekend. Not seeing an obvious option besides adding a smp_mb() before page_maybe_dma_pinned() as Peter once suggested. > .. looking at it more, I also think it could possibly lose the dirty > bit for the case where another CPU did a HW dirty/accessed bit update > in between the original read of the pte, and then us writing back the > writable pte again. Ah, I see: set_pte_at(src_mm, addr, src_pte, pte); wants to be some arch specific single bit ptep_clear_wrprotect().. Thanks, Jason