Skip to content

Commit d878106

Browse files
committed
Merge tag 'v6.18.5' into 6.18-main
This is the 6.18.5 stable release # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCgAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmljs1IACgkQONu9yGCS # aT66Kw//czXeq7+Mp+HJQNFQrdwIaaPmAON8gG14t5sAUe86qRGRrGzBr7TsArKA # dImgnMjg/BO1f1lpxyKxBbs5vxDN+5dPPaJksJn2UKGJhDnqEEvdsaJli69SxNfw # GXjbf2x2TUQQ/NAiP/qi4xatMjnOgCEcsdgxe64ZP8FzoJZP2NVf0dEBKdgC5Stp # i0Kg0SqrM39eQd7YXxq+cQmOM+PApeYz1l68OvnxLlIp0oT8emLC5YhscIQfH5PM # G1kfleYKTmKtf/Gbfq/DcNyhdHYrgJW/bInbx3gJXRdsr5PWoqSWBehvX9rAsnrK # k/XyK2JlmBRLVJvg3h0M7j90d043fuLncUK0Zj3WmMsN+/NPPr5M0V3lgQgETM6w # pOPIco2uOF9FHTe8mwXLZzjeLVCzodSDjRqwKWwH4PzobH64vASffVge1aDOzanA # tShSOiP/Qb31Ag8Q357qJnYhoci1ZslX6dVVI3KVXdy7jkgtJusuKd8TQOH6aCap # 6p/Rh7fMLp7htRAIGLZbpplgiuu3rQ6bk1MVE2X7FUBZzlkaa78FZTy5HCX+J3YF # dTCiviHxjqYsEGjw7trnKm7G7TlFRIBZtSeLv7i4mlQlGbWEFSpvjbSsFDg1Al2S # sOfjYVJk9w60/xBcM9BK44Tw+okpxQ8iBtZT3URG4ZnauUap0Mk= # =krUN # -----END PGP SIGNATURE----- # gpg: Signature made Sun Jan 11 15:27:30 2026 CET # gpg: using RSA key 647F28654894E3BD457199BE38DBBDC86092693E # gpg: Can't check signature: No public key
2 parents 6e9cf6d + dc554c8 commit d878106

10 files changed

Lines changed: 91 additions & 23 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 6
33
PATCHLEVEL = 18
4-
SUBLEVEL = 4
4+
SUBLEVEL = 5
55
EXTRAVERSION =
66
NAME = Baby Opossum Posse
77

fs/nfs/localio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,6 @@ static void nfs_local_call_read(struct work_struct *work)
623623
ssize_t status;
624624
int n_iters;
625625

626-
save_cred = override_creds(filp->f_cred);
627-
628626
n_iters = atomic_read(&iocb->n_iters);
629627
for (int i = 0; i < n_iters ; i++) {
630628
if (iocb->iter_is_dio_aligned[i]) {
@@ -637,7 +635,10 @@ static void nfs_local_call_read(struct work_struct *work)
637635
} else
638636
iocb->kiocb.ki_flags &= ~IOCB_DIRECT;
639637

638+
save_cred = override_creds(filp->f_cred);
640639
status = filp->f_op->read_iter(&iocb->kiocb, &iocb->iters[i]);
640+
revert_creds(save_cred);
641+
641642
if (status != -EIOCBQUEUED) {
642643
if (unlikely(status >= 0 && status < iocb->iters[i].count))
643644
force_done = true; /* Partial read */
@@ -647,8 +648,6 @@ static void nfs_local_call_read(struct work_struct *work)
647648
}
648649
}
649650
}
650-
651-
revert_creds(save_cred);
652651
}
653652

654653
static int
@@ -830,7 +829,6 @@ static void nfs_local_call_write(struct work_struct *work)
830829
int n_iters;
831830

832831
current->flags |= PF_LOCAL_THROTTLE | PF_MEMALLOC_NOIO;
833-
save_cred = override_creds(filp->f_cred);
834832

835833
file_start_write(filp);
836834
n_iters = atomic_read(&iocb->n_iters);
@@ -845,7 +843,10 @@ static void nfs_local_call_write(struct work_struct *work)
845843
} else
846844
iocb->kiocb.ki_flags &= ~IOCB_DIRECT;
847845

846+
save_cred = override_creds(filp->f_cred);
848847
status = filp->f_op->write_iter(&iocb->kiocb, &iocb->iters[i]);
848+
revert_creds(save_cred);
849+
849850
if (status != -EIOCBQUEUED) {
850851
if (unlikely(status >= 0 && status < iocb->iters[i].count))
851852
force_done = true; /* Partial write */
@@ -857,7 +858,6 @@ static void nfs_local_call_write(struct work_struct *work)
857858
}
858859
file_end_write(filp);
859860

860-
revert_creds(save_cred);
861861
current->flags = old_flags;
862862
}
863863

include/linux/sched/topology.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ struct sched_domain {
9292
unsigned int nr_balance_failed; /* initialise to 0 */
9393

9494
/* idle_balance() stats */
95+
unsigned int newidle_call;
96+
unsigned int newidle_success;
97+
unsigned int newidle_ratio;
9598
u64 max_newidle_lb_cost;
9699
unsigned long last_decay_max_lb_cost;
97100

kernel/sched/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp);
121121
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp);
122122

123123
DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
124+
DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);
124125

125126
#ifdef CONFIG_SCHED_PROXY_EXEC
126127
DEFINE_STATIC_KEY_TRUE(__sched_proxy_exec);
@@ -8591,6 +8592,8 @@ void __init sched_init_smp(void)
85918592
{
85928593
sched_init_numa(NUMA_NO_NODE);
85938594

8595+
prandom_init_once(&sched_rnd_state);
8596+
85948597
/*
85958598
* There's no userspace yet to cause hotplug operations; hence all the
85968599
* CPU masks are stable and all blatant races in the below code cannot

kernel/sched/fair.c

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12122,24 +12122,43 @@ void update_max_interval(void)
1212212122
max_load_balance_interval = HZ*num_online_cpus()/10;
1212312123
}
1212412124

12125-
static inline bool update_newidle_cost(struct sched_domain *sd, u64 cost)
12125+
static inline void update_newidle_stats(struct sched_domain *sd, unsigned int success)
1212612126
{
12127+
sd->newidle_call++;
12128+
sd->newidle_success += success;
12129+
12130+
if (sd->newidle_call >= 1024) {
12131+
sd->newidle_ratio = sd->newidle_success;
12132+
sd->newidle_call /= 2;
12133+
sd->newidle_success /= 2;
12134+
}
12135+
}
12136+
12137+
static inline bool
12138+
update_newidle_cost(struct sched_domain *sd, u64 cost, unsigned int success)
12139+
{
12140+
unsigned long next_decay = sd->last_decay_max_lb_cost + HZ;
12141+
unsigned long now = jiffies;
12142+
12143+
if (cost)
12144+
update_newidle_stats(sd, success);
12145+
1212712146
if (cost > sd->max_newidle_lb_cost) {
1212812147
/*
1212912148
* Track max cost of a domain to make sure to not delay the
1213012149
* next wakeup on the CPU.
1213112150
*/
1213212151
sd->max_newidle_lb_cost = cost;
12133-
sd->last_decay_max_lb_cost = jiffies;
12134-
} else if (time_after(jiffies, sd->last_decay_max_lb_cost + HZ)) {
12152+
sd->last_decay_max_lb_cost = now;
12153+
12154+
} else if (time_after(now, next_decay)) {
1213512155
/*
1213612156
* Decay the newidle max times by ~1% per second to ensure that
1213712157
* it is not outdated and the current max cost is actually
1213812158
* shorter.
1213912159
*/
1214012160
sd->max_newidle_lb_cost = (sd->max_newidle_lb_cost * 253) / 256;
12141-
sd->last_decay_max_lb_cost = jiffies;
12142-
12161+
sd->last_decay_max_lb_cost = now;
1214312162
return true;
1214412163
}
1214512164

@@ -12171,7 +12190,7 @@ static void sched_balance_domains(struct rq *rq, enum cpu_idle_type idle)
1217112190
* Decay the newidle max times here because this is a regular
1217212191
* visit to all the domains.
1217312192
*/
12174-
need_decay = update_newidle_cost(sd, 0);
12193+
need_decay = update_newidle_cost(sd, 0, 0);
1217512194
max_cost += sd->max_newidle_lb_cost;
1217612195

1217712196
/*
@@ -12787,14 +12806,16 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
1278712806

1278812807
rcu_read_lock();
1278912808
sd = rcu_dereference_check_sched_domain(this_rq->sd);
12809+
if (!sd) {
12810+
rcu_read_unlock();
12811+
goto out;
12812+
}
1279012813

1279112814
if (!get_rd_overloaded(this_rq->rd) ||
12792-
(sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) {
12815+
this_rq->avg_idle < sd->max_newidle_lb_cost) {
1279312816

12794-
if (sd)
12795-
update_next_balance(sd, &next_balance);
12817+
update_next_balance(sd, &next_balance);
1279612818
rcu_read_unlock();
12797-
1279812819
goto out;
1279912820
}
1280012821
rcu_read_unlock();
@@ -12814,17 +12835,37 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
1281412835
break;
1281512836

1281612837
if (sd->flags & SD_BALANCE_NEWIDLE) {
12838+
unsigned int weight = 1;
12839+
12840+
if (sched_feat(NI_RANDOM)) {
12841+
/*
12842+
* Throw a 1k sided dice; and only run
12843+
* newidle_balance according to the success
12844+
* rate.
12845+
*/
12846+
u32 d1k = sched_rng() % 1024;
12847+
weight = 1 + sd->newidle_ratio;
12848+
if (d1k > weight) {
12849+
update_newidle_stats(sd, 0);
12850+
continue;
12851+
}
12852+
weight = (1024 + weight/2) / weight;
12853+
}
1281712854

1281812855
pulled_task = sched_balance_rq(this_cpu, this_rq,
1281912856
sd, CPU_NEWLY_IDLE,
1282012857
&continue_balancing);
1282112858

1282212859
t1 = sched_clock_cpu(this_cpu);
1282312860
domain_cost = t1 - t0;
12824-
update_newidle_cost(sd, domain_cost);
12825-
1282612861
curr_cost += domain_cost;
1282712862
t0 = t1;
12863+
12864+
/*
12865+
* Track max cost of a domain to make sure to not delay the
12866+
* next wakeup on the CPU.
12867+
*/
12868+
update_newidle_cost(sd, domain_cost, weight * !!pulled_task);
1282812869
}
1282912870

1283012871
/*

kernel/sched/features.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,8 @@ SCHED_FEAT(WA_BIAS, true)
121121
SCHED_FEAT(UTIL_EST, true)
122122

123123
SCHED_FEAT(LATENCY_WARN, false)
124+
125+
/*
126+
* Do newidle balancing proportional to its success rate using randomization.
127+
*/
128+
SCHED_FEAT(NI_RANDOM, true)

kernel/sched/sched.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef _KERNEL_SCHED_SCHED_H
66
#define _KERNEL_SCHED_SCHED_H
77

8+
#include <linux/prandom.h>
89
#include <linux/sched/affinity.h>
910
#include <linux/sched/autogroup.h>
1011
#include <linux/sched/cpufreq.h>
@@ -1349,6 +1350,12 @@ static inline bool is_migration_disabled(struct task_struct *p)
13491350
}
13501351

13511352
DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
1353+
DECLARE_PER_CPU(struct rnd_state, sched_rnd_state);
1354+
1355+
static inline u32 sched_rng(void)
1356+
{
1357+
return prandom_u32_state(this_cpu_ptr(&sched_rnd_state));
1358+
}
13521359

13531360
#define cpu_rq(cpu) (&per_cpu(runqueues, (cpu)))
13541361
#define this_rq() this_cpu_ptr(&runqueues)

kernel/sched/topology.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,12 @@ sd_init(struct sched_domain_topology_level *tl,
16621662

16631663
.last_balance = jiffies,
16641664
.balance_interval = sd_weight,
1665+
1666+
/* 50% success rate */
1667+
.newidle_call = 512,
1668+
.newidle_success = 256,
1669+
.newidle_ratio = 512,
1670+
16651671
.max_newidle_lb_cost = 0,
16661672
.last_decay_max_lb_cost = jiffies,
16671673
.child = child,

net/mptcp/protocol.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,10 +2421,10 @@ bool __mptcp_retransmit_pending_data(struct sock *sk)
24212421
*/
24222422
static void __mptcp_subflow_disconnect(struct sock *ssk,
24232423
struct mptcp_subflow_context *subflow,
2424-
unsigned int flags)
2424+
bool fastclosing)
24252425
{
24262426
if (((1 << ssk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
2427-
subflow->send_fastclose) {
2427+
fastclosing) {
24282428
/* The MPTCP code never wait on the subflow sockets, TCP-level
24292429
* disconnect should never fail
24302430
*/
@@ -2476,7 +2476,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
24762476

24772477
need_push = (flags & MPTCP_CF_PUSH) && __mptcp_retransmit_pending_data(sk);
24782478
if (!dispose_it) {
2479-
__mptcp_subflow_disconnect(ssk, subflow, flags);
2479+
__mptcp_subflow_disconnect(ssk, subflow, msk->fastclosing);
24802480
release_sock(ssk);
24812481

24822482
goto out;
@@ -2789,6 +2789,7 @@ static void mptcp_do_fastclose(struct sock *sk)
27892789
struct mptcp_sock *msk = mptcp_sk(sk);
27902790

27912791
mptcp_set_state(sk, TCP_CLOSE);
2792+
msk->fastclosing = 1;
27922793

27932794
/* Explicitly send the fastclose reset as need */
27942795
if (__mptcp_check_fallback(msk))
@@ -3299,6 +3300,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
32993300
msk->bytes_sent = 0;
33003301
msk->bytes_retrans = 0;
33013302
msk->rcvspace_init = 0;
3303+
msk->fastclosing = 0;
33023304

33033305
WRITE_ONCE(sk->sk_shutdown, 0);
33043306
sk_error_report(sk);

net/mptcp/protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ struct mptcp_sock {
321321
fastopening:1,
322322
in_accept_queue:1,
323323
free_first:1,
324-
rcvspace_init:1;
324+
rcvspace_init:1,
325+
fastclosing:1;
325326
u32 notsent_lowat;
326327
int keepalive_cnt;
327328
int keepalive_idle;

0 commit comments

Comments
 (0)