Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp123821pxb; Wed, 4 Nov 2020 16:45:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPyUOKyM8Acl2A3gyeGUyJHJATYFF53jDhPw4r7kj2unEBcm34as5iw0QJL7o8qenu6zwl X-Received: by 2002:a05:6402:3066:: with SMTP id bs6mr463956edb.79.1604537142071; Wed, 04 Nov 2020 16:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604537142; cv=none; d=google.com; s=arc-20160816; b=B7OTNwN/2IibENGlO0yN1/y0a4g4Mto1IdBHrRiXVtwimnHkawx0XBQWB4kH1AOn4L Hvqp4kaHfDprdZ2JTkwjQdE+W0viAWqdjBn00QgHYYE7w6E5W/aUq5DiHSA8ZU/mb/0r jcFktUj1smGe+9VTSGt2UDES7GbOKGnK0OS3M5NIAdiBRAI6yDR/JskY2FXpJRcbzSiA QAMoQpqcwE7zpthWd+yx2PEtNhMyVM5neY4Ubxb0Ss+kb+qs4m2RNPbHdikPvmYdM0a9 1/hoi9uZkgoByFhvXeUCXrqqbsFaUmskOcwlZPpZ9YkGhiKnRbRV6SKOps8Ha91AdNDp AFHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rJ0JSJD7YhQrtyyxZarPnMZ/Oz0Aar8DucY8lFMMvvc=; b=husnYmiF6R4UBH2RW0Yz3+Mf1F1b+yRtAtr1FRf+fGrLQycrSGxsrM0MKxjsLIKHW9 vv0EMnQ6oSZMTuiurEbs72qGIpsj6ZHPwWLi/gZ++pwwgyoZ+KXsjmgh3nlOvlOrMWFr 8acCyZTBEa3KU23qsH5rqrtH7cxLj3MJ7n3Zi9sdRrVTQa1Jutuac0he3KKl65QdsHzc 5E5HtCZy8TP4GYynIgsVy/ORjl32xWrubEmnhRjn4l7IypSwyhzste5muNgQU5ZQ+en4 0cyolaCGFy86mi7bn+9r87xWS4U1oMMwRzdrvN5/71agqOnCEvXe2uEiPfRqf1sejHjI YZ3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=SH4kivAL; 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 b1si5772edy.451.2020.11.04.16.45.09; Wed, 04 Nov 2020 16:45:42 -0800 (PST) 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=@linux-foundation.org header.s=google header.b=SH4kivAL; 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 S1731308AbgKDSqv (ORCPT + 99 others); Wed, 4 Nov 2020 13:46:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726737AbgKDSqv (ORCPT ); Wed, 4 Nov 2020 13:46:51 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD4FCC0613D3 for ; Wed, 4 Nov 2020 10:46:50 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id gn41so13953973ejc.4 for ; Wed, 04 Nov 2020 10:46:50 -0800 (PST) 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=rJ0JSJD7YhQrtyyxZarPnMZ/Oz0Aar8DucY8lFMMvvc=; b=SH4kivALZPyu6z8Te1ke0S4tmokB361FaCC0AzDfHKGoHsDC9uO+0aTOFZsLDwisKr pWKOHAviOTaTLQEOEvik45JL9KgUGyK7BJTfllyxetUS/K8q/MHYet9UNjFcYRYchZsF 7yUEWICEhOTLfStxey617QMvYLuKg2c7ML7e4= 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=rJ0JSJD7YhQrtyyxZarPnMZ/Oz0Aar8DucY8lFMMvvc=; b=hizUKIzonyKIaK69t9MAWXm9TutRyEyRykLPrLAinegomgWnkOPH6lcdhVC7dxiW04 //SS4BvMIbcqCfW55m9CPnHQrhbYj1ySZ9yHLJit8EWpuy5ElI/9CNbLZYsMl5foVI/w 9CFBxHrOusURm5QPLCJQ7hIJOL83SYnMVMxlR2KOxH7+dYwAQHSbmb6zFa58p9Z25yRb CSLhFCJFpOEgf4W/TX1X0idKik+e/Z8CaOO4N9YWwkNPeG0m7wUJbbs+kjLOshByiNmM 6ymYlrliG7Sj+/QaQUkh7TDTQCKB5Mb8Z/9WNK4ZtpEoL0OBgcvx6eqMCKV32vHrATZg fBAw== X-Gm-Message-State: AOAM5321RNHr/1PAEv6kmBG+piTv5y8UowUmsW8tCSLu9GZ3EANaev+t kn8WQUTkU/FeKbIhgI7lVTmA98qvQxm++Q== X-Received: by 2002:a17:906:b312:: with SMTP id n18mr17168509ejz.353.1604515609239; Wed, 04 Nov 2020 10:46:49 -0800 (PST) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com. [209.85.218.45]) by smtp.gmail.com with ESMTPSA id t8sm1411586ejc.45.2020.11.04.10.46.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:46:49 -0800 (PST) Received: by mail-ej1-f45.google.com with SMTP id p5so31246064ejj.2 for ; Wed, 04 Nov 2020 10:46:48 -0800 (PST) X-Received: by 2002:a2e:868b:: with SMTP id l11mr10743770lji.102.1604515153445; Wed, 04 Nov 2020 10:39:13 -0800 (PST) MIME-Version: 1.0 References: <20201030225250.GB6357@xz-x1> <20201030235121.GQ2620339@nvidia.com> <20201103001712.GB52235@lx-t490> <20201103002532.GL2620339@nvidia.com> <20201103004133.GD52235@lx-t490> <20201103065225.GA63301@lx-t490> <20201104013212.GA82153@lx-t490> <29e4f7f7-5774-7d8f-694b-75eb55ae1b2e@nvidia.com> <20201104031711.GA227990@lx-t490> In-Reply-To: <20201104031711.GA227990@lx-t490> From: Linus Torvalds Date: Wed, 4 Nov 2020 10:38:57 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] mm: prevent gup_fast from racing with COW during fork To: "Ahmed S. Darwish" Cc: John Hubbard , Jason Gunthorpe , Peter Xu , Linux Kernel Mailing List , Andrea Arcangeli , Andrew Morton , "Aneesh Kumar K.V" , Christoph Hellwig , Hugh Dickins , Jan Kara , Jann Horn , Kirill Shutemov , Kirill Tkhai , Leon Romanovsky , Linux-MM , Michal Hocko , Oleg Nesterov , Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner , Sebastian Siewior Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 3, 2020 at 7:17 PM Ahmed S. Darwish wrote: > > Nonetheless, as you mentioned in the later (dropped) part of your > message, I think do_ is better than __do_, so the final result will be: > > do___read_seqcount_retry() > do_read_seqcount_retry() > do_raw_write_seqcount_begin() > do_raw_write_seqcount_end() > do_write_seqcount_begin() > ... > > and so on. Looks reasonable to me. And can you add a few comments to the magic type macros, so that it's a lot more obvious what the end result was. I clearly wasn't able to follow all the _Generic() cases from the seqcount_t to the final end result. It's a really odd combination of subtle _GENERIC() macro and token pasting to get from zeqcount_t to "false" in __seqcount_lock_preemptible(). I can see it when I really look, but when looking at the actual use, it's very non-obvious indeed. Linus