mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: yang.y.yi@gmail.com
To: "Evgeniy Polyakov" <johnpol@2ka.mipt.ru>
Cc: "Matt Helsley" <matthltc@us.ibm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Andrew Morton" <akpm@osdl.org>,
	"Michael Kerrisk" <michael.kerrisk@gmx.net>
Subject: Re: Connector: Filesystem Events Connector
Date: Fri, 24 Mar 2006 22:04:13 +0800	[thread overview]
Message-ID: <4c4443230603240604u6c999f2fsb83bce68801f04b8@mail.gmail.com> (raw)
In-Reply-To: <20060324100934.GA21697@2ka.mipt.ru>

On 3/24/06, Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:
> On Fri, Mar 24, 2006 at 01:42:17AM -0800, Matt Helsley (matthltc@us.ibm.com)
> wrote:
> > On Fri, 2006-03-24 at 11:11 +0300, Evgeniy Polyakov wrote:
> > > On Thu, Mar 23, 2006 at 11:35:50PM -0800, Matt Helsley
> (matthltc@us.ibm.com) wrote:
> > > > I would argue preemption should be disabled around the if-block at the
> > > > very least. Suppose your rate limit is 10k calls/sec and you have 4
> > > > procs. Each proc has a sequence of three instructions:
> > > >
> > > > load fsevent_sum into register rx (rx <= 1000)
> > > > rx++ (rx <= 1001)
> > > > store contents of register rx in fsevent_sum (fsevent_sum <= 1001)
> > > >
> > > >
> > > > Now consider the following sequence of steps:
> > > >
> > > > load fsevent_sum into rx (rx <= 1000)
> > > > <preempted>
> > > > <3 other processors each manage to increment the sum by 3333 bringing
> us
> > > > to 9999>
> > > > <resumed>
> > > > rx++ (rx <= 1001)
> > > > store contents of rx in fsevent_sum (fsevent_sum <= 1001)
> > > >
> > > > So every processor now thinks it won't exceed the rate limit by
> > > > generating more events when in fact we've just exceeded the limit. So,
> > > > unless my example is flawed, I think you need to disable preemption
> > > > here.
> > >
> > > Doesn't it just exceed the limit by one event per cpu?
> >
> > The example exceeds it by one at the time of the final store. Thanks to
> > the fact that the value is then 1001 it may shortly be exceeded by much
> > more than 1.
>
> +
> +       if (jiffies - last <= fsevent_ratelimit) {
> +               if (fsevent_sum > fsevent_burst_limit)
> +                       return -2;
> +               fsevent_sum++;
>
> Only process (and not process' syscall) can preempt us here,
> so fsevent_sum can only exceed fsevent_burst_limit by one per process
> (process can not preempt itself, so when it has finished syscall which
> ends up in event generation, fsevent_sum will be increased).
>
> +       } else {
> +               last = jiffies;
> +               fsevent_sum = 0;
> +       }
>
> Actually, since jiffies and atomic operations are already used, I do not
> think addition of new atomic_inc_return or something similar will
> even somehow change the picture.
rate limit is just for some abnormal cases, for example, an
application leads to a unlimited event loop, it should be very few, in
the worst case, the user application which induced this case will
terminate, this should be a reasonable result.
rate limit is intent to prevent this kind of case and avoid DoS of system.
>
>
> > Cheers,
> > 	-Matt Helsley
>
> --
> 	Evgeniy Polyakov
>

  reply	other threads:[~2006-03-24 14:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22 14:58 [2.6.16 PATCH] " Yi Yang
2006-03-22 20:14 ` Serge E. Hallyn
2006-03-23  1:01   ` Yi Yang
2006-03-23  7:43 ` Matt Helsley
2006-03-23  8:52   ` Evgeniy Polyakov
2006-03-24  1:25     ` Yi Yang
2006-03-24  1:21   ` Yi Yang
2006-03-24  7:35     ` Matt Helsley
2006-03-24  8:11       ` Evgeniy Polyakov
2006-03-24  9:42         ` Matt Helsley
2006-03-24 10:09           ` Evgeniy Polyakov
2006-03-24 14:04             ` yang.y.yi [this message]
2006-03-24  2:50   ` Yi Yang
2006-03-24  9:53     ` Matt Helsley
2006-03-23  8:17 ` Arjan van de Ven
2006-03-24  0:45   ` Yi Yang
2006-03-24  6:46     ` Arjan van de Ven

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=4c4443230603240604u6c999f2fsb83bce68801f04b8@mail.gmail.com \
    --to=yang.y.yi@gmail.com \
    --cc=akpm@osdl.org \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthltc@us.ibm.com \
    --cc=michael.kerrisk@gmx.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®