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.9 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 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 3E8CBC55178 for ; Fri, 6 Nov 2020 17:17:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A81D22243 for ; Fri, 6 Nov 2020 17:17:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="g/eVfSww"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WiqldJ8y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A81D22243 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ABBC16B0036; Fri, 6 Nov 2020 12:17:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A6C8D6B005D; Fri, 6 Nov 2020 12:17:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9341F6B0070; Fri, 6 Nov 2020 12:17:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id 6955F6B0036 for ; Fri, 6 Nov 2020 12:17:21 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 048E1181AEF10 for ; Fri, 6 Nov 2020 17:17:21 +0000 (UTC) X-FDA: 77454649482.17.badge89_2e07c4c272d4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id DE310180D0181 for ; Fri, 6 Nov 2020 17:17:20 +0000 (UTC) X-HE-Tag: badge89_2e07c4c272d4 X-Filterd-Recvd-Size: 3663 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 17:17:19 +0000 (UTC) Date: Fri, 6 Nov 2020 18:17:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604683037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AGKArt70WvEzDhknOx9Bw2ar6sCsCGBDr/06mOik2gM=; b=g/eVfSww/b1CEhuL2eMyf53TmumsVIW07T1fqEHtbVMmtgSmmYeKcdl1yN1XXv1uiKZbNt /v1rZjjcYQHJ+yBllEStZOSdwmKl+XmcUKQPV6lfIz8n5mVLG23GY2coQEFPBQdA6+fxeW Qlj6cmvSt2hkW8+S7ZePjBNeKQQZLsBq3dvNggfK9XXctqgqcGrKUZb18HrDVOApdO13ID UpYaVjNwa5gYxqvbGdCVK2pikVZDL5TRXxGGMY2GglwzCuwFrxwb+RXykwXCzpxKUWprNv /7ID/XVjSlO5usvGZmU1Ck5nkxUin+tUckvEcEdMRGhhLEM9VQpbsLYbtPKThg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604683037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AGKArt70WvEzDhknOx9Bw2ar6sCsCGBDr/06mOik2gM=; b=WiqldJ8yVWQCUmLRrVxIGMZ/Uj7faaADiudmoEnof1cifn4Yf97DuPNw8rTttyw4Y2PVQy nZEopSnPd0IdpnAg== From: "Ahmed S. Darwish" To: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, Peter Xu , Linus Torvalds , Andrea Arcangeli , Andrew Morton , "Aneesh Kumar K.V" , Christoph Hellwig , Hugh Dickins , Jan Kara , Jann Horn , John Hubbard , Kirill Shutemov , Kirill Tkhai , Leon Romanovsky , Linux-MM , Michal Hocko , Oleg Nesterov , Peter Zijlstra , "Sebastian A. Siewior" , Thomas Gleixner Subject: Re: [PATCH v3 2/2] mm: prevent gup_fast from racing with COW during fork Message-ID: <20201106171716.GA91138@lx-t490> References: <0-v3-7358966cab09+14e9-gup_fork_jgg@nvidia.com> <2-v3-7358966cab09+14e9-gup_fork_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2-v3-7358966cab09+14e9-gup_fork_jgg@nvidia.com> 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: Hi Jason, On Fri, Nov 06, 2020 at 11:55:14AM -0400, Jason Gunthorpe wrote: ... > + if (gup_flags & FOLL_PIN) { > + seq = raw_read_seqcount(¤t->mm->write_protect_seq); > + if (seq & 1) > + return 0; > + } > + ... > + if (gup_flags & FOLL_PIN) { > + if (read_seqcount_t_retry(¤t->mm->write_protect_seq, > + seq)) { > + unpin_user_pages(pages, nr_pinned); > + return 0; > + } > + } >From seqlock.h: /** * raw_read_seqcount() - read the raw seqcount_t counter value * ... * Return: count to be passed to read_seqcount_retry() */ #define raw_read_seqcount(s) Please avoid using the internal API (read_seqcount_*t*_retry) and just use read_seqcount_retry() as the documentation suggests. (I guess you just missed changing that last one... I'm in process of changing all these "*_seqcount_t_*" stuff to "do_*" as we talked on the v2 thread. Hopefully there will be no more confusion after that.) Kind regards, -- Ahmed S. Darwish Linutronix GmbH