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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 45E0DC55178 for ; Tue, 27 Oct 2020 11:32:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C84932074B for ; Tue, 27 Oct 2020 11:32:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="JLTnLiLL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C84932074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 208D26B0072; Tue, 27 Oct 2020 07:32:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DCD16B008A; Tue, 27 Oct 2020 07:32:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FF746B0072; Tue, 27 Oct 2020 07:32:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id D9C3D6B0072 for ; Tue, 27 Oct 2020 07:32:34 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 80ED033C4 for ; Tue, 27 Oct 2020 11:32:34 +0000 (UTC) X-FDA: 77417492628.05.lamp32_180cd292727b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 5E0CF1801C5FD for ; Tue, 27 Oct 2020 11:32:34 +0000 (UTC) X-HE-Tag: lamp32_180cd292727b X-Filterd-Recvd-Size: 6186 Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 11:32:33 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 27 Oct 2020 04:32:39 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 27 Oct 2020 11:32:31 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 27 Oct 2020 11:32:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlCQVh6Jg/NXaPtdfEwT7pcnsLT6L8/6GbRxxANGvaoKoLTzc+IDqqmsCma1uorAkpizReeiSfNrCKJKxekqHujELAVa2W+/iHAXEK7pblW3Nr3U6I4JBi3flvtb9d95tW7w0BU2gRaG5SUrlJl2TXlvb9kIr2uFofAcR9LZBi8hX68dHnl0ERCpShqFCp9g2SuYdPxkGvFx2doCCttS9b1eLlT92dZJtePnmPLD5g/uEQfmai2Bo2ZBNbXDiUlOt0y+JzNgxtvmB+luUEjziQkFVuQjmq+QwEommB+cmaOsD4ntN3AFyebHvpJOj6NBvSIoFJp2lzvcSi2L2PEctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M/xbrhLTe58leVT5hpXtDV7AqQjsQ6HpwaqzOFtOC6o=; b=Zi3SWPVbitc0WijnOYWTAqap8J2+bwFeqyTCTe+haps9ibcXQJqz4h8c/czBJst1z2Kl9pw31f25aTaZ4qPwOPkzFKJuMCNNgk5xBbbeQ2rRH1BIK67CT2qbfZjaPS2FQE3v/WBuMRmDtimgfHnUEd/C1UuCX3/Tl7TgnCxDOOj2RxJYSK0I6X80eaxAWY7cAcjyLCNabnFfbPFe4V/jlnfH/7wVKY9GD2aY0TqBCgFFF5MnI/OGR0goZmddPOi7ELzHkzpnj4apRtGEZ39YCCqbuYl2rDcwwwG8ellx6NV/ESJ5wOOuQ2rJU+HGjp49PqRuFcgkmuCTbmQYDGoWfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4499.namprd12.prod.outlook.com (2603:10b6:5:2ab::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Tue, 27 Oct 2020 11:32:30 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::cdbe:f274:ad65:9a78]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::cdbe:f274:ad65:9a78%7]) with mapi id 15.20.3477.028; Tue, 27 Oct 2020 11:32:30 +0000 Date: Tue, 27 Oct 2020 08:32:28 -0300 From: Jason Gunthorpe To: Linus Torvalds CC: John Hubbard , 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 Xu Subject: Re: [PATCH 2/2] mm: prevent gup_fast from racing with COW during fork Message-ID: <20201027113228.GF1523783@nvidia.com> References: <2-v1-281e425c752f+2df-gup_fork_jgg@nvidia.com> <32a38d92-6ecc-243b-77be-8f1ea0792334@nvidia.com> <20201026234952.GD1523783@nvidia.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL0PR05CA0023.namprd05.prod.outlook.com (2603:10b6:208:91::33) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (156.34.48.30) by BL0PR05CA0023.namprd05.prod.outlook.com (2603:10b6:208:91::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.6 via Frontend Transport; Tue, 27 Oct 2020 11:32:30 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kXNDI-009FSS-TN; Tue, 27 Oct 2020 08:32:28 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603798359; bh=M/xbrhLTe58leVT5hpXtDV7AqQjsQ6HpwaqzOFtOC6o=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Date: From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:X-ClientProxiedBy:MIME-Version: X-MS-Exchange-MessageSentRepresentingType; b=JLTnLiLLQM0hgJOfNZ7R1ySHYEHNeGXhr3ckzyQAGrKXu6s5s+Yl9KxTuR6NB5RLv wPN5jeZhObHmF0yBUViZFx/SC/tkEOMfpyxYta2UpJWLuy7IkQskbKr1YeuvKI13Ab f+Qtjr/FXzu7lrLbMVoY+SAqWPTy/iKNGHkgu/+wvV7EJKLbN4Z1nLWA9J1Ny7+uVe MIgA4tx4muOX2Y83UY7DplcYpjzpza78fAL8Sl5LLyO5s+YtrwRCfiSp+gYDZretcp EQ4Ck6IdH86G6wGLrcwfoFDSLHXq3ltGRkScenU6pPFZzKjhol9xV6JU4xgZS4MSdm 39KB12WSlS/yg== 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 Mon, Oct 26, 2020 at 05:14:35PM -0700, Linus Torvalds wrote: > On Mon, Oct 26, 2020 at 4:50 PM Jason Gunthorpe wrote: > > > > Right, it isn't a "seqcount" because the read side doesn't spin. > > Not all readers spin for seqcount either. > > Sure, it's the *common* case, but look at name resolution - it will > basically fail on a seqcount failure in RCU mode, and go to the "slow > and safe" version: > > if (unlikely(read_seqcount_retry(&d->d_seq, nd->seq))) > return -ECHILD; > > Exactly like gup_fast vs fork, in fact. > > So no, you don't need to retry for seqcount failures, doing > > seq = seqcount_begin(..); > ... optimistic fast case ... > if (!read_seqcount_retry(.., seq)) > return 0; // success > .. do slow case ... > > is valid and happens. Okay, I see d_seq using one of the raw_write versions, so I'll make this look like that Thanks, Jason