[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230118160020.jcubwokkipnm7fls@techsingularity.net>
Date: Wed, 18 Jan 2023 16:00:20 +0000
From: Mel Gorman <mgorman@...hsingularity.net>
To: Ingo Molnar <mingo@...nel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Davidlohr Bueso <dave@...olabs.net>,
Linux-RT <linux-rt-users@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] locking/rwbase: Prevent indefinite writer starvation
On Wed, Jan 18, 2023 at 11:45:45AM +0100, Ingo Molnar wrote:
>
> > +/*
> > + * Allow reader bias with a pending writer for a minimum of 4ms or 1 tick.
> > + * This matches RWSEM_WAIT_TIMEOUT for the generic RWSEM implementation.
> > + * The granularity is not exact as the lowest bit in rwbase_rt->waiter_timeout
> > + * is used to detect recent DL / RT tasks taking a read lock.
> > + */
> > +#define RWBASE_RT_WAIT_TIMEOUT DIV_ROUND_UP(HZ, 250)
> > +
> > +static void __sched update_dlrt_reader(struct rwbase_rt *rwb)
> > +{
> > + /* No update required if DL / RT tasks already identified. */
> > + if (rwb->waiter_timeout & 1)
> > + return;
> > +
> > + /*
> > + * Record a DL / RT task acquiring the lock for read. This may result
> > + * in indefinite writer starvation but DL / RT tasks should avoid such
> > + * behaviour.
> > + */
> > + if (rt_task(current)) {
> > + struct rt_mutex_base *rtm = &rwb->rtmutex;
> > + unsigned long flags;
> > +
> > + raw_spin_lock_irqsave(&rtm->wait_lock, flags);
> > + rwb->waiter_timeout |= 1;
> > + raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);
> > + }
> > +}
>
> So I'm not sure this should be dependent on the task being an RT task.
>
> Starvation scenarios are bad no matter what scheduling policy is used.
>
> Should be unconditional - and all workloads should live with the new
> behavior.
>
The DL / RT task special casing was based on feedback given here
https://lore.kernel.org/r/Y7wxjBN9bDaZ0BKo@hirez.programming.kicks-ass.net.
Based on that, I assumed that allowing write to blocks readers that
may be depending on priority inheritance is potentially problematic for
applications that likely have been designed with writer-starvation in mind.
The first version of the patch did not care about the scheduling classes
were but I admit there is a non-zero possibility that breaking reader bias
for a writer may break some unknown RT-specific application that relied
on writer starvation for DL / RT tasks.
--
Mel Gorman
SUSE Labs
Powered by blists - more mailing lists