From patchwork Thu Oct 3 15:50:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 175151 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp573618ill; Thu, 3 Oct 2019 09:43:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCUJrYw/zfqYQY9USa16sC8pM4GnyWdU90zfRcHHwPsmd3R6R0UkSsyJd05y9DPeUv6NRo X-Received: by 2002:aa7:dad3:: with SMTP id x19mr10555062eds.59.1570120858968; Thu, 03 Oct 2019 09:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120858; cv=none; d=google.com; s=arc-20160816; b=g+IXaxans6W6l7ZcJr5Ocm+sdZZAQVjkOkr/s37jSnV/+fyIPyK/rJODrmFMYd3vYR RLM3KTdvPIK3r3jZMhW3OptQPJcUBDRaFiIAhQ3BiYEqHFcP+XaQTs7mbvwVsa/3tuok Dq6On7M89+4jrUIdWpE3cI1raTSz/IWwnMyaqNGXPaMldbU8/szeQvXkWunrwKnNuZkY h5n8pXIVDonqrT3toGegJ9l3fJYPFUR15G/c8wPiWydaVexD7WL6QTa8KsDQ0hRMugko Tq79Ebkd+y4dNcOopABEMeOEfY0NFMQueVrB4BJxJbU9Z8J7hpKHk+U3wa4V1QOTHk7I Sxfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gjz9DCtJe6QcVFxELkDHyRozyHnXEhHPknlw+GIrEEY=; b=dusenh6BFPrQi+QnCHDk3bHkk5HqmU7GEY1NS/vqudR6xf7JNREzJsb3n5wG+XzfI4 wx5cIcj8Ac60hHChTSJZopGEUmkAd138HwKwyex9uFxHsYSmQQH/nXsFfYe7jcjDdUUI x6LrTmVlK6rgUvXpu15Jyo5qZMm8yD2BXJCEUAyOao+gICH1tqHWgm6nr0W7xtgQdnmc TsszXlzJSUNgSCRhwAb1j2hZdXdrtyxPYuvEOLZV8wu6np8I5ybit96bVjEGI9VMIJO7 R0dvoZHXSo+TI+g/pVEVRiuhYLUva+p0D/BvZrgaAZ5YK7x3m+4cuje1wrz+b0f0vc1f 1x9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UE2lttBd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sb7si1581045ejb.321.2019.10.03.09.40.58; Thu, 03 Oct 2019 09:40:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UE2lttBd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404978AbfJCQkz (ORCPT + 27 others); Thu, 3 Oct 2019 12:40:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:51038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404950AbfJCQkr (ORCPT ); Thu, 3 Oct 2019 12:40:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CD0872070B; Thu, 3 Oct 2019 16:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120846; bh=CKOJhoQWKwRHugdFdAlJKtgD9dw0sIWNrDvnzJWLrKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UE2lttBddwxvIOCXE5IWG3P2TCZLNX83wUpwqg6RcGK3jdyOhcUj04JZQ3KDSqQy6 26Mf9atrk+bD+ze+dFgJQyVSA8W4vphjdkZTu7mqWwUFZlF+yirNizdWOQbrdV2OnW 83oyucdbg8/VerRL1kOcIc8JTIBB5wFxKzRQ4fWs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Nick Desaulniers , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.3 058/344] media: vivid: work around high stack usage with clang Date: Thu, 3 Oct 2019 17:50:23 +0200 Message-Id: <20191003154545.857596867@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154540.062170222@linuxfoundation.org> References: <20191003154540.062170222@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit 1a03f91c2c2419c3709c4554952c66695575e91c ] Building a KASAN-enabled kernel with clang ends up in a case where too much is inlined into vivid_thread_vid_cap() and the stack usage grows a lot, possibly when the register allocation fails to produce efficient code and spills a lot of temporaries to the stack. This uses more than twice the amount of stack than the sum of the individual functions when they are not inlined: drivers/media/platform/vivid/vivid-kthread-cap.c:766:12: error: stack frame size of 2208 bytes in function 'vivid_thread_vid_cap' [-Werror,-Wframe-larger-than=] Marking two of the key functions in here as 'noinline_for_stack' avoids the pathological case in clang without any apparent downside for gcc. Signed-off-by: Arnd Bergmann Acked-by: Nick Desaulniers Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/vivid/vivid-kthread-cap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c b/drivers/media/platform/vivid/vivid-kthread-cap.c index ed466d737a90d..003319d7816d7 100644 --- a/drivers/media/platform/vivid/vivid-kthread-cap.c +++ b/drivers/media/platform/vivid/vivid-kthread-cap.c @@ -232,8 +232,8 @@ static void *plane_vaddr(struct tpg_data *tpg, struct vivid_buffer *buf, return vbuf; } -static int vivid_copy_buffer(struct vivid_dev *dev, unsigned p, u8 *vcapbuf, - struct vivid_buffer *vid_cap_buf) +static noinline_for_stack int vivid_copy_buffer(struct vivid_dev *dev, unsigned p, + u8 *vcapbuf, struct vivid_buffer *vid_cap_buf) { bool blank = dev->must_blank[vid_cap_buf->vb.vb2_buf.index]; struct tpg_data *tpg = &dev->tpg; @@ -672,7 +672,8 @@ static void vivid_cap_update_frame_period(struct vivid_dev *dev) dev->cap_frame_period = f_period; } -static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs) +static noinline_for_stack void vivid_thread_vid_cap_tick(struct vivid_dev *dev, + int dropped_bufs) { struct vivid_buffer *vid_cap_buf = NULL; struct vivid_buffer *vbi_cap_buf = NULL;