From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Potapenko <glider@google.com>
Cc: quic_jiangenj@quicinc.com, linux-kernel@vger.kernel.org,
kasan-dev@googlegroups.com, Aleksandr Nogikh <nogikh@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dmitry Vyukov <dvyukov@google.com>,
Ingo Molnar <mingo@redhat.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Marco Elver <elver@google.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 02/11] kcov: apply clang-format to kcov code
Date: Fri, 27 Jun 2025 10:02:48 +0200 [thread overview]
Message-ID: <20250627080248.GQ1613200@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250626134158.3385080-3-glider@google.com>
On Thu, Jun 26, 2025 at 03:41:49PM +0200, Alexander Potapenko wrote:
> kcov used to obey clang-format style, but somehow diverged over time.
> This patch applies clang-format to kernel/kcov.c and
> include/linux/kcov.h, no functional change.
I'm not sure I agree this is in fact a good thing. Very questionable
style choices made.
I had to kill clang-format hard in my nvim-lsp-clangd setup, because
clang-format is such a piece of shit.
> -static inline void kcov_task_init(struct task_struct *t) {}
> -static inline void kcov_task_exit(struct task_struct *t) {}
> -static inline void kcov_prepare_switch(struct task_struct *t) {}
> -static inline void kcov_finish_switch(struct task_struct *t) {}
> -static inline void kcov_remote_start(u64 handle) {}
> -static inline void kcov_remote_stop(void) {}
> +static inline void kcov_task_init(struct task_struct *t)
> +{
> +}
> +static inline void kcov_task_exit(struct task_struct *t)
> +{
> +}
> +static inline void kcov_prepare_switch(struct task_struct *t)
> +{
> +}
> +static inline void kcov_finish_switch(struct task_struct *t)
> +{
> +}
> +static inline void kcov_remote_start(u64 handle)
> +{
> +}
> +static inline void kcov_remote_stop(void)
> +{
> +}
This is not an improvement.
> @@ -52,36 +53,36 @@ struct kcov {
> * - task with enabled coverage (we can't unwire it from another task)
> * - each code section for remote coverage collection
> */
> - refcount_t refcount;
> + refcount_t refcount;
> /* The lock protects mode, size, area and t. */
> - spinlock_t lock;
> - enum kcov_mode mode;
> + spinlock_t lock;
> + enum kcov_mode mode;
> /* Size of arena (in long's). */
> - unsigned int size;
> + unsigned int size;
> /* Coverage buffer shared with user space. */
> - void *area;
> + void *area;
> /* Task for which we collect coverage, or NULL. */
> - struct task_struct *t;
> + struct task_struct *t;
> /* Collecting coverage from remote (background) threads. */
> - bool remote;
> + bool remote;
> /* Size of remote area (in long's). */
> - unsigned int remote_size;
> + unsigned int remote_size;
> /*
> * Sequence is incremented each time kcov is reenabled, used by
> * kcov_remote_stop(), see the comment there.
> */
> - int sequence;
> + int sequence;
> };
>
> struct kcov_remote_area {
> - struct list_head list;
> - unsigned int size;
> + struct list_head list;
> + unsigned int size;
> };
>
> struct kcov_remote {
> - u64 handle;
> - struct kcov *kcov;
> - struct hlist_node hnode;
> + u64 handle;
> + struct kcov *kcov;
> + struct hlist_node hnode;
> };
>
> static DEFINE_SPINLOCK(kcov_remote_lock);
> @@ -89,14 +90,14 @@ static DEFINE_HASHTABLE(kcov_remote_map, 4);
> static struct list_head kcov_remote_areas = LIST_HEAD_INIT(kcov_remote_areas);
>
> struct kcov_percpu_data {
> - void *irq_area;
> - local_lock_t lock;
> -
> - unsigned int saved_mode;
> - unsigned int saved_size;
> - void *saved_area;
> - struct kcov *saved_kcov;
> - int saved_sequence;
> + void *irq_area;
> + local_lock_t lock;
> +
> + unsigned int saved_mode;
> + unsigned int saved_size;
> + void *saved_area;
> + struct kcov *saved_kcov;
> + int saved_sequence;
> };
>
> static DEFINE_PER_CPU(struct kcov_percpu_data, kcov_percpu_data) = {
This is just plain wrong. Making something that was readable into a
trainwreck.
Please either teach clang-format sensible style choices, or refrain from
using it.
next prev parent reply other threads:[~2025-06-27 8:02 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 13:41 [PATCH v2 00/11] Coverage deduplication for KCOV Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 01/11] x86: kcov: disable instrumentation of arch/x86/kernel/tsc.c Alexander Potapenko
2025-06-27 7:59 ` Peter Zijlstra
2025-06-27 10:51 ` Alexander Potapenko
2025-06-30 7:43 ` Peter Zijlstra
2025-06-30 13:39 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 02/11] kcov: apply clang-format to kcov code Alexander Potapenko
2025-06-27 8:02 ` Peter Zijlstra [this message]
2025-06-27 12:50 ` Alexander Potapenko
2025-06-29 19:25 ` Miguel Ojeda
2025-06-30 6:40 ` Alexander Potapenko
2025-06-30 8:09 ` Peter Zijlstra
2025-06-30 18:14 ` Miguel Ojeda
2025-06-30 7:56 ` Peter Zijlstra
2025-07-03 7:51 ` David Laight
2025-06-26 13:41 ` [PATCH v2 03/11] kcov: elaborate on using the shared buffer Alexander Potapenko
2025-07-09 13:12 ` Dmitry Vyukov
2025-06-26 13:41 ` [PATCH v2 04/11] kcov: factor out struct kcov_state Alexander Potapenko
2025-07-09 14:51 ` Dmitry Vyukov
2025-07-24 14:08 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 05/11] mm/kasan: define __asan_before_dynamic_init, __asan_after_dynamic_init Alexander Potapenko
2025-07-09 14:53 ` Dmitry Vyukov
2025-06-26 13:41 ` [PATCH v2 06/11] kcov: x86: introduce CONFIG_KCOV_UNIQUE Alexander Potapenko
2025-06-27 8:11 ` Peter Zijlstra
2025-06-27 14:24 ` Alexander Potapenko
2025-06-27 14:32 ` Alexander Potapenko
2025-06-30 7:49 ` Peter Zijlstra
2025-07-09 15:01 ` Dmitry Vyukov
2025-07-25 10:07 ` Alexander Potapenko
2025-07-25 10:21 ` Dmitry Vyukov
2025-06-26 13:41 ` [PATCH v2 07/11] kcov: add trace and trace_size to struct kcov_state Alexander Potapenko
2025-06-27 12:34 ` kernel test robot
2025-07-09 15:05 ` Dmitry Vyukov
2025-07-25 10:45 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 08/11] kcov: add ioctl(KCOV_UNIQUE_ENABLE) Alexander Potapenko
2025-06-27 8:27 ` Peter Zijlstra
2025-06-27 13:58 ` Alexander Potapenko
2025-06-30 7:54 ` Peter Zijlstra
2025-06-26 13:41 ` [PATCH v2 09/11] kcov: add ioctl(KCOV_RESET_TRACE) Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 10/11] kcov: selftests: add kcov_test Alexander Potapenko
2025-07-09 15:15 ` Dmitry Vyukov
2025-07-25 14:37 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 11/11] kcov: use enum kcov_mode in kcov_mode_enabled() Alexander Potapenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250627080248.GQ1613200@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andreyknvl@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=jpoimboe@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nogikh@google.com \
--cc=quic_jiangenj@quicinc.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®