From: Matthias Brugger <mbrugger@suse.com>
To: Albert Vaca Cintora <albertvaka@gmail.com>,
akpm@linux-foundation.org, rdunlap@infradead.org,
mingo@kernel.org, Jan Kara <jack@suse.cz>,
ebiederm@xmission.com,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] kernel/ucounts: expose count of inotify watches in use
Date: Thu, 25 Apr 2019 17:58:15 +0200 [thread overview]
Message-ID: <f6d16e13-cdcb-2b6b-bfb4-1e02d4aed61d@suse.com> (raw)
In-Reply-To: <CAAQViEv2eBf9o7EaXo1=6hJrhDQJawf3jreFt=CWPDJCUzGRxw@mail.gmail.com>
On 22/02/2019 18:58, Albert Vaca Cintora wrote:
> On Fri, Feb 1, 2019 at 9:42 PM Albert Vaca Cintora <albertvaka@gmail.com> wrote:
>>
>> Adds a readonly 'current_inotify_watches' entry to the user sysctl table.
>> The handler for this entry is a custom function that ends up calling
>> proc_dointvec. Said sysctl table already contains 'max_inotify_watches'
>> and it gets mounted under /proc/sys/user/.
>>
>> Inotify watches are a finite resource, in a similar way to available file
>> descriptors. The motivation for this patch is to be able to set up
>> monitoring and alerting before an application starts failing because
>> it runs out of inotify watches.
>>
>> Signed-off-by: Albert Vaca Cintora <albertvaka@gmail.com>
>> Acked-by: Jan Kara <jack@suse.cz>
>> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> Friendly ping. Any comments on this?
>
Any comments on this? Just to make it clear, Albert found this problem while
working on montitoring software, so it fixes a real problem out there.
Regards,
Matthias
>> ---
>> kernel/ucount.c | 29 +++++++++++++++++++++++++++++
>> 1 file changed, 29 insertions(+)
>>
>> diff --git a/kernel/ucount.c b/kernel/ucount.c
>> index f48d1b6376a4..d8b11e53f098 100644
>> --- a/kernel/ucount.c
>> +++ b/kernel/ucount.c
>> @@ -57,6 +57,11 @@ static struct ctl_table_root set_root = {
>> .permissions = set_permissions,
>> };
>>
>> +#ifdef CONFIG_INOTIFY_USER
>> +int proc_read_inotify_watches(struct ctl_table *table, int write,
>> + void __user *buffer, size_t *lenp, loff_t *ppos);
>> +#endif
>> +
>> static int zero = 0;
>> static int int_max = INT_MAX;
>> #define UCOUNT_ENTRY(name) \
>> @@ -79,6 +84,12 @@ static struct ctl_table user_table[] = {
>> #ifdef CONFIG_INOTIFY_USER
>> UCOUNT_ENTRY("max_inotify_instances"),
>> UCOUNT_ENTRY("max_inotify_watches"),
>> + {
>> + .procname = "current_inotify_watches",
>> + .maxlen = sizeof(int),
>> + .mode = 0444,
>> + .proc_handler = proc_read_inotify_watches,
>> + },
>> #endif
>> { }
>> };
>> @@ -226,6 +237,24 @@ void dec_ucount(struct ucounts *ucounts, enum ucount_type type)
>> put_ucounts(ucounts);
>> }
>>
>> +#ifdef CONFIG_INOTIFY_USER
>> +int proc_read_inotify_watches(struct ctl_table *table, int write,
>> + void __user *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> + struct ucounts *ucounts;
>> + struct ctl_table fake_table;
>> + int count;
>> +
>> + ucounts = get_ucounts(current_user_ns(), current_euid());
>> + count = atomic_read(&ucounts->ucount[UCOUNT_INOTIFY_WATCHES]);
>> + put_ucounts(ucounts);
>> +
>> + fake_table.data = &count;
>> + fake_table.maxlen = sizeof(count);
>> + return proc_dointvec(&fake_table, write, buffer, lenp, ppos);
>> +}
>> +#endif
>> +
>> static __init int user_namespace_sysctl_init(void)
>> {
>> #ifdef CONFIG_SYSCTL
>> --
>> 2.20.1
>>
>
next prev parent reply other threads:[~2019-04-25 15:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-01 20:39 Albert Vaca Cintora
2019-02-22 17:58 ` Albert Vaca Cintora
2019-04-25 15:58 ` Matthias Brugger [this message]
2019-04-25 20:06 ` Andrew Morton
2019-04-25 21:39 ` Albert Vaca Cintora
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=f6d16e13-cdcb-2b6b-bfb4-1e02d4aed61d@suse.com \
--to=mbrugger@suse.com \
--cc=akpm@linux-foundation.org \
--cc=albertvaka@gmail.com \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=nsaenzjulienne@suse.de \
--cc=rdunlap@infradead.org \
/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®