Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4701672rdb; Tue, 12 Dec 2023 07:08:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuevmDoioW7SptsAl+KHUcFpzpRcoIwI0jOlwRCJj5aMFX29R0rzwzZ2CyQ23kjV9PwIrc X-Received: by 2002:a05:6a20:3829:b0:18f:97c:8a3a with SMTP id p41-20020a056a20382900b0018f097c8a3amr7001732pzf.101.1702393736789; Tue, 12 Dec 2023 07:08:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702393736; cv=pass; d=google.com; s=arc-20160816; b=UYZUk+iM65snN+1Z/VPYaTwz2d7UaHOWE+JS2WRkpzjbppqGANw9xFlUknwLAGhkJH 3hWGaU8FKwvsefr4u+CLf8VLzSFh6jqzTwq/MpKNcDsCGNaZxmxqQ2kgYXN0k3fPU1lt hW4ta9mZA/sCwGos9PmfXi/VEMW/ecYwMzP5yKMHHN/NPeAy6sIRtAZ6YAxwlua5ZaWB KP9Wa5HyGgj5bhCKXyrU02rSzeR1UK53ZeU/Pr0BnNN5iHIQ/RqDjblBgXxs3HKIOFgI PqNoK1b2L2uxR/tQHO+nJSr4s5nCC7Rv2lVaMzZ/xjhWGyRDEKx8lha6U7i43jxIqbke OaZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YByBA4oxfQwXTXAXysbLeGABlNGSnZnlorup2IUTvZk=; fh=RuIdZ3WmbXmtHIxq105H8rWQ6IfgUKaP+IEjkpRThj0=; b=P0dX56GVV1XBHVJpzZemmzPyQw/nepbIVgsjcdUlZ51/v7XYi/sn+5Jp5VYaJwUjWi YD0ZHOLXI7Jtd8UBgsbP37TESH78cYaVDNdmRIqeQk9lX04HUC4RX5Hi+8m8ixOwojcc 0i9+eDzphbObFNjmmN9b6GRSg8QIr9j+VT8PJ2lGXznfbzc5xoGOstuMuw6rOymskMX1 dJAH1zGELreodFSUSCVYSGZEi0ExblNhqM5MrW2/pFWXXaq1QJD/sY6qs7HQk4/0ZLBv brXjp6PHqUzWARktbNivtORtg3XuTXnsf4GddqJ6psVycN5i2ZDZ1wlfa5xTwQli++VW trag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=UEV5KMyZ; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 13-20020a63124d000000b005859c255ce8si7787573pgs.819.2023.12.12.07.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 07:08:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=UEV5KMyZ; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 52B77805F96D; Tue, 12 Dec 2023 07:08:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376469AbjLLPIg (ORCPT + 99 others); Tue, 12 Dec 2023 10:08:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376480AbjLLPIf (ORCPT ); Tue, 12 Dec 2023 10:08:35 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2082.outbound.protection.outlook.com [40.107.212.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2449AEA; Tue, 12 Dec 2023 07:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WI8TKw2ciedZLjG78hJpvoywrx7yF/KQZbvFRSS9vDMa0Z4BGvyRUoynYh3Odo129+/WwX2GT0nMks7/RgimHMq/ZAeH2ai6LBgdg2jbfl5EsCgpYPHYnI7pLqLZGSIj9MUPc+BeRCAbaC7V8jXQBx+EVDBnsdqLMTiaPDTZ3LwU1JO4GD2HoWHWIRO6NgFH6EqN3QSuvWwXu4p+cj011p7M7S6BY28Ntps2Zpi+ZvbKpizB86py9rWIMZMI1WXcOd97+pl/zFFBm0n6q/6Eh7+YQ5X6MFAt1wUow8lUF11vM+faTQH3+l5BCiVioq+XM9L57r24u1jIGf/IBrPv0A== 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=YByBA4oxfQwXTXAXysbLeGABlNGSnZnlorup2IUTvZk=; b=NQsaC3VP3r3cv7iHUrwaUt8BsSgKiZxx+J5r3AHiJLYE6kwXBdBa636T2Rhj5LKc33UNnKs37otHzN9PdsS/jK50dr2RoSaLKDO4Qp9wZ20AXSpZ+YkE28XNCnjxkGCEKjDu3OKCbDAq9ek5Gfci4e0A9iZKdRWxD43Qb1apq2gc+STR7cGwtGIdKEGtEvQv6+kA+zal3K/hoiIzkpZ65Nurtun6kwuxfT3+WuRVvaGmwaubttDh1mDdydAWAyNb98i6D89jl7kzJdA18dxRqfkNGs7OrtNHUqSP7mAFob+T5E0JdxZy8UUTgIOhA5CBEuz+E/CxQXGwFcNgbPontQ== 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=YByBA4oxfQwXTXAXysbLeGABlNGSnZnlorup2IUTvZk=; b=UEV5KMyZUZDzHJakZFGZ1NcaXmSZ0R1aav3/4wLMbkB68DbXuNsX4YuWf37OPGs9r7XqsrHnXevaOyc/uXb9RGRey5LAPNF1zsmjz6vsyrNr5FAnutNdCcHYc5NAXD9krX/9lNVilc/T+iVzb4be1M1kYP845zMiUuVkQzNh+Kkrk1czEiIkjdVHeTfNf9ajPC4WpSBVLPYQuiqyDQrhuIQH6JC46jiUqJP/IjuYPyx+x/yI7+1BIy0QTU81BFoLSXYf3enO1vcUuuv/xXuz6M6e83HReeijNuP1ou4B6zMAF6JjuTLLpWoOhzQ5+xqBtWPlshjjGT1fcgrpYF1CHA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by DM4PR12MB5722.namprd12.prod.outlook.com (2603:10b6:8:5d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Tue, 12 Dec 2023 15:08:35 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.7091.022; Tue, 12 Dec 2023 15:08:35 +0000 Date: Tue, 12 Dec 2023 11:08:34 -0400 From: Jason Gunthorpe To: Mina Almasry Cc: Shailend Chand , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jeroen de Borst , Praveen Kaligineedi , Jesper Dangaard Brouer , Ilias Apalodimas , Arnd Bergmann , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , Christian =?utf-8?B?S8O2bmln?= , Yunsheng Lin , Harshitha Ramamurthy , Shakeel Butt , Willem de Bruijn , Kaiyuan Zhang , Christoph Hellwig Subject: Re: [net-next v1 08/16] memory-provider: dmabuf devmem memory provider Message-ID: <20231212150834.GI3014157@nvidia.com> References: <20231208005250.2910004-1-almasrymina@google.com> <20231208005250.2910004-9-almasrymina@google.com> <20231212122535.GA3029808@nvidia.com> <20231212143942.GF3014157@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: MN2PR05CA0015.namprd05.prod.outlook.com (2603:10b6:208:c0::28) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5722:EE_ X-MS-Office365-Filtering-Correlation-Id: f7e77963-7a4e-47b7-5674-08dbfb24365a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GUfRm4Cu/wM1W78LaY01CcMxPpZ86o8WxOrzGItsyyOzMMz1i49I5c0fGcBeBjstddiBLrNnRwOlXS8M4VvWEinYizo0Fbh7+YkEBSHRsOmsgd7bhL4/19vdbVMbGVoqXvc7S3vEoiX5aTzCducWmrlIL4C/inqtVCmUQI2YbzImqjB5dD5qiYpQoKvfCOjz1rRgxxLgDtIHRcidZTcYI/B00L0913okY8ZKbOWGc/T+ZtmIAYVg2Wkac8yDr+nsP1sz4TUboGnQIPKTeP4G/vdZ/Q8zNxSoi86tZsvX726fL5ij0VL8KD1jY8JqA4h4ioil7+Ej49SNaPMgqIG9mefoZ6dCyc1xKnXKvb1Tzisc+jNmGNshxMIbr3RodaQbQNqpQeofSHIQZGvdiuVhBbQRsNXqUeUN2ioI9OzH0IQ0dV5YBU8rMamMl8IMEV2NUOxIxHIgGszTIaO6/mqB2rNzvS10/g2hUCdrObR8vxToc5BTGCssXPIBbeIyFdH0wNvRkZRhIINSsjRri1Jg5172xiVleWA/ZjBWXNNLvR/Jg3QZmc5+Wkx402KBzgRbVJfpoNxfTOT5cUmIcjYXWo7aJ4llciuz1IQwbPg1jhk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(396003)(366004)(136003)(39860400002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(54906003)(66556008)(66946007)(66476007)(41300700001)(6506007)(1076003)(6512007)(2616005)(26005)(36756003)(86362001)(38100700002)(33656002)(966005)(478600001)(6486002)(8936002)(8676002)(4326008)(2906002)(7416002)(7406005)(5660300002)(6916009)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mrEyRSkTR3gUgnuY1J2tdZGe/P6rs8W4YBEfEQXcPcFgl07D/PbU8F41j7N/?= =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xb8DVOQGSMvPj1vhET?= =?us-ascii?Q?VS0ZdNgN45O9vLYkkveSqCrbRFDTA1p4emQFHdchHfJ4iEYvnUSkplNBVOew?= =?us-ascii?Q?bHtAwKCTWABaGz1t6fVu7RA5QQqHWoJcR8S9/MCp9WFruHRXi85OUHErgKnh?= =?us-ascii?Q?Mr/JU4qYTEuEw8W4J9NQUW7wxNEbmHQ+/b0kO2ypB5qr8JfqlYvCLu3P0V7M?= =?us-ascii?Q?7AIUrHHQjetxDmzGtp+LONn4KnC4EmUHRkOniZJpGWPgAFyrWmsn3Ajrx9Ey?= =?us-ascii?Q?lkbzq5l1Fe1iDWyXsxIMKAZZLnXp10HzTalqJ7TcGHFIV1gtWB9JjLTGYU4f?= =?us-ascii?Q?SQN+DJOyrqcKRv1GhD0EBo21R08lGVdLVLtQ4tFpbDMA4erUotcGVL/t76cs?= =?us-ascii?Q?jk1scj27LnjchzJFChyyynn+2QhlX8beSWCe2J6CuQFRRca9NxPLuYCaxF2o?= =?us-ascii?Q?pZ1mf/OTeAhkLljGT1YDtpQEBH+F0RbvOzgdbVp7as6fTx2k8frB9IDkfCxS?= =?us-ascii?Q?xoQNMEp6BL5o+Ul2WAYtQoaCTrysScjvCoGTBDB599FhLGO4YAfG5SxxVg+R?= =?us-ascii?Q?L1DPU5oEMm7Te3tguCLYmdENqRk8w/wuGEF2iZajLXxCvzw06nlPvNK3HBxf?= =?us-ascii?Q?dzyMvzDiKKDe3XdHmO59yQYeaZX77P8phcd8FfT9?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7e77963-7a4e-47b7-5674-08dbfb24365a X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 15:08:35.3779 (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: JWLKQFKjSNhxNlo+bcKSshFN7zqiaPkLLotEj/GU512i4fMIL6yPfhGNEQwhFm54 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5722 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 07:08:46 -0800 (PST) On Tue, Dec 12, 2023 at 06:58:17AM -0800, Mina Almasry wrote: > Jason, we set the LSB on page_pool_iov pointers before casting it to > struct page pointers. The resulting pointers are not useable as page > pointers at all. I understand that, the second ask is about maintainability of the mm by using correct types. > > Perhaps you can simply avoid this by arranging for this driver to also > > exclusively use some special type to indicate the dual nature of the > > pointer and leave the other drivers as using the struct page version. > > This is certainly possible, but it requires us to rename all the page > pointers in the page_pool to the new type, and requires the driver > adding devmem TCP support to rename all the page* pointer instances to > the new type. It's possible but it introduces lots of code churn. Is > the LSB + cast not a reasonable compromise here? I feel like the trick > of setting the least significant bit on a pointer to indicate it's > something else has a fair amount of precedent in the kernel. Linus himself has complained about exactly this before, and written a cleanup: https://lore.kernel.org/linux-mm/20221108194139.57604-1-torvalds@linux-foundation.org/ If you mangle a pointer *so it is no longer a pointer* then give it a proper opaque type so the compiler can check everything statically and require that the necessary converters are called in all cases. You call it churn, I call it future maintainability. :( No objection to using the LSB, just properly type a LSB mangled pointer so everyone knows what is going on and don't call it MM's struct page *. I would say this is important here because it is a large driver facing API surface. Jason