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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6052ECAAD5 for ; Tue, 30 Aug 2022 18:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38A318D0002; Tue, 30 Aug 2022 14:45:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 339F48D0001; Tue, 30 Aug 2022 14:45:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DA828D0002; Tue, 30 Aug 2022 14:45:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0FF318D0001 for ; Tue, 30 Aug 2022 14:45:48 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CF702C0407 for ; Tue, 30 Aug 2022 18:45:47 +0000 (UTC) X-FDA: 79857137934.23.8FF1990 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2059.outbound.protection.outlook.com [40.107.220.59]) by imf15.hostedemail.com (Postfix) with ESMTP id D2B60A0037 for ; Tue, 30 Aug 2022 18:45:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSiQkPXJDuZNO+EBck5ennpMwK+iZvSae4V9P3s4lXosyP9xGNSS13/SY+i0r/9dPyXDezstK4FmhXfSePRN+jO4yr5yAze/ek9TvZCRQyD7O4J8/qzPm7gCD8ANMSoLjP4fscmIsEkXmC+zYSMAx3g+yl7zhqFWCXREwie7NrfE5lfTnrXSmLWi4U9V7tIXkYL00UujHWdTXMKd42db72MaVZOEs4jHsg6eiUPV+GBCErfq04+2c2J1uhvS3eo5muUNpmXTLyWufyThncwmfVP/ajzGZA/SABl45fDqRasAVy8pUSu8ESeBSW7LzmbdVVIl+FVkhAFv6igJmoLClw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=axqLozOc9FhoUkiBNpYX3BcKVtvlIqFzimKWa2ylR6Q=; b=F8Wuf/BcSBXIAj+kl1LJTC34Jx4YZclwodKE1Ap8+b9oxdjFJydXgux+yrLHIBttf6nsR6Gfshky1IY5aGkRoFkkLQRLDlTvRbh9I1iY8V/B6Rr+IRqgABgPSIgFIsSOn1KOstqwS4IHTdyHLV49FPk/FS8z5te5QBil+SzCy8TMMr7/oK0ql1+l66brcEv8+6nP6NEAwIB3hJA8HbHVcesvlPfsEeC6z6g617o7uRaCSqs352/qj1xkS31lFt9SdamNlnaeRYwz+2RCAWNjXcLRJ/HDucJs61YI9ByXhOqacg1+dRXNUXxd7i0XdW0QekSsLRZ0ajxvfGFqafnHwA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=axqLozOc9FhoUkiBNpYX3BcKVtvlIqFzimKWa2ylR6Q=; b=gdsbQDcquh8GhUpcGbl8BlvFTWy/aQgP5WK4rOwyK3c/CCGMvfmxm2L0Ioo5Bl0J+Vaa/nS2SauBl/kj2WfxcPDOP5ByfwOC3Wd88r/m+Ah/1zXNbXkdISpiyhQhHTfjxpt6KeduPl44aQvc35Pd0E4Sq1sqEfxsZOaq5jEG+Mu6cIwMsYVBuCwR38VdfDIcPrJ2rsb8xWjEWbKrKJTAW0FcTER7AIu99rymYpNbNQsGqZEEkOYmqqb2XrzUUu4C0FZAeSaKaxqbXwsCDICb4wtYlNg/vC81nRh6hGHqQk7nWadFswf8x8RHWJ/DCqhay6poAHvutUDjQlDevIWImg== Received: from MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) by MW4PR12MB7215.namprd12.prod.outlook.com (2603:10b6:303:228::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Tue, 30 Aug 2022 18:45:43 +0000 Received: from MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::462:7fe:f04f:d0d5]) by MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::462:7fe:f04f:d0d5%8]) with mapi id 15.20.5566.021; Tue, 30 Aug 2022 18:45:43 +0000 Date: Tue, 30 Aug 2022 15:45:42 -0300 From: Jason Gunthorpe To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Mel Gorman , John Hubbard , "Matthew Wilcox (Oracle)" , Andrea Arcangeli , Hugh Dickins , Peter Xu Subject: Re: [PATCH v1 2/3] mm/gup: use gup_can_follow_protnone() also in GUP-fast Message-ID: References: <20220825164659.89824-1-david@redhat.com> <20220825164659.89824-3-david@redhat.com> <1892f6de-fd22-0e8b-3ff6-4c8641e1c68e@redhat.com> <2e20c90d-4d1f-dd83-aa63-9d8d17021263@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2e20c90d-4d1f-dd83-aa63-9d8d17021263@redhat.com> X-ClientProxiedBy: BLAPR05CA0025.namprd05.prod.outlook.com (2603:10b6:208:335::6) To MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 958e5fc8-7ae8-4617-1aa5-08da8ab7d7ed X-MS-TrafficTypeDiagnostic: MW4PR12MB7215:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 93S+rV+45oa7Z5+G8nuyy6eRQ1UoTmzWfE8JXyVNR/475ZGdJ8joDM+zZTnbwgiOtmtK7Vye6SYD6ciyG6hm5KRE9PVJ3pZKfU4cPGR1g0DEcRo/TW9uLnCO6BnhpFNIe3B3Pe97rslIyyWizZ7AzkUCF8Jpq1SE2rHzgu208bxkX2upDA1GgueYqLfgzUqgKrHVTmxobbvRJ8c2/u3GmUkSDMYxmOIMGIOQv51yZnqJVOpymuGnpb7RTTwNpEl2anDyElpJyV4CLmo/mz6NDe0Ou4KC2gclRjZGi0EjwPjOqgdFRdEpY3tlzS0EFYUZesoS0XBiWZ7USCW10ONFMtLEUV5iNpg1MR441v6/zQLYR2QeoknwE5vyNlffKTJyHwAoo8Yf3a410yfOVpXSYQHsmfd+rGhv8SmlzPkLU4JIBMcXVU6VjYBEq6LElbyaTmathHf3mgy3cDbPR4VxTx/ScdlBzzJFAg4uxjKgd70dUSBCCB6WQe8SeZBruJ6sIiLRNFy8ik20X/8AKyqRTSb6sa42mEmRdvEBJYjUNetHOCRC/YLEfv/ViHWnrWGmfk7nVpLV/h1J/ao8SHmtbcEBawnRe47yAqxvA3Pbflx+jUHXBaxOtQLq24L0ZoCOE0pPEi0/r24ldXh5QXziv/oe9BteG3fwS509vT/jgx05TXwWxv7RZhiw77FCr5Z4ohynNG5xGZ5vubg7/2yPlA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4192.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(136003)(396003)(39860400002)(366004)(376002)(4326008)(186003)(2616005)(6506007)(6916009)(38100700002)(316002)(36756003)(2906002)(83380400001)(6512007)(26005)(8936002)(86362001)(54906003)(478600001)(41300700001)(5660300002)(6486002)(66946007)(8676002)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?RPn4FZrNryjYqp2gLRJfN/lkk/EwUx32r/ysw/gP/wxTahHN9M6GoOFbyEvZ?= =?us-ascii?Q?A1dM8pG9nngPIVvj6K5Kpe99d5axkHB0KNlurLd8zIyHGZevkP60uo+c456Q?= =?us-ascii?Q?Mtl+4GdQVKvraY3j4oWZ7/c84yuohPh7L6iTNos2CTAqYrsfzVoDBBb+7WL8?= =?us-ascii?Q?7tpOZZPYXf3lopA/9l7cZwzDeRd5+ZSlOaT2XLLm0+sF4njFXKC7R9tlGYP0?= =?us-ascii?Q?nQWCGaufIuzGWNh9IaJKG6rmS6aH2ZCGf+AIDGN7gIdj2XfKQ2xwOrSBdfQg?= =?us-ascii?Q?q+xOzb7kDE/uekB60VNku4Hm4t3QXJR2yUQ5d0qRmBiXZBKaosaUMAE9TQzH?= =?us-ascii?Q?pmuI0biZhBx4E5OpjnjO00g+o1VWG4vh6bdJgb+9Z1oQqfIRL0A7hbZY8S89?= =?us-ascii?Q?pP7aTfeGQA0584KEnURCCd+BVo6ik+uSf2tqRb1ixC2YZvps7ckwvD6gyq+N?= =?us-ascii?Q?RQKKMtCPT9BSmngpybaxiqPHx/w7AVSygivuhsRxh7wSMwZPFn3q3iwirL7I?= =?us-ascii?Q?9N5In8sJbYqk8eRNWR/Z6pd0m9+O0EEpdbLpfQPzAUQ8K8N/k3XgyGF4yzPb?= =?us-ascii?Q?nTMnTj5CJKoNrdV0ewZTuiMnfothv/uAVGMV7RyHPB6Nt26qwi1gArKR+QFf?= =?us-ascii?Q?+TiWAvyArWRA5RTlkyPv7WWjARW+WUqnpWU72h2/JrNhZD62ANyH0eFSGeKb?= =?us-asc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atorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 958e5fc8-7ae8-4617-1aa5-08da8ab7d7ed X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2022 18:45:43.4041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6Zf4Tlk+uisEMVPaDXlE+WaD6bJmKqYwITgd64fvQmbKX8LpsKdvQuuRR7N/ZubS X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7215 ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=gdsbQDcq; spf=pass (imf15.hostedemail.com: domain of jgg@nvidia.com designates 40.107.220.59 as permitted sender) smtp.mailfrom=jgg@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1661885147; a=rsa-sha256; cv=pass; b=YV/UbMp5T5HbGD1BDzcBcEZjTiaI4KtLyKMV9qnDjoUKP43W9CWSd/0VlENST++SgTXdyM 13gkMrg2z/SrxKz9l50DXpryVzgrza48XA5swiwN9091CvySfZvXhfy1H1ZUVN2CKr+yyu Bj3CqUIR8JZqJjWC00SvfnpN/EBgJH8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661885147; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=axqLozOc9FhoUkiBNpYX3BcKVtvlIqFzimKWa2ylR6Q=; b=CLKBZo7G/nU21zZcdOg7zkKAYPAHeRbS3jMaZC0cfxe4YWPGpw/wcKaq11YH0UZbUPH8N1 Te+YFZv6dBrp7roG/J/imIuIYDzRD1pjGna61JfZ7xz8Y+mcga7D4XftrWWvNWoCwSoz7i a1VZODCPZWJFqynD65Qkh0FnYryTSTM= X-Rspam-User: X-Rspamd-Queue-Id: D2B60A0037 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=gdsbQDcq; spf=pass (imf15.hostedemail.com: domain of jgg@nvidia.com designates 40.107.220.59 as permitted sender) smtp.mailfrom=jgg@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com X-Stat-Signature: t77cdxo1g3e45fcf1o1ohuz7nx8mcukf X-Rspamd-Server: rspam08 X-HE-Tag: 1661885145-389659 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, Aug 30, 2022 at 08:23:52PM +0200, David Hildenbrand wrote: > ... and looking into the details of TLB flush and GUP-fast interaction > nowadays, that case is no longer relevant. A TLB flush is no longer > sufficient to stop concurrent GUP-fast ever since we introduced generic > RCU GUP-fast. Yes, we've had RCU GUP fast for a while, and it is more widely used now, IIRC. It has been a bit, but if I remember, GUP fast in RCU mode worked on a few principles: - The PTE page must not be freed without RCU - The PTE page content must be convertable to a struct page using the usual rules (eg PTE Special) - That struct page refcount may go from 0->1 inside the RCU - In the case the refcount goes from 0->1 there must be sufficient barriers such that GUP fast observing the refcount of 1 will also observe the PTE entry has changed. ie before the refcount is dropped in the zap it has to clear the PTE entry, the refcount decr has to be a 'release' and the refcount incr in gup fast has be to be an 'acquire'. - The rest of the system must tolerate speculative refcount increments from GUP on any random page The basic idea being that if GUP fast obtains a valid reference on a page *and* the PTE entry has not changed then everything is fine. The tricks with TLB invalidation are just a "poor mans" RCU, and arguably these days aren't really needed since I think we could make everything use real RCU always without penalty if we really wanted. Today we can create a unique 'struct pagetable_page' as Matthew has been doing in other places that guarentees a rcu_head is always available for every page used in a page table. Using that we could drop the code in the TLB flusher that allocates memory for the rcu_head and hopes for the best. (Or even is the common struct page rcu_head already guarenteed to exist for pagetable pages now a days?) IMHO that is the main reason we still have the non-RCU mode at all.. Jason