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,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 CFAC1C2D0A3 for ; Wed, 4 Nov 2020 18:46:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EDCAE20780 for ; Wed, 4 Nov 2020 18:46:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="SH4kivAL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDCAE20780 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=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 535886B0072; Wed, 4 Nov 2020 13:46:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 50A436B0078; Wed, 4 Nov 2020 13:46:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F9376B007B; Wed, 4 Nov 2020 13:46:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id 138FD6B0072 for ; Wed, 4 Nov 2020 13:46:29 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A8355180AD811 for ; Wed, 4 Nov 2020 18:46:28 +0000 (UTC) X-FDA: 77447616456.19.kitty88_1104fbf272c3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 574C81AD1B5 for ; Wed, 4 Nov 2020 18:46:28 +0000 (UTC) X-HE-Tag: kitty88_1104fbf272c3 X-Filterd-Recvd-Size: 5208 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Nov 2020 18:46:27 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id k3so31162994ejj.10 for ; Wed, 04 Nov 2020 10:46:27 -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=FgX7GNxHXuC87Ssr7tLLsGvoW7BOy+jNc15SXkuxUYOTLYdql2JcMKM1Nn+wmK9RZL LTZeAGyz26IPiE4L0TJf5iaEkTwqDqkJdnMAB+xlRzkEBgJrihR2bQYV9sZfjttkAUFX nz4PM7GGRoKAbGaBjOioexpgw7WGDLOxQyGWUinVZhqwfX6HNb+QdMZMzPnYm5temf5R BQxdBfCA1xx1fBhrRcXPmiVJ25oeCcRgIQgZJ3R6P//77kxZHmrxC4UrP3Tf+qIrj+6/ kzVYkfmZTtOVGGSRXJDNQmxqTPUg4EsbD4AjeDpn+ax1tTu5dDfoBw4xy4RivsEilltb VMDA== X-Gm-Message-State: AOAM530mf0cxqOyxT74DVTEQOtjFs5s2Ye9LTwup3zLIXoCVxZMU9tNL nucdUMQAAptxWww6ZibZfBhR3q5wNBaTnA== X-Google-Smtp-Source: ABdhPJxVWBIuPVOCeKziSCFG5DF5TuPxV+9nrKxcJtk73OWIUT4YRaXSDD0rYbRfDB9KffFb/fLZzw== X-Received: by 2002:a17:906:e2c3:: with SMTP id gr3mr25643393ejb.471.1604515586300; Wed, 04 Nov 2020 10:46:26 -0800 (PST) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com. [209.85.221.47]) by smtp.gmail.com with ESMTPSA id ok21sm1431160ejb.96.2020.11.04.10.46.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:46:26 -0800 (PST) Received: by mail-wr1-f47.google.com with SMTP id w1so23222615wrm.4 for ; Wed, 04 Nov 2020 10:46:25 -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" 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, 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