From: agk@sourceware.org
To: dm-cvs@sourceware.org, dm-devel@redhat.com
Subject: device-mapper/dmeventd dmeventd.c
Date: 16 Jan 2007 20:13:05 -0000 [thread overview]
Message-ID: <20070116201305.1608.qmail@sourceware.org> (raw)
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-01-16 20:13:04
Modified files:
dmeventd : dmeventd.c
Log message:
dmeventd oom_adj + reduce thread stack size
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmeventd/dmeventd.c.diff?cvsroot=dm&r1=1.35&r2=1.36
--- device-mapper/dmeventd/dmeventd.c 2007/01/16 18:03:40 1.35
+++ device-mapper/dmeventd/dmeventd.c 2007/01/16 20:13:04 1.36
@@ -66,6 +66,8 @@
#define DM_THREAD_SHUTDOWN 1
#define DM_THREAD_DONE 2
+#define THREAD_STACK_SIZE 300*1024
+
/* Data kept about a DSO. */
struct dso_data {
struct list list;
@@ -213,6 +215,15 @@
return ret;
}
+/* Create a device monitoring thread. */
+static int _pthread_create_smallstack(pthread_t *t, void *(*fun)(void *), void *arg)
+{
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE);
+ return pthread_create(t, &attr, fun, arg);
+}
+
static void _free_dso_data(struct dso_data *data)
{
dm_free(data->dso_name);
@@ -458,8 +469,7 @@
if (!_timeout_running) {
pthread_t timeout_id;
- if (!(ret = -pthread_create(&timeout_id, NULL,
- _timeout_thread, NULL)))
+ if (!(ret = -_pthread_create_smallstack(&timeout_id, _timeout_thread, NULL)))
_timeout_running = 1;
}
@@ -688,7 +698,7 @@
/* Create a device monitoring thread. */
static int _create_thread(struct thread_status *thread)
{
- return pthread_create(&thread->thread, NULL, _monitor_thread, thread);
+ return _pthread_create_smallstack(&thread->thread, _monitor_thread, thread);
}
static int _terminate_thread(struct thread_status *thread)
@@ -1407,6 +1417,21 @@
return 0;
}
+static int _set_oom_adj(int val)
+{
+ FILE *fp;
+
+ fp = fopen("/proc/self/oom_adj", "w");
+
+ if (!fp)
+ return 0;
+
+ fprintf(fp, "%i", val);
+ fclose(fp);
+
+ return 1;
+}
+
static void _daemonize(void)
{
int status;
@@ -1495,6 +1520,9 @@
_daemonize();
+ if (!_set_oom_adj(-16))
+ syslog(LOG_ERR, "Failed to set oom_adj to protect against OOM killer");
+
_init_thread_signals();
//multilog_clear_logging();
next reply other threads:[~2007-01-16 20:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-16 20:13 agk [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-07-09 13:26 device-mapper/dmeventd dmeventd.c mornfall
2007-04-24 13:29 mornfall
2007-01-19 18:08 agk
2007-01-16 20:27 agk
2007-01-15 22:37 agk
2007-01-15 19:19 agk
2007-01-15 18:58 agk
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=20070116201305.1608.qmail@sourceware.org \
--to=agk@sourceware.org \
--cc=dm-cvs@sourceware.org \
--cc=dm-devel@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