mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qing Wang <wangqing7171@gmail.com>
To: peterz@infradead.org, linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, akpm@linux-foundation.org, song@kernel.org
Subject: Re: [PATCH] watchdog: Don't need a definition of the perf fallback-attr
Date: Sat, 9 Aug 2025 12:07:13 +0800	[thread overview]
Message-ID: <0dadd6c5-3790-4887-a370-69cb7f0cc0b7@gmail.com> (raw)
In-Reply-To: <20250727032516.10063-1-wangqing7171@gmail.com>

Hello,

PING.

Thanks,
Qing.

On 7/27/2025 11:25 AM, Qing Wong wrote:
> From: Qing Wang <wangqing7171@gmail.com>
>
> The 'hardlockup_config_perf_event()' only overwrites the type and
> config of the perf attr. It's wasteful that redefining a big static
> variable to fallback. It’s just a matter of simply fallback these
> two variables.
>
> Signed-off-by: Qing Wang <wangqing7171@gmail.com>
> ---
>   kernel/watchdog_perf.c | 17 +++++++----------
>   1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c
> index 75af12ff774e..08b9acbd2aa4 100644
> --- a/kernel/watchdog_perf.c
> +++ b/kernel/watchdog_perf.c
> @@ -92,14 +92,6 @@ static struct perf_event_attr wd_hw_attr = {
>   	.disabled	= 1,
>   };
>   
> -static struct perf_event_attr fallback_wd_hw_attr = {
> -	.type		= PERF_TYPE_HARDWARE,
> -	.config		= PERF_COUNT_HW_CPU_CYCLES,
> -	.size		= sizeof(struct perf_event_attr),
> -	.pinned		= 1,
> -	.disabled	= 1,
> -};
> -
>   /* Callback function for perf event subsystem */
>   static void watchdog_overflow_callback(struct perf_event *event,
>   				       struct perf_sample_data *data,
> @@ -114,6 +106,12 @@ static void watchdog_overflow_callback(struct perf_event *event,
>   	watchdog_hardlockup_check(smp_processor_id(), regs);
>   }
>   
> +static void fallback_wd_hw_attr(void)
> +{
> +	wd_hw_attr.type = PERF_TYPE_HARDWARE;
> +	wd_hw_attr.config = PERF_COUNT_HW_CPU_CYCLES;
> +}
> +
>   static int hardlockup_detector_event_create(void)
>   {
>   	unsigned int cpu;
> @@ -133,8 +131,7 @@ static int hardlockup_detector_event_create(void)
>   	evt = perf_event_create_kernel_counter(wd_attr, cpu, NULL,
>   					       watchdog_overflow_callback, NULL);
>   	if (IS_ERR(evt)) {
> -		wd_attr = &fallback_wd_hw_attr;
> -		wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
> +		fallback_wd_hw_attr();
>   		evt = perf_event_create_kernel_counter(wd_attr, cpu, NULL,
>   						       watchdog_overflow_callback, NULL);
>   	}

      reply	other threads:[~2025-08-09  4:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-27  3:25 Qing Wong
2025-08-09  4:07 ` Qing Wang [this message]

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=0dadd6c5-3790-4887-a370-69cb7f0cc0b7@gmail.com \
    --to=wangqing7171@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=song@kernel.org \
    /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®