From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5973F1B86DC for ; Thu, 30 Jan 2025 10:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738234234; cv=none; b=QdptP/CQtM/zeQ0i2cA6aIrGpGoXbwEz47lLz8l5V/DzwQ91+Im2Xn6kQTII8HSoHmzOLgpaBoM7W2xtJMLiXbXoHgPAryOmc+oGh5s84LM7RPWwZzFQVjYHRY/41JnRSaMVm6Tyd0CZL+XolKU7/TnuMHk3oiPOzOatP8/YAnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738234234; c=relaxed/simple; bh=SKBfS0WQtXwhn3Zs8dAn0uRWcnVH3Fp+ioSiHvDMYtk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cRtrIG8I1GsopveZZ8Uj5V4BPfASzYo8L8nuUy/0J5MxSsxtS6tHqmPw0zDU25vH2zJ/mCE+s3s+OdC25WYOZ3Dv8G9C4L1y12U8fU8jTYKowOUl/nEEZoWDJeUD5UavcS5yix/0vAOagP2HC4Ijp1z+1RHaEWt2lGVBC1A4s+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=QMszmrbO; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="QMszmrbO" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-437a92d7b96so6203955e9.2 for ; Thu, 30 Jan 2025 02:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1738234230; x=1738839030; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=WlIOJ9U3QA9sHWVQXA2SUvaDy201Q+tlYK7jAEa09Tg=; b=QMszmrbOwPzZGs7n/cbGZJGUOaxavUa2aEt33ex32VuH2DuuaxWrAXKz7CrUCST1xw v6i59Phgs6MSJmw/t+V92CxSvX2UFeYiSrGVW4CS4+FsZhhZ7WC5xH9l1frJ4dRROgTx 1kbTy+NBs9t8IBXqIVygjJaWNiRKg5ScLu9ag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738234230; x=1738839030; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WlIOJ9U3QA9sHWVQXA2SUvaDy201Q+tlYK7jAEa09Tg=; b=fsdipGsPLnLpKxqs1Oax+QN3Nk3PbRX8pcAINP3qxdbBje3lsk6CCLRIz8ArtLRaWU phJlxcr+KTaTElAtJSpxrHEK6HTVVdr9p+m+2AOy/H4NwG7HwB2sy3hKn3GFdLqYJYHq s1sDi/g9LjbSUNQ5EmbqySDKTmnKjwFzkYoAyvpsCEkb8aaKFuYOZZOXrVTKlLPRWbOC F90Vu3DhGVWfIR0Egza8pJjv0C31ddGToYpowH+/fK9XaqX0HGzlFlxhaeR83EWFlgnD UaksTeGcqEqVSUZezZLZVdCncbNR3mCQG5Xt+Zd9fi9oI1lBsIX5iwPGYcG5KOMbV97m Scfg== X-Forwarded-Encrypted: i=1; AJvYcCXK2farGPeWS+ZsOjA+jIEmb51msPL1ELcm2KeCGYrz9x590M7tI1nVN3HGaLqo9D5ArVkfRyYIO+jas8Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9s59S1E6V7Jn20DfyPZRKJbHeCIjSf/YYdNA+3PJUoFuozzcC aRlwfH78jwWa6oYbv/2aakduJlNlgoQwGAQZGXcpKsPSWscQd/ZpxbJWRafXgIE= X-Gm-Gg: ASbGnctJEXXZDjs4LhJV8utPQ02kZaCJdQg5Nqh9YifB2tCViTAOv4Tu5Cwy3otmBaa bb7gRymPE2oCNr3f5705vPJ6JTkLJJUYR+G8m7OJZu+yd3Nj5W8tcs7g7Pz7zbK41zW3xVVyZtW 0YlagGdVJpptIj9wnc3COcVTOU6O/jQpWoqFEK29YGVcap1/WAAyqWOCSzDvI2aairheF4F8AAB bHavfIeN3w9twFVj4kq28qWmhT3GsRowygpe6bMTMWXul+xPsBly/V6IMDLgb8Ljvye9Kv3CALt Rq5MuXJa0UOr5q3bRr6lPfYBn/k= X-Google-Smtp-Source: AGHT+IHMw0cYgOTvVvK6HIRKMLy20cgFzE3d4vlaCtti/GNUtg6PxQxKz8d7r2TT9CWFYzLA0t+WOA== X-Received: by 2002:a05:600c:4e0c:b0:434:a386:6cf with SMTP id 5b1f17b1804b1-438dc3a8faemr61859005e9.2.1738234230580; Thu, 30 Jan 2025 02:50:30 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:5485:d4b2:c087:b497]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438dcc81d74sm54599715e9.37.2025.01.30.02.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 02:50:29 -0800 (PST) Date: Thu, 30 Jan 2025 11:50:27 +0100 From: Simona Vetter To: Jason Gunthorpe Cc: Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Yonatan Maman , kherbst@redhat.com, lyude@redhat.com, dakr@redhat.com, airlied@gmail.com, simona@ffwll.ch, leon@kernel.org, jglisse@redhat.com, akpm@linux-foundation.org, GalShalom@nvidia.com, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, linux-tegra@vger.kernel.org Subject: Re: [RFC 1/5] mm/hmm: HMM API to enable P2P DMA for device private pages Message-ID: Mail-Followup-To: Jason Gunthorpe , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Yonatan Maman , kherbst@redhat.com, lyude@redhat.com, dakr@redhat.com, airlied@gmail.com, simona@ffwll.ch, leon@kernel.org, jglisse@redhat.com, akpm@linux-foundation.org, GalShalom@nvidia.com, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, linux-tegra@vger.kernel.org References: <20241201103659.420677-1-ymaman@nvidia.com> <20241201103659.420677-2-ymaman@nvidia.com> <7282ac68c47886caa2bc2a2813d41a04adf938e1.camel@linux.intel.com> <20250128132034.GA1524382@ziepe.ca> <20250128151610.GC1524382@ziepe.ca> <20250128172123.GD1524382@ziepe.ca> <20250129134757.GA2120662@ziepe.ca> 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-Disposition: inline In-Reply-To: <20250129134757.GA2120662@ziepe.ca> X-Operating-System: Linux phenom 6.12.11-amd64 On Wed, Jan 29, 2025 at 09:47:57AM -0400, Jason Gunthorpe wrote: > On Wed, Jan 29, 2025 at 02:38:58PM +0100, Simona Vetter wrote: > > > > The pgmap->owner doesn't *have* to fixed, certainly during early boot before > > > you hand out any page references it can be changed. I wouldn't be > > > surprised if this is useful to some requirements to build up the > > > private interconnect topology? > > > > The trouble I'm seeing is device probe and the fundemantal issue that you > > never know when you're done. And so if we entirely rely on pgmap->owner to > > figure out the driver private interconnect topology, that's going to be > > messy. That's why I'm also leaning towards both comparing owners and > > having an additional check whether the interconnect is actually there or > > not yet. > > Hoenstely, I'd rather invest more effort into being able to update > owner for those special corner cases than to slow down the fast path > in hmm_range_fault.. I'm not sure how you want to make the owner mutable. The only design that I think is solid is to evict all device private memory, unregister the dev_pagemap and register a new one with the updated owner. I think any other approach boils down to the same issue, except we pretend it's easier and just ignore all the race conditions. And I've looked at the lifetime fun of unregistering a dev_pagemap for device hotunplug and pretty firmly concluded it's unfixable and that I should run away to do something else :-P An optional callback is a lot less scary to me here (or redoing hmm_range_fault or whacking the migration helpers a few times) looks a lot less scary than making pgmap->owner mutable in some fashion. Cheers, Sima > The notion is that owner should represent a contiguous region of > connectivity. IMHO you can always create this, but I suppose there > could be corner cases where you need to split/merge owners. > > But again, this isn't set in stone, if someone has a better way to > match the private interconnects without going to driver callbacks then > try that too. > > I think driver callbacks inside hmm_range_fault should be the last resort.. > > > You can fake that by doing these checks after hmm_range_fault returned, > > and if you get a bunch of unsuitable pages, toss it back to > > hmm_range_fault asking for an unconditional migration to system memory for > > those. But that's kinda not great and I think goes at least against the > > spirit of how you want to handle pci p2p in step 2 below? > > Right, hmm_range_fault should return pages that can be used and you > should not call it twice. > > Jason -- Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch