[PATCH v5 4/4] kernel: virtio modules depend on x86_kvm_guest
[openwrt.git] / package / compcache / patches / 001-lzo-speed.patch
1 --- a/sub-projects/compression/lzo-kmod/lzo1x_compress.c
2 +++ b/sub-projects/compression/lzo-kmod/lzo1x_compress.c
3 @@ -62,8 +62,12 @@ _lzo1x_1_do_compress(const unsigned char
4 goto literal;
5
6 try_match:
7 +#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
8 if (get_unaligned((const unsigned short *)m_pos)
9 == get_unaligned((const unsigned short *)ip)) {
10 +#else
11 + if (m_pos[0] == ip[0] && m_pos[1] == ip[1]) {
12 +#endif
13 if (likely(m_pos[2] == ip[2]))
14 goto match;
15 }
16 @@ -94,9 +98,14 @@ match:
17 }
18 *op++ = tt;
19 }
20 - do {
21 - *op++ = *ii++;
22 - } while (--t > 0);
23 + if (t >= 2 * 4) {
24 + memcpy(op, ii, t);
25 + op += t;
26 + ii += t;
27 + } else
28 + do {
29 + *op++ = *ii++;
30 + } while (--t > 0);
31 }
32
33 ip += 3;
34 @@ -208,9 +217,14 @@ int lzo1x_1_compress(const unsigned char
35
36 *op++ = tt;
37 }
38 - do {
39 - *op++ = *ii++;
40 - } while (--t > 0);
41 + if (t >= 2 * 4) {
42 + memcpy(op, ii, t);
43 + op += t;
44 + ii += t;
45 + } else
46 + do {
47 + *op++ = *ii++;
48 + } while (--t > 0);
49 }
50
51 *op++ = M4_MARKER | 1;
52 @@ -224,4 +238,3 @@ EXPORT_SYMBOL_GPL(lzo1x_1_compress);
53
54 MODULE_LICENSE("GPL");
55 MODULE_DESCRIPTION("LZO1X-1 Compressor");
56 -
57 --- a/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
58 +++ b/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
59 @@ -45,10 +45,7 @@ int lzo1x_decompress_safe(const unsigned
60 goto output_overrun;
61 if (HAVE_IP(t + 1, ip_end, ip))
62 goto input_overrun;
63 - do {
64 - *op++ = *ip++;
65 - } while (--t > 0);
66 - goto first_literal_run;
67 + goto prep_first_literal_run;
68 }
69
70 while ((ip < ip_end)) {
71 @@ -71,30 +68,27 @@ int lzo1x_decompress_safe(const unsigned
72 if (HAVE_IP(t + 4, ip_end, ip))
73 goto input_overrun;
74
75 - COPY4(op, ip);
76 - op += 4;
77 - ip += 4;
78 - if (--t > 0) {
79 - if (t >= 4) {
80 - do {
81 - COPY4(op, ip);
82 - op += 4;
83 - ip += 4;
84 - t -= 4;
85 - } while (t >= 4);
86 - if (t > 0) {
87 - do {
88 - *op++ = *ip++;
89 - } while (--t > 0);
90 - }
91 - } else {
92 + t += (4 - 1);
93 + if (t >= 2 * 4) {
94 + memcpy(op, ip, t);
95 + op += t;
96 + ip += t;
97 + } else {
98 + do {
99 + COPY4(op, ip);
100 + op += 4;
101 + ip += 4;
102 + t -= 4;
103 + } while (t >= 4);
104 + if (t > 0) {
105 +prep_first_literal_run:
106 do {
107 *op++ = *ip++;
108 } while (--t > 0);
109 }
110 }
111
112 -first_literal_run:
113 +//first_literal_run:
114 t = *ip++;
115 if (t >= 16)
116 goto match;
117 @@ -139,8 +133,7 @@ match:
118 t += 31 + *ip++;
119 }
120 m_pos = op - 1;
121 - m_pos -= le16_to_cpu(get_unaligned(
122 - (const unsigned short *)ip)) >> 2;
123 + m_pos -= get_unaligned_le16(ip) >> 2;
124 ip += 2;
125 } else if (t >= 16) {
126 m_pos = op;
127 @@ -158,8 +151,7 @@ match:
128 }
129 t += 7 + *ip++;
130 }
131 - m_pos -= le16_to_cpu(get_unaligned(
132 - (const unsigned short *)ip)) >> 2;
133 + m_pos -= get_unaligned_le16(ip) >> 2;
134 ip += 2;
135 if (m_pos == op)
136 goto eof_found;
137 @@ -184,21 +176,33 @@ match:
138 if (HAVE_OP(t + 3 - 1, op_end, op))
139 goto output_overrun;
140
141 - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
142 - COPY4(op, m_pos);
143 - op += 4;
144 - m_pos += 4;
145 - t -= 4 - (3 - 1);
146 - do {
147 + if (t >= 2 * 4 - (3 - 1)) {
148 + /*
149 + * Assume memcpy don't copy
150 + * more than 32 bytes at once
151 + */
152 + if ((op - m_pos) >= 32) {
153 + t += (3 - 1);
154 + memcpy(op, m_pos, t);
155 + op += t;
156 + m_pos += t;
157 + } else if ((op - m_pos) >= 4) {
158 COPY4(op, m_pos);
159 op += 4;
160 m_pos += 4;
161 - t -= 4;
162 - } while (t >= 4);
163 - if (t > 0)
164 + t -= 4 - (3 - 1);
165 do {
166 - *op++ = *m_pos++;
167 - } while (--t > 0);
168 + COPY4(op, m_pos);
169 + op += 4;
170 + m_pos += 4;
171 + t -= 4;
172 + } while (t >= 4);
173 + if (t > 0)
174 + do {
175 + *op++ = *m_pos++;
176 + } while (--t > 0);
177 + } else
178 + goto copy_match;
179 } else {
180 copy_match:
181 *op++ = *m_pos++;
This page took 0.058397 seconds and 5 git commands to generate.