814593 Commits

Author SHA1 Message Date
Joey Huab
267459ae7e Remove qti_kernel_headers
Some checks failed
Continues testing / build (push) Has been cancelled
2025-06-09 12:55:40 +09:00
kondors1995
449189df28 R7.1 2025-05-30 18:25:38 +03:00
kondors1995
3925accb67 drivers:kernelsu: update to 1.0.7 2025-05-30 18:19:00 +03:00
Rafael J. Wysocki
a6a20216ad cpufreq/sched: Set need_freq_update in ignore_dl_rate_limit()
Notice that ignore_dl_rate_limit() need not piggy back on the
limits_changed handling to achieve its goal (which is to enforce a
frequency update before its due time).

Namely, if sugov_should_update_freq() is updated to check
sg_policy->need_freq_update and return 'true' if it is set when
sg_policy->limits_changed is not set, ignore_dl_rate_limit() may
set the former directly instead of setting the latter, so it can
avoid hitting the memory barrier in sugov_should_update_freq().

Update the code accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/10666429.nUPlyArG6x@rjwysocki.net
2025-05-20 21:57:27 +03:00
Rafael J. Wysocki
38ac58ce7f cpufreq/sched: Explicitly synchronize limits_changed flag handling
The handling of the limits_changed flag in struct sugov_policy needs to
be explicitly synchronized to ensure that cpufreq policy limits updates
will not be missed in some cases.

Without that synchronization it is theoretically possible that
the limits_changed update in sugov_should_update_freq() will be
reordered with respect to the reads of the policy limits in
cpufreq_driver_resolve_freq() and in that case, if the limits_changed
update in sugov_limits() clobbers the one in sugov_should_update_freq(),
the new policy limits may not take effect for a long time.

Likewise, the limits_changed update in sugov_limits() may theoretically
get reordered with respect to the updates of the policy limits in
cpufreq_set_policy() and if sugov_should_update_freq() runs between
them, the policy limits change may be missed.

To ensure that the above situations will not take place, add memory
barriers preventing the reordering in question from taking place and
add READ_ONCE() and WRITE_ONCE() annotations around all of the
limits_changed flag updates to prevent the compiler from messing up
with that code.

Fixes: 600f5badb78c ("cpufreq: schedutil: Don't skip freq update when limits change")
Cc: 5.3+ <stable@vger.kernel.org> # 5.3+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/3376719.44csPzL39Z@rjwysocki.net
2025-05-20 21:57:27 +03:00
Rafael J. Wysocki
f56461366c cpufreq/sched: Fix the usage of CPUFREQ_NEED_UPDATE_LIMITS
Commit 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused
by need_freq_update") modified sugov_should_update_freq() to set the
need_freq_update flag only for drivers with CPUFREQ_NEED_UPDATE_LIMITS
set, but that flag generally needs to be set when the policy limits
change because the driver callback may need to be invoked for the new
limits to take effect.

However, if the return value of cpufreq_driver_resolve_freq() after
applying the new limits is still equal to the previously selected
frequency, the driver callback needs to be invoked only in the case
when CPUFREQ_NEED_UPDATE_LIMITS is set (which means that the driver
specifically wants its callback to be invoked every time the policy
limits change).

Update the code accordingly to avoid missing policy limits changes for
drivers without CPUFREQ_NEED_UPDATE_LIMITS.

Fixes: 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused by need_freq_update")
Closes: https://lore.kernel.org/lkml/Z_Tlc6Qs-tYpxWYb@linaro.org/
Reported-by: Stephan Gerhold <stephan.gerhold@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/3010358.e9J7NaK4W3@rjwysocki.net
2025-05-20 21:57:22 +03:00
kondors1995
0024237557 workflows:cache toolcahin to speed up build 2025-05-20 21:57:07 +03:00
kondors1995
47745fd957 build.sh/workflow: switch to r547379 2025-05-20 21:56:34 +03:00
kondors1995
497082a53a R7.0 2025-05-20 21:55:29 +03:00
EmanuelCN
cdf9fbb231 MIUI: drivers/android/binder: Boost binder's priority
Signed-off-by: EmanuelCN <emanuelghub@gmail.com>
2025-05-20 21:55:21 +03:00
Helium-Studio
8622719814 fs: Add close_fd_get_file() for binder
* Extracted from upstream commit [1].
* Combined with commit [2] and [3].

[1]: 80cd795630
[2]: 6e802a4ba0
[3]: 9fe83c43e7

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:40 +03:00
kondors1995
1c0d8c3843 Revert "fs: Add __close_fd_get_file() for binder"
This reverts commit c0772849e1.
2025-05-20 21:54:40 +03:00
Chungkai Mei
32bbf7d814 ANDROID: binder: Store previous uclamp by uclamp_req
To restore previous uclamp value, we still need store uclamp_req directly.
Otherwise, saved_priority will store effective uclamp value and restore it
to uclamp_req later.

Bug: 277389699
Change-Id: I7b3e357fcfc3bd955789e85d730713c384d0ade7
Signed-off-by: Chungkai Mei <chungkai@google.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:40 +03:00
Chungkai Mei
e76106a246 ANDROID: binder: Set default min and max uclamp to 0 and SCHED_CAPACITY_SCALE
Don't use the uclamp of current task as the default uclamp for
binders, because the uclamp of current task influence
binders' placement when not in a transaction.

Just use default value 0 and SCHED_CAPACITY_SCALE for binders'
default uclamp min and max. Also replace set_inherited_uclamp with
set_binder_prio_uclamp

Bug: 277389699
Change-Id: I07c4f40c2689dbc7eb23e7d3e2a2f435353dc25f
Signed-off-by: Chungkai Mei <chungkai@google.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:40 +03:00
Qais Yousef
f7aeced115 ANDROID: binder: Skip uclamp inheritance if !uclamp_is_used()
uclamp inheritance is not relevant while !uclamp_is_used().

Partially addresses the issue of enabling uclamp_is_used static key
causing a splat because of holding cpus_read_lock() in_atomic() context.

Bug: 259145692
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: Ib752e96e41b2fcace6edcdcec169f1ca56540a9b
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:40 +03:00
ChungKai Mei
143c5d3363 ANDROID: binder: Add support for uclamp inheritance
We may still have long binder transaction due to
insufficient uclamp, so expand binder_prioity to
inherit uclamp as well.

Bug: 226003124
Signed-off-by: ChungKai Mei <chungkai@google.com>
Change-Id: I307ab812638eeea1ca3e80ae07dee05fb9797dd6
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:40 +03:00
Juhyung Park
7b0bda0160 binder: Extend kmem cache to binder_task_work_cb and binder_txn_fd_fixup
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:40 +03:00
Sultan Alsawaf
968edf5ff8 binder: Reserve caches for small, high-frequency memory allocations
Most of binder's memory allocations are tiny, and they're allocated
and freed extremely frequently. The latency from going through the page
allocator all the time for such small allocations ends up being quite
high, especially when the system is low on memory. Binder is
performance-critical, so this is suboptimal.

Instead of using kzalloc to allocate a struct every time, reserve caches
specifically for allocating each struct quickly.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:39 +03:00
Juhyung Park
fe078b9b26 binder: Avoid using kzalloc() whenever possible
Those are initialized fully right below, use kmalloc().

Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:39 +03:00
Andrzej Perczak
83f1fe7c3c binder: Conditionally compile logging
Every binder operation is being logged. This impacts performance and
increases memory footprint. Since binder is critical for Android
operation, doing any logging on production builds isn't best idea.

Quick grep over Android sources revealed that only lshal and dumpsys
binaries use binder_log directory, these are not critical so breaking
them won't hurt much. Anyways, I was able to succesfully run both and
bacis functionality was still there.

Benchmarks showed significant decrease in transaction time with an avg
of 1000ns.

Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
[Helium-Studio: Forwardport to 5.10 binder]
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>

# Conflicts:
#	drivers/android/Kconfig
2025-05-20 21:54:39 +03:00
Carlos Llamas
0400120fb0 binder: fix descriptor lookup for context manager
In commit 15d9da3f818c ("binder: use bitmap for faster descriptor
lookup"), it was incorrectly assumed that references to the context
manager node should always get descriptor zero assigned to them.

However, if the context manager dies and a new process takes its place,
then assigning descriptor zero to the new context manager might lead to
collisions, as there could still be references to the older node. This
issue was reported by syzbot with the following trace:

  kernel BUG at drivers/android/binder.c:1173!
  Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
  Modules linked in:
  CPU: 1 PID: 447 Comm: binder-util Not tainted 6.10.0-rc6-00348-g31643d84b8c3 #10
  Hardware name: linux,dummy-virt (DT)
  pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  pc : binder_inc_ref_for_node+0x500/0x544
  lr : binder_inc_ref_for_node+0x1e4/0x544
  sp : ffff80008112b940
  x29: ffff80008112b940 x28: ffff0e0e40310780 x27: 0000000000000000
  x26: 0000000000000001 x25: ffff0e0e40310738 x24: ffff0e0e4089ba34
  x23: ffff0e0e40310b00 x22: ffff80008112bb50 x21: ffffaf7b8f246970
  x20: ffffaf7b8f773f08 x19: ffff0e0e4089b800 x18: 0000000000000000
  x17: 0000000000000000 x16: 0000000000000000 x15: 000000002de4aa60
  x14: 0000000000000000 x13: 2de4acf000000000 x12: 0000000000000020
  x11: 0000000000000018 x10: 0000000000000020 x9 : ffffaf7b90601000
  x8 : ffff0e0e48739140 x7 : 0000000000000000 x6 : 000000000000003f
  x5 : ffff0e0e40310b28 x4 : 0000000000000000 x3 : ffff0e0e40310720
  x2 : ffff0e0e40310728 x1 : 0000000000000000 x0 : ffff0e0e40310710
  Call trace:
   binder_inc_ref_for_node+0x500/0x544
   binder_transaction+0xf68/0x2620
   binder_thread_write+0x5bc/0x139c
   binder_ioctl+0xef4/0x10c8
  [...]

This patch adds back the previous behavior of assigning the next
non-zero descriptor if references to previous context managers still
exist. It amends both strategies, the newer dbitmap code and also the
legacy slow_desc_lookup_olocked(), by allowing them to start looking
for available descriptors at a given offset.

Fixes: 15d9da3f818c ("binder: use bitmap for faster descriptor lookup")
Cc: stable@vger.kernel.org
Reported-and-tested-by: syzbot+3dae065ca76952a67257@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000c1c0a0061d1e6979@google.com/
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/20240722150512.4192473-1-cmllamas@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:39 +03:00
Carlos Llamas
5f359fe5ac binder: use bitmap for faster descriptor lookup
When creating new binder references, the driver assigns a descriptor id
that is shared with userspace. Regrettably, the driver needs to keep the
descriptors small enough to accommodate userspace potentially using them
as Vector indexes. Currently, the driver performs a linear search on the
rb-tree of references to find the smallest available descriptor id. This
approach, however, scales poorly as the number of references grows.

This patch introduces the usage of bitmaps to boost the performance of
descriptor assignments. This optimization results in notable performance
gains, particularly in processes with a large number of references. The
following benchmark with 100,000 references showcases the difference in
latency between the dbitmap implementation and the legacy approach:

  [  587.145098] get_ref_desc_olocked: 15us (dbitmap on)
  [  602.788623] get_ref_desc_olocked: 47343us (dbitmap off)

Note the bitmap size is dynamically adjusted in line with the number of
references, ensuring efficient memory usage. In cases where growing the
bitmap is not possible, the driver falls back to the slow legacy method.

A previous attempt to solve this issue was proposed in [1]. However,
such method involved adding new ioctls which isn't great, plus older
userspace code would not have benefited from the optimizations either.

Link: https://lore.kernel.org/all/20240417191418.1341988-1-cmllamas@google.com/ [1]
Cc: Tim Murray <timmurray@google.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Martijn Coenen <maco@android.com>
Cc: Todd Kjos <tkjos@android.com>
Cc: John Stultz <jstultz@google.com>
Cc: Steven Moreland <smoreland@google.com>
Suggested-by: Nick Chen <chenjia3@oppo.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/20240612042535.1556708-1-cmllamas@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:39 +03:00
Lei Liu
b7a8641301 binder_alloc: Replace kcalloc with kvcalloc to mitigate OOM issues
In binder_alloc, there is a frequent need for order3 memory allocation,
especially on small-memory mobile devices, which can lead to OOM and
cause foreground applications to be killed, resulting in flashbacks.

We use kvcalloc to allocate memory, which can reduce system OOM
occurrences, as well as decrease the time and probability of failure for
order3 memory allocations. Additionally, It has little impact on the
throughput of the binder. (as verified by Google's binder_benchmark
testing tool).

We have conducted multiple tests on an 8GB memory phone, kvcalloc has
little performance degradation and resolves frequent OOM issues, Below
is a partial excerpt of the test data.

throughput(TH_PUT) = (size * Iterations)/Time
kcalloc->kvcalloc:

Sample with kcalloc():
adb shell stop/ kcalloc /8+256G
---------------------------------------------------------------------
Benchmark                Time     CPU   Iterations  TH-PUT  TH-PUTCPU
                         (ns)     (ns)              (GB/s)    (GB/s)
---------------------------------------------------------------------
BM_sendVec_binder4      39126    18550    38894    3.976282  8.38684
BM_sendVec_binder8      38924    18542    37786    7.766108  16.3028
BM_sendVec_binder16     38328    18228    36700    15.32039  32.2141
BM_sendVec_binder32     38154    18215    38240    32.07213  67.1798
BM_sendVec_binder64     39093    18809    36142    59.16885  122.977
BM_sendVec_binder128    40169    19188    36461    116.1843  243.2253
BM_sendVec_binder256    40695    19559    35951    226.1569  470.5484
BM_sendVec_binder512    41446    20211    34259    423.2159  867.8743
BM_sendVec_binder1024   44040    22939    28904    672.0639  1290.278
BM_sendVec_binder2048   47817    25821    26595    1139.063  2109.393
BM_sendVec_binder4096   54749    30905    22742    1701.423  3014.115
BM_sendVec_binder8192   68316    42017    16684    2000.634  3252.858
BM_sendVec_binder16384  95435    64081    10961    1881.752  2802.469
BM_sendVec_binder32768  148232  107504     6510    1439.093  1984.295
BM_sendVec_binder65536  326499  229874     3178    637.8991  906.0329
NORAML TEST                                 SUM    10355.79  17188.15
stressapptest eat 2G                        SUM    10088.39  16625.97

Sample with kvcalloc():
adb shell stop/ kvcalloc /8+256G
----------------------------------------------------------------------
Benchmark                Time     CPU   Iterations  TH-PUT  TH-PUTCPU
                         (ns)     (ns)              (GB/s)    (GB/s)
----------------------------------------------------------------------
BM_sendVec_binder4       39673    18832    36598    3.689965  7.773577
BM_sendVec_binder8       39869    18969    37188    7.462038  15.68369
BM_sendVec_binder16      39774    18896    36627    14.73405  31.01355
BM_sendVec_binder32      40225    19125    36995    29.43045  61.90013
BM_sendVec_binder64      40549    19529    35148    55.47544  115.1862
BM_sendVec_binder128     41580    19892    35384    108.9262  227.6871
BM_sendVec_binder256     41584    20059    34060    209.6806  434.6857
BM_sendVec_binder512     42829    20899    32493    388.4381  796.0389
BM_sendVec_binder1024    45037    23360    29251    665.0759  1282.236
BM_sendVec_binder2048    47853    25761    27091    1159.433  2153.735
BM_sendVec_binder4096    55574    31745    22405    1651.328  2890.877
BM_sendVec_binder8192    70706    43693    16400    1900.105  3074.836
BM_sendVec_binder16384   96161    64362    10793    1838.921  2747.468
BM_sendVec_binder32768  147875   107292     6296    1395.147  1922.858
BM_sendVec_binder65536  330324   232296     3053    605.7126  861.3209
NORAML TEST                                 SUM     10033.56  16623.35
stressapptest eat 2G                        SUM      9958.43  16497.55

Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
Acked-by: Carlos Llamas <cmllamas@google.com>

Bug: 350604214
Bug: 331900628
Link: https://lore.kernel.org/all/20240619113841.3362-1-liulei.rjpt@vivo.com/

Change-Id: I46e19121d03466e9f1ac42c8c7731c92b9eb9bbf
Signed-off-by: Lei Liu <liulei.rjpt@vivo.corp-partner.google.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:39 +03:00
Sean Du
34617ec7c6 binder: Fix compilation on 4.14
Helium-Studio: This is a squash of the following commits:
86429a2403
ff225d3e91
fc245aac49

Co-authored-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:39 +03:00
Helium-Studio
9fab75510d binder: Checkout to android13-5.10-lts
* HEAD: 76b049b586

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>

# Conflicts:
#	drivers/android/binder.c
#	drivers/android/binder_alloc.c
#	drivers/android/binder_alloc.h
#	drivers/android/binder_internal.h
#	drivers/android/binderfs.c
#	include/uapi/linux/android/binder.h
2025-05-20 21:54:38 +03:00
Michael Bestas
ec33655eb7 sched: Provide sched_setattr_nocheck()
Based on upstream commit 794a56ebd9a57db12abaec63f038c6eb073461f7

Change-Id: I2a6be669c847da253f09e72c6f41437a9c0f11ef
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:29 +03:00
Helium-Studio
e32461b411 defconfig: Switch to 250 Hz scheduler tick rate
* This can improve battery ever so slightly, over 300 Hz, according to Sultan.

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:13 +03:00
Helium-Studio
ccf0633356 defconfig: Set SBalance polling interval to 20 seconds
* On qcom devices, there are not too many IRQs to balance, set polling interval
  to 20 seconds should improve battery backup w/o hurting performance.

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:13 +03:00
zihan zhou
dcc4fc8469 sched: Reduce the default slice to avoid tasks getting an extra tick
The old default value for slice is 0.75 msec * (1 + ilog(ncpus)) which
means that we have a default slice of:

  0.75 for 1 cpu
  1.50 up to 3 cpus
  2.25 up to 7 cpus
  3.00 for 8 cpus and above.

For HZ=250 and HZ=100, because of the tick accuracy, the runtime of
tasks is far higher than their slice.

For HZ=1000 with 8 cpus or more, the accuracy of tick is already
satisfactory, but there is still an issue that tasks will get an extra
tick because the tick often arrives a little faster than expected. In
this case, the task can only wait until the next tick to consider that it
has reached its deadline, and will run 1ms longer.

vruntime + sysctl_sched_base_slice =     deadline
        |-----------|-----------|-----------|-----------|
             1ms          1ms         1ms         1ms
                   ^           ^           ^           ^
                 tick1       tick2       tick3       tick4(nearly 4ms)

There are two reasons for tick error: clockevent precision and the
CONFIG_IRQ_TIME_ACCOUNTING/CONFIG_PARAVIRT_TIME_ACCOUNTING. with
CONFIG_IRQ_TIME_ACCOUNTING every tick will be less than 1ms, but even
without it, because of clockevent precision, tick still often less than
1ms.

In order to make scheduling more precise, we changed 0.75 to 0.70,
Using 0.70 instead of 0.75 should not change much for other configs
and would fix this issue:

  0.70 for 1 cpu
  1.40 up to 3 cpus
  2.10 up to 7 cpus
  2.8 for 8 cpus and above.

This does not guarantee that tasks can run the slice time accurately
every time, but occasionally running an extra tick has little impact.

Signed-off-by: zihan zhou <15645113830zzh@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lkml.kernel.org/r/20250208075322.13139-1-15645113830zzh@gmail.com
[Helium-Studio: Adapt for 8 cpus]
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:13 +03:00
Alexander Winkowski
6d7dccfd20 sched: Apply Android tweaks manually
Tunables can't be changed with CONFIG_SCHED_DEBUG=n

b4b3950e52/rootdir/init.rc (L323)

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:12 +03:00
Helium-Studio
fc1fb82ca2 Revert "sched: promote nodes out of CONFIG_SCHED_DEBUG"
* Let's apply android tunes manually.

This reverts commit c810b18857.

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:12 +03:00
Helium-Studio
4ebe2c4d97 Makefile: Correct some optimization flags
* 4.14 doesn't have KBUILD_LDFLAGS, rename it to LDFLAGS
* Use --plugin-opt=O3 for LTO_CLANG, use -O3 for !LTO_CLANG

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:54:12 +03:00
kondors1995
2d1e1c8056 kernel:rcu: Drop Ofast flag
I have no idea way i even had it
2025-05-20 21:54:12 +03:00
John Galt
d81fcc9b86 Makefile: over inline optimization
To further improve MLGO inliner optimization
2025-05-20 21:54:12 +03:00
John Galt
d922fa4dbd Makefile: enable MLGO inliner optimization 2025-05-20 21:53:46 +03:00
Tashfin Shakeer Rhythm
60edd2fc8d lz4: Use ARM64 v8 ASM to accelerate lz4 decompression
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:35 +03:00
Tashfin Shakeer Rhythm
2d362c2cec lz4: Rename current variable to currentPos
Compiler gets confused between current variable in lz4.c and the
current macro in current.h.

This fixes the following compilation errors:

../lib/lz4/lz4.c:1145:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
 1145 |                                 U32 const current = (U32)(forwardIp - base);
      |                                           ^
../arch/arm64/include/asm/current.h:24:28: note: expanded from macro 'current'
   24 | #define current get_current()
      |                            ^
../lib/lz4/lz4.c:1145:15: error: conflicting types for 'get_current'
../arch/arm64/include/asm/current.h:24:17: note: expanded from macro 'current'
   24 | #define current get_current()
      |                 ^
../arch/arm64/include/asm/current.h:15:44: note: previous definition is here
   15 | static __always_inline struct task_struct *get_current(void)
      |                                            ^
../lib/lz4/lz4.c:1145:15: error: illegal initializer (only variables can be initialized)
 1145 |                                 U32 const current = (U32)(forwardIp - base);
      |                                           ^
../arch/arm64/include/asm/current.h:24:17: note: expanded from macro 'current'
   24 | #define current get_current()
      |                 ^

Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:35 +03:00
Dark-Matter7232
c202c41ba7 lz4armv8: Update assembly instructions from Huawei kernel drop
Signed-off-by: Dark-Matter7232 <me@const.eu.org>
[Tashar02: Fragment from original commit, improve indentations and reword commit message]
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:35 +03:00
阿菌•未霜
aacc61cd54 lib/lz4: Import ARM64 v8 ASM decompression acceleration
Change-Id: I3c8dd91df090bb692784a6b7a61c8877b1e1dfba
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:35 +03:00
Helium-Studio
583b9ecede lz4: Only compile lz4hc if needed
* We may not enable lz4hc, so compile it conditionally.

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:35 +03:00
Helium-Studio
0b79f5925a lz4: Reformat code using clang-format
* The official lz4 source files don't follow the Linux kernel coding style,
  reformat to keep the coding style consistent.

Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:34 +03:00
Chenyang Zhong
3f2dac333e lz4: Enable LZ4_FAST_DEC_LOOP
Upstream lz4 mentioned a performance regression on Qualcomm SoCs
when built with Clang, but not with GCC [1]. However, according to my
testing on sm8350 with LLVM Clang 15, this patch does offer a nice
10% boost in decompression, so enable the fast dec loop for Clang
as well.

Testing procedure:
- pre-fill zram with 1GB of real-word zram data dumped under memory
  pressure, for example
  $ dd if=/sdcard/zram.test of=/dev/block/zram0 bs=1m count=1000
- $ fio --readonly --name=randread --direct=1 --rw=randread \
  --ioengine=psync --randrepeat=0 --numjobs=4 --iodepth=1 \
  --group_reporting=1 --filename=/dev/block/zram0 --bs=4K --size=1000M

Results:
- vanilla lz4: read: IOPS=1646k, BW=6431MiB/s (6743MB/s)(4000MiB/622msec)
- lz4 fast dec: read: IOPS=1775k, BW=6932MiB/s (7269MB/s)(4000MiB/577msec)

[1] https://github.com/lz4/lz4/pull/707

Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
[Helium-Studio: Reword the commit message to reflect unconditionally enabling]
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:34 +03:00
Juhyung Park
8083c7b0d2 lz4: Fix LZ4_compress_fast() definition
LZ4_compress_fast() should be exported with wrkmem.

Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:34 +03:00
Juhyung Park
f54b07e6c5 lz4: Define LZ4HC_DEFAULT_CLEVEL for compatibility
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:34 +03:00
Juhyung Park
0be5ad894f lz4: Adapt to Linux kernel
A quick benchmark shows this improves zram performance by 3.8% in
4K blocks, 3.4% in 1M blocks.

Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>
2025-05-20 21:53:26 +03:00
Juhyung Park
ce31fef3ea lz4: Import v1.10.0 from upstream
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com>

# Conflicts:
#	include/linux/lz4.h
#	include/linux/lz4.h~HEAD
#	lib/lz4/Makefile
#	lib/lz4/lz4_compress.c
#	lib/lz4/lz4_decompress.c
#	lib/lz4/lz4defs.h
#	lib/lz4/lz4hc_compress.c
2025-05-20 21:53:14 +03:00
Christoph Hellwig
98df9ec19a BACKPORT: maccess: rename strncpy_from_unsafe_user to strncpy_from_user_nofault
This matches the naming of strncpy_from_user, and also makes it more
clear what the function is supposed to do.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20200521152301.2587579-7-hch@lst.de
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

cherry picked from bd88bb5d40 upstream
Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
2025-05-18 18:21:58 +03:00
sidex15
f9f11c4b9a security: kernelsu manual security hooks
More info: backslashxx/KernelSU#7
2025-05-18 18:21:58 +03:00
sidex15
ab8921296e fs: kernelsu: scope-minimized manual hooks
This refactors original KSU hooks to replace deep kernel function hooks with targeted hooks.
This backports KernelSU pr#1657 and having pr#2084 elements (32-bit sucompat).
It reduces the scope of kernel function interception and still maintains full fucntionality.

more info: backslashxx/KernelSU#5
2025-05-18 18:21:50 +03:00
kondors1995
3d46e261d9 drivers: kernelsu: update to 1.0.6 2025-05-18 18:21:38 +03:00