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 18E94FCE066 for ; Thu, 26 Feb 2026 12:23:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1848010E912; Thu, 26 Feb 2026 12:23:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="g9Kl0Ddd"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 42AB110E040; Thu, 26 Feb 2026 12:23:44 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 06E884173E; Thu, 26 Feb 2026 12:23:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 533E9C19422; Thu, 26 Feb 2026 12:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772108623; bh=tmoQ8NMtoL4FR91LkCRDafLZ639jNUiDpE0JDfaia4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g9Kl0DdduTYqLNE0GczAwmNvQQuQvmx13FtpSNP8HCGWTi2yXbEOWKg3wXEnitl4H EFsDDECpkDcu/QEV1pVuGet/13kpDJzIMGrcaDgsXueU7Azkl7b2MGETmUsJHNV9il Tf9n8OWDEvxoiN7Kzd9GqfvxLJmT9SsuyGRkgFeRCpakXNmbESqDuzOF7LxmPKpmD5 fAZyvDEyctsMQuYKTdP7GePcjQCgs3gR91Z4vr7D+64X38qXCQYtlJ/otFmDzfumvs KFH8NUR08drQMKY26uO4pk+T6pIOTvkKSCq+eD+dCvfrcdv8M+CeymX6wk66MjgUIl +YXdWaLu4jezQ== Date: Thu, 26 Feb 2026 13:23:38 +0100 From: Andi Shyti To: Janusz Krzysztofik Cc: Andi Shyti , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Andrew Morton , "Matthew Wilcox (Oracle)" , Krzysztof Karas , Sebastian Brzezinka , Krzysztof Niemiec Subject: Re: [PATCH] drm/i915: Fix potential overflow of shmem scatterlist length Message-ID: References: <20260224094944.2447913-2-janusz.krzysztofik@linux.intel.com> <5887622.44csPzL39Z@jkrzyszt-mobl2.ger.corp.intel.com> <10397304.EvYhyI6sBW@jkrzyszt-mobl2.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10397304.EvYhyI6sBW@jkrzyszt-mobl2.ger.corp.intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Feb 25, 2026 at 06:29:12PM +0100, Janusz Krzysztofik wrote: > On Wednesday, 25 February 2026 16:38:18 CET Andi Shyti wrote: > > > > For clarity this can be written as > > > > > > > > nr_pages = min_t(unsigned long, > > > > folio_nr_pages(folio), page_count - i); > > > > nr_pages = min_t(unsigned long, nr_pages, max_pages); > > > > > > Do you think the min_array() is less clear? Let's see what others say. > > > > min_array() is clear, it's the ((unsigned long[]) { ... }) that > > iis nice and fancy but of difficult first read. But, as I said, > > it can stay, I don't have a strong opinion, maybe I'd have done > > the same. > > Would you be more happy with a locally declared unsigned long table, > initalized with those 3 values, nr_pages - i and max_segment << PAGE_SHIFT > statically, folio_nr_pages(folio) once folio is ready, then passed to > min_array()? mine was only an idea, I'm fine with what it is now if no one has anything against it. Perhaps, just a little comment could help understand why we are evaluating out of three elements (but we are talking trivial details here :) ). Thanks, Andi