Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp711366rdb; Tue, 5 Dec 2023 19:01:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9Ny6ptBnphgB1LvglS5TDii5/sN6rSs7x+9M2sxPBVLEurw77FzWICn7uyWBuAwDLVbCB X-Received: by 2002:a05:6a00:150c:b0:6ce:8261:58fb with SMTP id q12-20020a056a00150c00b006ce826158fbmr147435pfu.14.1701831676727; Tue, 05 Dec 2023 19:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701831676; cv=none; d=google.com; s=arc-20160816; b=fbqO5rLz+sKU3n+w+XOAmDQllsOlxG0rngl6JpoYWLJ+IonQKIDZLffccwJpuWN65P ZZCvmhNdUK2Bz6O3kn4OnzH/mCaMN0AqP4yj99w93trJ1Vl7+isssGMLeG7l1TVfHY0J 3nXyYbc5pFv1pVhX7tqHXwaFjL+O1ug+Lc8JsejxcTBPDB0RjvukHJLhi659iNFQWdvj xa+Y6KVg2uY+pY487YSioe9JEwmK9fwW/saDueqI3fpUI7BPhaEPQ0pyxdEoXxa/Ra8H vMlDo9fyvPmOhglu3d7TYtJM7/PupEBVCvIjw01F5t66I1SbluMfpxidxSYJUJnkzvNV fVQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CRYeTAu4svuvDJpTKsWkQ36MOqp3Y1tO+HPMsezk7QU=; fh=Bn+dNc76c52z0y0i4AgMMBNkkaBE/SaonuxRzZuZRZc=; b=cAm9xQxaf+5GNw/bUNH0tAJhitMs7bAA0RvIVRhQ235p326jPaLTPUlvXRHBp4JT+B Yimm7WjKLGNwNNpnbL9fZNYlgOdJz8GhxAJ3o7dxOViBpCDVMudauHS0h6BDrEUnr8sD /k1VJVvA7vz2LLTeZIZrxHzHmXlLobB9f2wTR4ALi4bF9qQpfAYOpzMybg5N1ymBEypO ygvCnoejYU7Yo20Iaj2H4kKKNGTLv8QhQtJD3ZaafaYona5u37Pne86Ll12hNjGh/2FX oDpE+rvZZwyX7YbW9ScdN+drgQZylWdEScVkSX0+5/z9z+mEn57JGZ04Gs1OIUlEl+Ek ZzUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b="UGCB/HMx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q20-20020a656854000000b005b92b048254si6375733pgt.201.2023.12.05.19.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 19:01:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b="UGCB/HMx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1018D82C5175; Tue, 5 Dec 2023 19:01:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbjLFDAs (ORCPT + 99 others); Tue, 5 Dec 2023 22:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbjLFDAr (ORCPT ); Tue, 5 Dec 2023 22:00:47 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B79F1AA; Tue, 5 Dec 2023 19:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CRYeTAu4svuvDJpTKsWkQ36MOqp3Y1tO+HPMsezk7QU=; b=UGCB/HMxCuoH0kFgL4hrI3koRN ATSArs23UpdraQQVBBYMojJjygn1M1gqfoTIlWDBwto1vZDJhu7MgpKz4D4+Xudb3C1Rpp+3pGN6k FD4NljAXVHQq7905LuDDH5T34DBSZa8NGrfJOalyKhAMplJM7FUGPNVZxtapsE1DP4wrT1PpGMe+R 17NDxSvSIzv1DGg41XUagyV+JVvsIvjk19blOHoeFWDJT3WZTos+LJE4iZiKRqnW+uN3/q9uOtSAD ICFYUVuT1SkRdC3xKwHSPHd3ZZDEuO8TvG6SYoZJx48PNXw5/c3R7wi7cCXF/JYG+zyzEmgXS8Wce l3MlFD7g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rAi9X-007Yl3-1L; Wed, 06 Dec 2023 03:00:47 +0000 Date: Wed, 6 Dec 2023 03:00:47 +0000 From: Al Viro To: Greg KH Cc: Nick Desaulniers , tanzirh@google.com, Kees Cook , Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nick DeSaulniers , Andrew Morton , llvm@lists.linux.dev Subject: Re: [PATCH] lib/string: shrink lib/string.i via IWYU Message-ID: <20231206030047.GL1674809@ZenIV> References: <20231205-libstringheader-v1-1-7f9c573053a7@gmail.com> <20231205213807.GE1674809@ZenIV> <2023120608-ivy-snowdrop-890d@gregkh> <2023120657-henna-spongy-9ef6@gregkh> <20231206005542.GJ1674809@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231206005542.GJ1674809@ZenIV> Sender: Al Viro X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 19:01:13 -0800 (PST) On Wed, Dec 06, 2023 at 12:55:42AM +0000, Al Viro wrote: > On Wed, Dec 06, 2023 at 08:46:50AM +0900, Greg KH wrote: > > > > > > > > But of course, it doesn't always hold true, there are a few minor > > > > exceptions, but they are rare. > > > > > > $ grep -r \\#include lib | grep asm > > > > > > shows quite a few exceptions, and just in lib/. > > > > > > For example, lib/math/int_log.c includes asm/bug.h. Is that a case > > > where lib/math/int_log.c should be #include 'ing linux/bug.h rather > > > than asm/bug.h? > > > > Probably yes, but we don't normally go back and take coding style fixes > > for old files like this as it doesn't make much sense to do so. > > > > But, if you are cleaning up the headers for large portions with the goal > > of faster builds, that's a good reason. > > FWIW, the most common (by far - about 13% of such includes, over drivers/, fs/, > mm/, net/ and sound/) is asm/unaligned.h. Why the hell is unaligned.h in asm/*, anyway? We have 3 variants: arc, parisc and generic (== everything else). Both arc and parisc instances have an explicit include of asm-generic/unaligned.h (i.e. the generic variant). On arc there's also misaligned_fixup() extern or stub, with exactly one user (in arch/arc/kernel/traps.c). On parisc there are externs for handle_unaligned() and check_unaligned() (3 call sites, all in arch/parisc/kernel/traps.c). How about we take those into arch/{arc,parisc}/kernel/unaligned.h, slap #include "unaligned.h" into their traps.c and unaligned.c (callers and definitions resp.) and strip those from asm/unaligned.h? At that point we can remove arch/{arc,parisc}/asm/unaligned.h - everything will pick include/asm-generic/unaligned.h. Then the next cycle we ask Linus to run the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild right before releasing -rc1 and asm/unaligned.h is gone... Completely untested delta (for the non-automatic parts, that is) follows: ------------------ arc, parisc: get rid of private asm/unaligned.h Declarations local to arch/*/kernel/*.c are better off *not* in a public header - arch/{arc,parisc}/kernel/unaligned.h is just fine for those bits. With that done these asm/unaligned.h instances are reduced to include of asm-generic/unaligned.h and can be removed - unaligned.h is in mandatory-y in include/asm-generic/Kbuild. Signed-off-by: Al Viro --- diff --git a/arch/arc/include/asm/unaligned.h b/arch/arc/include/asm/unaligned.h deleted file mode 100644 index cf5a02382e0e..000000000000 --- a/arch/arc/include/asm/unaligned.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) - */ - -#ifndef _ASM_ARC_UNALIGNED_H -#define _ASM_ARC_UNALIGNED_H - -/* ARC700 can't handle unaligned Data accesses. */ - -#include -#include - -#ifdef CONFIG_ARC_EMUL_UNALIGNED -int misaligned_fixup(unsigned long address, struct pt_regs *regs, - struct callee_regs *cregs); -#else -static inline int -misaligned_fixup(unsigned long address, struct pt_regs *regs, - struct callee_regs *cregs) -{ - /* Not fixed */ - return 1; -} -#endif - -#endif /* _ASM_ARC_UNALIGNED_H */ diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index 9b9570b79362..8e40f0881e02 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -20,6 +20,7 @@ #include #include #include +#include "unaligned.h" void die(const char *str, struct pt_regs *regs, unsigned long address) { diff --git a/arch/arc/kernel/unaligned.c b/arch/arc/kernel/unaligned.c index 99a9b92ed98d..d2f5ceaaed1b 100644 --- a/arch/arc/kernel/unaligned.c +++ b/arch/arc/kernel/unaligned.c @@ -12,6 +12,7 @@ #include #include #include +#include "unaligned.h" #ifdef CONFIG_CPU_BIG_ENDIAN #define BE 1 diff --git a/arch/arc/kernel/unaligned.h b/arch/arc/kernel/unaligned.h new file mode 100644 index 000000000000..5244453bb85f --- /dev/null +++ b/arch/arc/kernel/unaligned.h @@ -0,0 +1,16 @@ +struct pt_regs; +struct callee_regs; + +#ifdef CONFIG_ARC_EMUL_UNALIGNED +int misaligned_fixup(unsigned long address, struct pt_regs *regs, + struct callee_regs *cregs); +#else +static inline int +misaligned_fixup(unsigned long address, struct pt_regs *regs, + struct callee_regs *cregs) +{ + /* Not fixed */ + return 1; +} +#endif + diff --git a/arch/parisc/include/asm/unaligned.h b/arch/parisc/include/asm/unaligned.h deleted file mode 100644 index c0621295100d..000000000000 --- a/arch/parisc/include/asm/unaligned.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_PARISC_UNALIGNED_H -#define _ASM_PARISC_UNALIGNED_H - -#include - -struct pt_regs; -void handle_unaligned(struct pt_regs *regs); -int check_unaligned(struct pt_regs *regs); - -#endif /* _ASM_PARISC_UNALIGNED_H */ diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index 1107ca819ac8..7ab0d44ef698 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -47,6 +47,8 @@ #include #include +#include "unaligned.h" + #if defined(CONFIG_LIGHTWEIGHT_SPINLOCK_CHECK) #include #endif diff --git a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c index ce25acfe4889..39cd222366bb 100644 --- a/arch/parisc/kernel/unaligned.c +++ b/arch/parisc/kernel/unaligned.c @@ -15,6 +15,7 @@ #include #include #include +#include "unaligned.h" /* #define DEBUG_UNALIGNED 1 */ diff --git a/arch/parisc/kernel/unaligned.h b/arch/parisc/kernel/unaligned.h new file mode 100644 index 000000000000..c1aa4b12e284 --- /dev/null +++ b/arch/parisc/kernel/unaligned.h @@ -0,0 +1,3 @@ +struct pt_regs; +void handle_unaligned(struct pt_regs *regs); +int check_unaligned(struct pt_regs *regs);