From patchwork Tue Jul 18 21:11:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13318391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD4C7C001B0 for ; Wed, 19 Jul 2023 06:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lzydxleurKX1n4cQOE5NugH9QlQQE0hTTi8EFmw724A=; b=xuoSc9n4VgJbqA y9QZxLvtbWy0fJaa3w54qYuUZ7+5EvHxYBJyvSwETjtmzcVca5FMPUz/vQwthG8+0RhFl6YroicW4 PJSFmZ5w09XTfgdo5QxMeWPq6sDvv1iEBPqcI/E4oC1B1NwuH4/OZ/w26uizAzeLPI7ZhUEe6VDcD 4z/uze3v3iW66hAgj1nSHanDoEttNctCMHYWFcg7xnHBkEpAJ2EwgTCgNhHolEEFmlgv929+xRVTV hpO54yK57OsLuCtZYfji9HGxxPYFyktI0wDHJ9LA7A7iFC8H2NSN0F8uR/k7B97QIQUaAZvF40K9b pyv/hy9ItR/RGndidkkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM13A-005wgF-1T; Wed, 19 Jul 2023 06:52:40 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM139-005wf2-0x for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Jul 2023 06:52:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=l8R6lNRK1TWCK1AKG93F9HdbW29WXER0ueAedRqGnYY=; b=X329wjxu7w7Y52895xc2SFoI1x V+c6YDIXklDTh86jB8C2WwwgJlOdOzz6z+bENCvgGOBAEg+jwkg/P8taFUnwZ7beZ2Oxbe9jEzNKF xnpr+FPpsU8lkbRSBS3gtdlpXU0BrwMwP7oID36VaU+u+Nidv/lA05hXxJoRaMTwlEhWo5zNRIrpn 0UgMvNcqH/rbv5Tvy3Uq/tHwAuzlEPygJfIYVzII2/d+fSCBlSqQAbMJ3lFNh42GxbL7L5MSB0pW/ ojxBsSOWh9yTrP7vsAaSquxuevqM7/wM9kLtS2UY20cQH9fy3bPc6FFU7ArAaxT4OkYUKzvoLlAWD sMLIWPfw==; Received: from mga07.intel.com ([134.134.136.100]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLrza-00C3CB-2V for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2023 21:12:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689714742; x=1721250742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/GbUJlxD6B4ZMSBm1ruFiwzehTQGXiEYVbSNTGBn/Ao=; b=EIa673/icls4RKAooXCMCR3MvOu0t86Rqas0sPe0JG4oHJbkRjrZxk7T DAmWdlVe0etil+a4C5o/zz0BgSeXxFnJl59INuJNvYLvVtPJuOpM2cyUD SWYP4dAXDU37Pjxgah6Qc8jNDtd9fAAA2RJMeZhWlffe5WPwu2M1Ia3nM LD2yVIuAcFyEOHPUxUX+iX0e5z1sfBLDbNQsLe8p3j6BdCXED5BvahO+C 6H2eCE1TNMeYBL1TXRBkqmHDBlvSs7WnTdc/ZV2WPetO7SZ+URT/SAHls XpsrotjcKyytr00bJWv/QwbbnSlo2uispZbXbBk1ugDyYPIoOws/drpP5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="432495837" X-IronPort-AV: E=Sophos;i="6.01,215,1684825200"; d="scan'208";a="432495837" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 14:11:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="753469039" X-IronPort-AV: E=Sophos;i="6.01,215,1684825200"; d="scan'208";a="753469039" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 18 Jul 2023 14:11:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A9EFC12C; Wed, 19 Jul 2023 00:11:49 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Shuah Khan , David Gow , Daniel Latypov , "Steven Rostedt (Google)" , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Brendan Higgins , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , Masami Hiramatsu , Andrew Morton Subject: [PATCH v4 1/4] kernel.h: Split out COUNT_ARGS() and CONCATENATE() to args.h Date: Wed, 19 Jul 2023 00:11:44 +0300 Message-Id: <20230718211147.18647-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230718211147.18647-1-andriy.shevchenko@linux.intel.com> References: <20230718211147.18647-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_221232_333875_61C2B03E X-CRM114-Status: GOOD ( 20.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org kernel.h is being used as a dump for all kinds of stuff for a long time. The COUNT_ARGS() and CONCATENATE() macros may be used in some places without need of the full kernel.h dependency train with it. Here is the attempt on cleaning it up by splitting out these macros(). While at it, include new header where it's being used. Signed-off-by: Andy Shevchenko Acked-by: Steven Rostedt (Google) Acked-by: Bjorn Helgaas # PCI --- include/kunit/test.h | 1 + include/linux/args.h | 28 ++++++++++++++++++++++++++++ include/linux/kernel.h | 7 ------- include/linux/pci.h | 2 +- include/trace/bpf_probe.h | 2 ++ 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 include/linux/args.h diff --git a/include/kunit/test.h b/include/kunit/test.h index 23120d50499e..107c81431634 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/include/linux/args.h b/include/linux/args.h new file mode 100644 index 000000000000..8ff60a54eb7d --- /dev/null +++ b/include/linux/args.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_ARGS_H +#define _LINUX_ARGS_H + +/* + * How do these macros work? + * + * In __COUNT_ARGS() _0 to _12 are just placeholders from the start + * in order to make sure _n is positioned over the correct number + * from 12 to 0 (depending on X, which is a variadic argument list). + * They serve no purpose other than occupying a position. Since each + * macro parameter must have a distinct identifier, those identifiers + * are as good as any. + * + * In COUNT_ARGS() we use actual integers, so __COUNT_ARGS() returns + * that as _n. + */ + +/* This counts to 12. Any more, it will return 13th argument. */ +#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n +#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + +/* Concatenate two parameters, but allow them to be expanded beforehand. */ +#define __CONCAT(a, b) a ## b +#define CONCATENATE(a, b) __CONCAT(a, b) + +#endif /* _LINUX_ARGS_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 0b00e1aef33d..15d9496db169 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -419,13 +419,6 @@ ftrace_vprintk(const char *fmt, va_list ap) static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } #endif /* CONFIG_TRACING */ -/* This counts to 12. Any more, it will return 13th argument. */ -#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n -#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) - -#define __CONCAT(a, b) a ## b -#define CONCATENATE(a, b) __CONCAT(a, b) - /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD diff --git a/include/linux/pci.h b/include/linux/pci.h index 0ff7500772e6..eeb2e6f6130f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -23,7 +23,7 @@ #ifndef LINUX_PCI_H #define LINUX_PCI_H - +#include #include #include diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 1f7fc1fc590c..e609cd7da47e 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -12,6 +12,8 @@ #undef __perf_task #define __perf_task(t) (t) +#include + /* cast any integer, pointer, or small struct to u64 */ #define UINTTYPE(size) \ __typeof__(__builtin_choose_expr(size == 1, (u8)1, \