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.133.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 24B2B28CF7C for ; Wed, 23 Apr 2025 18:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745433454; cv=none; b=GaoP1MZqZfiYO65qFsGxXJY+Wwl8Dt0d17fA2yeyXYnA1K8kBWHcgQ2+TNVqC5+6NjZJcvG1zohcMDiQArVptouy5K2KGw03IFRdtd1eDYMtXOeDrAbuLAeEDDcBqDRq30pNnyynseMYOqaKuR0JiVPFojwDq2t3HTzhcFCOBtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745433454; c=relaxed/simple; bh=gh76Cwi537UAiZiZzvQ7qO7K4eMJvXZ5GcYqQsv4qVM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pZ57ZW7QzCJ/50sOIoFKQ1VYTf4jyraYqKGcueVgL5M0qfZB+sWb/vzRgN6V8RPHl4Oh3zpsIa3Vis5bmhJcYxNzQ3gqnR5esXHUfUzYzfDamWT2AS6fL8Zt9YcxW4bY4I9zCCJYmueLqRM4qr7a4xtfJHTKc4mM65nrN1oHp1Y= 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=EUEOBP2n; arc=none smtp.client-ip=170.10.133.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="EUEOBP2n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745433452; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y6pwEnRnhkHgazDgVxPbcQpa5mERaCMyYK1dziw6UIo=; b=EUEOBP2nmpJF5XmufuyC/HIcBOTM8TgYaIueDWTT8ofPtnfWc/CGh3aJJ3MVbfT+1Wnu7k lXE+Q4rq9n1OekVQ7HgQ9A3XJsQxwfXGDLp62Ftd8CJS3PkPqDfIls4Vs6ZrAhAN2DrRm8 ebc2avXQ5w+A40Yi7hkS0kSRLfNt934= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-p4c6TcZGOduEkJ0IjInMdg-1; Wed, 23 Apr 2025 14:37:28 -0400 X-MC-Unique: p4c6TcZGOduEkJ0IjInMdg-1 X-Mimecast-MFC-AGG-ID: p4c6TcZGOduEkJ0IjInMdg_1745433447 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-30bf554ea7bso897191fa.1 for ; Wed, 23 Apr 2025 11:37:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745433447; x=1746038247; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y6pwEnRnhkHgazDgVxPbcQpa5mERaCMyYK1dziw6UIo=; b=dmqWEBaH6mT2g4qNdif13NLsQXGrXwuVykOsaUp3ZtLCOF1AFNa0w/9DexSif9DZFS 9yuuMzyWBYSEkKfJvhlZfUZM0zTqZPtkcOvnymhstJ0SUy5QJIpe+knCtoWNdKbIeT6M Gl87xNig3UDZWp00inX+YziEqLa+rPSkKE18gHpwz9YXXCgCkxUBYpLQI6RbEDzB9kB0 YeCYR5XMzCSgwscOalxdgfAtEtDpdSWaZY5Wl1eouCaDzHQWNIe6hDG616XwuLRZPCjq P/HxmRZPIT9SFOA9eVvF2/BEw2hR31i+EJknWdi10LrytLhR36O6dgZ4yhepVKbw74ZE tpeg== X-Forwarded-Encrypted: i=1; AJvYcCVFJXPJmbHnoTR91NVJj/ypVkJArBLw9DEVFoZNHBjftOwviwBdjJgpWwdC5j/ZdXwcO2JSoQ==@lists.linux.dev X-Gm-Message-State: AOJu0YyDuzQQeioydF0ZrMx6+IsX/+kB52dl7eiF9RLz5VXvp0wAOWXT mkXU44CyStDrPAje35nplPh/RhGi1KMX2t7lmUsPm/ck3p8ZoMyn8r0DbB4Kku9RLsSpLjN/WWa GLo1X/KJuMIIYCDsl2kRm5jTnmplzXb/n7delU7m3EjJ7DJacCL8= X-Gm-Gg: ASbGncud9YvEYvm8u6Yt87CsSYuCZRXAaZ3hOJi3zO7Z3tv/tT0OHcvOM6uwVEi2aUQ WuWJanY0qcESvToYWHxLIc6fjN7OEmQQD/vGpBacNu1538PrF4v/qMzbkbZ9Db3dG0FjLMDuE3s /0TB7V0Sf0V1xlgwQ1nXun6rQMIhwqizCYCkgtUvYif0DRjbTVJqL4Np3brH93ybTn+udi80O+G Ux8X0wZH49DRRga3OnOCtHuK/Ohy7kKglx4O7fe4ufXF3oalVEhiDUbLNGeNSqY4Vxyqr5BFTfe NVXVVwacoAdV7On8XMoUWOAEWtxwXvwg85FsjQ== X-Received: by 2002:a2e:8818:0:b0:308:e956:66e with SMTP id 38308e7fff4ca-3179449456amr500171fa.0.1745433446938; Wed, 23 Apr 2025 11:37:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeLX03zhP8nSlFHqNWBiKFBjf3MShxZQb8tc2EeW+8vLK6+b+87nnEoR+0vFre3XFcDl9w4g== X-Received: by 2002:a2e:8818:0:b0:308:e956:66e with SMTP id 38308e7fff4ca-3179449456amr499761fa.0.1745433446435; Wed, 23 Apr 2025 11:37:26 -0700 (PDT) Received: from [192.168.1.86] (85-23-48-6.bb.dnainternet.fi. [85.23.48.6]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3109075e8e9sm19833701fa.12.2025.04.23.11.37.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Apr 2025 11:37:26 -0700 (PDT) Message-ID: <36891b0e-d5fa-4cf8-a181-599a20af1da3@redhat.com> Date: Wed, 23 Apr 2025 21:37:24 +0300 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 10/24] mm/hmm: let users to tag specific PFN with DMA mapped bit To: Jason Gunthorpe Cc: Leon Romanovsky , Marek Szyprowski , Jens Axboe , Christoph Hellwig , Keith Busch , Leon Romanovsky , Jake Edge , Jonathan Corbet , Zhu Yanjun , Robin Murphy , Joerg Roedel , Will Deacon , Sagi Grimberg , Bjorn Helgaas , Logan Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, Niklas Schnelle , Chuck Lever , Luis Chamberlain , Matthew Wilcox , Dan Williams , Kanchan Joshi , Chaitanya Kulkarni References: <0a7c1e06269eee12ff8912fe0da4b7692081fcde.1745394536.git.leon@kernel.org> <7185c055-fc9e-4510-a9bf-6245673f2f92@redhat.com> <20250423181706.GT1213339@ziepe.ca> From: =?UTF-8?Q?Mika_Penttil=C3=A4?= In-Reply-To: <20250423181706.GT1213339@ziepe.ca> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _I8YbYrl-5tXneRC13c0PGzt4VAwKAy1lRFxlhgIies_1745433447 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 4/23/25 21:17, Jason Gunthorpe wrote: > On Wed, Apr 23, 2025 at 08:54:05PM +0300, Mika Penttilä wrote: >>> @@ -36,6 +38,13 @@ enum hmm_pfn_flags { >>> HMM_PFN_VALID = 1UL << (BITS_PER_LONG - 1), >>> HMM_PFN_WRITE = 1UL << (BITS_PER_LONG - 2), >>> HMM_PFN_ERROR = 1UL << (BITS_PER_LONG - 3), >>> + >>> + /* >>> + * Sticky flags, carried from input to output, >>> + * don't forget to update HMM_PFN_INOUT_FLAGS >>> + */ >>> + HMM_PFN_DMA_MAPPED = 1UL << (BITS_PER_LONG - 7), >>> + >> How is this playing together with the mapped order usage? > Order shift starts at bit 8, DMA_MAPPED is at bit 7 hmm bits are the high bits, and order is 5 bits starting from (BITS_PER_LONG - 8) > The pfn array is linear and simply indexed. The order is intended for > page table like HW to be able to build larger entries from the hmm > data without having to scan for contiguity. > > Even if order is present the entry is still replicated across all the > pfns that are inside the order. > > At least this series should replicate the dma_mapped flag as well as > it doesn't pay attention to order. > > I suspect a page table implementation may need to make some small > changes. Indeed with guarenteed contiguous IOVA there may be a > significant optimization available to have the HW page table cover all > the contiguous present pages in the iommu, which would be a higher > order than the pages themselves. However this would require being able > to punch non-present holes into contiguous mappings... > > Jason > --Mika