Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5022377rdb; Tue, 12 Dec 2023 17:10:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEy5yNGDpYoGUnhyuy+A3K1T64PAxU8zKyEOklKdMC9kHjCpvkt62xegEJ7WOnBFRq5lhmR X-Received: by 2002:a05:6a20:8423:b0:190:93e:f224 with SMTP id c35-20020a056a20842300b00190093ef224mr9857537pzd.76.1702429804480; Tue, 12 Dec 2023 17:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702429804; cv=none; d=google.com; s=arc-20160816; b=W6zbA1iBEvpmwkLDLpwXkAWJJ34f4TNXbtN5bbbGLYpiTVhLeppTP1NRrxrQPwpllI xCLxk07MLvj7CTlM9bnVfjjnl8IFCZL9t/n1n8MUItnUgMSmfZLrCeYmu0fGOOgkJiWi dCldhFgnEm8n1LfSGmd8tXs+yVvNuh/3qTqXZIBCawMomRKU2QxORUtTMgTI9OSz/TGp qZAXnkwLwBqo2IkxhbZdHBLNW7Th6OrLidTORaEUKhLO8CqQx78vDm5maDTABaeKA4UW JLhQ/EisCN8aM0ZHuXrz/sot274d/MSk5mpRH1gBQNXnDbPqs5yX9fd/spNPlYXasMgT F4GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0i1d9QvoS4OxhYISeUTScW7akaFRcF7KdLSyFQ8hFdE=; fh=wSmogdqjTJe2Ef4drMTCCx7PTCV4aGsgEPM9DHsoaRs=; b=XSd7LlwlXMH5buNTHiPS/gQ/L16s+qocU9Vznee4Ovz3iDyZTmh4YXJfvnT/BbCX4T Ac2S1B/aQGgf/cQFiBxKvwJtezqHqZN+/CLjfII8dJ0JaaeL2dqibeTg9lIgNC6PHdmp WqwcPuxwo5Yf7iJJs77DmH3PGbCBp9MP6WsBdR7ksb6GV13G77ORQaQXr8OhE4opInnu eg4Oynx3ByFb4v0vNOD93g5lwL4enAAvRRi5fj5sNTsCZvluF6iF8doYMv0V0RXYMu80 wZ7jIqnLqR6HAGqrcZ18taNdpowoSJ6SKlAK0qFxGbaQ0GGGYwQ6/a0vWDJIkwWc8+1n L5bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MLHbNY0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g14-20020a056a000b8e00b006cb852928ffsi8680139pfj.66.2023.12.12.17.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:10:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MLHbNY0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id AEA60801B3E1; Tue, 12 Dec 2023 17:10:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378116AbjLMBJr (ORCPT + 99 others); Tue, 12 Dec 2023 20:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378076AbjLMBJp (ORCPT ); Tue, 12 Dec 2023 20:09:45 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C16BCF for ; Tue, 12 Dec 2023 17:09:51 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33340c50af9so6265679f8f.3 for ; Tue, 12 Dec 2023 17:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702429789; x=1703034589; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0i1d9QvoS4OxhYISeUTScW7akaFRcF7KdLSyFQ8hFdE=; b=MLHbNY0Czd3wPe32uDHEc/p1QFAuW5t37BjMpcSQ2JrBYEKt/Wqd1QbsTFzgLXsEN+ e3zrFyeJbLcDbesFlbaAbJ4AkhT9MSKbiUSpFqgK+n3Ihyw51fmrpHKKATAsVyY7MeGB fWBqPUvZmrKqbfVAVled2XVKP8ba27dIcf7oKvZ76EK+crAx7CGdVTPrRzYOlRNuhU7p pvX0DfSrYhSZXjFc5E5n9LKb5R4aBzuu2LPN/nbNqGeYnsUe4ftFMqYIqRFh+WScy9yx UD8XfTMfQyY0XR1pW3zgLXJ425d57zXmHsWNryMgdpTfLKmrQXK9O2funHSfzgsFvrjJ mWjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702429789; x=1703034589; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0i1d9QvoS4OxhYISeUTScW7akaFRcF7KdLSyFQ8hFdE=; b=YPUWUKlwJklHYueoJsQJW09MsKYpaaswM2JVmaNstKlEl6119SL1BEMyelVxp9wY4W ZYprYvrj1RENBQeyoBeerRKDo7zM67k4VChsNnZYIWtHV72kx9bNR7bkMrQPGKiArwcA NrlbocqsUd0wFgOt5+hFypzic9gRlNp0x2CMop1D7+tEG/lOtjUPwzqgykp4HaVPr/Kw m9vXls3kPq2zvyvayDvQtCYL4jm+G5twym/Ht7p/oZWEbUJcH/Fp2qWwAr9G/unD6iRF 16FNW0CZqMjW/eJUiqsleMIAwC1Y/lx/PScT+ImMyj1PBM0WR0uABa4Fp5aI0Qu+7eQu ZUxA== X-Gm-Message-State: AOJu0Yzt2QHZgU4AFK+00jSOQ4F4kSoHVASaWqqRy98VnFm8SCbJuaCT luAvlxLpK3sUe1frKA4SLmfvcOnedcWqXoMVRPawlg== X-Received: by 2002:a05:600c:4f86:b0:40c:48fb:ea01 with SMTP id n6-20020a05600c4f8600b0040c48fbea01mr1374675wmq.209.1702429789212; Tue, 12 Dec 2023 17:09:49 -0800 (PST) MIME-Version: 1.0 References: <20231208005250.2910004-1-almasrymina@google.com> <20231208005250.2910004-9-almasrymina@google.com> <20231212122535.GA3029808@nvidia.com> <20231212143942.GF3014157@nvidia.com> <20231212150834.GI3014157@nvidia.com> In-Reply-To: <20231212150834.GI3014157@nvidia.com> From: Mina Almasry Date: Tue, 12 Dec 2023 17:09:35 -0800 Message-ID: Subject: Re: [net-next v1 08/16] memory-provider: dmabuf devmem memory provider To: Jason Gunthorpe 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 , =?UTF-8?Q?Christian_K=C3=B6nig?= , Yunsheng Lin , Harshitha Ramamurthy , Shakeel Butt , Willem de Bruijn , Kaiyuan Zhang , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 17:10:01 -0800 (PST) On Tue, Dec 12, 2023 at 7:08=E2=80=AFAM Jason Gunthorpe wr= ote: > > 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 als= o > > > 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 cle= anup: > > https://lore.kernel.org/linux-mm/20221108194139.57604-1-torvalds@linux-fo= undation.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. > OK, I imagine this is not that hard to implement - it's really whether the change is acceptable to reviewers. I figure I can start by implementing a no-op abstraction to page*: typedef struct page netmem_t and replace the page* in the following places with netmem_t*: 1. page_pool API (not internals) 2. drivers using the page_pool. 3. skb_frag_t. I think that change needs to be a separate series by itself. Then the devmem patches would on top of that change netmem_t such that it can be a union between struct page and page_pool_iov and add the special handling of page_pool_iov. Does this sound reasonable? -- Thanks, Mina