All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Zeng Heng <zengheng4@huawei.com>
Cc: broonie@kernel.org, joey.gouly@arm.com, will@kernel.org,
	amit.kachhap@arm.com, rafael@kernel.org, catalin.marinas@arm.com,
	james.morse@arm.com, maz@kernel.org, viresh.kumar@linaro.org,
	sumitg@nvidia.com, yang@os.amperecomputing.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, wangxiongfeng2@huawei.com,
	xiexiuqi@huawei.com, Ionela Voinescu <ionela.voinescu@arm.com>
Subject: Re: [PATCH 3/3] cpufreq: CPPC: Eliminate the impact of cpc_read() latency error
Date: Thu, 26 Oct 2023 12:26:20 +0100	[thread overview]
Message-ID: <ZTpM3OXZ8C1OrBIQ@FVFF77S0Q05N> (raw)
In-Reply-To: <abb15757-cbe6-037f-e8d3-5df9fbbf6c04@huawei.com>

On Thu, Oct 26, 2023 at 09:55:39AM +0800, Zeng Heng wrote:
> 
> 在 2023/10/25 19:01, Mark Rutland 写道:
> > On Wed, Oct 25, 2023 at 05:38:47PM +0800, Zeng Heng wrote:
> > 
> > The previous patch added this function, and calls it with smp_call_on_cpu(),
> > where it'll run in IRQ context with IRQs disabled...
> 
> smp_call_on_cpu() puts the work to the bind-cpu worker.

Ah, sorry -- I had confused this with the smp_call_function*() family, which do
this in IRQ context.

> And this function will be called in task context, and IRQs is certainly enabled.

Understood; given that, please ignore my comments below.

Mark.

> 
> 
> Zeng Heng
> 
> > >   	struct fb_ctr_pair *fb_ctrs = val;
> > >   	int cpu = fb_ctrs->cpu;
> > >   	int ret;
> > > +	unsigned long timeout;
> > >   	ret = cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t0);
> > >   	if (ret)
> > >   		return ret;
> > > -	udelay(2); /* 2usec delay between sampling */
> > > +	if (likely(!irqs_disabled())) {
> > > +		/*
> > > +		 * Set 1ms as sampling interval, but never schedule
> > > +		 * to the idle task to prevent the AMU counters from
> > > +		 * stopping working.
> > > +		 */
> > > +		timeout = jiffies + msecs_to_jiffies(1);
> > > +		while (!time_after(jiffies, timeout))
> > > +			cond_resched();
> > > +
> > > +	} else {
> > ... so we'll enter this branch of the if-else ...
> > 
> > > +		pr_warn_once("CPU%d: Get rate in atomic context", cpu);
> > ... and pr_warn_once() for something that's apparently normal and outside of
> > the user's control?
> > 
> > That doesn't make much sense to me.
> > 
> > Mark.
> > 
> > > +		udelay(2); /* 2usec delay between sampling */
> > > +	}
> > >   	return cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t1);
> > >   }
> > > -- 
> > > 2.25.1
> > > 

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Zeng Heng <zengheng4@huawei.com>
Cc: broonie@kernel.org, joey.gouly@arm.com, will@kernel.org,
	amit.kachhap@arm.com, rafael@kernel.org, catalin.marinas@arm.com,
	james.morse@arm.com, maz@kernel.org, viresh.kumar@linaro.org,
	sumitg@nvidia.com, yang@os.amperecomputing.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, wangxiongfeng2@huawei.com,
	xiexiuqi@huawei.com, Ionela Voinescu <ionela.voinescu@arm.com>
Subject: Re: [PATCH 3/3] cpufreq: CPPC: Eliminate the impact of cpc_read() latency error
Date: Thu, 26 Oct 2023 12:26:20 +0100	[thread overview]
Message-ID: <ZTpM3OXZ8C1OrBIQ@FVFF77S0Q05N> (raw)
In-Reply-To: <abb15757-cbe6-037f-e8d3-5df9fbbf6c04@huawei.com>

On Thu, Oct 26, 2023 at 09:55:39AM +0800, Zeng Heng wrote:
> 
> 在 2023/10/25 19:01, Mark Rutland 写道:
> > On Wed, Oct 25, 2023 at 05:38:47PM +0800, Zeng Heng wrote:
> > 
> > The previous patch added this function, and calls it with smp_call_on_cpu(),
> > where it'll run in IRQ context with IRQs disabled...
> 
> smp_call_on_cpu() puts the work to the bind-cpu worker.

Ah, sorry -- I had confused this with the smp_call_function*() family, which do
this in IRQ context.

> And this function will be called in task context, and IRQs is certainly enabled.

Understood; given that, please ignore my comments below.

Mark.

> 
> 
> Zeng Heng
> 
> > >   	struct fb_ctr_pair *fb_ctrs = val;
> > >   	int cpu = fb_ctrs->cpu;
> > >   	int ret;
> > > +	unsigned long timeout;
> > >   	ret = cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t0);
> > >   	if (ret)
> > >   		return ret;
> > > -	udelay(2); /* 2usec delay between sampling */
> > > +	if (likely(!irqs_disabled())) {
> > > +		/*
> > > +		 * Set 1ms as sampling interval, but never schedule
> > > +		 * to the idle task to prevent the AMU counters from
> > > +		 * stopping working.
> > > +		 */
> > > +		timeout = jiffies + msecs_to_jiffies(1);
> > > +		while (!time_after(jiffies, timeout))
> > > +			cond_resched();
> > > +
> > > +	} else {
> > ... so we'll enter this branch of the if-else ...
> > 
> > > +		pr_warn_once("CPU%d: Get rate in atomic context", cpu);
> > ... and pr_warn_once() for something that's apparently normal and outside of
> > the user's control?
> > 
> > That doesn't make much sense to me.
> > 
> > Mark.
> > 
> > > +		udelay(2); /* 2usec delay between sampling */
> > > +	}
> > >   	return cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t1);
> > >   }
> > > -- 
> > > 2.25.1
> > > 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-10-26 11:26 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25  9:38 [PATCH 0/3] Make the cpuinfo_cur_freq interface read correctly Zeng Heng
2023-10-25  9:38 ` Zeng Heng
2023-10-25  9:38 ` [PATCH 1/3] arm64: cpufeature: Export cpu_has_amu_feat() Zeng Heng
2023-10-25  9:38   ` Zeng Heng
2023-10-25  9:38 ` [PATCH 2/3] cpufreq: CPPC: Keep the target core awake when reading its cpufreq rate Zeng Heng
2023-10-25  9:38   ` Zeng Heng
2023-10-25 10:54   ` Mark Rutland
2023-10-25 10:54     ` Mark Rutland
2023-10-25 14:57     ` Sumit Gupta
2023-10-25 14:57       ` Sumit Gupta
2023-10-30 13:19       ` Beata Michalska
2023-10-30 13:19         ` Beata Michalska
2023-10-26  3:21     ` Zeng Heng
2023-10-26  3:21       ` Zeng Heng
2023-10-25 11:13   ` Sudeep Holla
2023-10-25 11:13     ` Sudeep Holla
2023-10-26  2:24     ` Zeng Heng
2023-10-26  2:24       ` Zeng Heng
2023-10-26  8:53       ` Sudeep Holla
2023-10-26  8:53         ` Sudeep Holla
2023-10-26  9:05         ` Zeng Heng
2023-10-26  9:05           ` Zeng Heng
2023-10-31 23:52   ` kernel test robot
2023-10-31 23:52     ` kernel test robot
2023-10-25  9:38 ` [PATCH 3/3] cpufreq: CPPC: Eliminate the impact of cpc_read() latency error Zeng Heng
2023-10-25  9:38   ` Zeng Heng
2023-10-25 11:01   ` Mark Rutland
2023-10-25 11:01     ` Mark Rutland
2023-10-26  1:55     ` Zeng Heng
2023-10-26  1:55       ` Zeng Heng
2023-10-26 11:26       ` Mark Rutland [this message]
2023-10-26 11:26         ` Mark Rutland

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=ZTpM3OXZ8C1OrBIQ@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=amit.kachhap@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=ionela.voinescu@arm.com \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=rafael@kernel.org \
    --cc=sumitg@nvidia.com \
    --cc=viresh.kumar@linaro.org \
    --cc=wangxiongfeng2@huawei.com \
    --cc=will@kernel.org \
    --cc=xiexiuqi@huawei.com \
    --cc=yang@os.amperecomputing.com \
    --cc=zengheng4@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.