Re: [PATCH 2/2] kernel: rerun task_work while freezing in get_signal()

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

 



On Mon, Jul 08, 2024 at 04:40:07PM +0100, Pavel Begunkov wrote:

> > > --- a/kernel/signal.c
> > > +++ b/kernel/signal.c
> > > @@ -2694,6 +2694,10 @@ bool get_signal(struct ksignal *ksig)
> > >   	try_to_freeze();
> > >   relock:
> > > +	clear_notify_signal();
> > > +	if (unlikely(task_work_pending(current)))
> > > +		task_work_run();
> > > +
> > >   	spin_lock_irq(&sighand->siglock);
> > 
> > Well, but can't we kill the same code at the start of get_signal() then?
> > Of course, in this case get_signal() should check signal_pending(), not
> > task_sigpending().
> 
> Should be fine, but I didn't want to change the
> try_to_freeze() -> __refrigerator() path, which also reschedules.
> 
> > Or perhaps something like the patch below makes more sense? I dunno...
> 
> It needs a far backporting, I'd really prefer to keep it
> lean and without more side effects if possible, unless
> there is a strong opinion on that.

It's been a minute since I dug my way through the signal code, but I
think I slightly favour Oleg's version for not duplicating that
task_work_run().


> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index 1f9dd41c04be..e2ae85293fbb 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -2676,6 +2676,7 @@ bool get_signal(struct ksignal *ksig)
> >   	struct signal_struct *signal = current->signal;
> >   	int signr;
> > +start:
> >   	clear_notify_signal();
> >   	if (unlikely(task_work_pending(current)))
> >   		task_work_run();
> > @@ -2760,10 +2761,11 @@ bool get_signal(struct ksignal *ksig)
> >   			if (current->jobctl & JOBCTL_TRAP_MASK) {
> >   				do_jobctl_trap();
> >   				spin_unlock_irq(&sighand->siglock);
> > +				goto relock;
> >   			} else if (current->jobctl & JOBCTL_TRAP_FREEZE)
> >   				do_freezer_trap();
> > -
> > -			goto relock;
> > +				goto start;
> > +			}
> >   		}
> >   		/*
> > 
> 
> -- 
> Pavel Begunkov




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux