Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5439148rwb; Tue, 1 Aug 2023 02:32:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlH4wRNLpZzR51ben5ncqhSZchzu5vR9pZjTSH00+dMjRZfl1NZR9f48xGAk4K/nuazSaIJX X-Received: by 2002:a17:907:a079:b0:99b:4378:a5aa with SMTP id ia25-20020a170907a07900b0099b4378a5aamr1949916ejc.49.1690882373573; Tue, 01 Aug 2023 02:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690882373; cv=none; d=google.com; s=arc-20160816; b=CLOKCHSfb5LK3mFVGO7YMiAYGZdcYXxoGcGhS6SOnhsNyihqeAuPvt4i3g12qXJ1aW nlxjZc08F07ZKisl+hu5j6bJKAaPsOQteFJjV1c4uKGr+4l13w48KU+eyq/2/Q1KP6Ov GM+uATuWIIkQuPyQiio53qnHOB6DtXpddGq5dGHvbMiuGW2KrVkWFp++ddSbuMixafFv C1VGyq+i1EdjvgwlyVnufeZt9fcVWlqGXcuirB3g9g1L/Phq14qJLi+13O5Jwz7AogzX jK43YaFbOvi+KLKYy3DcGvsJAvR42helmgNwrsh7Q69tV5ir4ZqxK1+8nGfJF/FVs+9+ jm5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Zlam6fhtO1Te7rifXFvhpFclvD68LUKtowmBmMeLx6A=; fh=TTF1lt49Sby0rKay1qRjEqWFbUkg3/0Ba8LROUDUaGE=; b=x1k4d7y7Y7t/ArWB9TOLhwykRf/rSlh+0Ki17d0+SRT0kNTZvaoxBA1BuSJIlzswNk 0RQjNa2BkHyG03Q15gXJmWJeRbXTL9QjVAMQ3XrpSmIBtNALcGbCoI6USUxNJKOcTZYC 9W6prUuRv3CM3SyO7V9dP6/ws3jEKD2KC1UFSjol5X2D78lrNYLFTvaxfczt3984nXQv iSNFoUq9/RLPwYIRR6sieR0ifko2jMVxpGg1mPj89AGFsMXaY5iB5aZsU4bpp90pGNGd 3a5ldfSVhJNdLZTSbFkOGcnAV+92/ethEYCvMGolNumCQAuodviMsonvp3Pc27/Djnip 0Hyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gy18-20020a170906f25200b0099bc0888138si8376804ejb.1009.2023.08.01.02.32.28; Tue, 01 Aug 2023 02:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232718AbjHAJRo (ORCPT + 99 others); Tue, 1 Aug 2023 05:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbjHAJRQ (ORCPT ); Tue, 1 Aug 2023 05:17:16 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA0CD2728; Tue, 1 Aug 2023 02:16:18 -0700 (PDT) Received: (from willy@localhost) by mail.home.local (8.17.1/8.17.1/Submit) id 3719DrhR031934; Tue, 1 Aug 2023 11:13:53 +0200 Date: Tue, 1 Aug 2023 11:13:53 +0200 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu Subject: Re: [PATCH v2 06/10] selftests/nolibc: make functions static if possible Message-ID: References: <20230801-nolibc-warnings-v2-0-1ba5ca57bd9b@weissschuh.net> <20230801-nolibc-warnings-v2-6-1ba5ca57bd9b@weissschuh.net> <4ad4b853-b89f-4c5a-a50b-28739d7b81c0@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4ad4b853-b89f-4c5a-a50b-28739d7b81c0@t-8ch.de> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 01, 2023 at 10:50:05AM +0200, Thomas Wei?schuh wrote: > > > An alternative would be to add -g to CFLAGS (and remove -s from LDFLAGS). > > > This way we get full debugability including breakpoints for everything. > > > > It wouldn't change much because while it would allow the debugger to know > > where the function was possibly inlined, it's still not very convenient: > > you believe you're in a function but in fact you're in the caller. It > > really depends what you're debugging but here I don't see all that as > > providing a value, at least it brings more annoyance and little to no > > gain IMHO. > > Even if it doesn't work 100% properly it wouldn't it still be a superset > of the previous functionality? No, we need to be able to disassemble this to understand what was done to the code we believe is being tested. All of us have been dealing with this already, and making that code less mappable from asm to C is quite annoying. > And we don't have to manually keep track of which ones should be static > and which shouldn't (See this discussion). We should not have to be concerned about this, because it's out of the scope of what this "program" is used for. If we're wondering too much, we're wasting our time on the wrong topic. So we have to find a reasonable rule. One that sounds fine to me is to say: - all that's part of the framework to help with testing (i.e. the expect functions, errorname() etc) could be static because we don't really care about them (at least we won't be placing breakpoints there). They may be marked inline or unused and we can be done with them. - user code and the calling stack from main should be easily traceable using gdb and objdump -dr so that when you start with a new arch and it breaks early (as happens by definition when syscalls or crt code don't all work well) then it's possible to accurately trace it without having to worry too much about what was transformed how. > Would it be better with -ggdb? It doesn't change. The thing is: by saying "static" you tell the compiler "I promise it cannot be used anywhere else, do what you want with it", and it can trivially decide to inline all or part of it, or change its number of arguments or whatever as it sees fit because no other code part relies on that function. And when you're trying to disassemble your test_mmap_munmap() and can't find it and can only infer its inlined presence in run_syscall() by seeing a value in a register that vaguely reminds you about __NR_mmap, it's clearly much less easy. > If you are still not conviced I'll drop the argument here :-) > (And the changes in the next revision) No problem, it's fine to discuss the current situation. I've just noticed a number of static on some test functions that would deserve being removed precisely for the reasons above. But that justifies the need for some doc about all this. > > > I didn't find the reasoning for -s in LDFLAGS. > > > > It's historic, because normally when you want small binaries you strip > > them, and the command line was reused as-is, but I agree that we could > > get rid of it! > > I'll remove it. It was annoying to figure out why my "-g" CFLAG didn't > work at all. Yes I can definitely understand! Thanks, Willy