Re: [PATCH V3 2/3] tracing/osnoise: Add preempt/irq disable options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/28/22 21:39, Steven Rostedt wrote:
> On Fri, 25 Nov 2022 22:20:23 +0100
> Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:
> 
>> @@ -1308,6 +1315,8 @@ static void notify_new_max_latency(u64 latency)
>>   */
>>  static int run_osnoise(void)
>>  {
>> +	bool preempt_disable = test_bit(OSN_PREEMPT_DISABLE, &osnoise_options);
>> +	bool irq_disable = test_bit(OSN_IRQ_DISABLE, &osnoise_options);
> 
> 	bool irq_disable = test_bit(OSN_IRQ_DISABLE, &osnoise_options);
> 	bool preempt_disable = IS_ENABLED(CONFIG_PREEMPT) &&
> 			!irq_disable && test_bit(OSN_PREEMPT_DISABLE, &osnoise_options);

Ooops again, that is not exactly what I wanted, because...

>>  	struct osnoise_variables *osn_var = this_cpu_osn_var();
>>  	u64 start, sample, last_sample;
>>  	u64 last_int_count, int_count;
>> @@ -1335,6 +1344,14 @@ static int run_osnoise(void)
>>  	 */
>>  	threshold = tracing_thresh ? : 5000;
>>  
>> +	/*
>> +	 * IRQ disable also implies in preempt disable.
>> +	 */
>> +	if (irq_disable)
>> +		local_irq_disable();
> 
> 	if (preempt_disable)
>> +		preempt_disable();
>> +
>>  	/*
>>  	 * Make sure NMIs see sampling first
>>  	 */
>> @@ -1422,16 +1439,21 @@ static int run_osnoise(void)
>>  		 * cond_resched()
>>  		 */
>>  		if (IS_ENABLED(CONFIG_PREEMPT_RCU)) {
>> -			local_irq_disable();
>> +			if (!irq_disable)
>> +				local_irq_disable();
>> +
>>  			rcu_momentary_dyntick_idle();
>> -			local_irq_enable();
>> +
>> +			if (!irq_disable)
>> +				local_irq_enable();
>>  		}
>>  
>>  		/*
>>  		 * For the non-preemptive kernel config: let threads runs, if
>> -		 * they so wish.
>> +		 * they so wish, unless set not do to so.
>>  		 */

Then I end up cond_resched'ing here in the non-preemptive kernel.

>> -		cond_resched();
>> +		if (!irq_disable && !preempt_disable)
>> +			cond_resched();

But I also want to avoid this cond_resched if preempt_disable is set.

So, I will merge both things:

	- change the preempt_disable assignment to check !irq_disabled, like:

		/*
		 * Disabling preemption is only required if IRQs are enabled, and the options is set on.
		 */
		preempt_disable = !irq_disable && test_bit(OSN_PREEMPT_DISABLE, &osnoise_options);

	- change the preempt disabled if to
		if (IS_ENABLED(CONFIG_PREEMPT) && preempt_disabled)
			preempt_disable();

I tested with both preemption models (preemptive and not preemptive) and it works fine.

am I missing something?

-- Daniel

>>  		last_sample = sample;
>>  		last_int_count = int_count;
>> @@ -1450,6 +1472,14 @@ static int run_osnoise(void)
>>  	 */
>>  	barrier();
>>  
>> +	/*
>> +	 * Return to the preemptive state.
>> +	 */
> 
> 	if (preempt_disable)
>> +		preempt_enable();
>> +
> 
>> +	if (irq_disable)
>> +		local_irq_enable();
> 
> -- Steve
> 
>>  	/*
>>  	 * Save noise info.
>>  	 */




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux