lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54FEFB66.1070606@canonical.com>
Date:	Tue, 10 Mar 2015 15:10:46 +0100
From:	Maarten Lankhorst <maarten.lankhorst@...onical.com>
To:	Peter Zijlstra <peterz@...radead.org>,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
CC:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
	Mike Galbraith <umgwanakikbuti@...il.com>
Subject: Re: [PATCH 2/3] locking: ww_mutex: Allow to use rt_mutex instead
 of mutex for the baselock

Op 10-03-15 om 13:37 schreef Peter Zijlstra:
> On Fri, Feb 27, 2015 at 05:57:08PM +0100, Sebastian Andrzej Siewior wrote:
>> +static int __sched __mutex_lock_check_stamp(struct rt_mutex *lock,
>> +					    struct ww_acquire_ctx *ctx)
>> +{
>> +#ifdef CONFIG_WW_MUTEX_RTMUTEX
>> +	struct ww_mutex *ww = container_of(lock, struct ww_mutex, base.lock);
>> +	struct ww_acquire_ctx *hold_ctx = ACCESS_ONCE(ww->ctx);
>> +
>> +	if (!hold_ctx)
>> +		return 0;
>> +
>> +	if (unlikely(ctx == hold_ctx))
>> +		return -EALREADY;
>> +
>> +	if (ctx->stamp - hold_ctx->stamp <= LONG_MAX &&
>> +	    (ctx->stamp != hold_ctx->stamp || ctx > hold_ctx)) {
>> +#ifdef CONFIG_DEBUG_MUTEXES
>> +		DEBUG_LOCKS_WARN_ON(ctx->contending_lock);
>> +		ctx->contending_lock = ww;
>> +#endif
>> +		return -EDEADLK;
>> +	}
>> +#endif
>> +	return 0;
>> +}
> So IIRC this is the function that checks who gets wounded (and gets to
> do the whole retry thing), right?
>
> So for the RT case, I think we should extend it to not (primarily) be a
> FIFO thing, but also consider the priority of the tasks involved.
>
> Maybe a little something like:
>
> 	if (hold_ctx->task->prio < ctx->task->prio)
> 		return -EDEADLOCK;
>
> before the timestamp check; although I suppose we should also add a
> deadline test in case both prios are -1.
I think that's useful but if you implement -EDEADLK based on thread priority, any boosted thread should receive -EDEADLK when it tries to acquire a new lock in the same context, to force it to back off..
I'm not sure how you'd implement it though..

~Maarten
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ