Message ID | 157301538629.678524.5328247190031479757.stgit@magnolia (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xfs: fix scrub timeout warnings | expand |
On Tue, Nov 05, 2019 at 08:43:06PM -0800, Darrick J. Wong wrote: > +++ b/fs/xfs/scrub/common.h > @@ -14,8 +14,20 @@ > static inline bool > xchk_should_terminate( > struct xfs_scrub *sc, > - int *error) > + int *error) > { > +#if !IS_ENABLED(CONFIG_PREEMPT) > + /* > + * If preemption is disabled, we need to yield to the scheduler every > + * few seconds so that we don't run afoul of the soft lockup watchdog > + * or RCU stall detector. > + */ > + if (sc->next_yield != 0 && time_after(jiffies, sc->next_yield)) > + return false; > + schedule(); > + sc->next_yield = jiffies + msecs_to_jiffies(5000); > +#endif This looks weird. Can't we just do a cond_resched() here?
On Wed, Nov 06, 2019 at 03:44:46PM +0100, Christoph Hellwig wrote: > On Tue, Nov 05, 2019 at 08:43:06PM -0800, Darrick J. Wong wrote: > > +++ b/fs/xfs/scrub/common.h > > @@ -14,8 +14,20 @@ > > static inline bool > > xchk_should_terminate( > > struct xfs_scrub *sc, > > - int *error) > > + int *error) > > { > > +#if !IS_ENABLED(CONFIG_PREEMPT) > > + /* > > + * If preemption is disabled, we need to yield to the scheduler every > > + * few seconds so that we don't run afoul of the soft lockup watchdog > > + * or RCU stall detector. > > + */ > > + if (sc->next_yield != 0 && time_after(jiffies, sc->next_yield)) > > + return false; > > + schedule(); > > + sc->next_yield = jiffies + msecs_to_jiffies(5000); > > +#endif > > This looks weird. Can't we just do a cond_resched() here? DOH. Yes, probably. Dave even suggested it a few nights ago to fix a similar problem and apparently I forgot. Will fix. :( --D
diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index 003a772cd26c..597b4d45e990 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -14,8 +14,20 @@ static inline bool xchk_should_terminate( struct xfs_scrub *sc, - int *error) + int *error) { +#if !IS_ENABLED(CONFIG_PREEMPT) + /* + * If preemption is disabled, we need to yield to the scheduler every + * few seconds so that we don't run afoul of the soft lockup watchdog + * or RCU stall detector. + */ + if (sc->next_yield != 0 && time_after(jiffies, sc->next_yield)) + return false; + schedule(); + sc->next_yield = jiffies + msecs_to_jiffies(5000); +#endif + if (fatal_signal_pending(current)) { if (*error == 0) *error = -EAGAIN; diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h index ad1ceb44a628..ada8e4976024 100644 --- a/fs/xfs/scrub/scrub.h +++ b/fs/xfs/scrub/scrub.h @@ -75,6 +75,15 @@ struct xfs_scrub { /* State tracking for single-AG operations. */ struct xchk_ag sa; + +#if !IS_ENABLED(CONFIG_PREEMPT) + /* + * This is the time (in jiffies) when this scrub thread needs to + * yield the processor back to the scheduler so that we don't run + * afoul of either the soft lockup watchdog or RCU stall detector. + */ + unsigned long next_yield; +#endif }; /* XCHK state flags grow up from zero, XREP state flags grown down from 2^31 */