Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp600193rdb; Tue, 5 Dec 2023 14:21:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IH84oklaQqCIXJv+b+xZ76ObszKAqj+h4lyifpURVhF76FWDakzvhzHJtqPEE6etp/21BrN X-Received: by 2002:a17:90a:ad42:b0:286:6cd8:ef01 with SMTP id w2-20020a17090aad4200b002866cd8ef01mr2346050pjv.25.1701814876412; Tue, 05 Dec 2023 14:21:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701814876; cv=none; d=google.com; s=arc-20160816; b=ZOWCe4v3mx0ahXXErC2ZQnBiCwH3DCHl3k/jw6LpQAW5rGd8Rhn2uWaWm1Y3G6UJcS eNE84+B22EdkqQTFucVWQylUXpi3ftHVbTg8RnDfzqO9dZU0pH2hJvHCEKyj6WKWQvo2 /cokR6PUTMRg/7sMvH6sgDNNOhwC1kgAwapyXhSDX8y40i5V6X0AV58m6J6cmlqWHXhd 96zHZK6penx6woy85kIv/pUlWlNruqEkt2SoOdSXuHbmRQ+zEsUvrROrDBnMr4or2k2q zVs6HnNdAU6VjINq7wzB3dwL3BPuAnNc1HM1fyGVkJWG5vj9xDk5s2YPuOvZHaaew/sp 03TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OtdgYO2/5wzcNxCn3VtqicgQzIviRp5CjfOT6b/JWQ0=; fh=XGtB8XHf6F8N0LUD5bjPUjq0MkVidbTOjbEz/MfhQQo=; b=KyoJZasdUY068wUPJQyOyKOG2W4g8UNl2NWMx/CpmwbV9dkOc/ZROPpHtl1907Opsi W9T64+bRyuEHvS8N8/IyjdKCcThPy9/HBpThKQ12+oCQ5x/c5srRmLBYSWJqHu5thkig K31A9qZk4YoJM9lBJktLWOg4oJ1K5E0nu+NXn85ErpXUQpN+gkcAKw70bJcEvuzYD8kp 97VCq4fSHB+UmfshvUsjfPih+3kIbo+0EqFo8M1pSJOdfytTJNDPYdnnoXnndesUSmUk Zn9Fedomh9ciZKRsHIBJD+5oW1tnwyWDkClClkT6yw8+25NbTygAM/LvWnOEJ1bD+Zan RPcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tRlIzDb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id hb18-20020a17090b209200b00286edd97032si1049042pjb.134.2023.12.05.14.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 14:21:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tRlIzDb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 08E3680BD276; Tue, 5 Dec 2023 14:21:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346478AbjLEWVE (ORCPT + 99 others); Tue, 5 Dec 2023 17:21:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbjLEWVC (ORCPT ); Tue, 5 Dec 2023 17:21:02 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1ACD137 for ; Tue, 5 Dec 2023 14:21:08 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40b2ddab817so64122565e9.3 for ; Tue, 05 Dec 2023 14:21:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701814867; x=1702419667; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OtdgYO2/5wzcNxCn3VtqicgQzIviRp5CjfOT6b/JWQ0=; b=tRlIzDb4uNTyUDRQFsBCDd/+gfoE++6balB9VVWBmuUjCJgBqdWGvBCYS2WmJHZVNH 6Lf2Tpb03aCOEZLQwf5C7xy5VE0OAmKr4P3jRWRhJT8DSOh3fne6oM9sXjrB0QE4Sf1m kbIpvzl4OSyU31MSYwWPilXOdCaX3uLu/PMtFw4994vdLmaQt7fE1DK7s6//1oRNfzng p4z+9vR0uVQ5+2QIXGAuW08MGoTo3WTqGQvczcP100NO0tHfChR5dFWMDQzYBvwsDfK1 5SXFf4AVcBRMeuAaMTXoz/6aOUImGXoMRFukQIIIhpZR76LjB4bHwYCwuqd63kXhakmS L3tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701814867; x=1702419667; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OtdgYO2/5wzcNxCn3VtqicgQzIviRp5CjfOT6b/JWQ0=; b=QUTMhWVDRLAjoiBsntcyZqvsjQwY2Uo6r31WW05oI36crHo6FlxMkL7kpGwqRfaaCE HleY4GBOh/0KKwb+cbe0r+kywp9YO1Jx2cbUXrc7+9f9+DEZVGnKjjp+ZD5zi3ECthni Qhw67328nPov55DpjU7/mK1NDjka6y8Jg66fR9EoKpWpeViVBw/8GSGXY2u+pBJ+alFj DZ6DyUmrN3lQM1qBPtOvBqdwaKWRB/wehRn1Ar8rCjzzV8UkLF5b0sy9ZO7POfFEa975 J4O9TZXqz05dI6itp+HFypLQUtxQZ6ps85xIWFZ+PppLfoIVcd/9Rmv01IRby3LzdGv/ veDg== X-Gm-Message-State: AOJu0YxIRWxYkdaILFCAdrrMVXmSjhBm33/dzzobSFiLLJ8jTIid1Uto ocUAeG+VTd3e0zz+YKXAu+JNaJVQRLDbEFyZ4EAyLQ== X-Received: by 2002:a05:600c:4f81:b0:40c:67a:b3bc with SMTP id n1-20020a05600c4f8100b0040c067ab3bcmr14832wmq.71.1701814867131; Tue, 05 Dec 2023 14:21:07 -0800 (PST) MIME-Version: 1.0 References: <20231205-libstringheader-v1-1-7f9c573053a7@gmail.com> <20231205213807.GE1674809@ZenIV> <20231205221521.GH1674809@ZenIV> In-Reply-To: <20231205221521.GH1674809@ZenIV> From: Nick Desaulniers Date: Tue, 5 Dec 2023 14:20:55 -0800 Message-ID: Subject: Re: [PATCH] lib/string: shrink lib/string.i via IWYU To: Al Viro , Andy Shevchenko Cc: tanzirh@google.com, Kees Cook , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nick DeSaulniers , Andrew Morton , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 05 Dec 2023 14:21:15 -0800 (PST) On Tue, Dec 5, 2023 at 2:15=E2=80=AFPM Al Viro wr= ote: > > On Wed, Dec 06, 2023 at 12:01:56AM +0200, Andy Shevchenko wrote: > > On Tue, Dec 05, 2023 at 01:51:10PM -0800, Nick Desaulniers wrote: > > > On Tue, Dec 5, 2023 at 1:38=E2=80=AFPM Al Viro wrote: > > > > On Tue, Dec 05, 2023 at 08:58:53PM +0000, tanzirh@google.com wrote: > > > > ... > > > > > > > IWYU is implemented using the IWYUScripts github repository which= is a tool that is > > > > > currently undergoing development. These changes seek to improve b= uild times. > > > > > > > > > > This change to lib/string.c resulted in a preprocessed size of > > > > > lib/string.i from 26371 lines to 5232 lines (-80%). > > > > > > > > It also breeds includes of asm/*.h, by the look of the output, whic= h is > > > > not a good thing in general ;-/ E.g. #include *any= where* > > > > outside of linux/uaccess.h is a bad idea. > > > > > > It's not clear to me when it's ok to #include . Is there a > > > convention here that I'm missing? > > > > The mandatory ones can be used, but not all of them. > > In some cases you even must include asm and not linux > > (unaligned.h, byteorder.h, maybe others...). > > > > As I told, it comes with experience, we lack of the > > respective documentation (or file which is good for > > automation checks, like with IWYU). > > It would certainly be nice to have such information in the tree; > "where should I pick $SYMBOL from?" is something one needs to > find out often enough. To a large extent it's covered by "where > in include/*.h do we have it defined?", but that's not all there > is to it. E.g. "get_user() =3D> use linux/uaccess.h". > > There's also stuff like "$SYMBOL should not be used outside of arch/* > and include/*, better use $OTHER_SYMBOL", etc. That's basically one of the tables we maintain. https://github.com/ClangBuiltLinux/IWYUScripts/blob/main/symbol.imp Of course, such a table is a living document; whether it resides in tree or out of tree eventually I don't particularly care either way. There are outstanding questions like "is it even possible to autogenerate such a table (vs manual curation)" and "are the ones we've coded so far correct?" I don't expect to have all of the answers with the initial implementation, but instead to collect feedback from kernel devs and iterate from there. Very helpful responses in this thread so far; we appreciate it. I suspect that folks that have played with IWYU in the past encountered great difficulty since these override tables are poorly documented, and the out of the box defaults assume more of a userspace layout for common definitions (which our script which wraps IWYU disables). --=20 Thanks, ~Nick Desaulniers