Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp198268pxb; Wed, 25 Aug 2021 00:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz51pInxx/aSID8wuRaGMq4jRkZk/fL8w+g+FFi71mUkKaV7hM2zDHr53zGpT/9LJgYv5iN X-Received: by 2002:a17:906:b4d:: with SMTP id v13mr14297072ejg.468.1629877283737; Wed, 25 Aug 2021 00:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629877283; cv=none; d=google.com; s=arc-20160816; b=pT4a+0bF5t1mooMix0nm+dL1PrpKYBuWzUndYIe+nkzFVpyaIx+dpw/joKoeCID+RI eajcBcivkw0CDbmENMOnYlDNpeZj+kyjhhPaNzWeD9Whc+YCWXOgXaXu7kNk9D7J2U6F XOZe3k3zhO1sG1/KuoIlK7iBVsR9SizqjoHEa3y4HutVS7W3HWao7wrR1Byx86aME0e1 v5ROgqMiQTtrcS0+LGmxlXp1GqIf1aEzqKCKKXSClnL+rxJCNsinpySXU3jv2P6knw15 5WiJn3H9AsXxl3jzwcDWrNR8BMKWPLKCJFRWxi1NLRiZsH/yY85zMv2dBfVBkfu1NJCs WPug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zjGS5LNTns8O0CmA0OqmacXEyX6W1MYjL4KUDi91u4c=; b=L4Pxd39ZjbE0PCl32khYrPCGYuBNZ6nDVJLbuaJXHMDb/RnmB2I6ZrUw0y7n6A9AK/ TFgFPA/qnIaZ7N9Wswi86HcXn/Wpql0z+cET0eYLzyny6oJZlAOsRiBwtid0i2MMItlG 507GCYDGSYIt9yJW3D3M76FzWQd2PLrmNYpu3R31I0ZACyLxqY1lNhygoMms8/3z7cTO xI2ZTG5VRSfTARikjCwm9GvpIcCPGv3WgvmXb3DPi9MfmSeLjCI2EETv7jHWbvxlqMNA heF7/WKrC6i6Niftd7/v163uYL9RrnqWF5kWuW9s6GR2ASZT5EyjX1yi4Jj3IJVciopE Syng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si17850234edt.506.2021.08.25.00.41.00; Wed, 25 Aug 2021 00:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238114AbhHYHlS (ORCPT + 99 others); Wed, 25 Aug 2021 03:41:18 -0400 Received: from verein.lst.de ([213.95.11.211]:55132 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbhHYHlS (ORCPT ); Wed, 25 Aug 2021 03:41:18 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 2F4E067357; Wed, 25 Aug 2021 09:40:30 +0200 (CEST) Date: Wed, 25 Aug 2021 09:40:29 +0200 From: Christoph Hellwig To: Alex Sierra Cc: akpm@linux-foundation.org, Felix.Kuehling@amd.com, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jgg@nvidia.com, jglisse@redhat.com Subject: Re: [PATCH v1 03/14] mm: add iomem vma selection for memory migration Message-ID: <20210825074029.GC29433@lst.de> References: <20210825034828.12927-1-alex.sierra@amd.com> <20210825034828.12927-4-alex.sierra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210825034828.12927-4-alex.sierra@amd.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Aug 24, 2021 at 10:48:17PM -0500, Alex Sierra wrote: > In this case, this is used to migrate pages from device memory, back to > system memory. This particular device memory type should be accessible > by the CPU, through IOMEM access. Typically, zone device public type > memory falls into this category. > > Signed-off-by: Alex Sierra > --- > include/linux/migrate.h | 1 + > mm/migrate.c | 3 ++- > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/linux/migrate.h b/include/linux/migrate.h > index 4bb4e519e3f5..6b16f417384f 100644 > --- a/include/linux/migrate.h > +++ b/include/linux/migrate.h > @@ -156,6 +156,7 @@ static inline unsigned long migrate_pfn(unsigned long pfn) > enum migrate_vma_direction { > MIGRATE_VMA_SELECT_SYSTEM = 1 << 0, > MIGRATE_VMA_SELECT_DEVICE_PRIVATE = 1 << 1, > + MIGRATE_VMA_SELECT_IOMEM = 1 << 2, > }; > > struct migrate_vma { > diff --git a/mm/migrate.c b/mm/migrate.c > index e3a10e2a1bb3..d4ae2da99607 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2406,7 +2406,8 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > if (is_write_device_private_entry(entry)) > mpfn |= MIGRATE_PFN_WRITE; > } else { > - if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) > + if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM) && > + !(migrate->flags & MIGRATE_VMA_SELECT_IOMEM)) This makes the MIGRATE_VMA_SELECT_SYSTEM and MIGRATE_VMA_SELECT_IOMEM behave entirely identifical, that is redundant. I think we need to distinguish between the dfferent cases here. I think the right check would be pfn_valid(), which should be true for system memory, and false for iomem. Also shouldn't this be called DEVICE_PUBLIC instead of IOMEM?