Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp575329rdb; Tue, 5 Dec 2023 13:25:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYAwgB15UfmOYk6aHfNCe/8SbXE2cmO2HCRftMi1SKNHZDR9IC6G8Dicu8Uixu/5WreOSZ X-Received: by 2002:a92:d98e:0:b0:35d:59a2:bbe with SMTP id r14-20020a92d98e000000b0035d59a20bbemr4083199iln.84.1701811506749; Tue, 05 Dec 2023 13:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701811506; cv=none; d=google.com; s=arc-20160816; b=mX/BKbtWZubJRoE7XyoBsn5dOCrMSHOL4GVnb8d77PdiObaF+O6XgRzVJdl2SoyMZw bSnPza6ZWTPF516uf6zdZWsmiUQjSsefFMQk1IdwlNl+gCIqjpXp66c4S3ZZPB0LMjf+ tsY64qIQ10G1Owp3LZbiMUL1tgzwoFhv+EdwHr+JDDoptrRcCSakHidOCj0dV6shSq5U kM3lqg5G9VMfv31s1xv7lotkc5da93hYmqepccccYGJw7v2gdLeTOmRPzleFV5t2MTvC AAfSCKKnIlHTMksKsnRNCx2MXes1hUh58nbwFh4wuhSsPxQTuN9SeoPALoCchoo4kPKY GQjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=x93+NXckBYfQSm+9xetJF1UEjcYGyRrb3SBJkdnNlzw=; fh=gg0lhDnHJ6bqpiaX9n2eAMpz2pZxSqGJSxase9R2HQU=; b=uqaLqVhE2o4TCcM2V7zwFwtjXGfiRdfo8TeN7Y4mIaov1eoAuHXBQkBgOtN3nKnY7i SVOrS27yl15DRlaoJcR+zu+zrNSWcQdPN408/jGedQ+uWAdG+U8EdtLfQtnB2Bt7Z+vO sXLig2IDe4wWvEAzd6jY9kLWNN0Udspn3l7rAG8YHgZkHoY9ubfpJWA/byTikmnw6E5v KyHDLy65GOTunAz5FzfKgsQLZyG2Sk+8SN6ZrUOfkB1px6/M+EBrm0qZRjIePUYYDXBG VPHghLJoCvyZfsUJXVXA0CNPb0VpTutI9zUMeL5q0LW/18urU8FLkEZgegwdDrAQynME y6JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=eA4NeptR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n186-20020a6327c3000000b005c690ba4078si3981755pgn.410.2023.12.05.13.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 13:25:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=eA4NeptR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B4B79803EBAD; Tue, 5 Dec 2023 13:25:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345724AbjLEVYr (ORCPT + 99 others); Tue, 5 Dec 2023 16:24:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjLEVYr (ORCPT ); Tue, 5 Dec 2023 16:24:47 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C2AA5 for ; Tue, 5 Dec 2023 13:24:53 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CD60C433C8; Tue, 5 Dec 2023 21:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1701811493; bh=ziKcsiIBH+rVgZNoT8/bVPVFDuiUG8Ohd3nbih5ZSno=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eA4NeptRfWGP7RLlgV6CwB/RCO8zJvjm+FnpVCfH/n2QN2xI21GwNZG5xrmz3d3O3 1FgZpw89cd+LbAipWDBToGBVvr27rX6YcPXkXC81dWlzwt7Entb+gzzVSvi2WBZzH6 qJOPUZ+SGN30v32YbnJeUXj+oZC/8QeIb7h3XVMM= Date: Tue, 5 Dec 2023 13:24:52 -0800 From: Andrew Morton To: Nick Desaulniers Cc: tanzirh@google.com, Kees Cook , Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nick DeSaulniers , llvm@lists.linux.dev Subject: Re: [PATCH] lib/string: shrink lib/string.i via IWYU Message-Id: <20231205132452.418722bea8f6878dca88142a@linux-foundation.org> In-Reply-To: References: <20231205-libstringheader-v1-1-7f9c573053a7@gmail.com> <20231205130449.8e330a26ecbed1f7b5ad5d7a@linux-foundation.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Tue, 05 Dec 2023 13:25:04 -0800 (PST) On Tue, 5 Dec 2023 13:14:16 -0800 Nick Desaulniers wrote: > > > > The preferred way to import bit-fiddling stuff is to include > > . Under the hood this may include asm/bitsperlong.h. Or > > it may not, depending on Kconfig settings (particularly architecture). > > > > Just triple checking my understanding; it looks like > include/linux/bits.h unconditionally includes asm/bitsperlong.h (which > is implemented per arch) most of which seem to include > asm-generic/bitsperlong.h. > > include/linux/bits.h also defines a few macros (BIT_MASK, BIT_WORD, > BITS_PER_BYTE, GENMASK, etc). If lib/string.c is not using any of > those, why can't we go straight to #including asm/bitsperlong.h? That > should resolve to the arch specific impl which may include > asm-generic/bitsperlong.h? It's just a general rule. If the higher-level include is present, use that. Because of the above, plus I guess things might change in the future. We've been getting better about irregular asm/include files. But bits.h is a poor example. A better case to study is spinlock.h. If this tool recommended including asm/spinlock.h then that won't work on any architecture which doesn't implement SMP (there is no arch/nios2/include/asm/spinlock.h).