Re: A panic a day

From: Mark Johnston <markj_at_freebsd.org>
Date: Sat, 24 Sep 2022 00:22:31 UTC
On Fri, Sep 23, 2022 at 09:46:08AM -0700, Steve Kargl wrote:
> On Thu, Sep 22, 2022 at 03:00:53PM -0400, Mark Johnston wrote:
> > 
> > I think this untested patch will address the panics.  The bug was there
> > for a long time but some recent restructuring added an assertion which
> > caught it.
> > 
> > diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
> > index 9d48aa746f6d..484864b66c1c 100644
> > --- a/sys/kern/sched_4bsd.c
> > +++ b/sys/kern/sched_4bsd.c
> > @@ -1282,9 +1282,10 @@ kick_other_cpu(int pri, int cpuid)
> >  	}
> >  #endif /* defined(IPI_PREEMPTION) && defined(PREEMPTION) */
> >  
> > -	ast_sched_locked(pcpu->pc_curthread, TDA_SCHED);
> > -	ipi_cpu(cpuid, IPI_AST);
> > -	return;
> > +	if (pcpu->pc_curthread->td_lock == &sched_lock) {
> > +		ast_sched_locked(pcpu->pc_curthread, TDA_SCHED);
> > +		ipi_cpu(cpuid, IPI_AST);
> > +	}
> >  }
> >  #endif /* SMP */
> >  
> > @@ -1397,7 +1398,7 @@ sched_add(struct thread *td, int flags)
> >  
> >  	cpuid = PCPU_GET(cpuid);
> >  	if (single_cpu && cpu != cpuid) {
> > -	        kick_other_cpu(td->td_priority, cpu);
> > +		kick_other_cpu(td->td_priority, cpu);
> >  	} else {
> >  		if (!single_cpu) {
> >  			tidlemsk = idle_cpus_mask;
> 
> Mark,
> 
> My system has been running a fairly heavy load with this
> patch for the last 20 or so hours without any incidences.
> In fact, the system feels snappier.  Thanks for the quick
> response with a patch.

Thanks, committed in c2d27b0ec700.