Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp582146rdb; Tue, 5 Dec 2023 13:40:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHqDROJ5ThrJFo1pikPJz56VmJk6yc25zEH4k2Tz6MTqdw3mbH4n6Pvgs/oQkQ/Pqs9pjE X-Received: by 2002:a05:6a21:1ca5:b0:18f:97c:4f62 with SMTP id sf37-20020a056a211ca500b0018f097c4f62mr3556483pzb.110.1701812422871; Tue, 05 Dec 2023 13:40:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701812422; cv=none; d=google.com; s=arc-20160816; b=Pzv3lWRCM7OjEE5XVV0bwlGn49xXAC3axk/36vCJKQ+oiSzMx4G2h4N6Q4GjDqnEto PqBkZA9qAvItsTzhDi1S9fNl+WHKRaU0/kDlWgesdJ4Xzs1n2JUBO7sfAHT5LKdy1kjC apHdlvzMijWLDncM/PaTGGlpnG90gAGrwP5zFHA4k0RuIgbzGsDCIcbuGmsnxq7Ta1vo rUcaaJr35Y662vZ8VjQhoHzN90cjVlNO0ZaHp4cdMZf3gAtYbbe3MsIrQJ3+lAy6aRVc q6lDRo+9ffCIljGHooxSAnsjdhCxdCMehZdbSMdR5UW6JL82bOPIgypscrTWWJCASGxt XDSw== 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=/kbHlqbkhYwBbDQLJMz0TJVKvZVaLjuc/LRCzX5dlF4=; fh=wyPa9jhyS/9S9G2ZZJIftNjklABAoq43Vo7AJkCc2nI=; b=w6K+e9AUAT5KtWThHcJU8Qe5Snu/RLkxFs/vGLumj+kpMpviKACFSNQ/D7PGgyZng+ 28gIXljNQG0d3hQhWHvAT7uMY76+V0tZoehfeZA+iYqbl3yKR9dH9uo2AGPQppUjV0sR qrzQ6aJUCiVypbs89gwll5N77NBuXuiDacgEMCYyCiAACB74mb8xTnxTN8VO85M95ylW MHrS0f8hzs17uqfBy/uB/abAfmLp6T4sQUm6IAXYYV7nkDBNFSI+4rwYy45kSey+T7f3 ywQkxKq7yFLwibZcltAYjpdlsWdE4gLP1JqrSifWSR2Hxj4+/QAcuc2EBGRX7WOZomYf oqKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SEl+lJSI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w1-20020aa78581000000b006c0e3332534si5934186pfn.42.2023.12.05.13.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 13:40:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SEl+lJSI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 72ED280B7AF2; Tue, 5 Dec 2023 13:40:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345718AbjLEVj6 (ORCPT + 99 others); Tue, 5 Dec 2023 16:39:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbjLEVj5 (ORCPT ); Tue, 5 Dec 2023 16:39:57 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F3BC6 for ; Tue, 5 Dec 2023 13:40:03 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3316d3d11e1so61625f8f.0 for ; Tue, 05 Dec 2023 13:40:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701812401; x=1702417201; 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=/kbHlqbkhYwBbDQLJMz0TJVKvZVaLjuc/LRCzX5dlF4=; b=SEl+lJSI5/18sOa7xg5F6Zg72YnHaaOuw4X4ako1eM5Weo4rQadC5HKdEB3SDmsfBj XrfJ7nf3psLYjgaZV9JwpfJpWA7bcWUZiI6u7OvExzTH+q22OF/HjMke5fJaspBCcUtx fMxG4lXS0pbIMp/hYQpLh+g35UIjuqWJzPI/PyxqjggmoR3YftbgIuFSO7CMaVBrS45I nmuxxyZASKJvOTry17Rbi1S6vV/LXQmrePsHiTFpLEvM13PL+VYNLTl9EbCrBrjYae1O fROWaaNhKKer6ksIx//XQ91ewO651dw96YZXrgTPrg4V3W33ZlxzZLQaKT4VRo8MIRvi u4qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701812401; x=1702417201; 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=/kbHlqbkhYwBbDQLJMz0TJVKvZVaLjuc/LRCzX5dlF4=; b=R/ATkP0oWA58xyt+dOdfuW8S4NzIYbOr5xdr++ksK33WnuSP3kxHveCafQpeH3r2+n z5korL3r5jM9wXv/p0lnDWyZSYxADBuhzEtF5nii2gIbIGXhotxBmDHDMMXHT6WRcs5c LsJil0SoKrCzCBXnvN252xDsgKTFLhSGxXDm5erMC7E4krGB48etPHX9nWBniiGuODDN ga3vYob5/9qBQI1uIGTOHvaToODT+7lTf5wjX3epMjNa+KHHw37VrIodAmmMOKNyAZjv iEI/3bD2iaQV9mFOBAavPTZ34NFul4zo7ELRTkpoLkPKRwP6bNA37otYbZxKJXX6OW/F ywHQ== X-Gm-Message-State: AOJu0YybUfSvVDhlIWfg8xl68iBYMdDbgmabuCGhsjE64N94y6UQFdDH lLasik6em+3yog0ubp5XumFM7y/df+jHoeSp6h1/+eRTQUGc5y5/oH+WQQ== X-Received: by 2002:adf:ea4a:0:b0:333:3b79:27d7 with SMTP id j10-20020adfea4a000000b003333b7927d7mr1299396wrn.59.1701812401438; Tue, 05 Dec 2023 13:40:01 -0800 (PST) MIME-Version: 1.0 References: <20231205-libstringheader-v1-1-7f9c573053a7@gmail.com> <20231205130449.8e330a26ecbed1f7b5ad5d7a@linux-foundation.org> <20231205132452.418722bea8f6878dca88142a@linux-foundation.org> In-Reply-To: <20231205132452.418722bea8f6878dca88142a@linux-foundation.org> From: Nick Desaulniers Date: Tue, 5 Dec 2023 13:39:47 -0800 Message-ID: Subject: Re: [PATCH] lib/string: shrink lib/string.i via IWYU To: Andrew Morton Cc: tanzirh@google.com, Kees Cook , Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nick DeSaulniers , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 05 Dec 2023 13:40:20 -0800 (PST) On Tue, Dec 5, 2023 at 1:24=E2=80=AFPM Andrew Morton wrote: > > 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. Hmm...how does one know that linux/bits.h is the higher-level include of asm/bitsperlong.h? Do we mention these conventions anywhere under Documentation? > > 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). The tooling Tanzir is working on does wrap IWYU, and does support such mapping (of 'low level' to 'high level' headers; more so, if it recommends X you can override to suggest Y instead). arch/nios/ also doesn't provide a bug.h, which this patch is suggesting we include directly. I guess the same goes for asm/rwonce.h. --=20 Thanks, ~Nick Desaulniers