Skip to contentSkip to conversation

locking in hidraw

DISCUSSION Oliver Neukum 3 participants 6 messages Nov 4, 2008 – Dec 8, 2008 HID

lore
Share & tools
lore
#0 lore raw

Hi,

in this code:

		mutex_lock(&list->read_mutex);

		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);

it would make more sense to lock the mutex interruptable so all tasks sleep the same way. Is this intentional?

Regards
Oliver

#1 lore raw

Ccing jikos.

Oliver Neukum napsal(a):

Quoted 12 lines

Hi,

in this code:

		mutex_lock(&list->read_mutex);

		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);

it would make more sense to lock the mutex interruptable so all tasks sleep the same way. Is this intentional?

#2 lore raw
Quoted 10 lines · Jiri Slaby
Quoted 10 lines

in this code:

		mutex_lock(&list->read_mutex);

		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);

it would make more sense to lock the mutex interruptable so all tasks sleep the same way. Is this intentional?

Well, we have the test for pending signals just below that code, right?

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw

Am Mittwoch, 12. November 2008 15:39:49 schrieb Jiri Kosina:

Quoted 6 lines · Jiri Slaby
Quoted 5 lines
Quoted 5 lines

in this code:

		mutex_lock(&list->read_mutex);
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);

it would make more sense to lock the mutex interruptable so all tasks sleep the same way. Is this intentional?

Well, we have the test for pending signals just below that code, right?

So the tasks blocking on the mutex sleep all the time until another task is finished and unlocks the mutex, only to return to user space because signals are pending. Therefore why not make the wait on the mutex interruptible, so the signals are processed right away?

Regards
Oliver

#4 lore raw
Quoted 9 lines · Oliver Neukum
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

in this code:

		mutex_lock(&list->read_mutex);

		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);

it would make more sense to lock the mutex interruptable so all tasks sleep the same way. Is this intentional?

Quoted 5 lines
Quoted 1 line

Well, we have the test for pending signals just below that code, right?

So the tasks blocking on the mutex sleep all the time until another task is finished and unlocks the mutex, only to return to user space because signals are pending. Therefore why not make the wait on the mutex interruptible, so the signals are processed right away?

Yes, it makes sense. Could you please fold this change together with the hidraw changes you are going to push with the autosuspend patches?

Thanks,

Signature · 1 line
Jiri Kosina
#5 lore raw

Am Montag, 1. Dezember 2008 11:07:13 schrieb Jiri Kosina:

Quoted 11 lines · Oliver Neukum
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

in this code:

		mutex_lock(&list->read_mutex);

		if (list->head == list->tail) {
			add_wait_queue(&list->hidraw->wait, &wait);
			set_current_state(TASK_INTERRUPTIBLE);

it would make more sense to lock the mutex interruptable so all tasks sleep the same way. Is this intentional?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Well, we have the test for pending signals just below that code, right?

So the tasks blocking on the mutex sleep all the time until another task is finished and unlocks the mutex, only to return to user space because signals are pending. Therefore why not make the wait on the mutex interruptible, so the signals are processed right away?

Yes, it makes sense. Could you please fold this change together with the hidraw changes you are going to push with the autosuspend patches?

On second thought, no, this would not be a good idea. Bug fixes, fixes for oddities such as this and clear enhancements, like autosuspend, should be kept apart. I'd rather send separate patches for this, what do you think?

Regards
Oliver