All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@openvz.org" <devel@openvz.org>
Subject: Re: [RFC PATCH v2] posix timers: allocate timer id per task
Date: Wed, 17 Oct 2012 18:26:13 +0400	[thread overview]
Message-ID: <507EC005.5070301@parallels.com> (raw)
In-Reply-To: <1350482246.26103.487.camel@edumazet-glaptop>

17.10.2012 17:57, Eric Dumazet пишет:
> On Wed, 2012-10-17 at 17:18 +0400, Stanislav Kinsbursky wrote:
>
>> +static int posix_timer_add(struct k_itimer *timer)
>> +{
>> +	struct signal_struct *sig = current->signal;
>> +	int next_free_id = sig->posix_timer_id;
>> +	struct hlist_head *head;
>> +	int ret = -ENOENT;
>> +
>> +	do {
>> +		spin_lock(&hash_lock);
>> +		head = &posix_timers_hashtable[hash(sig, sig->posix_timer_id)];
>> +		if (__posix_timers_find(head, sig, sig->posix_timer_id) == NULL) {
>> +			hlist_add_head_rcu(&timer->t_hash, head);
>
> Hmm...
>
>> +			ret = sig->posix_timer_id++;
>> +		} else {
>> +			if (++sig->posix_timer_id < 0)
>> +				sig->posix_timer_id = 0;
>> +			if (sig->posix_timer_id == next_free_id)
>> +				ret = -EAGAIN;
>> +		}
>> +		spin_unlock(&hash_lock);
>> +	} while (ret == -ENOENT);
>> +	return ret;
>> +}
>> +
>
> You probably need to add a rcu_assign_pointer() or smp_wmb() before
> the :
>
> new_timer->it_signal = current->signal;
>
> in the following block :
>
>          spin_lock_irq(&current->sighand->siglock);
>          new_timer->it_signal = current->signal;
>          list_add(&new_timer->list, &current->signal->posix_timers);
>          spin_unlock_irq(&current->sighand->siglock);
>
> Or else another thread can read outdated informations...
>
>
>          spin_lock_irq(&current->sighand->siglock);
>          list_add(&new_timer->list, &current->signal->posix_timers);
>          spin_unlock_irq(&current->sighand->siglock);
> 	smp_wmb();
>          new_timer->it_signal = current->signal;
>
>

Sorry, but I don't understand what races you are talking about.
Could you specify, please?

-- 
Best regards,
Stanislav Kinsbursky

      reply	other threads:[~2012-10-17 14:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 13:18 [RFC PATCH v2] posix timers: allocate timer id per task Stanislav Kinsbursky
2012-10-17 13:44 ` Eric Dumazet
2012-10-17 14:19   ` Stanislav Kinsbursky
2012-10-17 13:57 ` Eric Dumazet
2012-10-17 14:26   ` Stanislav Kinsbursky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=507EC005.5070301@parallels.com \
    --to=skinsbursky@parallels.com \
    --cc=devel@openvz.org \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.