From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DFABCCD194 for ; Thu, 16 Oct 2025 05:56:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CA5810E2D2; Thu, 16 Oct 2025 05:56:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="QX6T8jHl"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2A5D10E173; Thu, 16 Oct 2025 05:56:43 +0000 (UTC) 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) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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?