Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1426787pxb; Fri, 6 Nov 2020 09:19:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjiq7zi6sPM3/xL2sAVYaMdeNU8Gw68LiLMtXafgpS8s31i7paIcY+fro4OUAb2B3SKvz8 X-Received: by 2002:aa7:cb02:: with SMTP id s2mr2985151edt.211.1604683156912; Fri, 06 Nov 2020 09:19:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604683156; cv=none; d=google.com; s=arc-20160816; b=kDgr6+NYsRfXLuQ0Q/rABmQFpSgOgNBaTabxtRBBgjC6YNB3CF0Pb7M2fcatDikpxq t3ADJB8Kr8QBDggEPOiTzXa8F+6DsBS73lwVVgZbcwSbu3TwXgI7wJektGM6woV0ahWR 6Ti4F32RbtV/Q/H52FT5SwXvTEUNSPYkLlCDCcvbzAXglliT7sKD8C37AtXJwZEz1gy5 3McAhDZuAv48zbPzC/lQjQXj7b08mu8zlrTFPxK1BymX1/loFMKHgC6tsQNKu+42vB/P daNR3bs9wkozSuvXuLgNiqE9L7WEN5A2bAgQfg+U2y5k3jAkCdlLCN2ee887WuEbd0pV 6Lyw== 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:dkim-signature :dkim-signature:date; bh=AGKArt70WvEzDhknOx9Bw2ar6sCsCGBDr/06mOik2gM=; b=VL9fBHe34dmpsIEBK0kNUCxkgbmrREkRlgm/a8E0kO1ZYfY82VrwJwsViyAbkJBXUt Vt4WzTKdGaodUPrzZZyDTpNrUGC1y+PHuj/7sq3yXrngtgDIysnrPRDbu2OQ6HixtoL9 POjgMyyDrlGFhrbyjOZYvdGnJ7fFeigri5boSdyA4CyytkGRixVC0oXBXQ1r6GDkAvk3 BSF9A/XumrYqiYYUt4xgDYiVtLyW2PZLs2WuSa2xQ3w4BcWCmzkaU9wuV/2LB1TsV6AO DwcXz+K4ufCvLNju7SLLPHIbWSM8y5/jFjL6JZpvMFJ5ah9IBbcLfC4xAqsR1/gea5Sv +g5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="g/eVfSww"; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si1499136edv.50.2020.11.06.09.18.51; Fri, 06 Nov 2020 09:19:16 -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=@linutronix.de header.s=2020 header.b="g/eVfSww"; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726999AbgKFRRU (ORCPT + 99 others); Fri, 6 Nov 2020 12:17:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725868AbgKFRRT (ORCPT ); Fri, 6 Nov 2020 12:17:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8488EC0613CF for ; Fri, 6 Nov 2020 09:17:19 -0800 (PST) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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