Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp888080ybj; Tue, 5 May 2020 09:07:28 -0700 (PDT) X-Google-Smtp-Source: APiQypLVZEfm/YShKqbotDn1Vg0B2J1cm6Yzu8OXd2f/JRLdFhpP9PI2tfJyPi7KzrSCdkAiR62n X-Received: by 2002:a1c:c2d4:: with SMTP id s203mr4577087wmf.128.1588694848746; Tue, 05 May 2020 09:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588694848; cv=none; d=google.com; s=arc-20160816; b=p+KYN34DBJUkXgFfZkh1jJ1d6GAmdF+AnNKjc2R+ByytcYDRR2eb6awMdBcvInSuoL rUV/dnPJITxuigD4p6RBYsPfR3emjjt5tJTNKtEIRoPZI5Sm9Uu3aOA0ytY1iVc2/SLd EWX6LmaZL3xj0HRfNpkM3jXorZsWbQP0diQknHSsVNRiRWKqX0FIopkOFogLL9ENo1yP RWZquxCHgPw3KbEkPD1gAVkFioExnokLcluMsTmLWgipwd8zR/OuGKczai9MKSnnven1 j5yoJGkaCa1V3yEVHAVAj50GzT7sV3AmrZ9e0DjPj/n23uEZrqJSx3RvEUU1ZB8BTKHG OsxQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=9Y5FqZzub22TsbFAalRIGVy7bbG5ElObgbHv9gg5Ubk=; b=y8VJRz0goymygnx5Ir5qCSovEaURk03gjFzqTIVlvSpZT/DGLZnnWtUzpHIizccScT 6stPkddo1DFSm3qN7Gf0IZqcF7WJ6wvbuOG0ORXMCmgPr/AVRNqZZM9z3qpR8r6egBu3 erW5RJCmZr/Pjky7ubcnEc7bfP/8RMn3kOQw+cD/OB2+zhoqYek2BwNxQ89X/5ttou4/ SFSCz8NyByRQtt5EOaDZ5xmCv8wx71G2D/4R4iCPbq/rU9Kul3TCHIMBAIcCFZpBA6h3 FvQQVyFGYFw3nKiMRQvsTi0a9HHiKDJl5tqgwekmN2MSC1laltZP/OlQJnBwXUflHt0A v/eA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si1387238edw.356.2020.05.05.09.07.03; Tue, 05 May 2020 09:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729315AbgEEQCV (ORCPT + 99 others); Tue, 5 May 2020 12:02:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:45822 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728804AbgEEQCV (ORCPT ); Tue, 5 May 2020 12:02:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8B845AEFD; Tue, 5 May 2020 16:02:21 +0000 (UTC) Subject: Re: [PATCH] xenbus: avoid stack overflow warning To: Arnd Bergmann Cc: Boris Ostrovsky , Stefano Stabellini , Yan Yankovskyi , Wei Liu , xen-devel , "linux-kernel@vger.kernel.org" , clang-built-linux References: <20200505141546.824573-1-arnd@arndb.de> <30d49e6d-570b-f6fd-3a6f-628abcc8b127@suse.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <48893239-dde9-4e94-040d-859f4348816d@suse.com> Date: Tue, 5 May 2020 18:02:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.05.20 17:01, Arnd Bergmann wrote: > On Tue, May 5, 2020 at 4:34 PM Jürgen Groß wrote: >> On 05.05.20 16:15, Arnd Bergmann wrote: >>> The __xenbus_map_ring() function has two large arrays, 'map' and >>> 'unmap' on its stack. When clang decides to inline it into its caller, >>> xenbus_map_ring_valloc_hvm(), the total stack usage exceeds the warning >>> limit for stack size on 32-bit architectures. >>> >>> drivers/xen/xenbus/xenbus_client.c:592:12: error: stack frame size of 1104 bytes in function 'xenbus_map_ring_valloc_hvm' [-Werror,-Wframe-larger-than=] >>> >>> As far as I can tell, other compilers don't inline it here, so we get >>> no warning, but the stack usage is actually the same. It is possible >>> for both arrays to use the same location on the stack, but the compiler >>> cannot prove that this is safe because they get passed to external >>> functions that may end up using them until they go out of scope. >>> >>> Move the two arrays into separate basic blocks to limit the scope >>> and force them to occupy less stack in total, regardless of the >>> inlining decision. >> >> Why don't you put both arrays into a union? > > I considered that as well, and don't really mind either way. I think it does > get a bit ugly whatever we do. If you prefer the union, I can respin the > patch that way. Hmm, thinking more about it I think the real clean solution would be to extend struct map_ring_valloc_hvm to cover the pv case, too, to add the map and unmap arrays (possibly as a union) to it and to allocate it dynamically instead of having it on the stack. Would you be fine doing this? Juergen