From: Jiri Olsa <jolsa@redhat.com>
To: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Cc: linux-kernel@vger.kernel.org, Aristeu Rozanski <aris@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC] rlimit exceed notification events
Date: Wed, 24 Aug 2016 13:24:28 +0200 [thread overview]
Message-ID: <20160824112428.GA15743@krava> (raw)
In-Reply-To: <xunyh9ag254f.fsf@redhat.com>
On Fri, Aug 19, 2016 at 05:41:20PM +0300, Yauheni Kaliuta wrote:
> Hi!
>
> At the moment there is no clear indication if a process exceeds resource
> limit. In some cases the problematic syscall can return a error, in some cases
> the process can be just killed.
>
> I'm trying to implement some sort of monitoring of such events and have a
> question, what way would be acceptable.
>
> 1) The straight forward solution would be to instrument every such a place with
> a printk (something related implemented, for example, by
> d977d56ce5b3e8842236f2f9e7483d4914c9592e).
>
> It has some concerns about reliablity and performance (giving a way to flood
> printk buffer because of bad application, for example).
>
> 2) Using tracepoints. I've used a simple program, which dup()s until gets the
> error 3 times:
just to start up the discussion.. ;-)
I'd think this one (2) is the proper way, but generaly you need to
come with good justification/usecase to add new tracepoint
also rlimit seems to be difficult to add tracepoints to,
because the checks are spread all over the code..
can't think of a good solution ATM
> $ sudo ./perf record -e rlimit:rlimit_exceeded ./a.out
> Couldn't dup file: Too many open files, iteration 1020
> Couldn't dup file: Too many open files, iteration 1021
> Couldn't dup file: Too many open files, iteration 1022
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.010 MB perf.data (3 samples) ]
>
> $ sudo ./perf report
> # To display the perf.data header info, please use --header/--header-only options.
> #
> #
> # Total Lost Samples: 0
> #
> # Samples: 3 of event 'rlimit:rlimit_exceeded'
> # Event count (approx.): 3
> #
> # Overhead Trace output
> # ........ ........................................................
> #
> 100.00% RLIMIT NOFILE violation. Current 1024, requested Unknown
>
> The code to demonstrate the idea below:
>
> diff --git a/fs/file.c b/fs/file.c
> index 6b1acdfe59da..a358de041ac4 100644
> --- a/fs/file.c
> +++ b/fs/file.c
> @@ -947,6 +947,9 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
> else
> fput(file);
> }
> + if (ret == -EMFILE)
> + rlimit_exceeded(RLIMIT_NOFILE,
> + rlimit(RLIMIT_NOFILE), (u64)-1);
> return ret;
how about other places? alloc_fd/get_unused_fd_flags/replace_fd..
jirka
next prev parent reply other threads:[~2016-08-24 11:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 14:41 [RFC] rlimit exceed notification events Yauheni Kaliuta
2016-08-24 11:24 ` Jiri Olsa [this message]
2016-08-25 10:07 ` Yauheni Kaliuta
2016-09-07 10:27 ` [PATCH RFC 0/2] " Yauheni Kaliuta
2016-09-07 10:27 ` [PATCH RFC 1/2] rlimits: add infra to report violations Yauheni Kaliuta
2016-09-07 10:27 ` [PATCH RFC 2/2] rlimits: report resource limits violations Yauheni Kaliuta
2016-09-07 21:20 ` Alexei Starovoitov
2016-09-08 13:09 ` Hannes Frederic Sowa
2016-09-09 9:28 ` [PATCH RFC 0/2] rlimit exceed notification events Christoph Hellwig
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=20160824112428.GA15743@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=aris@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=yauheni.kaliuta@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox