From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 650BD242D70; Thu, 16 Oct 2025 05:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760594206; cv=none; b=ZDr5R/YcMHQJITNWs91GKcq7dHkQRLEmpy2hF9etMtpa4xY5PgGJV/d6GrqXj1nbVuYSpfD0JMMCGOI9CsgHHo3SXvR806v/jKqkx2AzRDwn+pIUgaMHz9xntplw9jmKdrnsbKkWbNMuecDqMQHDt/9mo///BNDCxU1Mqn7HTXE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760594206; c=relaxed/simple; bh=v28SW4C2/MMOF14xcWGZoBm6mtw65G/uoNs/VCAmapM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tsCtXI0yM8E5JdzQL1Z1jUoYVNZdaHvk2vH0hSl4iYkTnD2DlcPcmErtE60kPNJtSkR8irZWauWh2o3lfXL5F3NPytmgmCYLYztvouzJ1v22WF/1W4MPl1BH0tBh2vMiEhnCkgEMw7qDVvq141U5dItv3/J1EdYy4ySq4gr3QUE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=QX6T8jHl; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="QX6T8jHl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1760594202; bh=v28SW4C2/MMOF14xcWGZoBm6mtw65G/uoNs/VCAmapM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QX6T8jHlaUjF0jv51uLgXQcAH7TxnY63c9Eq9eYQ1SzI7HC8icxUPRUT+OqhI3q2a aNY85XuyJmUMasOXGX4UFdMBaBlsUXPRsLEkcDqYLhYXLCC87kSqkwEAZTGLVKiRJb RXsiqT3UNRlkB9Txx8SCDvpvuSTsIbsL46Dc0PEWOe5iwjhpl/Mc3MRc2tphIzbg73 GsyPOGwRLs/KVDy6n4d58AS2lyJfGM/dCUIdWvij/K5YtOzG7UDxC2nkMq34mPuzvY LXm8HjtBEZEL6kXwi2xc4qY3QLgDb9uYZIci2jO8EuCNonyr6x82jtHXk4wRc+X800 5sfj3NaFXCraQ== Received: from fedora (unknown [IPv6:2a01:e0a:2c:6930:d919:a6e:5ea1:8a9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 0EE9017E05FE; Thu, 16 Oct 2025 07:56:41 +0200 (CEST) Date: Thu, 16 Oct 2025 07:56:37 +0200 From: Boris Brezillon To: =?UTF-8?B?TG/Dr2M=?= Molinari Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Rob Herring , Steven Price , Liviu Dudau , Melissa Wen , =?UTF-8?B?TWHDrXJh?= Canal , Hugh Dickins , Baolin Wang , Andrew Morton , Al Viro , =?UTF-8?B?TWlrb8WCYWo=?= Wasiak , Christian Brauner , Nitin Gote , Andi Shyti , Jonathan Corbet , Christopher Healy , Matthew Wilcox , Bagas Sanjaya , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v4 08/13] drm/v3d: Fix builds with CONFIG_TRANSPARENT_HUGEPAGE=n Message-ID: <20251016075637.3aec3465@fedora> In-Reply-To: References: <20251015153018.43735-1-loic.molinari@collabora.com> <20251015153018.43735-9-loic.molinari@collabora.com> <20251015201737.3956f801@fedora> Organization: Collabora X-Mailer: Claws Mail 4.3.1 (GTK 3.24.49; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 15 Oct 2025 22:41:59 +0200 Lo=C3=AFc Molinari wrote: > On 15/10/2025 20:17, Boris Brezillon wrote: > > On Wed, 15 Oct 2025 17:30:12 +0200 > > Lo=C3=AFc Molinari wrote: > > =20 > >> Don't declare "super_pages" on builds with CONFIG_TRANSPARENT_HUGEPAGE > >> disabled to prevent build error: > >> > >> ERROR: modpost: "super_pages" [drivers/gpu/drm/v3d/v3d.ko] undefined! = =20 > >=20 > > I believe this is a bug introduced by the previous commit: the > > compiler probably drops any code between the > > IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) check and the err label > > because IS_ENABLED() evaluates to false at compile time. So I'd squash > > those changes in the previous commit. =20 >=20 > Right, it's been introduced in previous commit. >=20 > > =20 > >> > >> Signed-off-by: Lo=C3=AFc Molinari > >> --- > >> drivers/gpu/drm/v3d/v3d_drv.h | 2 ++ > >> drivers/gpu/drm/v3d/v3d_gem.c | 2 ++ > >> 2 files changed, 4 insertions(+) > >> > >> diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_d= rv.h > >> index 99a39329bb85..481502104391 100644 > >> --- a/drivers/gpu/drm/v3d/v3d_drv.h > >> +++ b/drivers/gpu/drm/v3d/v3d_drv.h > >> @@ -564,7 +564,9 @@ extern const struct dma_fence_ops v3d_fence_ops; > >> struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_que= ue q); > >> =20 > >> /* v3d_gem.c */ > >> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > >> extern bool super_pages; > >> +#endif > >> int v3d_gem_init(struct drm_device *dev); > >> void v3d_gem_destroy(struct drm_device *dev); > >> void v3d_reset_sms(struct v3d_dev *v3d); > >> diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_g= em.c > >> index 635ff0fabe7e..0039063eb8b2 100644 > >> --- a/drivers/gpu/drm/v3d/v3d_gem.c > >> +++ b/drivers/gpu/drm/v3d/v3d_gem.c > >> @@ -269,7 +269,9 @@ v3d_huge_mnt_init(struct v3d_dev *v3d) > >> * match our usecase. > >> */ > >> =20 > >> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > >> if (super_pages) > >> +#endif > >> err =3D drm_gem_huge_mnt_create(&v3d->drm, "within_size"); =20 > >=20 > > Why not > >=20 > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > > if (super_pages) > > err =3D drm_gem_huge_mnt_create(&v3d->drm, "within_size"); > > #endif > >=20 > > I guess > >=20 > > if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && super_pages) > > err =3D drm_gem_huge_mnt_create(&v3d->drm, "within_size"); > >=20 > > would also do, since it's likely to rely on the same optimization the > > previous v3d_gemfs_init() implementation was relying on, but it's > > fragile (not sure what happens when compiled with -O0). =20 >=20 > I'll remove the #ifdef/#endif around the super_pages declaration in=20 > v3d_drv.h because it isn't necessary if super_pages is compiled out in=20 > v3d_huge_mnt_init(). >=20 > In v3d_huge_mnt_init(), I'd add the #ifdef before the ret variable=20 > declaration and the #endif right after the last else so that it's clear=20 > drm_notice("THP is recommended...") is called unconditionally when=20 > CONFIG_TRANSPARENT_HUGEPAGE=3Dn, whatever the optim level. What do you th= ink? First off, I'm not a huge fan of the following pattern #if foo if (xxxx) #endif do_something which also applies to #if foo if (xxxx) do_xxx else if (yyy) do_yyy else #endif do_something I'd rather have do_something duplicated in an #else section like that: #if foo if (xxxx) do_xxx else if (yyy) do_yyy else do_something #else do_something #endif But I'm not even seeing what the problem is here. If you do: int err =3D 0; #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (super_pages) err =3D drm_gem_huge_mnt_create(&v3d->drm, "within_size"); #endif if (v3d->drm.huge_mnt) drm_info(&v3d->drm, "Using Transparent Hugepages\n"); else if (err) drm_warn(&v3d->drm, "Can't use Transparent Hugepages (%d)\n", err); else drm_notice(&v3d->drm, "Transparent Hugepage support is recommended for optimal performance = on this platform!\n"); You're guaranteed that err=3D0 and v3d->drm.huge_mnt=3DNULL when CONFIG_TRANSPARENT_HUGEPAGE=3Dn, so the "THP recommended" message should be displayed unconditionally. Am I missing something?