From: "Sébastien Dugué" <sebastien.dugue@bull.net>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Laurent Vivier <laurent.vivier@bull.net>,
Zach Brown <zach.brown@oracle.com>,
Suparna Bhattacharya <suparna@in.ibm.com>,
Benjamin LaHaise <bcrl@kvack.org>,
Ulrich Drepper <drepper@redhat.com>, Ingo Molnar <mingo@elte.hu>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: + aio-completion-signal-notification.patch added to -mm tree
Date: Fri, 26 Jan 2007 12:14:07 +0100 [thread overview]
Message-ID: <20070126121407.1437928a@frecb000686> (raw)
In-Reply-To: <20070125162141.GA226@tv-sign.ru>
On Thu, 25 Jan 2007 19:21:41 +0300 Oleg Nesterov <oleg@tv-sign.ru> wrote:
> Sebastien Dugue wrote:
> >
> > +static long aio_setup_sigevent(struct aio_notify *notify,
> > + struct sigevent __user *user_event)
> > +{
> > + sigevent_t event;
> > + struct task_struct *target;
> > +
> > + if (copy_from_user(&event, user_event, sizeof(event)))
> > + return -EFAULT;
> > +
> > + if (event.sigev_notify == SIGEV_NONE)
> > + return 0;
> > +
> > + notify->notify = event.sigev_notify;
> > + notify->signo = event.sigev_signo;
> > + notify->value = event.sigev_value;
> > +
> > + read_lock(&tasklist_lock);
>
> We don't need tasklist_lock, we can use rcu_read_lock() instead.
Right that will be beneficial, will change.
>
> > + target = good_sigevent(&event);
> > +
> > + if (unlikely(!target || (target->flags & PF_EXITING)))
> > + goto out_unlock;
>
> PF_EXITING check is racy and unneded. In fact, it is wrong. If the main
> thread is already died, we can only use SIGEV_THREAD_ID signals, because
> otherwise good_sigevent() returns ->group_leader.
Care to explain here please, I'm not following you.
>
> > @@ -994,6 +1077,15 @@ int fastcall aio_complete(struct kiocb *
> > kunmap_atomic(ring, KM_IRQ1);
> >
> > pr_debug("added to ring %p at [%lu]\n", iocb, tail);
> > +
> > + if (iocb->ki_notify.notify != SIGEV_NONE) {
> > + ret = aio_send_signal(&iocb->ki_notify);
> > +
> > + /* If signal generation failed, release the sigqueue */
> > + if (ret)
> > + sigqueue_free(iocb->ki_notify.sigq);
>
> We should not use sigqueue_free() here. It takes current->sighand->siglock
> to remove sigqueue from "struct sigpending". But current is just a "random"
> process here.
>
> Yes, if I understand this patch correctly, it is not possible that this
> sigqueue is pending, but still this is bad imho.
Yes, in fact the sigqueue is used for a single signal delivery and then
free. In fact I could have used directly __sigqueue_free() instead here
except for the fact that it's private to signal.c and I'm reluctant
to export it to other subsystems.
>
> > static void __sigqueue_free(struct sigqueue *q)
> > {
> > - if (q->flags & SIGQUEUE_PREALLOC)
> > + if (q->flags & SIGQUEUE_PREALLOC && q->info.si_code != SI_ASYNCIO)
> > return;
>
> Oh, this is not nice. Could we change send_sigqueue/send_group_sigqueue
> instead ?
Yep, that's the other solution.
>
> - BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
> + BUG_ON(!(q->flags & SIGQUEUE_PREALLOC) && q->info.si_code != SI_ASYNCIO);
>
> This way aio can use __sigqueue_alloc/__sigqueue_free directly and forget
> about SIGQUEUE_PREALLOC.
Well, I don't think it's cleaner. The aio error path calls sigqueue_free()
directly whereas in case of success sigqueue_free() is called from the signal
delivery path.
>
> On the other hand, imho this patch takes a wrong direction.
>
> The purpose of SIGQUEUE_PREALLOC + send_sigqueue() is to re-use the same
> sigqueue while sending a stream of signals. But in aio case we allocate
> sigqueue to send only 1 signal, then it freed after the delivery like
> the regular sigqueue. So what is the point?
>
> I'd suggest to not use this interface. Just use group_send_sig_info() or
> specific_send_sig_info(). Yes, this way we will do GFP_ATOMIC allocation
> of sigqueue in interrupt context, but is this so bad in this case?
Well, the thihere is that in the past we used group_send_sig_info()
and specific_send_sig_info() for notification but Zach Brown raised
the question about reliable signal delivery. IOW an aio submission
should not succeed if signal delivery is going to fail. Hence the
use of the preallocated sigqueue.
Thanks,
Sébastien.
next prev parent reply other threads:[~2007-01-26 11:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-25 16:21 + aio-completion-signal-notification.patch added to -mm tree Oleg Nesterov
2007-01-25 16:34 ` Oleg Nesterov
2007-01-26 11:14 ` Sébastien Dugué [this message]
2007-01-26 11:52 ` Oleg Nesterov
2007-01-26 13:05 ` Sébastien Dugué
-- strict thread matches above, loose matches on Subject: below --
2007-02-01 23:04 akpm
2007-01-24 6:05 akpm
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=20070126121407.1437928a@frecb000686 \
--to=sebastien.dugue@bull.net \
--cc=akpm@osdl.org \
--cc=bcrl@kvack.org \
--cc=drepper@redhat.com \
--cc=laurent.vivier@bull.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=suparna@in.ibm.com \
--cc=tglx@linutronix.de \
--cc=zach.brown@oracle.com \
/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.