Re: [PATCH 2/2] jffs2: Provide jffs2_sync files to track gc POLL progress

From: Al Viro
Date: Sun Jul 22 2018 - 09:50:23 EST


On Sun, Jul 22, 2018 at 03:17:07PM +0200, Richard Weinberger wrote:

> On Fri, Jul 20, 2018 at 2:54 AM, Theuns Verwoerd
> <Theuns.Verwoerd@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On 07/20/2018 12:04 PM, Al Viro wrote:
> >> On Fri, Jul 20, 2018 at 11:50:12AM +1200, Theuns Verwoerd wrote:
> >>
> >>> +ssize_t jffs2_sync_file_read(struct file *f,
> >>> + char __user *b, size_t len, loff_t *ofs)
> >>> +{
> >>> + struct jffs2_sb_info *c = file_inode(f)->i_private;
> >>> +
> >>> + while (c->tidemark)
> >>> + schedule();
> >>> +
> >>> + return 0;
> >>> +}
> >> Brilliant. So when that gets called with c->tidemark being true and
> >> need_resched() - false, we shall...
> > By my reading, schedule() will happily force a reschedule (once) when
> > need_resched() is false. Every time the process is granted a time
> > slice, it'll check the condition and surrender if not ready.

Except that the task remains runnable (and not using its timeslice up).
It won't sleep; there's nothing to drive it into TASK_NOT_RUNNING
state.

Try it and watch what's going on when you trigger that loop. That's
really not a good way to wait for something to happen.