From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BF472367B0 for ; Mon, 23 Jun 2025 10:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750675873; cv=none; b=C+clK4MDe1Meo71HNuEf41ptsbjCPUtnpUA4OIOfLwNQtbHqaaHmEqQSNvSJq47oQSl1CoiWdjWMYfm46NME54dTUr6WJ0LVP+NlwAIUwABgq9T6nsUcVxDYShncKtsIeqPbCW5rX39MxA9KWyr/4qDU2JkrfzcxkTU8h4HnrF0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750675873; c=relaxed/simple; bh=UWME3XWaA3mYNTAF4jzXFx44J7v0qfaW41Ag+aZwT7k=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=SwcQ7wquWIykSxGQUY/O0qA7CFtgpMUtTdhe+1d7dWkXR3SPYt+Gmo3WWsC5yeMTGKDALV/3F4onnsIqU9P6wuO8yLOpcazGVMTe80JFE8uPh2fmbWlV8bIow4cLXpBt5sOvoVTgLiF/D2NO6/IyE2PkLG7+A1K3rVtagGbx1sw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QodC+Ulq; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QodC+Ulq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750675870; 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=QsYyfB+Z7vJsNRi6uhzXLbhNGPzqKCN+qJj9FfeE5iA=; b=QodC+UlqbygJowEgAbcdHVqxyO25btDTAzU1GGNyrx1izyN/dZwA/mf4SOKzIX05vCokkD ku6XXDk/+DPhOmYUkCZ+Xl7m1dtJPYLMRJScFrgfLSr4LZ/TL3yIJgB4hBUxD6OVUqojlL Evjs6zm0a05xVWZcXkOHciXgxYYhDGo= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-CFX2wP3BN9qpbl-vblsOvA-1; Mon, 23 Jun 2025 06:51:07 -0400 X-MC-Unique: CFX2wP3BN9qpbl-vblsOvA-1 X-Mimecast-MFC-AGG-ID: CFX2wP3BN9qpbl-vblsOvA_1750675865 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E38E21809C82; Mon, 23 Jun 2025 10:51:04 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.81]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D4A430001A1; Mon, 23 Jun 2025 10:50:59 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <2135907.1747061490@warthog.procyon.org.uk> References: <2135907.1747061490@warthog.procyon.org.uk> <1069540.1746202908@warthog.procyon.org.uk> <165f5d5b-34f2-40de-b0ec-8c1ca36babe8@lunn.ch> <0aa1b4a2-47b2-40a4-ae14-ce2dd457a1f7@lunn.ch> <1015189.1746187621@warthog.procyon.org.uk> <1021352.1746193306@warthog.procyon.org.uk> To: Christoph Hellwig Cc: dhowells@redhat.com, Andrew Lunn , Eric Dumazet , "David S. Miller" , Jakub Kicinski , David Hildenbrand , John Hubbard , Mina Almasry , willy@infradead.org, Christian Brauner , Al Viro , netdev@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: How to handle P2P DMA with only {physaddr,len} in bio_vec? Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1098394.1750675858.1@warthog.procyon.org.uk> Date: Mon, 23 Jun 2025 11:50:58 +0100 Message-ID: <1098395.1750675858@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Hi Christoph, Looking at the DMA address mapping infrastructure, it makes use of the page struct to access the physical address (which obviously shouldn't be a problem) and to find out if the page is involved in P2P DMA. dma_direct_map_page() calls is_pci_p2pdma_page(): static inline bool is_pci_p2pdma_page(const struct page *page) { return IS_ENABLED(CONFIG_PCI_P2PDMA) && is_zone_device_page(page) && page_pgmap(page)->type == MEMORY_DEVICE_PCI_P2PDMA; } What's the best way to manage this without having to go back to the page struct for every DMA mapping we want to make? Do we need to have iov_extract_user_pages() note this in the bio_vec? struct bio_vec { physaddr_t bv_base_addr; /* 64-bits */ size_t bv_len:56; /* Maybe just u32 */ bool p2pdma:1; /* Region is involved in P2P */ unsigned int spare:7; }; I'm guessing that only folio-type pages can be involved in this: static inline struct dev_pagemap *page_pgmap(const struct page *page) { VM_WARN_ON_ONCE_PAGE(!is_zone_device_page(page), page); return page_folio(page)->pgmap; } as only struct folio has a pointer to dev_pagemap? And I assume this is going to get removed from struct page itself at some point soonish. David