From patchwork Tue Oct 19 19:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12570995 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A5DDC433F5 for ; Tue, 19 Oct 2021 19:18:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EA0D36135F for ; Tue, 19 Oct 2021 19:18:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EA0D36135F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2923F6E869; Tue, 19 Oct 2021 19:18:22 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC5C26E869 for ; Tue, 19 Oct 2021 19:18:20 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id BD43A60EE2; Tue, 19 Oct 2021 19:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634671100; bh=gQ8mFwkO2LHy0BaSGZp8wy9fYbOMNeZ+u2d3mSVXVjc=; h=From:To:Cc:Subject:Date:From; b=YWX3iEMh3xVmNbS9D1V3gsCoaa9IpyGzVbxWcU7EVHqorf7b24KMocLmkT4Z9R/Qd YVCGGboYxN6f0gksXEAQfzaaLhwb+K6WmHpWqfhuGvRTtXcFU+t3WsKC1Qvz/gHwQl 3KmarBccafeAP/R9LAGYymZpJQs3w6IuY0s8cwHXgGMkCSGtjeh0ApmWJUjboJA37V hWno2+j8UKNCggoOpcuX6L6/YGG8b9w16pgQY+aXB/bIYlVaAF4SuTytjp/8XoAbX+ zczigJtCvQZIaB4DO7cHmEqivd+/glA34CP50uvUvycp3Te57VIvxQl0hhPLsGjleI UNiEAc5bG0S+w== From: Arnd Bergmann To: David Airlie , Daniel Vetter , =?utf-8?q?Christian_K=C3=B6nig?= , Nirmoy Das , Chris Wilson Cc: Arnd Bergmann , Lee Jones , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] [SUBMITTED 20200529] drm/selftests/mm: reduce per-function stack usage Date: Tue, 19 Oct 2021 21:18:06 +0200 Message-Id: <20211019191815.3159266-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 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" From: Arnd Bergmann The check_reserve_boundaries() function has a large array on the stack, over 500 bytes. It gets inlined into __igt_reserve, which has multiple other large structures as well but stayed just under the stack size warning limit of 1024 bytes until one more member got added to struct drm_mm_node, causing a warning: drivers/gpu/drm/selftests/test-drm_mm.c:371:12: error: stack frame size of 1032 bytes in function '__igt_reserve' [-Werror,-Wframe-larger-than=] As far as I can tell, this is not nice but will not be called from a context that is already low for the kernel stack, so just annotate the inner function as noinline_for_stack to ensure that each function by itself stays under the warning limit. Fixes: 0cdea4455acd ("drm/mm: optimize rb_hole_addr rbtree search") Reviewed-by: Chris Wilson Link: https://lore.kernel.org/all/20200529201534.474853-1-arnd@arndb.de/ Signed-off-by: Arnd Bergmann --- This happens rather rarely, I just ran into it again and found my old patch. --- drivers/gpu/drm/selftests/test-drm_mm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c index b768b53c4aee..76973c72855e 100644 --- a/drivers/gpu/drm/selftests/test-drm_mm.c +++ b/drivers/gpu/drm/selftests/test-drm_mm.c @@ -324,9 +324,8 @@ static bool expect_reserve_fail(struct drm_mm *mm, struct drm_mm_node *node) return false; } -static bool check_reserve_boundaries(struct drm_mm *mm, - unsigned int count, - u64 size) +static noinline_for_stack bool +check_reserve_boundaries(struct drm_mm *mm, unsigned int count, u64 size) { const struct boundary { u64 start, size;