summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2014-02-10 19:33:35 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-11 11:56:56 +0000
commit6bf21ce08264e18c0b27b373af3cebef1ca18098 (patch)
tree9b09ebbc428a24ac7d23a417861a2e017752a11a /meta/recipes-core
parent410a3e157414448bb7de613b7055a4a33ad20fae (diff)
downloadpoky-6bf21ce08264e18c0b27b373af3cebef1ca18098.tar.gz
systemd: Fix misc journald memory bugs
These set of patches fix journald exhibiting some issues under load. One of the prevelant issues is that when appending to journal it is not able to allocate memory and starts taking 100% cpu spewing errors like systemd-journald[2934]: Failed to write entry (19 items, 452 bytes), ignoring: Cannot allocate memory Other memory issues crept up with time e.g.vacuuming (From OE-Core rev: b1bdc1c6fb6914d85f888acde9d806d5560c84d8) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/systemd/systemd/journal-Add-missing-byte-order-conversions.patch60
-rw-r--r--meta/recipes-core/systemd/systemd/journal-file-protect-against-alloca-0.patch23
-rw-r--r--meta/recipes-core/systemd/systemd/journal-when-appending-to-journal-file-allocate-larg.patch83
-rw-r--r--meta/recipes-core/systemd/systemd/journald-add-missing-error-check.patch16
-rw-r--r--meta/recipes-core/systemd/systemd/journald-fix-minor-memory-leak.patch16
-rw-r--r--meta/recipes-core/systemd/systemd_208.bb5
6 files changed, 203 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/journal-Add-missing-byte-order-conversions.patch b/meta/recipes-core/systemd/systemd/journal-Add-missing-byte-order-conversions.patch
new file mode 100644
index 0000000000..21ea0f9502
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/journal-Add-missing-byte-order-conversions.patch
@@ -0,0 +1,60 @@
1From 43539d6b60ef0db3e98d00bef0024614c8c1807a Mon Sep 17 00:00:00 2001
2From: George McCollister <george.mccollister@gmail.com>
3Date: Tue, 31 Dec 2013 14:37:32 -0600
4Subject: [PATCH] journal: Add missing byte order conversions
5
6Convert entry_array.items[0] to host byte order prior to passing it to
7chain_cache_put().
8
9[zj: also use le64toh in journal-verify.c]
10
11https://bugs.freedesktop.org/show_bug.cgi?id=73194
12
13Upstream-Status: Backport [Fedora]
14---
15 src/journal/journal-file.c | 4 ++--
16 src/journal/journal-verify.c | 6 +++---
17 2 files changed, 5 insertions(+), 5 deletions(-)
18
19Index: systemd-208/src/journal/journal-file.c
20===================================================================
21--- systemd-208.orig/src/journal/journal-file.c 2014-02-07 22:51:44.000000000 -0800
22+++ systemd-208/src/journal/journal-file.c 2014-02-07 22:58:40.665062951 -0800
23@@ -1447,7 +1447,7 @@
24
25 found:
26 /* Let's cache this item for the next invocation */
27- chain_cache_put(f->chain_cache, ci, first, a, o->entry_array.items[0], t);
28+ chain_cache_put(f->chain_cache, ci, first, a, le64toh(o->entry_array.items[0]), t);
29
30 r = journal_file_move_to_object(f, OBJECT_ENTRY, p, &o);
31 if (r < 0)
32@@ -1624,7 +1624,7 @@
33 return 0;
34
35 /* Let's cache this item for the next invocation */
36- chain_cache_put(f->chain_cache, ci, first, a, array->entry_array.items[0], t);
37+ chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t);
38
39 if (subtract_one && i == 0)
40 p = last_p;
41Index: systemd-208/src/journal/journal-verify.c
42===================================================================
43--- systemd-208.orig/src/journal/journal-verify.c 2013-08-13 13:02:46.000000000 -0700
44+++ systemd-208/src/journal/journal-verify.c 2014-02-07 22:57:14.849308409 -0800
45@@ -249,12 +249,12 @@
46 }
47
48 for (i = 0; i < journal_file_entry_array_n_items(o); i++)
49- if (o->entry_array.items[i] != 0 &&
50- !VALID64(o->entry_array.items[i])) {
51+ if (le64toh(o->entry_array.items[i]) != 0 &&
52+ !VALID64(le64toh(o->entry_array.items[i]))) {
53 log_error(OFSfmt": invalid object entry array item (%"PRIu64"/%"PRIu64"): "OFSfmt,
54 offset,
55 i, journal_file_entry_array_n_items(o),
56- o->entry_array.items[i]);
57+ le64toh(o->entry_array.items[i]));
58 return -EBADMSG;
59 }
60
diff --git a/meta/recipes-core/systemd/systemd/journal-file-protect-against-alloca-0.patch b/meta/recipes-core/systemd/systemd/journal-file-protect-against-alloca-0.patch
new file mode 100644
index 0000000000..953373ee49
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/journal-file-protect-against-alloca-0.patch
@@ -0,0 +1,23 @@
1From a25fd0d4bd3cf652e55c24e7dc873fe530fa111a Mon Sep 17 00:00:00 2001
2From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
3Date: Mon, 16 Dec 2013 23:35:30 +0100
4Subject: [PATCH] journal-file: protect against alloca(0)
5
6---
7 src/journal/journal-file.c | 3 ++-
8 1 file changed, 2 insertions(+), 1 deletion(-)
9
10diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
11index 090cf97..8ea258b 100644
12--- a/src/journal/journal-file.c
13+++ b/src/journal/journal-file.c
14@@ -2737,7 +2737,8 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
15 ts.realtime = le64toh(o->entry.realtime);
16
17 n = journal_file_entry_n_items(o);
18- items = alloca(sizeof(EntryItem) * n);
19+ /* alloca() can't take 0, hence let's allocate at least one */
20+ items = alloca(sizeof(EntryItem) * MAX(1u, n));
21
22 for (i = 0; i < n; i++) {
23 uint64_t l, h;
diff --git a/meta/recipes-core/systemd/systemd/journal-when-appending-to-journal-file-allocate-larg.patch b/meta/recipes-core/systemd/systemd/journal-when-appending-to-journal-file-allocate-larg.patch
new file mode 100644
index 0000000000..89573bbaf9
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/journal-when-appending-to-journal-file-allocate-larg.patch
@@ -0,0 +1,83 @@
1From c0658e1948c301177b1527227be0c18932cd7cce Mon Sep 17 00:00:00 2001
2From: Lennart Poettering <lennart@poettering.net>
3Date: Tue, 26 Nov 2013 18:39:42 +0100
4Subject: [PATCH] journal: when appending to journal file, allocate larger
5 blocks at once
6
7(cherry picked from commit a676e66535e12458ea6d366a653f8dd60f982504)
8
9Conflicts:
10 src/journal/journal-file.c
11---
12 src/journal/journal-file.c | 26 +++++++++++++++++---------
13 1 file changed, 17 insertions(+), 9 deletions(-)
14
15Upstream-Status: Backport
16
17Index: systemd-208/src/journal/journal-file.c
18===================================================================
19--- systemd-208.orig/src/journal/journal-file.c 2014-02-07 22:37:06.013722798 -0800
20+++ systemd-208/src/journal/journal-file.c 2014-02-07 22:44:51.563341090 -0800
21@@ -68,6 +68,9 @@
22 /* How many entries to keep in the entry array chain cache at max */
23 #define CHAIN_CACHE_MAX 20
24
25+/* How much to increase the journal file size at once each time we allocate something new. */
26+#define FILE_SIZE_INCREASE (8ULL*1024ULL*1024ULL) /* 8MB */
27+
28 int journal_file_set_online(JournalFile *f) {
29 assert(f);
30
31@@ -218,8 +221,7 @@
32 journal_file_set_online(f);
33
34 /* Sync the online state to disk */
35- msync(f->header, PAGE_ALIGN(sizeof(Header)), MS_SYNC);
36- fdatasync(f->fd);
37+ fsync(f->fd);
38
39 return 0;
40 }
41@@ -313,7 +315,7 @@
42 }
43
44 static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
45- uint64_t old_size, new_size;
46+ uint64_t old_size, new_size, file_size;
47 int r;
48
49 assert(f);
50@@ -333,12 +335,10 @@
51 if (new_size <= old_size)
52 return 0;
53
54- if (f->metrics.max_size > 0 &&
55- new_size > f->metrics.max_size)
56+ if (f->metrics.max_size > 0 && new_size > f->metrics.max_size)
57 return -E2BIG;
58
59- if (new_size > f->metrics.min_size &&
60- f->metrics.keep_free > 0) {
61+ if (new_size > f->metrics.min_size && f->metrics.keep_free > 0) {
62 struct statvfs svfs;
63
64 if (fstatvfs(f->fd, &svfs) >= 0) {
65@@ -363,8 +363,16 @@
66 if (r != 0)
67 return -r;
68
69- if (fstat(f->fd, &f->last_stat) < 0)
70- return -errno;
71+ /* Increase the file size a bit further than this, so that we
72+ * we can create larger memory maps to cache */
73+ file_size = ((new_size+FILE_SIZE_INCREASE-1) / FILE_SIZE_INCREASE) * FILE_SIZE_INCREASE;
74+ if (file_size > (uint64_t) f->last_stat.st_size) {
75+ if (file_size > new_size)
76+ ftruncate(f->fd, file_size);
77+
78+ if (fstat(f->fd, &f->last_stat) < 0)
79+ return -errno;
80+ }
81
82 f->header->arena_size = htole64(new_size - le64toh(f->header->header_size));
83
diff --git a/meta/recipes-core/systemd/systemd/journald-add-missing-error-check.patch b/meta/recipes-core/systemd/systemd/journald-add-missing-error-check.patch
new file mode 100644
index 0000000000..10590e142c
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/journald-add-missing-error-check.patch
@@ -0,0 +1,16 @@
1Upstream-Status: Backport [Fedora]
2
3Index: systemd-208/src/journal/journal-file.c
4===================================================================
5--- systemd-208.orig/src/journal/journal-file.c 2013-08-13 13:02:46.397707086 -0700
6+++ systemd-208/src/journal/journal-file.c 2014-02-07 22:29:01.398794277 -0800
7@@ -907,7 +907,8 @@
8
9 osize = offsetof(Object, field.payload) + size;
10 r = journal_file_append_object(f, OBJECT_FIELD, osize, &o, &p);
11-
12+ if (r < 0)
13+ return r;
14 o->field.hash = htole64(hash);
15 memcpy(o->field.payload, field, size);
16
diff --git a/meta/recipes-core/systemd/systemd/journald-fix-minor-memory-leak.patch b/meta/recipes-core/systemd/systemd/journald-fix-minor-memory-leak.patch
new file mode 100644
index 0000000000..9b90ed2688
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/journald-fix-minor-memory-leak.patch
@@ -0,0 +1,16 @@
1Fix minor memory leak
2
3Upstream-Status: Backport [Fedora]
4
5Index: systemd-208/src/journal/journal-vacuum.c
6===================================================================
7--- systemd-208.orig/src/journal/journal-vacuum.c 2013-09-12 05:51:57.258256643 -0700
8+++ systemd-208/src/journal/journal-vacuum.c 2014-02-07 22:35:55.695747001 -0800
9@@ -277,6 +277,7 @@
10 freed += size;
11 } else if (errno != ENOENT)
12 log_warning("Failed to delete %s/%s: %m", directory, p);
13+ free(p);
14
15 continue;
16 }
diff --git a/meta/recipes-core/systemd/systemd_208.bb b/meta/recipes-core/systemd/systemd_208.bb
index 5ed31c35b0..f94ce56252 100644
--- a/meta/recipes-core/systemd/systemd_208.bb
+++ b/meta/recipes-core/systemd/systemd_208.bb
@@ -20,6 +20,11 @@ inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d update-altern
20SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \ 20SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \
21 file://0001-Use-bin-mkdir-instead-of-host-mkdir-path.patch \ 21 file://0001-Use-bin-mkdir-instead-of-host-mkdir-path.patch \
22 file://binfmt-install.patch \ 22 file://binfmt-install.patch \
23 file://journald-add-missing-error-check.patch \
24 file://journald-fix-minor-memory-leak.patch \
25 file://journal-when-appending-to-journal-file-allocate-larg.patch \
26 file://journal-file-protect-against-alloca-0.patch \
27 file://journal-Add-missing-byte-order-conversions.patch \
23 file://touchscreen.rules \ 28 file://touchscreen.rules \
24 ${UCLIBCPATCHES} \ 29 ${UCLIBCPATCHES} \
25 file://00-create-volatile.conf \ 30 file://00-create-volatile.conf \