Message ID | 20240311100959.205545-3-mcanal@igalia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/v3d: Enable Super Pages | expand |
Hi Maira, On 11/03/2024 10:05, Maíra Canal wrote: > For some applications, such as using huge pages, we might want to have a > different mountpoint, for which we pass in mount flags that better match > our usecase. > > Therefore, add a new parameter to drm_gem_object_init() that allow us to > define the tmpfs mountpoint where the GEM object will be created. If > this parameter is NULL, then we fallback to shmem_file_setup(). One strategy for reducing churn, and so the number of drivers this patch touches, could be to add a lower level drm_gem_object_init() (which takes vfsmount, call it __drm_gem_object_init(), or drm__gem_object_init_mnt(), and make drm_gem_object_init() call that one with a NULL argument. Regards, Tvrtko > > Cc: Russell King <linux@armlinux.org.uk> > Cc: Lucas Stach <l.stach@pengutronix.de> > Cc: Christian Gmeiner <christian.gmeiner@gmail.com> > Cc: Inki Dae <inki.dae@samsung.com> > Cc: Seung-Woo Kim <sw0312.kim@samsung.com> > Cc: Kyungmin Park <kyungmin.park@samsung.com> > Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > Cc: Alim Akhtar <alim.akhtar@samsung.com> > Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> > Cc: Sui Jingfeng <suijingfeng@loongson.cn> > Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org> > Cc: Philipp Zabel <p.zabel@pengutronix.de> > Cc: Matthias Brugger <matthias.bgg@gmail.com> > Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > Cc: Rob Clark <robdclark@gmail.com> > Cc: Abhinav Kumar <quic_abhinavk@quicinc.com> > Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Cc: Sean Paul <sean@poorly.run> > Cc: Marijn Suijten <marijn.suijten@somainline.org> > Cc: Karol Herbst <kherbst@redhat.com> > Cc: Lyude Paul <lyude@redhat.com> > Cc: Danilo Krummrich <dakr@redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > Cc: Gerd Hoffmann <kraxel@redhat.com> > Cc: Sandy Huang <hjc@rock-chips.com> > Cc: "Heiko Stübner" <heiko@sntech.de> > Cc: Andy Yan <andy.yan@rock-chips.com> > Cc: Thierry Reding <thierry.reding@gmail.com> > Cc: Mikko Perttunen <mperttunen@nvidia.com> > Cc: Jonathan Hunter <jonathanh@nvidia.com> > Cc: Christian König <christian.koenig@amd.com> > Cc: Huang Rui <ray.huang@amd.com> > Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> > Cc: Karolina Stolarek <karolina.stolarek@intel.com> > Cc: Andi Shyti <andi.shyti@linux.intel.com> > Signed-off-by: Maíra Canal <mcanal@igalia.com> > --- > drivers/gpu/drm/armada/armada_gem.c | 2 +- > drivers/gpu/drm/drm_gem.c | 12 ++++++++++-- > drivers/gpu/drm/drm_gem_dma_helper.c | 2 +- > drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- > drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- > drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- > drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +- > drivers/gpu/drm/gma500/gem.c | 2 +- > drivers/gpu/drm/loongson/lsdc_ttm.c | 2 +- > drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +- > drivers/gpu/drm/msm/msm_gem.c | 2 +- > drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- > drivers/gpu/drm/nouveau/nouveau_prime.c | 2 +- > drivers/gpu/drm/omapdrm/omap_gem.c | 2 +- > drivers/gpu/drm/qxl/qxl_object.c | 2 +- > drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +- > drivers/gpu/drm/tegra/gem.c | 2 +- > drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 2 +- > drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +- > include/drm/drm_gem.h | 3 ++- > 20 files changed, 30 insertions(+), 21 deletions(-) > > diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c > index 26d10065d534..36a25e667341 100644 > --- a/drivers/gpu/drm/armada/armada_gem.c > +++ b/drivers/gpu/drm/armada/armada_gem.c > @@ -226,7 +226,7 @@ static struct armada_gem_object *armada_gem_alloc_object(struct drm_device *dev, > > obj->obj.funcs = &armada_gem_object_funcs; > > - if (drm_gem_object_init(dev, &obj->obj, size)) { > + if (drm_gem_object_init(dev, &obj->obj, size, NULL)) { > kfree(obj); > return NULL; > } > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > index 44a948b80ee1..ddd8777fcda5 100644 > --- a/drivers/gpu/drm/drm_gem.c > +++ b/drivers/gpu/drm/drm_gem.c > @@ -118,18 +118,26 @@ drm_gem_init(struct drm_device *dev) > * @dev: drm_device the object should be initialized for > * @obj: drm_gem_object to initialize > * @size: object size > + * @gemfs: tmpfs mount where the GEM object will be created. If NULL, use > + * the usual tmpfs mountpoint (`shm_mnt`). > * > * Initialize an already allocated GEM object of the specified size with > * shmfs backing store. > */ > int drm_gem_object_init(struct drm_device *dev, > - struct drm_gem_object *obj, size_t size) > + struct drm_gem_object *obj, size_t size, > + struct vfsmount *gemfs) > { > struct file *filp; > > drm_gem_private_object_init(dev, obj, size); > > - filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); > + if (gemfs) > + filp = shmem_file_setup_with_mnt(gemfs, "drm mm object", size, > + VM_NORESERVE); > + else > + filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); > + > if (IS_ERR(filp)) > return PTR_ERR(filp); > > diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c > index 870b90b78bc4..9ada5ac85dd6 100644 > --- a/drivers/gpu/drm/drm_gem_dma_helper.c > +++ b/drivers/gpu/drm/drm_gem_dma_helper.c > @@ -95,7 +95,7 @@ __drm_gem_dma_create(struct drm_device *drm, size_t size, bool private) > /* Always use writecombine for dma-buf mappings */ > dma_obj->map_noncoherent = false; > } else { > - ret = drm_gem_object_init(drm, gem_obj, size); > + ret = drm_gem_object_init(drm, gem_obj, size, NULL); > } > if (ret) > goto error; > diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c > index e435f986cd13..15635b330ca8 100644 > --- a/drivers/gpu/drm/drm_gem_shmem_helper.c > +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c > @@ -77,7 +77,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private) > drm_gem_private_object_init(dev, obj, size); > shmem->map_wc = false; /* dma-buf mappings use always writecombine */ > } else { > - ret = drm_gem_object_init(dev, obj, size); > + ret = drm_gem_object_init(dev, obj, size, NULL); > } > if (ret) { > drm_gem_private_object_fini(obj); > diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c > index 75f2eaf0d5b6..90649899dbef 100644 > --- a/drivers/gpu/drm/drm_gem_vram_helper.c > +++ b/drivers/gpu/drm/drm_gem_vram_helper.c > @@ -210,7 +210,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, > if (!gem->funcs) > gem->funcs = &drm_gem_vram_object_funcs; > > - ret = drm_gem_object_init(dev, gem, size); > + ret = drm_gem_object_init(dev, gem, size, NULL); > if (ret) { > kfree(gbo); > return ERR_PTR(ret); > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c > index 71a6d2b1c80f..aa4b61c48b7f 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c > @@ -596,7 +596,7 @@ int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file, > > lockdep_set_class(&to_etnaviv_bo(obj)->lock, &etnaviv_shm_lock_class); > > - ret = drm_gem_object_init(dev, obj, size); > + ret = drm_gem_object_init(dev, obj, size, NULL); > if (ret) > goto fail; > > diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c > index 638ca96830e9..c50c0d12246e 100644 > --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c > +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c > @@ -160,7 +160,7 @@ static struct exynos_drm_gem *exynos_drm_gem_init(struct drm_device *dev, > > obj->funcs = &exynos_drm_gem_object_funcs; > > - ret = drm_gem_object_init(dev, obj, size); > + ret = drm_gem_object_init(dev, obj, size, NULL); > if (ret < 0) { > DRM_DEV_ERROR(dev->dev, "failed to initialize gem object\n"); > kfree(exynos_gem); > diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c > index 4b7627a72637..315e085dc9ee 100644 > --- a/drivers/gpu/drm/gma500/gem.c > +++ b/drivers/gpu/drm/gma500/gem.c > @@ -169,7 +169,7 @@ psb_gem_create(struct drm_device *dev, u64 size, const char *name, bool stolen, > if (stolen) { > drm_gem_private_object_init(dev, obj, size); > } else { > - ret = drm_gem_object_init(dev, obj, size); > + ret = drm_gem_object_init(dev, obj, size, NULL); > if (ret) > goto err_release_resource; > > diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c > index 465f622ac05d..d392ea66d72e 100644 > --- a/drivers/gpu/drm/loongson/lsdc_ttm.c > +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c > @@ -458,7 +458,7 @@ struct lsdc_bo *lsdc_bo_create(struct drm_device *ddev, > > size = ALIGN(size, PAGE_SIZE); > > - ret = drm_gem_object_init(ddev, &tbo->base, size); > + ret = drm_gem_object_init(ddev, &tbo->base, size, NULL); > if (ret) { > kfree(lbo); > return ERR_PTR(ret); > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c > index 4f2e3feabc0f..261d386921dc 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c > @@ -44,7 +44,7 @@ static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev, > > mtk_gem_obj->base.funcs = &mtk_drm_gem_object_funcs; > > - ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size); > + ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size, NULL); > if (ret < 0) { > DRM_ERROR("failed to initialize gem object\n"); > kfree(mtk_gem_obj); > diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c > index 175ee4ab8a6f..6fe17cf28ef6 100644 > --- a/drivers/gpu/drm/msm/msm_gem.c > +++ b/drivers/gpu/drm/msm/msm_gem.c > @@ -1222,7 +1222,7 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev, uint32_t size, uint32 > > vma->iova = physaddr(obj); > } else { > - ret = drm_gem_object_init(dev, obj, size); > + ret = drm_gem_object_init(dev, obj, size, NULL); > if (ret) > goto fail; > /* > diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c > index 49c2bcbef129..434325fa8752 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_gem.c > +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c > @@ -262,7 +262,7 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain, > > /* Initialize the embedded gem-object. We return a single gem-reference > * to the caller, instead of a normal nouveau_bo ttm reference. */ > - ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size); > + ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size, NULL); > if (ret) { > drm_gem_object_release(&nvbo->bo.base); > kfree(nvbo); > diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c > index 1b2ff0c40fc1..c9b3572df555 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_prime.c > +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c > @@ -62,7 +62,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, > > /* Initialize the embedded gem-object. We return a single gem-reference > * to the caller, instead of a normal nouveau_bo ttm reference. */ > - ret = drm_gem_object_init(dev, &nvbo->bo.base, size); > + ret = drm_gem_object_init(dev, &nvbo->bo.base, size, NULL); > if (ret) { > nouveau_bo_ref(NULL, &nvbo); > obj = ERR_PTR(-ENOMEM); > diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c > index 3421e8389222..53b4ec64c7b0 100644 > --- a/drivers/gpu/drm/omapdrm/omap_gem.c > +++ b/drivers/gpu/drm/omapdrm/omap_gem.c > @@ -1352,7 +1352,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, > if (!(flags & OMAP_BO_MEM_SHMEM)) { > drm_gem_private_object_init(dev, obj, size); > } else { > - ret = drm_gem_object_init(dev, obj, size); > + ret = drm_gem_object_init(dev, obj, size, NULL); > if (ret) > goto err_free; > > diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c > index 1e46b0a6e478..45d7abe26ebd 100644 > --- a/drivers/gpu/drm/qxl/qxl_object.c > +++ b/drivers/gpu/drm/qxl/qxl_object.c > @@ -123,7 +123,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned long size, > if (bo == NULL) > return -ENOMEM; > size = roundup(size, PAGE_SIZE); > - r = drm_gem_object_init(&qdev->ddev, &bo->tbo.base, size); > + r = drm_gem_object_init(&qdev->ddev, &bo->tbo.base, size, NULL); > if (unlikely(r)) { > kfree(bo); > return r; > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c > index 93ed841f5dce..daba285bd78f 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c > @@ -295,7 +295,7 @@ static struct rockchip_gem_object * > > obj->funcs = &rockchip_gem_object_funcs; > > - drm_gem_object_init(drm, obj, size); > + drm_gem_object_init(drm, obj, size, NULL); > > return rk_obj; > } > diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c > index b4eb030ea961..63f10d5a57ba 100644 > --- a/drivers/gpu/drm/tegra/gem.c > +++ b/drivers/gpu/drm/tegra/gem.c > @@ -311,7 +311,7 @@ static struct tegra_bo *tegra_bo_alloc_object(struct drm_device *drm, > host1x_bo_init(&bo->base, &tegra_bo_ops); > size = round_up(size, PAGE_SIZE); > > - err = drm_gem_object_init(drm, &bo->gem, size); > + err = drm_gem_object_init(drm, &bo->gem, size, NULL); > if (err < 0) > goto free; > > diff --git a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c > index 7b7c1fa805fc..a9bf7d5a887c 100644 > --- a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c > +++ b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c > @@ -61,7 +61,7 @@ struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test, > KUNIT_ASSERT_NOT_NULL(test, bo); > > bo->base = gem_obj; > - err = drm_gem_object_init(devs->drm, &bo->base, size); > + err = drm_gem_object_init(devs->drm, &bo->base, size, NULL); > KUNIT_ASSERT_EQ(test, err, 0); > > bo->bdev = devs->ttm_dev; > diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c > index 3ad2b4cfd1f0..1b36c958340b 100644 > --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c > +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c > @@ -122,7 +122,7 @@ static struct xen_gem_object *gem_create_obj(struct drm_device *dev, > > xen_obj->base.funcs = &xen_drm_front_gem_object_funcs; > > - ret = drm_gem_object_init(dev, &xen_obj->base, size); > + ret = drm_gem_object_init(dev, &xen_obj->base, size, NULL); > if (ret < 0) { > kfree(xen_obj); > return ERR_PTR(ret); > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h > index 2ebec3984cd4..c75611ae8f93 100644 > --- a/include/drm/drm_gem.h > +++ b/include/drm/drm_gem.h > @@ -471,7 +471,8 @@ struct drm_gem_object { > void drm_gem_object_release(struct drm_gem_object *obj); > void drm_gem_object_free(struct kref *kref); > int drm_gem_object_init(struct drm_device *dev, > - struct drm_gem_object *obj, size_t size); > + struct drm_gem_object *obj, size_t size, > + struct vfsmount *gemfs); > void drm_gem_private_object_init(struct drm_device *dev, > struct drm_gem_object *obj, size_t size); > void drm_gem_private_object_fini(struct drm_gem_object *obj); > -- > 2.43.0 > >
Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: > > Hi Maira, > > On 11/03/2024 10:05, Maíra Canal wrote: >> For some applications, such as using huge pages, we might want to have a >> different mountpoint, for which we pass in mount flags that better match >> our usecase. >> >> Therefore, add a new parameter to drm_gem_object_init() that allow us to >> define the tmpfs mountpoint where the GEM object will be created. If >> this parameter is NULL, then we fallback to shmem_file_setup(). > > One strategy for reducing churn, and so the number of drivers this > patch touches, could be to add a lower level drm_gem_object_init() > (which takes vfsmount, call it __drm_gem_object_init(), or > drm__gem_object_init_mnt(), and make drm_gem_object_init() call that > one with a NULL argument. I would even go a step further into the other direction. The shmem backed GEM object is just some special handling as far as I can see. So I would rather suggest to rename all drm_gem_* function which only deal with the shmem backed GEM object into drm_gem_shmem_*. Also the explanation why a different mount point helps with something isn't very satisfying. Regards, Christian. > > Regards, > > Tvrtko > >> >> Cc: Russell King <linux@armlinux.org.uk> >> Cc: Lucas Stach <l.stach@pengutronix.de> >> Cc: Christian Gmeiner <christian.gmeiner@gmail.com> >> Cc: Inki Dae <inki.dae@samsung.com> >> Cc: Seung-Woo Kim <sw0312.kim@samsung.com> >> Cc: Kyungmin Park <kyungmin.park@samsung.com> >> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >> Cc: Alim Akhtar <alim.akhtar@samsung.com> >> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> >> Cc: Sui Jingfeng <suijingfeng@loongson.cn> >> Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org> >> Cc: Philipp Zabel <p.zabel@pengutronix.de> >> Cc: Matthias Brugger <matthias.bgg@gmail.com> >> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> >> Cc: Rob Clark <robdclark@gmail.com> >> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com> >> Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >> Cc: Sean Paul <sean@poorly.run> >> Cc: Marijn Suijten <marijn.suijten@somainline.org> >> Cc: Karol Herbst <kherbst@redhat.com> >> Cc: Lyude Paul <lyude@redhat.com> >> Cc: Danilo Krummrich <dakr@redhat.com> >> Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> >> Cc: Gerd Hoffmann <kraxel@redhat.com> >> Cc: Sandy Huang <hjc@rock-chips.com> >> Cc: "Heiko Stübner" <heiko@sntech.de> >> Cc: Andy Yan <andy.yan@rock-chips.com> >> Cc: Thierry Reding <thierry.reding@gmail.com> >> Cc: Mikko Perttunen <mperttunen@nvidia.com> >> Cc: Jonathan Hunter <jonathanh@nvidia.com> >> Cc: Christian König <christian.koenig@amd.com> >> Cc: Huang Rui <ray.huang@amd.com> >> Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> >> Cc: Karolina Stolarek <karolina.stolarek@intel.com> >> Cc: Andi Shyti <andi.shyti@linux.intel.com> >> Signed-off-by: Maíra Canal <mcanal@igalia.com> >> --- >> drivers/gpu/drm/armada/armada_gem.c | 2 +- >> drivers/gpu/drm/drm_gem.c | 12 ++++++++++-- >> drivers/gpu/drm/drm_gem_dma_helper.c | 2 +- >> drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- >> drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- >> drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- >> drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +- >> drivers/gpu/drm/gma500/gem.c | 2 +- >> drivers/gpu/drm/loongson/lsdc_ttm.c | 2 +- >> drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +- >> drivers/gpu/drm/msm/msm_gem.c | 2 +- >> drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- >> drivers/gpu/drm/nouveau/nouveau_prime.c | 2 +- >> drivers/gpu/drm/omapdrm/omap_gem.c | 2 +- >> drivers/gpu/drm/qxl/qxl_object.c | 2 +- >> drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +- >> drivers/gpu/drm/tegra/gem.c | 2 +- >> drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 2 +- >> drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +- >> include/drm/drm_gem.h | 3 ++- >> 20 files changed, 30 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/gpu/drm/armada/armada_gem.c >> b/drivers/gpu/drm/armada/armada_gem.c >> index 26d10065d534..36a25e667341 100644 >> --- a/drivers/gpu/drm/armada/armada_gem.c >> +++ b/drivers/gpu/drm/armada/armada_gem.c >> @@ -226,7 +226,7 @@ static struct armada_gem_object >> *armada_gem_alloc_object(struct drm_device *dev, >> >> obj->obj.funcs = &armada_gem_object_funcs; >> >> - if (drm_gem_object_init(dev, &obj->obj, size)) { >> + if (drm_gem_object_init(dev, &obj->obj, size, NULL)) { >> kfree(obj); >> return NULL; >> } >> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c >> index 44a948b80ee1..ddd8777fcda5 100644 >> --- a/drivers/gpu/drm/drm_gem.c >> +++ b/drivers/gpu/drm/drm_gem.c >> @@ -118,18 +118,26 @@ drm_gem_init(struct drm_device *dev) >> * @dev: drm_device the object should be initialized for >> * @obj: drm_gem_object to initialize >> * @size: object size >> + * @gemfs: tmpfs mount where the GEM object will be created. If >> NULL, use >> + * the usual tmpfs mountpoint (`shm_mnt`). >> * >> * Initialize an already allocated GEM object of the specified size >> with >> * shmfs backing store. >> */ >> int drm_gem_object_init(struct drm_device *dev, >> - struct drm_gem_object *obj, size_t size) >> + struct drm_gem_object *obj, size_t size, >> + struct vfsmount *gemfs) >> { >> struct file *filp; >> >> drm_gem_private_object_init(dev, obj, size); >> >> - filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); >> + if (gemfs) >> + filp = shmem_file_setup_with_mnt(gemfs, "drm mm object", size, >> + VM_NORESERVE); >> + else >> + filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); >> + >> if (IS_ERR(filp)) >> return PTR_ERR(filp); >> >> diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c >> b/drivers/gpu/drm/drm_gem_dma_helper.c >> index 870b90b78bc4..9ada5ac85dd6 100644 >> --- a/drivers/gpu/drm/drm_gem_dma_helper.c >> +++ b/drivers/gpu/drm/drm_gem_dma_helper.c >> @@ -95,7 +95,7 @@ __drm_gem_dma_create(struct drm_device *drm, size_t >> size, bool private) >> /* Always use writecombine for dma-buf mappings */ >> dma_obj->map_noncoherent = false; >> } else { >> - ret = drm_gem_object_init(drm, gem_obj, size); >> + ret = drm_gem_object_init(drm, gem_obj, size, NULL); >> } >> if (ret) >> goto error; >> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c >> b/drivers/gpu/drm/drm_gem_shmem_helper.c >> index e435f986cd13..15635b330ca8 100644 >> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c >> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c >> @@ -77,7 +77,7 @@ __drm_gem_shmem_create(struct drm_device *dev, >> size_t size, bool private) >> drm_gem_private_object_init(dev, obj, size); >> shmem->map_wc = false; /* dma-buf mappings use always >> writecombine */ >> } else { >> - ret = drm_gem_object_init(dev, obj, size); >> + ret = drm_gem_object_init(dev, obj, size, NULL); >> } >> if (ret) { >> drm_gem_private_object_fini(obj); >> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c >> b/drivers/gpu/drm/drm_gem_vram_helper.c >> index 75f2eaf0d5b6..90649899dbef 100644 >> --- a/drivers/gpu/drm/drm_gem_vram_helper.c >> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c >> @@ -210,7 +210,7 @@ struct drm_gem_vram_object >> *drm_gem_vram_create(struct drm_device *dev, >> if (!gem->funcs) >> gem->funcs = &drm_gem_vram_object_funcs; >> >> - ret = drm_gem_object_init(dev, gem, size); >> + ret = drm_gem_object_init(dev, gem, size, NULL); >> if (ret) { >> kfree(gbo); >> return ERR_PTR(ret); >> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c >> b/drivers/gpu/drm/etnaviv/etnaviv_gem.c >> index 71a6d2b1c80f..aa4b61c48b7f 100644 >> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c >> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c >> @@ -596,7 +596,7 @@ int etnaviv_gem_new_handle(struct drm_device >> *dev, struct drm_file *file, >> >> lockdep_set_class(&to_etnaviv_bo(obj)->lock, >> &etnaviv_shm_lock_class); >> >> - ret = drm_gem_object_init(dev, obj, size); >> + ret = drm_gem_object_init(dev, obj, size, NULL); >> if (ret) >> goto fail; >> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c >> b/drivers/gpu/drm/exynos/exynos_drm_gem.c >> index 638ca96830e9..c50c0d12246e 100644 >> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c >> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c >> @@ -160,7 +160,7 @@ static struct exynos_drm_gem >> *exynos_drm_gem_init(struct drm_device *dev, >> >> obj->funcs = &exynos_drm_gem_object_funcs; >> >> - ret = drm_gem_object_init(dev, obj, size); >> + ret = drm_gem_object_init(dev, obj, size, NULL); >> if (ret < 0) { >> DRM_DEV_ERROR(dev->dev, "failed to initialize gem object\n"); >> kfree(exynos_gem); >> diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c >> index 4b7627a72637..315e085dc9ee 100644 >> --- a/drivers/gpu/drm/gma500/gem.c >> +++ b/drivers/gpu/drm/gma500/gem.c >> @@ -169,7 +169,7 @@ psb_gem_create(struct drm_device *dev, u64 size, >> const char *name, bool stolen, >> if (stolen) { >> drm_gem_private_object_init(dev, obj, size); >> } else { >> - ret = drm_gem_object_init(dev, obj, size); >> + ret = drm_gem_object_init(dev, obj, size, NULL); >> if (ret) >> goto err_release_resource; >> >> diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c >> b/drivers/gpu/drm/loongson/lsdc_ttm.c >> index 465f622ac05d..d392ea66d72e 100644 >> --- a/drivers/gpu/drm/loongson/lsdc_ttm.c >> +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c >> @@ -458,7 +458,7 @@ struct lsdc_bo *lsdc_bo_create(struct drm_device >> *ddev, >> >> size = ALIGN(size, PAGE_SIZE); >> >> - ret = drm_gem_object_init(ddev, &tbo->base, size); >> + ret = drm_gem_object_init(ddev, &tbo->base, size, NULL); >> if (ret) { >> kfree(lbo); >> return ERR_PTR(ret); >> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c >> b/drivers/gpu/drm/mediatek/mtk_drm_gem.c >> index 4f2e3feabc0f..261d386921dc 100644 >> --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c >> +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c >> @@ -44,7 +44,7 @@ static struct mtk_drm_gem_obj >> *mtk_drm_gem_init(struct drm_device *dev, >> >> mtk_gem_obj->base.funcs = &mtk_drm_gem_object_funcs; >> >> - ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size); >> + ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size, NULL); >> if (ret < 0) { >> DRM_ERROR("failed to initialize gem object\n"); >> kfree(mtk_gem_obj); >> diff --git a/drivers/gpu/drm/msm/msm_gem.c >> b/drivers/gpu/drm/msm/msm_gem.c >> index 175ee4ab8a6f..6fe17cf28ef6 100644 >> --- a/drivers/gpu/drm/msm/msm_gem.c >> +++ b/drivers/gpu/drm/msm/msm_gem.c >> @@ -1222,7 +1222,7 @@ struct drm_gem_object *msm_gem_new(struct >> drm_device *dev, uint32_t size, uint32 >> >> vma->iova = physaddr(obj); >> } else { >> - ret = drm_gem_object_init(dev, obj, size); >> + ret = drm_gem_object_init(dev, obj, size, NULL); >> if (ret) >> goto fail; >> /* >> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c >> b/drivers/gpu/drm/nouveau/nouveau_gem.c >> index 49c2bcbef129..434325fa8752 100644 >> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c >> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c >> @@ -262,7 +262,7 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 >> size, int align, uint32_t domain, >> >> /* Initialize the embedded gem-object. We return a single >> gem-reference >> * to the caller, instead of a normal nouveau_bo ttm reference. */ >> - ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size); >> + ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size, NULL); >> if (ret) { >> drm_gem_object_release(&nvbo->bo.base); >> kfree(nvbo); >> diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c >> b/drivers/gpu/drm/nouveau/nouveau_prime.c >> index 1b2ff0c40fc1..c9b3572df555 100644 >> --- a/drivers/gpu/drm/nouveau/nouveau_prime.c >> +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c >> @@ -62,7 +62,7 @@ struct drm_gem_object >> *nouveau_gem_prime_import_sg_table(struct drm_device *dev, >> >> /* Initialize the embedded gem-object. We return a single >> gem-reference >> * to the caller, instead of a normal nouveau_bo ttm reference. */ >> - ret = drm_gem_object_init(dev, &nvbo->bo.base, size); >> + ret = drm_gem_object_init(dev, &nvbo->bo.base, size, NULL); >> if (ret) { >> nouveau_bo_ref(NULL, &nvbo); >> obj = ERR_PTR(-ENOMEM); >> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c >> b/drivers/gpu/drm/omapdrm/omap_gem.c >> index 3421e8389222..53b4ec64c7b0 100644 >> --- a/drivers/gpu/drm/omapdrm/omap_gem.c >> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c >> @@ -1352,7 +1352,7 @@ struct drm_gem_object *omap_gem_new(struct >> drm_device *dev, >> if (!(flags & OMAP_BO_MEM_SHMEM)) { >> drm_gem_private_object_init(dev, obj, size); >> } else { >> - ret = drm_gem_object_init(dev, obj, size); >> + ret = drm_gem_object_init(dev, obj, size, NULL); >> if (ret) >> goto err_free; >> >> diff --git a/drivers/gpu/drm/qxl/qxl_object.c >> b/drivers/gpu/drm/qxl/qxl_object.c >> index 1e46b0a6e478..45d7abe26ebd 100644 >> --- a/drivers/gpu/drm/qxl/qxl_object.c >> +++ b/drivers/gpu/drm/qxl/qxl_object.c >> @@ -123,7 +123,7 @@ int qxl_bo_create(struct qxl_device *qdev, >> unsigned long size, >> if (bo == NULL) >> return -ENOMEM; >> size = roundup(size, PAGE_SIZE); >> - r = drm_gem_object_init(&qdev->ddev, &bo->tbo.base, size); >> + r = drm_gem_object_init(&qdev->ddev, &bo->tbo.base, size, NULL); >> if (unlikely(r)) { >> kfree(bo); >> return r; >> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c >> b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c >> index 93ed841f5dce..daba285bd78f 100644 >> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c >> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c >> @@ -295,7 +295,7 @@ static struct rockchip_gem_object * >> >> obj->funcs = &rockchip_gem_object_funcs; >> >> - drm_gem_object_init(drm, obj, size); >> + drm_gem_object_init(drm, obj, size, NULL); >> >> return rk_obj; >> } >> diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c >> index b4eb030ea961..63f10d5a57ba 100644 >> --- a/drivers/gpu/drm/tegra/gem.c >> +++ b/drivers/gpu/drm/tegra/gem.c >> @@ -311,7 +311,7 @@ static struct tegra_bo >> *tegra_bo_alloc_object(struct drm_device *drm, >> host1x_bo_init(&bo->base, &tegra_bo_ops); >> size = round_up(size, PAGE_SIZE); >> >> - err = drm_gem_object_init(drm, &bo->gem, size); >> + err = drm_gem_object_init(drm, &bo->gem, size, NULL); >> if (err < 0) >> goto free; >> >> diff --git a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c >> b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c >> index 7b7c1fa805fc..a9bf7d5a887c 100644 >> --- a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c >> +++ b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c >> @@ -61,7 +61,7 @@ struct ttm_buffer_object *ttm_bo_kunit_init(struct >> kunit *test, >> KUNIT_ASSERT_NOT_NULL(test, bo); >> >> bo->base = gem_obj; >> - err = drm_gem_object_init(devs->drm, &bo->base, size); >> + err = drm_gem_object_init(devs->drm, &bo->base, size, NULL); >> KUNIT_ASSERT_EQ(test, err, 0); >> >> bo->bdev = devs->ttm_dev; >> diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c >> b/drivers/gpu/drm/xen/xen_drm_front_gem.c >> index 3ad2b4cfd1f0..1b36c958340b 100644 >> --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c >> +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c >> @@ -122,7 +122,7 @@ static struct xen_gem_object >> *gem_create_obj(struct drm_device *dev, >> >> xen_obj->base.funcs = &xen_drm_front_gem_object_funcs; >> >> - ret = drm_gem_object_init(dev, &xen_obj->base, size); >> + ret = drm_gem_object_init(dev, &xen_obj->base, size, NULL); >> if (ret < 0) { >> kfree(xen_obj); >> return ERR_PTR(ret); >> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h >> index 2ebec3984cd4..c75611ae8f93 100644 >> --- a/include/drm/drm_gem.h >> +++ b/include/drm/drm_gem.h >> @@ -471,7 +471,8 @@ struct drm_gem_object { >> void drm_gem_object_release(struct drm_gem_object *obj); >> void drm_gem_object_free(struct kref *kref); >> int drm_gem_object_init(struct drm_device *dev, >> - struct drm_gem_object *obj, size_t size); >> + struct drm_gem_object *obj, size_t size, >> + struct vfsmount *gemfs); >> void drm_gem_private_object_init(struct drm_device *dev, >> struct drm_gem_object *obj, size_t size); >> void drm_gem_private_object_fini(struct drm_gem_object *obj); >> -- >> 2.43.0 >> >>
On 12/03/2024 08:59, Christian König wrote: > Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >> >> Hi Maira, >> >> On 11/03/2024 10:05, Maíra Canal wrote: >>> For some applications, such as using huge pages, we might want to have a >>> different mountpoint, for which we pass in mount flags that better match >>> our usecase. >>> >>> Therefore, add a new parameter to drm_gem_object_init() that allow us to >>> define the tmpfs mountpoint where the GEM object will be created. If >>> this parameter is NULL, then we fallback to shmem_file_setup(). >> >> One strategy for reducing churn, and so the number of drivers this >> patch touches, could be to add a lower level drm_gem_object_init() >> (which takes vfsmount, call it __drm_gem_object_init(), or >> drm__gem_object_init_mnt(), and make drm_gem_object_init() call that >> one with a NULL argument. > > I would even go a step further into the other direction. The shmem > backed GEM object is just some special handling as far as I can see. > > So I would rather suggest to rename all drm_gem_* function which only > deal with the shmem backed GEM object into drm_gem_shmem_*. That makes sense although it would be very churny. I at least would be on the fence regarding the cost vs benefit. > Also the explanation why a different mount point helps with something > isn't very satisfying. Not satisfying as you think it is not detailed enough to say driver wants to use huge pages for performance? Or not satisying as you question why huge pages would help? Regards, Tvrtko
Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: > > On 12/03/2024 08:59, Christian König wrote: >> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>> >>> Hi Maira, >>> >>> On 11/03/2024 10:05, Maíra Canal wrote: >>>> For some applications, such as using huge pages, we might want to >>>> have a >>>> different mountpoint, for which we pass in mount flags that better >>>> match >>>> our usecase. >>>> >>>> Therefore, add a new parameter to drm_gem_object_init() that allow >>>> us to >>>> define the tmpfs mountpoint where the GEM object will be created. If >>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>> >>> One strategy for reducing churn, and so the number of drivers this >>> patch touches, could be to add a lower level drm_gem_object_init() >>> (which takes vfsmount, call it __drm_gem_object_init(), or >>> drm__gem_object_init_mnt(), and make drm_gem_object_init() call that >>> one with a NULL argument. >> >> I would even go a step further into the other direction. The shmem >> backed GEM object is just some special handling as far as I can see. >> >> So I would rather suggest to rename all drm_gem_* function which only >> deal with the shmem backed GEM object into drm_gem_shmem_*. > > That makes sense although it would be very churny. I at least would be > on the fence regarding the cost vs benefit. Yeah, it should clearly not be part of this patch here. > >> Also the explanation why a different mount point helps with something >> isn't very satisfying. > > Not satisfying as you think it is not detailed enough to say driver > wants to use huge pages for performance? Or not satisying as you > question why huge pages would help? That huge pages are beneficial is clear to me, but I'm missing the connection why a different mount point helps with using huge pages. Regards, Christian. > > Regards, > > Tvrtko
On 12/03/2024 10:23, Christian König wrote: > Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >> >> On 12/03/2024 08:59, Christian König wrote: >>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>> >>>> Hi Maira, >>>> >>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>> For some applications, such as using huge pages, we might want to >>>>> have a >>>>> different mountpoint, for which we pass in mount flags that better >>>>> match >>>>> our usecase. >>>>> >>>>> Therefore, add a new parameter to drm_gem_object_init() that allow >>>>> us to >>>>> define the tmpfs mountpoint where the GEM object will be created. If >>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>> >>>> One strategy for reducing churn, and so the number of drivers this >>>> patch touches, could be to add a lower level drm_gem_object_init() >>>> (which takes vfsmount, call it __drm_gem_object_init(), or >>>> drm__gem_object_init_mnt(), and make drm_gem_object_init() call that >>>> one with a NULL argument. >>> >>> I would even go a step further into the other direction. The shmem >>> backed GEM object is just some special handling as far as I can see. >>> >>> So I would rather suggest to rename all drm_gem_* function which only >>> deal with the shmem backed GEM object into drm_gem_shmem_*. >> >> That makes sense although it would be very churny. I at least would be >> on the fence regarding the cost vs benefit. > > Yeah, it should clearly not be part of this patch here. > >> >>> Also the explanation why a different mount point helps with something >>> isn't very satisfying. >> >> Not satisfying as you think it is not detailed enough to say driver >> wants to use huge pages for performance? Or not satisying as you >> question why huge pages would help? > > That huge pages are beneficial is clear to me, but I'm missing the > connection why a different mount point helps with using huge pages. Ah right, same as in i915, one needs to mount a tmpfs instance passing huge=within_size or huge=always option. Default is 'never', see man 5 tmpfs. Regards, Tvrtko
Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: > > On 12/03/2024 10:23, Christian König wrote: >> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>> >>> On 12/03/2024 08:59, Christian König wrote: >>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>> >>>>> Hi Maira, >>>>> >>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>> For some applications, such as using huge pages, we might want to >>>>>> have a >>>>>> different mountpoint, for which we pass in mount flags that >>>>>> better match >>>>>> our usecase. >>>>>> >>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>> allow us to >>>>>> define the tmpfs mountpoint where the GEM object will be created. If >>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>> >>>>> One strategy for reducing churn, and so the number of drivers this >>>>> patch touches, could be to add a lower level drm_gem_object_init() >>>>> (which takes vfsmount, call it __drm_gem_object_init(), or >>>>> drm__gem_object_init_mnt(), and make drm_gem_object_init() call >>>>> that one with a NULL argument. >>>> >>>> I would even go a step further into the other direction. The shmem >>>> backed GEM object is just some special handling as far as I can see. >>>> >>>> So I would rather suggest to rename all drm_gem_* function which >>>> only deal with the shmem backed GEM object into drm_gem_shmem_*. >>> >>> That makes sense although it would be very churny. I at least would >>> be on the fence regarding the cost vs benefit. >> >> Yeah, it should clearly not be part of this patch here. >> >>> >>>> Also the explanation why a different mount point helps with >>>> something isn't very satisfying. >>> >>> Not satisfying as you think it is not detailed enough to say driver >>> wants to use huge pages for performance? Or not satisying as you >>> question why huge pages would help? >> >> That huge pages are beneficial is clear to me, but I'm missing the >> connection why a different mount point helps with using huge pages. > > Ah right, same as in i915, one needs to mount a tmpfs instance passing > huge=within_size or huge=always option. Default is 'never', see man 5 > tmpfs. Thanks for the explanation, I wasn't aware of that. Mhm, shouldn't we always use huge pages? Is there a reason for a DRM device to not use huge pages with the shmem backend? I mean it would make this patch here even smaller. Regards, Christian. > > > Regards, > > Tvrtko
On 12/03/2024 10:37, Christian König wrote: > Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >> >> On 12/03/2024 10:23, Christian König wrote: >>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>> >>>> On 12/03/2024 08:59, Christian König wrote: >>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>> >>>>>> Hi Maira, >>>>>> >>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>> For some applications, such as using huge pages, we might want to >>>>>>> have a >>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>> better match >>>>>>> our usecase. >>>>>>> >>>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>>> allow us to >>>>>>> define the tmpfs mountpoint where the GEM object will be created. If >>>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>>> >>>>>> One strategy for reducing churn, and so the number of drivers this >>>>>> patch touches, could be to add a lower level drm_gem_object_init() >>>>>> (which takes vfsmount, call it __drm_gem_object_init(), or >>>>>> drm__gem_object_init_mnt(), and make drm_gem_object_init() call >>>>>> that one with a NULL argument. >>>>> >>>>> I would even go a step further into the other direction. The shmem >>>>> backed GEM object is just some special handling as far as I can see. >>>>> >>>>> So I would rather suggest to rename all drm_gem_* function which >>>>> only deal with the shmem backed GEM object into drm_gem_shmem_*. >>>> >>>> That makes sense although it would be very churny. I at least would >>>> be on the fence regarding the cost vs benefit. >>> >>> Yeah, it should clearly not be part of this patch here. >>> >>>> >>>>> Also the explanation why a different mount point helps with >>>>> something isn't very satisfying. >>>> >>>> Not satisfying as you think it is not detailed enough to say driver >>>> wants to use huge pages for performance? Or not satisying as you >>>> question why huge pages would help? >>> >>> That huge pages are beneficial is clear to me, but I'm missing the >>> connection why a different mount point helps with using huge pages. >> >> Ah right, same as in i915, one needs to mount a tmpfs instance passing >> huge=within_size or huge=always option. Default is 'never', see man 5 >> tmpfs. > > Thanks for the explanation, I wasn't aware of that. > > Mhm, shouldn't we always use huge pages? Is there a reason for a DRM > device to not use huge pages with the shmem backend? AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), back then the understanding was within_size may overallocate, meaning there would be some space wastage, until the memory pressure makes the thp code split the trailing huge page. I haven't checked if that still applies. Other than that I don't know if some drivers/platforms could have problems if they have some limitations or hardcoded assumptions when they iterate the sg list. Te Cc is plenty large so perhaps someone else will have additional information. :) Regards, Tvrtko > > I mean it would make this patch here even smaller. > > Regards, > Christian. > >> >> >> Regards, >> >> Tvrtko >
Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: > > On 12/03/2024 10:37, Christian König wrote: >> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>> >>> On 12/03/2024 10:23, Christian König wrote: >>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>> >>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>> >>>>>>> Hi Maira, >>>>>>> >>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>> For some applications, such as using huge pages, we might want >>>>>>>> to have a >>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>> better match >>>>>>>> our usecase. >>>>>>>> >>>>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>>>> allow us to >>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>> created. If >>>>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>>>> >>>>>>> One strategy for reducing churn, and so the number of drivers >>>>>>> this patch touches, could be to add a lower level >>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and make >>>>>>> drm_gem_object_init() call that one with a NULL argument. >>>>>> >>>>>> I would even go a step further into the other direction. The >>>>>> shmem backed GEM object is just some special handling as far as I >>>>>> can see. >>>>>> >>>>>> So I would rather suggest to rename all drm_gem_* function which >>>>>> only deal with the shmem backed GEM object into drm_gem_shmem_*. >>>>> >>>>> That makes sense although it would be very churny. I at least >>>>> would be on the fence regarding the cost vs benefit. >>>> >>>> Yeah, it should clearly not be part of this patch here. >>>> >>>>> >>>>>> Also the explanation why a different mount point helps with >>>>>> something isn't very satisfying. >>>>> >>>>> Not satisfying as you think it is not detailed enough to say >>>>> driver wants to use huge pages for performance? Or not satisying >>>>> as you question why huge pages would help? >>>> >>>> That huge pages are beneficial is clear to me, but I'm missing the >>>> connection why a different mount point helps with using huge pages. >>> >>> Ah right, same as in i915, one needs to mount a tmpfs instance >>> passing huge=within_size or huge=always option. Default is 'never', >>> see man 5 tmpfs. >> >> Thanks for the explanation, I wasn't aware of that. >> >> Mhm, shouldn't we always use huge pages? Is there a reason for a DRM >> device to not use huge pages with the shmem backend? > > AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), back > then the understanding was within_size may overallocate, meaning there > would be some space wastage, until the memory pressure makes the thp > code split the trailing huge page. I haven't checked if that still > applies. > > Other than that I don't know if some drivers/platforms could have > problems if they have some limitations or hardcoded assumptions when > they iterate the sg list. Yeah, that was the whole point behind my question. As far as I can see this isn't driver specific, but platform specific. I might be wrong here, but I think we should then probably not have that handling in each individual driver, but rather centralized in the DRM code. Regards, Christian. > > Te Cc is plenty large so perhaps someone else will have additional > information. :) > > Regards, > > Tvrtko > >> >> I mean it would make this patch here even smaller. >> >> Regards, >> Christian. >> >>> >>> >>> Regards, >>> >>> Tvrtko >>
Hi Christian, On 3/12/24 10:48, Christian König wrote: > Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >> >> On 12/03/2024 10:37, Christian König wrote: >>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>> >>>> On 12/03/2024 10:23, Christian König wrote: >>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>> >>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>> >>>>>>>> Hi Maira, >>>>>>>> >>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>> For some applications, such as using huge pages, we might want >>>>>>>>> to have a >>>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>>> better match >>>>>>>>> our usecase. >>>>>>>>> >>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>>>>> allow us to >>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>> created. If >>>>>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>>>>> >>>>>>>> One strategy for reducing churn, and so the number of drivers >>>>>>>> this patch touches, could be to add a lower level >>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and make >>>>>>>> drm_gem_object_init() call that one with a NULL argument. >>>>>>> >>>>>>> I would even go a step further into the other direction. The >>>>>>> shmem backed GEM object is just some special handling as far as I >>>>>>> can see. >>>>>>> >>>>>>> So I would rather suggest to rename all drm_gem_* function which >>>>>>> only deal with the shmem backed GEM object into drm_gem_shmem_*. >>>>>> >>>>>> That makes sense although it would be very churny. I at least >>>>>> would be on the fence regarding the cost vs benefit. >>>>> >>>>> Yeah, it should clearly not be part of this patch here. >>>>> >>>>>> >>>>>>> Also the explanation why a different mount point helps with >>>>>>> something isn't very satisfying. >>>>>> >>>>>> Not satisfying as you think it is not detailed enough to say >>>>>> driver wants to use huge pages for performance? Or not satisying >>>>>> as you question why huge pages would help? >>>>> >>>>> That huge pages are beneficial is clear to me, but I'm missing the >>>>> connection why a different mount point helps with using huge pages. >>>> >>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>> passing huge=within_size or huge=always option. Default is 'never', >>>> see man 5 tmpfs. >>> >>> Thanks for the explanation, I wasn't aware of that. >>> >>> Mhm, shouldn't we always use huge pages? Is there a reason for a DRM >>> device to not use huge pages with the shmem backend? >> >> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), back >> then the understanding was within_size may overallocate, meaning there >> would be some space wastage, until the memory pressure makes the thp >> code split the trailing huge page. I haven't checked if that still >> applies. >> >> Other than that I don't know if some drivers/platforms could have >> problems if they have some limitations or hardcoded assumptions when >> they iterate the sg list. > > Yeah, that was the whole point behind my question. As far as I can see > this isn't driver specific, but platform specific. > > I might be wrong here, but I think we should then probably not have that > handling in each individual driver, but rather centralized in the DRM code. I don't see a point in enabling THP for all shmem drivers. A huge page is only useful if the driver is going to use it. On V3D, for example, I only need huge pages because I need the memory contiguously allocated to implement Super Pages. Otherwise, if we don't have the Super Pages support implemented in the driver, I would be creating memory pressure without any performance gain. Best Regards, - Maíra > > Regards, > Christian. > > >> >> Te Cc is plenty large so perhaps someone else will have additional >> information. :) >> >> Regards, >> >> Tvrtko >> >>> >>> I mean it would make this patch here even smaller. >>> >>> Regards, >>> Christian. >>> >>>> >>>> >>>> Regards, >>>> >>>> Tvrtko >>> >
Am 18.03.24 um 13:42 schrieb Maíra Canal: > Hi Christian, > > On 3/12/24 10:48, Christian König wrote: >> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>> >>> On 12/03/2024 10:37, Christian König wrote: >>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>> >>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>> >>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>> >>>>>>>>> Hi Maira, >>>>>>>>> >>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>> want to have a >>>>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>>>> better match >>>>>>>>>> our usecase. >>>>>>>>>> >>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>>>>>> allow us to >>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>> created. If >>>>>>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>>>>>> >>>>>>>>> One strategy for reducing churn, and so the number of drivers >>>>>>>>> this patch touches, could be to add a lower level >>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and >>>>>>>>> make drm_gem_object_init() call that one with a NULL argument. >>>>>>>> >>>>>>>> I would even go a step further into the other direction. The >>>>>>>> shmem backed GEM object is just some special handling as far as >>>>>>>> I can see. >>>>>>>> >>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>> drm_gem_shmem_*. >>>>>>> >>>>>>> That makes sense although it would be very churny. I at least >>>>>>> would be on the fence regarding the cost vs benefit. >>>>>> >>>>>> Yeah, it should clearly not be part of this patch here. >>>>>> >>>>>>> >>>>>>>> Also the explanation why a different mount point helps with >>>>>>>> something isn't very satisfying. >>>>>>> >>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>> driver wants to use huge pages for performance? Or not satisying >>>>>>> as you question why huge pages would help? >>>>>> >>>>>> That huge pages are beneficial is clear to me, but I'm missing >>>>>> the connection why a different mount point helps with using huge >>>>>> pages. >>>>> >>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>> passing huge=within_size or huge=always option. Default is >>>>> 'never', see man 5 tmpfs. >>>> >>>> Thanks for the explanation, I wasn't aware of that. >>>> >>>> Mhm, shouldn't we always use huge pages? Is there a reason for a >>>> DRM device to not use huge pages with the shmem backend? >>> >>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>> back then the understanding was within_size may overallocate, >>> meaning there would be some space wastage, until the memory pressure >>> makes the thp code split the trailing huge page. I haven't checked >>> if that still applies. >>> >>> Other than that I don't know if some drivers/platforms could have >>> problems if they have some limitations or hardcoded assumptions when >>> they iterate the sg list. >> >> Yeah, that was the whole point behind my question. As far as I can >> see this isn't driver specific, but platform specific. >> >> I might be wrong here, but I think we should then probably not have >> that handling in each individual driver, but rather centralized in >> the DRM code. > > I don't see a point in enabling THP for all shmem drivers. A huge page > is only useful if the driver is going to use it. On V3D, for example, > I only need huge pages because I need the memory contiguously allocated > to implement Super Pages. Otherwise, if we don't have the Super Pages > support implemented in the driver, I would be creating memory pressure > without any performance gain. Well that's the point I'm disagreeing with. THP doesn't seem to create much extra memory pressure for this use case. As far as I can see background for the option is that files in tmpfs usually have a varying size, so it usually isn't beneficial to allocate a huge page just to find that the shmem file is much smaller than what's needed. But GEM objects have a fixed size. So we of hand knew if we need 4KiB or 1GiB and can therefore directly allocate huge pages if they are available and object large enough to back them with. If the memory pressure is so high that we don't have huge pages available the shmem code falls back to standard pages anyway. So THP is almost always beneficial for GEM even if the driver doesn't actually need it. The only potential case I can think of which might not be handled gracefully is the tail pages, e.g. huge + 4kib. But that is trivial to optimize in the shmem code when the final size of the file is known beforehand. Regards, Christian. > > Best Regards, > - Maíra > >> >> Regards, >> Christian. >> >> >>> >>> Te Cc is plenty large so perhaps someone else will have additional >>> information. :) >>> >>> Regards, >>> >>> Tvrtko >>> >>>> >>>> I mean it would make this patch here even smaller. >>>> >>>> Regards, >>>> Christian. >>>> >>>>> >>>>> >>>>> Regards, >>>>> >>>>> Tvrtko >>>> >>
Hi Christian, On 3/18/24 10:10, Christian König wrote: > Am 18.03.24 um 13:42 schrieb Maíra Canal: >> Hi Christian, >> >> On 3/12/24 10:48, Christian König wrote: >>> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>>> >>>> On 12/03/2024 10:37, Christian König wrote: >>>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>>> >>>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>>> >>>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>>> >>>>>>>>>> Hi Maira, >>>>>>>>>> >>>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>>> want to have a >>>>>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>>>>> better match >>>>>>>>>>> our usecase. >>>>>>>>>>> >>>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>>>>>>> allow us to >>>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>>> created. If >>>>>>>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>>>>>>> >>>>>>>>>> One strategy for reducing churn, and so the number of drivers >>>>>>>>>> this patch touches, could be to add a lower level >>>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and >>>>>>>>>> make drm_gem_object_init() call that one with a NULL argument. >>>>>>>>> >>>>>>>>> I would even go a step further into the other direction. The >>>>>>>>> shmem backed GEM object is just some special handling as far as >>>>>>>>> I can see. >>>>>>>>> >>>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>>> drm_gem_shmem_*. >>>>>>>> >>>>>>>> That makes sense although it would be very churny. I at least >>>>>>>> would be on the fence regarding the cost vs benefit. >>>>>>> >>>>>>> Yeah, it should clearly not be part of this patch here. >>>>>>> >>>>>>>> >>>>>>>>> Also the explanation why a different mount point helps with >>>>>>>>> something isn't very satisfying. >>>>>>>> >>>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>>> driver wants to use huge pages for performance? Or not satisying >>>>>>>> as you question why huge pages would help? >>>>>>> >>>>>>> That huge pages are beneficial is clear to me, but I'm missing >>>>>>> the connection why a different mount point helps with using huge >>>>>>> pages. >>>>>> >>>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>>> passing huge=within_size or huge=always option. Default is >>>>>> 'never', see man 5 tmpfs. >>>>> >>>>> Thanks for the explanation, I wasn't aware of that. >>>>> >>>>> Mhm, shouldn't we always use huge pages? Is there a reason for a >>>>> DRM device to not use huge pages with the shmem backend? >>>> >>>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>>> back then the understanding was within_size may overallocate, >>>> meaning there would be some space wastage, until the memory pressure >>>> makes the thp code split the trailing huge page. I haven't checked >>>> if that still applies. >>>> >>>> Other than that I don't know if some drivers/platforms could have >>>> problems if they have some limitations or hardcoded assumptions when >>>> they iterate the sg list. >>> >>> Yeah, that was the whole point behind my question. As far as I can >>> see this isn't driver specific, but platform specific. >>> >>> I might be wrong here, but I think we should then probably not have >>> that handling in each individual driver, but rather centralized in >>> the DRM code. >> >> I don't see a point in enabling THP for all shmem drivers. A huge page >> is only useful if the driver is going to use it. On V3D, for example, >> I only need huge pages because I need the memory contiguously allocated >> to implement Super Pages. Otherwise, if we don't have the Super Pages >> support implemented in the driver, I would be creating memory pressure >> without any performance gain. > > Well that's the point I'm disagreeing with. THP doesn't seem to create > much extra memory pressure for this use case. > > As far as I can see background for the option is that files in tmpfs > usually have a varying size, so it usually isn't beneficial to allocate > a huge page just to find that the shmem file is much smaller than what's > needed. > > But GEM objects have a fixed size. So we of hand knew if we need 4KiB or > 1GiB and can therefore directly allocate huge pages if they are > available and object large enough to back them with. > > If the memory pressure is so high that we don't have huge pages > available the shmem code falls back to standard pages anyway. The matter is: how do we define the point where the memory pressure is high? For example, notice that in this implementation of Super Pages for the V3D driver, I only use a Super Page if the BO is bigger than 2MB. I'm doing that because the Raspberry Pi only has 4GB of RAM available for the GPU. If I created huge pages for every BO allocation (and initially, I tried that), I would end up with hangs in some applications. At least, for V3D, I wouldn't like to see THP being used for all the allocations. But, we have maintainers of other drivers in the CC. Best Regards, - Maíra > > So THP is almost always beneficial for GEM even if the driver doesn't > actually need it. The only potential case I can think of which might not > be handled gracefully is the tail pages, e.g. huge + 4kib. > > But that is trivial to optimize in the shmem code when the final size of > the file is known beforehand. > > Regards, > Christian. > >> >> Best Regards, >> - Maíra >> >>> >>> Regards, >>> Christian. >>> >>> >>>> >>>> Te Cc is plenty large so perhaps someone else will have additional >>>> information. :) >>>> >>>> Regards, >>>> >>>> Tvrtko >>>> >>>>> >>>>> I mean it would make this patch here even smaller. >>>>> >>>>> Regards, >>>>> Christian. >>>>> >>>>>> >>>>>> >>>>>> Regards, >>>>>> >>>>>> Tvrtko >>>>> >>> >
On 3/18/24 10:28, Maíra Canal wrote: > Hi Christian, > > On 3/18/24 10:10, Christian König wrote: >> Am 18.03.24 um 13:42 schrieb Maíra Canal: >>> Hi Christian, >>> >>> On 3/12/24 10:48, Christian König wrote: >>>> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>>>> >>>>> On 12/03/2024 10:37, Christian König wrote: >>>>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>>>> >>>>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>>>> >>>>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>>>> >>>>>>>>>>> Hi Maira, >>>>>>>>>>> >>>>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>>>> want to have a >>>>>>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>>>>>> better match >>>>>>>>>>>> our usecase. >>>>>>>>>>>> >>>>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() that >>>>>>>>>>>> allow us to >>>>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>>>> created. If >>>>>>>>>>>> this parameter is NULL, then we fallback to shmem_file_setup(). >>>>>>>>>>> >>>>>>>>>>> One strategy for reducing churn, and so the number of drivers >>>>>>>>>>> this patch touches, could be to add a lower level >>>>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and >>>>>>>>>>> make drm_gem_object_init() call that one with a NULL argument. >>>>>>>>>> >>>>>>>>>> I would even go a step further into the other direction. The >>>>>>>>>> shmem backed GEM object is just some special handling as far >>>>>>>>>> as I can see. >>>>>>>>>> >>>>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>>>> drm_gem_shmem_*. >>>>>>>>> >>>>>>>>> That makes sense although it would be very churny. I at least >>>>>>>>> would be on the fence regarding the cost vs benefit. >>>>>>>> >>>>>>>> Yeah, it should clearly not be part of this patch here. >>>>>>>> >>>>>>>>> >>>>>>>>>> Also the explanation why a different mount point helps with >>>>>>>>>> something isn't very satisfying. >>>>>>>>> >>>>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>>>> driver wants to use huge pages for performance? Or not >>>>>>>>> satisying as you question why huge pages would help? >>>>>>>> >>>>>>>> That huge pages are beneficial is clear to me, but I'm missing >>>>>>>> the connection why a different mount point helps with using huge >>>>>>>> pages. >>>>>>> >>>>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>>>> passing huge=within_size or huge=always option. Default is >>>>>>> 'never', see man 5 tmpfs. >>>>>> >>>>>> Thanks for the explanation, I wasn't aware of that. >>>>>> >>>>>> Mhm, shouldn't we always use huge pages? Is there a reason for a >>>>>> DRM device to not use huge pages with the shmem backend? >>>>> >>>>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>>>> back then the understanding was within_size may overallocate, >>>>> meaning there would be some space wastage, until the memory >>>>> pressure makes the thp code split the trailing huge page. I haven't >>>>> checked if that still applies. >>>>> >>>>> Other than that I don't know if some drivers/platforms could have >>>>> problems if they have some limitations or hardcoded assumptions >>>>> when they iterate the sg list. >>>> >>>> Yeah, that was the whole point behind my question. As far as I can >>>> see this isn't driver specific, but platform specific. >>>> >>>> I might be wrong here, but I think we should then probably not have >>>> that handling in each individual driver, but rather centralized in >>>> the DRM code. >>> >>> I don't see a point in enabling THP for all shmem drivers. A huge page >>> is only useful if the driver is going to use it. On V3D, for example, >>> I only need huge pages because I need the memory contiguously allocated >>> to implement Super Pages. Otherwise, if we don't have the Super Pages >>> support implemented in the driver, I would be creating memory pressure >>> without any performance gain. >> >> Well that's the point I'm disagreeing with. THP doesn't seem to create >> much extra memory pressure for this use case. >> >> As far as I can see background for the option is that files in tmpfs >> usually have a varying size, so it usually isn't beneficial to >> allocate a huge page just to find that the shmem file is much smaller >> than what's needed. >> >> But GEM objects have a fixed size. So we of hand knew if we need 4KiB >> or 1GiB and can therefore directly allocate huge pages if they are >> available and object large enough to back them with. >> >> If the memory pressure is so high that we don't have huge pages >> available the shmem code falls back to standard pages anyway. > > The matter is: how do we define the point where the memory pressure is > high? For example, notice that in this implementation of Super Pages > for the V3D driver, I only use a Super Page if the BO is bigger than > 2MB. I'm doing that because the Raspberry Pi only has 4GB of RAM > available for the GPU. If I created huge pages for every BO allocation > (and initially, I tried that), I would end up with hangs in some > applications. > > At least, for V3D, I wouldn't like to see THP being used for all the > allocations. But, we have maintainers of other drivers in the CC. Okay, I'm thinking about a compromise. What if we create a gemfs mountpoint in the DRM core and everytime we init a object, we can choose if we will use huge pages or not. Therefore, drm_gem_shmem_create() would have a new parameter called huge_pages, that can be true or false. This way each driver would have the opportunity to use its own heuristics to create huge pages. What do you think? Best Regards, - Maíra > > Best Regards, > - Maíra > >> >> So THP is almost always beneficial for GEM even if the driver doesn't >> actually need it. The only potential case I can think of which might >> not be handled gracefully is the tail pages, e.g. huge + 4kib. >> >> But that is trivial to optimize in the shmem code when the final size >> of the file is known beforehand. >> >> Regards, >> Christian. >> >>> >>> Best Regards, >>> - Maíra >>> >>>> >>>> Regards, >>>> Christian. >>>> >>>> >>>>> >>>>> Te Cc is plenty large so perhaps someone else will have additional >>>>> information. :) >>>>> >>>>> Regards, >>>>> >>>>> Tvrtko >>>>> >>>>>> >>>>>> I mean it would make this patch here even smaller. >>>>>> >>>>>> Regards, >>>>>> Christian. >>>>>> >>>>>>> >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> Tvrtko >>>>>> >>>> >>
Am 18.03.24 um 14:28 schrieb Maíra Canal: > Hi Christian, > > On 3/18/24 10:10, Christian König wrote: >> Am 18.03.24 um 13:42 schrieb Maíra Canal: >>> Hi Christian, >>> >>> On 3/12/24 10:48, Christian König wrote: >>>> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>>>> >>>>> On 12/03/2024 10:37, Christian König wrote: >>>>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>>>> >>>>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>>>> >>>>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>>>> >>>>>>>>>>> Hi Maira, >>>>>>>>>>> >>>>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>>>> want to have a >>>>>>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>>>>>> better match >>>>>>>>>>>> our usecase. >>>>>>>>>>>> >>>>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() >>>>>>>>>>>> that allow us to >>>>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>>>> created. If >>>>>>>>>>>> this parameter is NULL, then we fallback to >>>>>>>>>>>> shmem_file_setup(). >>>>>>>>>>> >>>>>>>>>>> One strategy for reducing churn, and so the number of >>>>>>>>>>> drivers this patch touches, could be to add a lower level >>>>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and >>>>>>>>>>> make drm_gem_object_init() call that one with a NULL argument. >>>>>>>>>> >>>>>>>>>> I would even go a step further into the other direction. The >>>>>>>>>> shmem backed GEM object is just some special handling as far >>>>>>>>>> as I can see. >>>>>>>>>> >>>>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>>>> drm_gem_shmem_*. >>>>>>>>> >>>>>>>>> That makes sense although it would be very churny. I at least >>>>>>>>> would be on the fence regarding the cost vs benefit. >>>>>>>> >>>>>>>> Yeah, it should clearly not be part of this patch here. >>>>>>>> >>>>>>>>> >>>>>>>>>> Also the explanation why a different mount point helps with >>>>>>>>>> something isn't very satisfying. >>>>>>>>> >>>>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>>>> driver wants to use huge pages for performance? Or not >>>>>>>>> satisying as you question why huge pages would help? >>>>>>>> >>>>>>>> That huge pages are beneficial is clear to me, but I'm missing >>>>>>>> the connection why a different mount point helps with using >>>>>>>> huge pages. >>>>>>> >>>>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>>>> passing huge=within_size or huge=always option. Default is >>>>>>> 'never', see man 5 tmpfs. >>>>>> >>>>>> Thanks for the explanation, I wasn't aware of that. >>>>>> >>>>>> Mhm, shouldn't we always use huge pages? Is there a reason for a >>>>>> DRM device to not use huge pages with the shmem backend? >>>>> >>>>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>>>> back then the understanding was within_size may overallocate, >>>>> meaning there would be some space wastage, until the memory >>>>> pressure makes the thp code split the trailing huge page. I >>>>> haven't checked if that still applies. >>>>> >>>>> Other than that I don't know if some drivers/platforms could have >>>>> problems if they have some limitations or hardcoded assumptions >>>>> when they iterate the sg list. >>>> >>>> Yeah, that was the whole point behind my question. As far as I can >>>> see this isn't driver specific, but platform specific. >>>> >>>> I might be wrong here, but I think we should then probably not have >>>> that handling in each individual driver, but rather centralized in >>>> the DRM code. >>> >>> I don't see a point in enabling THP for all shmem drivers. A huge page >>> is only useful if the driver is going to use it. On V3D, for example, >>> I only need huge pages because I need the memory contiguously allocated >>> to implement Super Pages. Otherwise, if we don't have the Super Pages >>> support implemented in the driver, I would be creating memory pressure >>> without any performance gain. >> >> Well that's the point I'm disagreeing with. THP doesn't seem to >> create much extra memory pressure for this use case. >> >> As far as I can see background for the option is that files in tmpfs >> usually have a varying size, so it usually isn't beneficial to >> allocate a huge page just to find that the shmem file is much smaller >> than what's needed. >> >> But GEM objects have a fixed size. So we of hand knew if we need 4KiB >> or 1GiB and can therefore directly allocate huge pages if they are >> available and object large enough to back them with. >> >> If the memory pressure is so high that we don't have huge pages >> available the shmem code falls back to standard pages anyway. > > The matter is: how do we define the point where the memory pressure is > high? Well as driver developers/maintainers we simply don't do that. This is the job of the shmem code. > For example, notice that in this implementation of Super Pages > for the V3D driver, I only use a Super Page if the BO is bigger than > 2MB. I'm doing that because the Raspberry Pi only has 4GB of RAM > available for the GPU. If I created huge pages for every BO allocation > (and initially, I tried that), I would end up with hangs in some > applications. Yeah, that is what I meant with the trivial optimisation to the shmem code. Essentially when you have 2MiB+4KiB as BO size then the shmem code should use a 2MiB and a 4KiB page to back them, but what it currently does is to use two 2MiB pages and then split up the second page when it find that it isn't needed. That is wasteful and leads to fragmentation, but as soon as we stop doing that we should be fine to enable it unconditionally for all drivers. TTM does essentially the same thing for years. Regards, Christian. > > > At least, for V3D, I wouldn't like to see THP being used for all the > allocations. But, we have maintainers of other drivers in the CC. > > Best Regards, > - Maíra > >> >> So THP is almost always beneficial for GEM even if the driver doesn't >> actually need it. The only potential case I can think of which might >> not be handled gracefully is the tail pages, e.g. huge + 4kib. >> >> But that is trivial to optimize in the shmem code when the final size >> of the file is known beforehand. >> >> Regards, >> Christian. >> >>> >>> Best Regards, >>> - Maíra >>> >>>> >>>> Regards, >>>> Christian. >>>> >>>> >>>>> >>>>> Te Cc is plenty large so perhaps someone else will have additional >>>>> information. :) >>>>> >>>>> Regards, >>>>> >>>>> Tvrtko >>>>> >>>>>> >>>>>> I mean it would make this patch here even smaller. >>>>>> >>>>>> Regards, >>>>>> Christian. >>>>>> >>>>>>> >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> Tvrtko >>>>>> >>>> >>
Not that the CC list wasn't big enough, but I'm adding MM folks in the CC list. On 3/18/24 11:04, Christian König wrote: > Am 18.03.24 um 14:28 schrieb Maíra Canal: >> Hi Christian, >> >> On 3/18/24 10:10, Christian König wrote: >>> Am 18.03.24 um 13:42 schrieb Maíra Canal: >>>> Hi Christian, >>>> >>>> On 3/12/24 10:48, Christian König wrote: >>>>> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>>>>> >>>>>> On 12/03/2024 10:37, Christian König wrote: >>>>>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>>>>> >>>>>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>>>>> >>>>>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>>>>> >>>>>>>>>>>> Hi Maira, >>>>>>>>>>>> >>>>>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>>>>> want to have a >>>>>>>>>>>>> different mountpoint, for which we pass in mount flags that >>>>>>>>>>>>> better match >>>>>>>>>>>>> our usecase. >>>>>>>>>>>>> >>>>>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() >>>>>>>>>>>>> that allow us to >>>>>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>>>>> created. If >>>>>>>>>>>>> this parameter is NULL, then we fallback to >>>>>>>>>>>>> shmem_file_setup(). >>>>>>>>>>>> >>>>>>>>>>>> One strategy for reducing churn, and so the number of >>>>>>>>>>>> drivers this patch touches, could be to add a lower level >>>>>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), and >>>>>>>>>>>> make drm_gem_object_init() call that one with a NULL argument. >>>>>>>>>>> >>>>>>>>>>> I would even go a step further into the other direction. The >>>>>>>>>>> shmem backed GEM object is just some special handling as far >>>>>>>>>>> as I can see. >>>>>>>>>>> >>>>>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>>>>> drm_gem_shmem_*. >>>>>>>>>> >>>>>>>>>> That makes sense although it would be very churny. I at least >>>>>>>>>> would be on the fence regarding the cost vs benefit. >>>>>>>>> >>>>>>>>> Yeah, it should clearly not be part of this patch here. >>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Also the explanation why a different mount point helps with >>>>>>>>>>> something isn't very satisfying. >>>>>>>>>> >>>>>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>>>>> driver wants to use huge pages for performance? Or not >>>>>>>>>> satisying as you question why huge pages would help? >>>>>>>>> >>>>>>>>> That huge pages are beneficial is clear to me, but I'm missing >>>>>>>>> the connection why a different mount point helps with using >>>>>>>>> huge pages. >>>>>>>> >>>>>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>>>>> passing huge=within_size or huge=always option. Default is >>>>>>>> 'never', see man 5 tmpfs. >>>>>>> >>>>>>> Thanks for the explanation, I wasn't aware of that. >>>>>>> >>>>>>> Mhm, shouldn't we always use huge pages? Is there a reason for a >>>>>>> DRM device to not use huge pages with the shmem backend? >>>>>> >>>>>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>>>>> back then the understanding was within_size may overallocate, >>>>>> meaning there would be some space wastage, until the memory >>>>>> pressure makes the thp code split the trailing huge page. I >>>>>> haven't checked if that still applies. >>>>>> >>>>>> Other than that I don't know if some drivers/platforms could have >>>>>> problems if they have some limitations or hardcoded assumptions >>>>>> when they iterate the sg list. >>>>> >>>>> Yeah, that was the whole point behind my question. As far as I can >>>>> see this isn't driver specific, but platform specific. >>>>> >>>>> I might be wrong here, but I think we should then probably not have >>>>> that handling in each individual driver, but rather centralized in >>>>> the DRM code. >>>> >>>> I don't see a point in enabling THP for all shmem drivers. A huge page >>>> is only useful if the driver is going to use it. On V3D, for example, >>>> I only need huge pages because I need the memory contiguously allocated >>>> to implement Super Pages. Otherwise, if we don't have the Super Pages >>>> support implemented in the driver, I would be creating memory pressure >>>> without any performance gain. >>> >>> Well that's the point I'm disagreeing with. THP doesn't seem to >>> create much extra memory pressure for this use case. >>> >>> As far as I can see background for the option is that files in tmpfs >>> usually have a varying size, so it usually isn't beneficial to >>> allocate a huge page just to find that the shmem file is much smaller >>> than what's needed. >>> >>> But GEM objects have a fixed size. So we of hand knew if we need 4KiB >>> or 1GiB and can therefore directly allocate huge pages if they are >>> available and object large enough to back them with. >>> >>> If the memory pressure is so high that we don't have huge pages >>> available the shmem code falls back to standard pages anyway. >> >> The matter is: how do we define the point where the memory pressure is >> high? > > Well as driver developers/maintainers we simply don't do that. This is > the job of the shmem code. > >> For example, notice that in this implementation of Super Pages >> for the V3D driver, I only use a Super Page if the BO is bigger than >> 2MB. I'm doing that because the Raspberry Pi only has 4GB of RAM >> available for the GPU. If I created huge pages for every BO allocation >> (and initially, I tried that), I would end up with hangs in some >> applications. > > Yeah, that is what I meant with the trivial optimisation to the shmem > code. Essentially when you have 2MiB+4KiB as BO size then the shmem code > should use a 2MiB and a 4KiB page to back them, but what it currently > does is to use two 2MiB pages and then split up the second page when it > find that it isn't needed. > > That is wasteful and leads to fragmentation, but as soon as we stop > doing that we should be fine to enable it unconditionally for all drivers. I see your point, but I believe that it would be tangent to the goal of this series. As you mentioned, currently, we have a lot of memory fragmentation when using THP and while we don't solve that (at the tmpfs level), I believe we could move on with the current implementation (with improvements proposed by Tvrtko). Best Regards, - Maíra > > TTM does essentially the same thing for years. > > Regards, > Christian. > >> >> >> At least, for V3D, I wouldn't like to see THP being used for all the >> allocations. But, we have maintainers of other drivers in the CC. >> >> Best Regards, >> - Maíra >> >>> >>> So THP is almost always beneficial for GEM even if the driver doesn't >>> actually need it. The only potential case I can think of which might >>> not be handled gracefully is the tail pages, e.g. huge + 4kib. >>> >>> But that is trivial to optimize in the shmem code when the final size >>> of the file is known beforehand. >>> >>> Regards, >>> Christian. >>> >>>> >>>> Best Regards, >>>> - Maíra >>>> >>>>> >>>>> Regards, >>>>> Christian. >>>>> >>>>> >>>>>> >>>>>> Te Cc is plenty large so perhaps someone else will have additional >>>>>> information. :) >>>>>> >>>>>> Regards, >>>>>> >>>>>> Tvrtko >>>>>> >>>>>>> >>>>>>> I mean it would make this patch here even smaller. >>>>>>> >>>>>>> Regards, >>>>>>> Christian. >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Regards, >>>>>>>> >>>>>>>> Tvrtko >>>>>>> >>>>> >>> >
Am 18.03.24 um 15:24 schrieb Maíra Canal: > Not that the CC list wasn't big enough, but I'm adding MM folks > in the CC list. > > On 3/18/24 11:04, Christian König wrote: >> Am 18.03.24 um 14:28 schrieb Maíra Canal: >>> Hi Christian, >>> >>> On 3/18/24 10:10, Christian König wrote: >>>> Am 18.03.24 um 13:42 schrieb Maíra Canal: >>>>> Hi Christian, >>>>> >>>>> On 3/12/24 10:48, Christian König wrote: >>>>>> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>>>>>> >>>>>>> On 12/03/2024 10:37, Christian König wrote: >>>>>>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>>>>>> >>>>>>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>>>>>> >>>>>>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>>>>>> >>>>>>>>>>>>> Hi Maira, >>>>>>>>>>>>> >>>>>>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>>>>>> want to have a >>>>>>>>>>>>>> different mountpoint, for which we pass in mount flags >>>>>>>>>>>>>> that better match >>>>>>>>>>>>>> our usecase. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() >>>>>>>>>>>>>> that allow us to >>>>>>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>>>>>> created. If >>>>>>>>>>>>>> this parameter is NULL, then we fallback to >>>>>>>>>>>>>> shmem_file_setup(). >>>>>>>>>>>>> >>>>>>>>>>>>> One strategy for reducing churn, and so the number of >>>>>>>>>>>>> drivers this patch touches, could be to add a lower level >>>>>>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), >>>>>>>>>>>>> and make drm_gem_object_init() call that one with a NULL >>>>>>>>>>>>> argument. >>>>>>>>>>>> >>>>>>>>>>>> I would even go a step further into the other direction. >>>>>>>>>>>> The shmem backed GEM object is just some special handling >>>>>>>>>>>> as far as I can see. >>>>>>>>>>>> >>>>>>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>>>>>> drm_gem_shmem_*. >>>>>>>>>>> >>>>>>>>>>> That makes sense although it would be very churny. I at >>>>>>>>>>> least would be on the fence regarding the cost vs benefit. >>>>>>>>>> >>>>>>>>>> Yeah, it should clearly not be part of this patch here. >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Also the explanation why a different mount point helps with >>>>>>>>>>>> something isn't very satisfying. >>>>>>>>>>> >>>>>>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>>>>>> driver wants to use huge pages for performance? Or not >>>>>>>>>>> satisying as you question why huge pages would help? >>>>>>>>>> >>>>>>>>>> That huge pages are beneficial is clear to me, but I'm >>>>>>>>>> missing the connection why a different mount point helps with >>>>>>>>>> using huge pages. >>>>>>>>> >>>>>>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>>>>>> passing huge=within_size or huge=always option. Default is >>>>>>>>> 'never', see man 5 tmpfs. >>>>>>>> >>>>>>>> Thanks for the explanation, I wasn't aware of that. >>>>>>>> >>>>>>>> Mhm, shouldn't we always use huge pages? Is there a reason for >>>>>>>> a DRM device to not use huge pages with the shmem backend? >>>>>>> >>>>>>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>>>>>> back then the understanding was within_size may overallocate, >>>>>>> meaning there would be some space wastage, until the memory >>>>>>> pressure makes the thp code split the trailing huge page. I >>>>>>> haven't checked if that still applies. >>>>>>> >>>>>>> Other than that I don't know if some drivers/platforms could >>>>>>> have problems if they have some limitations or hardcoded >>>>>>> assumptions when they iterate the sg list. >>>>>> >>>>>> Yeah, that was the whole point behind my question. As far as I >>>>>> can see this isn't driver specific, but platform specific. >>>>>> >>>>>> I might be wrong here, but I think we should then probably not >>>>>> have that handling in each individual driver, but rather >>>>>> centralized in the DRM code. >>>>> >>>>> I don't see a point in enabling THP for all shmem drivers. A huge >>>>> page >>>>> is only useful if the driver is going to use it. On V3D, for example, >>>>> I only need huge pages because I need the memory contiguously >>>>> allocated >>>>> to implement Super Pages. Otherwise, if we don't have the Super Pages >>>>> support implemented in the driver, I would be creating memory >>>>> pressure >>>>> without any performance gain. >>>> >>>> Well that's the point I'm disagreeing with. THP doesn't seem to >>>> create much extra memory pressure for this use case. >>>> >>>> As far as I can see background for the option is that files in >>>> tmpfs usually have a varying size, so it usually isn't beneficial >>>> to allocate a huge page just to find that the shmem file is much >>>> smaller than what's needed. >>>> >>>> But GEM objects have a fixed size. So we of hand knew if we need >>>> 4KiB or 1GiB and can therefore directly allocate huge pages if they >>>> are available and object large enough to back them with. >>>> >>>> If the memory pressure is so high that we don't have huge pages >>>> available the shmem code falls back to standard pages anyway. >>> >>> The matter is: how do we define the point where the memory pressure >>> is high? >> >> Well as driver developers/maintainers we simply don't do that. This >> is the job of the shmem code. >> >>> For example, notice that in this implementation of Super Pages >>> for the V3D driver, I only use a Super Page if the BO is bigger than >>> 2MB. I'm doing that because the Raspberry Pi only has 4GB of RAM >>> available for the GPU. If I created huge pages for every BO >>> allocation (and initially, I tried that), I would end up with hangs >>> in some applications. >> >> Yeah, that is what I meant with the trivial optimisation to the shmem >> code. Essentially when you have 2MiB+4KiB as BO size then the shmem >> code should use a 2MiB and a 4KiB page to back them, but what it >> currently does is to use two 2MiB pages and then split up the second >> page when it find that it isn't needed. >> >> That is wasteful and leads to fragmentation, but as soon as we stop >> doing that we should be fine to enable it unconditionally for all >> drivers. > > I see your point, but I believe that it would be tangent to the goal of > this series. As you mentioned, currently, we have a lot of memory > fragmentation when using THP and while we don't solve that (at the tmpfs > level), I believe we could move on with the current implementation (with > improvements proposed by Tvrtko). Oh, I seriously don't want to block this patch set here. Just asking if it's the right approach. Point is we might need to revert the driver changes again when THP is further optimized and the options aren't needed any more. But if and how that should happen is perfectly up to Tvrtko. Regards, Christian. > > Best Regards, > - Maíra > >> >> TTM does essentially the same thing for years. >> >> Regards, >> Christian. >> >>> >>> >>> At least, for V3D, I wouldn't like to see THP being used for all the >>> allocations. But, we have maintainers of other drivers in the CC. >>> >>> Best Regards, >>> - Maíra >>> >>>> >>>> So THP is almost always beneficial for GEM even if the driver >>>> doesn't actually need it. The only potential case I can think of >>>> which might not be handled gracefully is the tail pages, e.g. huge >>>> + 4kib. >>>> >>>> But that is trivial to optimize in the shmem code when the final >>>> size of the file is known beforehand. >>>> >>>> Regards, >>>> Christian. >>>> >>>>> >>>>> Best Regards, >>>>> - Maíra >>>>> >>>>>> >>>>>> Regards, >>>>>> Christian. >>>>>> >>>>>> >>>>>>> >>>>>>> Te Cc is plenty large so perhaps someone else will have >>>>>>> additional information. :) >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> Tvrtko >>>>>>> >>>>>>>> >>>>>>>> I mean it would make this patch here even smaller. >>>>>>>> >>>>>>>> Regards, >>>>>>>> Christian. >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Regards, >>>>>>>>> >>>>>>>>> Tvrtko >>>>>>>> >>>>>> >>>> >>
On 18/03/2024 15:05, Christian König wrote: > Am 18.03.24 um 15:24 schrieb Maíra Canal: >> Not that the CC list wasn't big enough, but I'm adding MM folks >> in the CC list. >> >> On 3/18/24 11:04, Christian König wrote: >>> Am 18.03.24 um 14:28 schrieb Maíra Canal: >>>> Hi Christian, >>>> >>>> On 3/18/24 10:10, Christian König wrote: >>>>> Am 18.03.24 um 13:42 schrieb Maíra Canal: >>>>>> Hi Christian, >>>>>> >>>>>> On 3/12/24 10:48, Christian König wrote: >>>>>>> Am 12.03.24 um 14:09 schrieb Tvrtko Ursulin: >>>>>>>> >>>>>>>> On 12/03/2024 10:37, Christian König wrote: >>>>>>>>> Am 12.03.24 um 11:31 schrieb Tvrtko Ursulin: >>>>>>>>>> >>>>>>>>>> On 12/03/2024 10:23, Christian König wrote: >>>>>>>>>>> Am 12.03.24 um 10:30 schrieb Tvrtko Ursulin: >>>>>>>>>>>> >>>>>>>>>>>> On 12/03/2024 08:59, Christian König wrote: >>>>>>>>>>>>> Am 12.03.24 um 09:51 schrieb Tvrtko Ursulin: >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Maira, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 11/03/2024 10:05, Maíra Canal wrote: >>>>>>>>>>>>>>> For some applications, such as using huge pages, we might >>>>>>>>>>>>>>> want to have a >>>>>>>>>>>>>>> different mountpoint, for which we pass in mount flags >>>>>>>>>>>>>>> that better match >>>>>>>>>>>>>>> our usecase. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Therefore, add a new parameter to drm_gem_object_init() >>>>>>>>>>>>>>> that allow us to >>>>>>>>>>>>>>> define the tmpfs mountpoint where the GEM object will be >>>>>>>>>>>>>>> created. If >>>>>>>>>>>>>>> this parameter is NULL, then we fallback to >>>>>>>>>>>>>>> shmem_file_setup(). >>>>>>>>>>>>>> >>>>>>>>>>>>>> One strategy for reducing churn, and so the number of >>>>>>>>>>>>>> drivers this patch touches, could be to add a lower level >>>>>>>>>>>>>> drm_gem_object_init() (which takes vfsmount, call it >>>>>>>>>>>>>> __drm_gem_object_init(), or drm__gem_object_init_mnt(), >>>>>>>>>>>>>> and make drm_gem_object_init() call that one with a NULL >>>>>>>>>>>>>> argument. >>>>>>>>>>>>> >>>>>>>>>>>>> I would even go a step further into the other direction. >>>>>>>>>>>>> The shmem backed GEM object is just some special handling >>>>>>>>>>>>> as far as I can see. >>>>>>>>>>>>> >>>>>>>>>>>>> So I would rather suggest to rename all drm_gem_* function >>>>>>>>>>>>> which only deal with the shmem backed GEM object into >>>>>>>>>>>>> drm_gem_shmem_*. >>>>>>>>>>>> >>>>>>>>>>>> That makes sense although it would be very churny. I at >>>>>>>>>>>> least would be on the fence regarding the cost vs benefit. >>>>>>>>>>> >>>>>>>>>>> Yeah, it should clearly not be part of this patch here. >>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> Also the explanation why a different mount point helps with >>>>>>>>>>>>> something isn't very satisfying. >>>>>>>>>>>> >>>>>>>>>>>> Not satisfying as you think it is not detailed enough to say >>>>>>>>>>>> driver wants to use huge pages for performance? Or not >>>>>>>>>>>> satisying as you question why huge pages would help? >>>>>>>>>>> >>>>>>>>>>> That huge pages are beneficial is clear to me, but I'm >>>>>>>>>>> missing the connection why a different mount point helps with >>>>>>>>>>> using huge pages. >>>>>>>>>> >>>>>>>>>> Ah right, same as in i915, one needs to mount a tmpfs instance >>>>>>>>>> passing huge=within_size or huge=always option. Default is >>>>>>>>>> 'never', see man 5 tmpfs. >>>>>>>>> >>>>>>>>> Thanks for the explanation, I wasn't aware of that. >>>>>>>>> >>>>>>>>> Mhm, shouldn't we always use huge pages? Is there a reason for >>>>>>>>> a DRM device to not use huge pages with the shmem backend? >>>>>>>> >>>>>>>> AFAIU, according to b901bb89324a ("drm/i915/gemfs: enable THP"), >>>>>>>> back then the understanding was within_size may overallocate, >>>>>>>> meaning there would be some space wastage, until the memory >>>>>>>> pressure makes the thp code split the trailing huge page. I >>>>>>>> haven't checked if that still applies. >>>>>>>> >>>>>>>> Other than that I don't know if some drivers/platforms could >>>>>>>> have problems if they have some limitations or hardcoded >>>>>>>> assumptions when they iterate the sg list. >>>>>>> >>>>>>> Yeah, that was the whole point behind my question. As far as I >>>>>>> can see this isn't driver specific, but platform specific. >>>>>>> >>>>>>> I might be wrong here, but I think we should then probably not >>>>>>> have that handling in each individual driver, but rather >>>>>>> centralized in the DRM code. >>>>>> >>>>>> I don't see a point in enabling THP for all shmem drivers. A huge >>>>>> page >>>>>> is only useful if the driver is going to use it. On V3D, for example, >>>>>> I only need huge pages because I need the memory contiguously >>>>>> allocated >>>>>> to implement Super Pages. Otherwise, if we don't have the Super Pages >>>>>> support implemented in the driver, I would be creating memory >>>>>> pressure >>>>>> without any performance gain. >>>>> >>>>> Well that's the point I'm disagreeing with. THP doesn't seem to >>>>> create much extra memory pressure for this use case. >>>>> >>>>> As far as I can see background for the option is that files in >>>>> tmpfs usually have a varying size, so it usually isn't beneficial >>>>> to allocate a huge page just to find that the shmem file is much >>>>> smaller than what's needed. >>>>> >>>>> But GEM objects have a fixed size. So we of hand knew if we need >>>>> 4KiB or 1GiB and can therefore directly allocate huge pages if they >>>>> are available and object large enough to back them with. >>>>> >>>>> If the memory pressure is so high that we don't have huge pages >>>>> available the shmem code falls back to standard pages anyway. >>>> >>>> The matter is: how do we define the point where the memory pressure >>>> is high? >>> >>> Well as driver developers/maintainers we simply don't do that. This >>> is the job of the shmem code. >>> >>>> For example, notice that in this implementation of Super Pages >>>> for the V3D driver, I only use a Super Page if the BO is bigger than >>>> 2MB. I'm doing that because the Raspberry Pi only has 4GB of RAM >>>> available for the GPU. If I created huge pages for every BO >>>> allocation (and initially, I tried that), I would end up with hangs >>>> in some applications. >>> >>> Yeah, that is what I meant with the trivial optimisation to the shmem >>> code. Essentially when you have 2MiB+4KiB as BO size then the shmem >>> code should use a 2MiB and a 4KiB page to back them, but what it >>> currently does is to use two 2MiB pages and then split up the second >>> page when it find that it isn't needed. >>> >>> That is wasteful and leads to fragmentation, but as soon as we stop >>> doing that we should be fine to enable it unconditionally for all >>> drivers. >> >> I see your point, but I believe that it would be tangent to the goal of >> this series. As you mentioned, currently, we have a lot of memory >> fragmentation when using THP and while we don't solve that (at the tmpfs >> level), I believe we could move on with the current implementation (with >> improvements proposed by Tvrtko). > > Oh, I seriously don't want to block this patch set here. Just asking if > it's the right approach. > > Point is we might need to revert the driver changes again when THP is > further optimized and the options aren't needed any more. > > But if and how that should happen is perfectly up to Tvrtko. Seem I got some un-intended voting powers here. :) What I think would work best is, if Maíra solves the v3d part first and then she can propose/float the wider DRM/GEM change to always use THP. Because that one will require some wider testing and acks. My concern there will be the behaviour of within_size mode. I was reading 465c403cb508 (drm/i915: introduce simple gemfs) the other day which made my think even then THP would initially over allocate. Or maybe the comment added in that commit wasn't fully accurate. If within_size is not high impact like that, then it GEM wide change might be feasible. With some opt-out facility or not I don't know. In any case, as long as the v3d work can be done with not too much churn to common code, I think separating that as follow up should not cause a lot of additional churn. Should all be hidden in the implementation details if all goes to plan. Regards, Tvrtko
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c index 26d10065d534..36a25e667341 100644 --- a/drivers/gpu/drm/armada/armada_gem.c +++ b/drivers/gpu/drm/armada/armada_gem.c @@ -226,7 +226,7 @@ static struct armada_gem_object *armada_gem_alloc_object(struct drm_device *dev, obj->obj.funcs = &armada_gem_object_funcs; - if (drm_gem_object_init(dev, &obj->obj, size)) { + if (drm_gem_object_init(dev, &obj->obj, size, NULL)) { kfree(obj); return NULL; } diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 44a948b80ee1..ddd8777fcda5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -118,18 +118,26 @@ drm_gem_init(struct drm_device *dev) * @dev: drm_device the object should be initialized for * @obj: drm_gem_object to initialize * @size: object size + * @gemfs: tmpfs mount where the GEM object will be created. If NULL, use + * the usual tmpfs mountpoint (`shm_mnt`). * * Initialize an already allocated GEM object of the specified size with * shmfs backing store. */ int drm_gem_object_init(struct drm_device *dev, - struct drm_gem_object *obj, size_t size) + struct drm_gem_object *obj, size_t size, + struct vfsmount *gemfs) { struct file *filp; drm_gem_private_object_init(dev, obj, size); - filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); + if (gemfs) + filp = shmem_file_setup_with_mnt(gemfs, "drm mm object", size, + VM_NORESERVE); + else + filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); + if (IS_ERR(filp)) return PTR_ERR(filp); diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c index 870b90b78bc4..9ada5ac85dd6 100644 --- a/drivers/gpu/drm/drm_gem_dma_helper.c +++ b/drivers/gpu/drm/drm_gem_dma_helper.c @@ -95,7 +95,7 @@ __drm_gem_dma_create(struct drm_device *drm, size_t size, bool private) /* Always use writecombine for dma-buf mappings */ dma_obj->map_noncoherent = false; } else { - ret = drm_gem_object_init(drm, gem_obj, size); + ret = drm_gem_object_init(drm, gem_obj, size, NULL); } if (ret) goto error; diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index e435f986cd13..15635b330ca8 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -77,7 +77,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private) drm_gem_private_object_init(dev, obj, size); shmem->map_wc = false; /* dma-buf mappings use always writecombine */ } else { - ret = drm_gem_object_init(dev, obj, size); + ret = drm_gem_object_init(dev, obj, size, NULL); } if (ret) { drm_gem_private_object_fini(obj); diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 75f2eaf0d5b6..90649899dbef 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -210,7 +210,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, if (!gem->funcs) gem->funcs = &drm_gem_vram_object_funcs; - ret = drm_gem_object_init(dev, gem, size); + ret = drm_gem_object_init(dev, gem, size, NULL); if (ret) { kfree(gbo); return ERR_PTR(ret); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 71a6d2b1c80f..aa4b61c48b7f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -596,7 +596,7 @@ int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file, lockdep_set_class(&to_etnaviv_bo(obj)->lock, &etnaviv_shm_lock_class); - ret = drm_gem_object_init(dev, obj, size); + ret = drm_gem_object_init(dev, obj, size, NULL); if (ret) goto fail; diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 638ca96830e9..c50c0d12246e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -160,7 +160,7 @@ static struct exynos_drm_gem *exynos_drm_gem_init(struct drm_device *dev, obj->funcs = &exynos_drm_gem_object_funcs; - ret = drm_gem_object_init(dev, obj, size); + ret = drm_gem_object_init(dev, obj, size, NULL); if (ret < 0) { DRM_DEV_ERROR(dev->dev, "failed to initialize gem object\n"); kfree(exynos_gem); diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c index 4b7627a72637..315e085dc9ee 100644 --- a/drivers/gpu/drm/gma500/gem.c +++ b/drivers/gpu/drm/gma500/gem.c @@ -169,7 +169,7 @@ psb_gem_create(struct drm_device *dev, u64 size, const char *name, bool stolen, if (stolen) { drm_gem_private_object_init(dev, obj, size); } else { - ret = drm_gem_object_init(dev, obj, size); + ret = drm_gem_object_init(dev, obj, size, NULL); if (ret) goto err_release_resource; diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c index 465f622ac05d..d392ea66d72e 100644 --- a/drivers/gpu/drm/loongson/lsdc_ttm.c +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c @@ -458,7 +458,7 @@ struct lsdc_bo *lsdc_bo_create(struct drm_device *ddev, size = ALIGN(size, PAGE_SIZE); - ret = drm_gem_object_init(ddev, &tbo->base, size); + ret = drm_gem_object_init(ddev, &tbo->base, size, NULL); if (ret) { kfree(lbo); return ERR_PTR(ret); diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c index 4f2e3feabc0f..261d386921dc 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c @@ -44,7 +44,7 @@ static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev, mtk_gem_obj->base.funcs = &mtk_drm_gem_object_funcs; - ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size); + ret = drm_gem_object_init(dev, &mtk_gem_obj->base, size, NULL); if (ret < 0) { DRM_ERROR("failed to initialize gem object\n"); kfree(mtk_gem_obj); diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 175ee4ab8a6f..6fe17cf28ef6 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -1222,7 +1222,7 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev, uint32_t size, uint32 vma->iova = physaddr(obj); } else { - ret = drm_gem_object_init(dev, obj, size); + ret = drm_gem_object_init(dev, obj, size, NULL); if (ret) goto fail; /* diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 49c2bcbef129..434325fa8752 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -262,7 +262,7 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain, /* Initialize the embedded gem-object. We return a single gem-reference * to the caller, instead of a normal nouveau_bo ttm reference. */ - ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size); + ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size, NULL); if (ret) { drm_gem_object_release(&nvbo->bo.base); kfree(nvbo); diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c index 1b2ff0c40fc1..c9b3572df555 100644 --- a/drivers/gpu/drm/nouveau/nouveau_prime.c +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c @@ -62,7 +62,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, /* Initialize the embedded gem-object. We return a single gem-reference * to the caller, instead of a normal nouveau_bo ttm reference. */ - ret = drm_gem_object_init(dev, &nvbo->bo.base, size); + ret = drm_gem_object_init(dev, &nvbo->bo.base, size, NULL); if (ret) { nouveau_bo_ref(NULL, &nvbo); obj = ERR_PTR(-ENOMEM); diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 3421e8389222..53b4ec64c7b0 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1352,7 +1352,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, if (!(flags & OMAP_BO_MEM_SHMEM)) { drm_gem_private_object_init(dev, obj, size); } else { - ret = drm_gem_object_init(dev, obj, size); + ret = drm_gem_object_init(dev, obj, size, NULL); if (ret) goto err_free; diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index 1e46b0a6e478..45d7abe26ebd 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c @@ -123,7 +123,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned long size, if (bo == NULL) return -ENOMEM; size = roundup(size, PAGE_SIZE); - r = drm_gem_object_init(&qdev->ddev, &bo->tbo.base, size); + r = drm_gem_object_init(&qdev->ddev, &bo->tbo.base, size, NULL); if (unlikely(r)) { kfree(bo); return r; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 93ed841f5dce..daba285bd78f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -295,7 +295,7 @@ static struct rockchip_gem_object * obj->funcs = &rockchip_gem_object_funcs; - drm_gem_object_init(drm, obj, size); + drm_gem_object_init(drm, obj, size, NULL); return rk_obj; } diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index b4eb030ea961..63f10d5a57ba 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -311,7 +311,7 @@ static struct tegra_bo *tegra_bo_alloc_object(struct drm_device *drm, host1x_bo_init(&bo->base, &tegra_bo_ops); size = round_up(size, PAGE_SIZE); - err = drm_gem_object_init(drm, &bo->gem, size); + err = drm_gem_object_init(drm, &bo->gem, size, NULL); if (err < 0) goto free; diff --git a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c index 7b7c1fa805fc..a9bf7d5a887c 100644 --- a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c +++ b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c @@ -61,7 +61,7 @@ struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test, KUNIT_ASSERT_NOT_NULL(test, bo); bo->base = gem_obj; - err = drm_gem_object_init(devs->drm, &bo->base, size); + err = drm_gem_object_init(devs->drm, &bo->base, size, NULL); KUNIT_ASSERT_EQ(test, err, 0); bo->bdev = devs->ttm_dev; diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index 3ad2b4cfd1f0..1b36c958340b 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -122,7 +122,7 @@ static struct xen_gem_object *gem_create_obj(struct drm_device *dev, xen_obj->base.funcs = &xen_drm_front_gem_object_funcs; - ret = drm_gem_object_init(dev, &xen_obj->base, size); + ret = drm_gem_object_init(dev, &xen_obj->base, size, NULL); if (ret < 0) { kfree(xen_obj); return ERR_PTR(ret); diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 2ebec3984cd4..c75611ae8f93 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -471,7 +471,8 @@ struct drm_gem_object { void drm_gem_object_release(struct drm_gem_object *obj); void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, - struct drm_gem_object *obj, size_t size); + struct drm_gem_object *obj, size_t size, + struct vfsmount *gemfs); void drm_gem_private_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_fini(struct drm_gem_object *obj);
For some applications, such as using huge pages, we might want to have a different mountpoint, for which we pass in mount flags that better match our usecase. Therefore, add a new parameter to drm_gem_object_init() that allow us to define the tmpfs mountpoint where the GEM object will be created. If this parameter is NULL, then we fallback to shmem_file_setup(). Cc: Russell King <linux@armlinux.org.uk> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Christian Gmeiner <christian.gmeiner@gmail.com> Cc: Inki Dae <inki.dae@samsung.com> Cc: Seung-Woo Kim <sw0312.kim@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Cc: Alim Akhtar <alim.akhtar@samsung.com> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Cc: Sui Jingfeng <suijingfeng@loongson.cn> Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com> Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Cc: Sean Paul <sean@poorly.run> Cc: Marijn Suijten <marijn.suijten@somainline.org> Cc: Karol Herbst <kherbst@redhat.com> Cc: Lyude Paul <lyude@redhat.com> Cc: Danilo Krummrich <dakr@redhat.com> Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Sandy Huang <hjc@rock-chips.com> Cc: "Heiko Stübner" <heiko@sntech.de> Cc: Andy Yan <andy.yan@rock-chips.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Mikko Perttunen <mperttunen@nvidia.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Cc: Christian König <christian.koenig@amd.com> Cc: Huang Rui <ray.huang@amd.com> Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Cc: Karolina Stolarek <karolina.stolarek@intel.com> Cc: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Maíra Canal <mcanal@igalia.com> --- drivers/gpu/drm/armada/armada_gem.c | 2 +- drivers/gpu/drm/drm_gem.c | 12 ++++++++++-- drivers/gpu/drm/drm_gem_dma_helper.c | 2 +- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +- drivers/gpu/drm/gma500/gem.c | 2 +- drivers/gpu/drm/loongson/lsdc_ttm.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +- drivers/gpu/drm/msm/msm_gem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_prime.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 2 +- drivers/gpu/drm/qxl/qxl_object.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 2 +- drivers/gpu/drm/tegra/gem.c | 2 +- drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 2 +- drivers/gpu/drm/xen/xen_drm_front_gem.c | 2 +- include/drm/drm_gem.h | 3 ++- 20 files changed, 30 insertions(+), 21 deletions(-) -- 2.43.0