s390: Remove or replace cond_resched() calls
Subsystems (7)
Heiko Carstens
maintainerPATCH v2 3/4 s390: Remove cond_resched() calls
In reply to Heiko CarstensSince [1] cond_resched() is a no-op on s390. Remove all calls.
[1] commit 7dadeaa6e851 ("sched: Further restrict the preemption modes")
--- arch/s390/kernel/perf_cpum_cf.c | 1 - arch/s390/mm/cmm.c | 2 -- arch/s390/mm/pageattr.c | 5 ----- arch/s390/mm/pgalloc.c | 1 - arch/s390/pci/pci.c | 4 +--- 5 files changed, 1 insertion(+), 12 deletions(-)
arch/s390/kernel/perf_cpum_cf.c +0 -1
@@ -1496,7 +1496,6 @@ static int cfset_all_copy(unsigned long arg, cpumask_t *mask) goto out; } uptr +=sizeof (struct s390_ctrset_cpudata ) + cpuhw->used; -cond_resched (); } cpus =cpumask_weight (mask);if (put_user (cpus, &ctrset_read->no_cpus))
arch/s390/mm/cmm.c +0 -2
@@ -95,7 +95,6 @@ static long cmm_alloc_pages(long nr, long *counter, (*counter)++;spin_unlock (&cmm_lock); nr--; -cond_resched (); }return nr; }
@@ -134,7 +133,6 @@ static long cmm_free_pages(long nr, long *counter, struct cmm_page_array **list) inc =__cmm_free_pages (inc, counter, list);if (inc)break ; -cond_resched (); }return nr + inc; }
arch/s390/mm/pageattr.c +0 -5
@@ -105,7 +105,6 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,pgt_set ((unsigned long *)ptep,pte_val (new), addr,CRDTE_DTT_PAGE ); ptep++; addr +=PAGE_SIZE ; -cond_resched (); }while (addr < end);return 0 ; }
@@ -194,7 +193,6 @@ static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end, } pmdp++; addr = next; -cond_resched (); }while (addr < end);return rc; }
@@ -281,7 +279,6 @@ static int walk_pud_level(p4d_t *p4d, unsigned long addr, unsigned long end, } pudp++; addr = next; -cond_resched (); }while (addr < end && !rc);return rc; }
@@ -301,7 +298,6 @@ static int walk_p4d_level(pgd_t *pgd, unsigned long addr, unsigned long end, rc =walk_pud_level (p4dp, addr, next, flags); p4dp++; addr = next; -cond_resched (); }while (addr < end && !rc);return rc; }
@@ -323,7 +319,6 @@ static int change_page_attr(unsigned long addr, unsigned long end, rc =walk_p4d_level (pgdp, addr, next, flags);if (rc)break ; -cond_resched (); }while (pgdp++, addr = next, addr < end && !rc);return rc; }
arch/s390/mm/pgalloc.c +0 -1
@@ -268,7 +268,6 @@ static int base_segment_walk(unsigned long *origin, unsigned long addr,return rc;if (!alloc)base_pgt_free (table); -cond_resched (); }while (ste++, addr = next, addr < end);return 0 ; }
arch/s390/pci/pci.c +1 -3
@@ -1173,10 +1173,8 @@ int zpci_scan_devices(void)return rc;zpci_add_devices (&scan_list); -zpci_bus_for_each (zbus) { +zpci_bus_for_each (zbus)zpci_bus_scan_bus (zbus); -cond_resched (); - }return 0 ; }
Signature · 1 line
2.53.0
Heiko Carstens
maintainerv2 cover s390: Remove or replace cond_resched() calls
v2:
- Use msleep() in crypto code (Holger Dengler)
- Add Reviewed-by tag from Peter Oberparleiter
v1:
Since [1] it is only possible to select the PREEMPT or PREEMPT_LAZY preemption models for s390. This has caused some minor problems, but everything has been addressed.
Given that for both preemption models cond_resched() is a no-op remove or replace it everywhere.
[1] commit 7dadeaa6e851 ("sched: Further restrict the preemption modes")
Heiko Carstens (4):
s390/crypto: Replace cond_resched() with msleep(1)
KVM: s390: Remove cond_resched() calls
s390: Remove cond_resched() calls s390/cio: Remove cond_resched() calls
arch/s390/crypto/paes_s390.c | 8 ++++---- arch/s390/crypto/phmac_s390.c | 4 ++-- arch/s390/include/asm/uv.h | 1 - arch/s390/kernel/perf_cpum_cf.c | 1 - arch/s390/kvm/gaccess.c | 8 ++------ arch/s390/kvm/gmap.c | 4 ---- arch/s390/kvm/kvm-s390.c | 1 - arch/s390/kvm/pv.c | 1 - arch/s390/kvm/vsie.c | 1 - arch/s390/mm/cmm.c | 2 -- arch/s390/mm/gmap_helpers.c | 1 - arch/s390/mm/pageattr.c | 5 ----- arch/s390/mm/pgalloc.c | 1 - arch/s390/pci/pci.c | 4 +--- drivers/s390/cio/css.c | 8 -------- 15 files changed, 9 insertions(+), 41 deletions(-)
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH v2 1/4 s390/crypto: Replace cond_resched() with msleep(1)
With [1] cond_resched() is always compiled away and becomes a no-op.
The comments for all cond_resched() calls in crypto code however indicate that the current process should be scheduled away to avoid instant re-invocation of a callback. This is not what cond_resched() would do or did.
Instead of just removing the cond_resched() calls, replace them with msleep() calls, as suggested by Holger Dengler. This forces the current task to be scheduled away (sleeps) like originally intended.
[1] commit 7dadeaa6e851 ("sched: Further restrict the preemption modes")
--- arch/s390/crypto/paes_s390.c | 8 ++++---- arch/s390/crypto/phmac_s390.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
arch/s390/crypto/paes_s390.c +4 -4
@@ -555,7 +555,7 @@ static int ecb_paes_do_one_request(struct crypto_engine *engine, void *areq)* To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ; }else if (rc) {
@@ -821,7 +821,7 @@ static int cbc_paes_do_one_request(struct crypto_engine *engine, void *areq)* To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ; }else if (rc) {
@@ -1129,7 +1129,7 @@ static int ctr_paes_do_one_request(struct crypto_engine *engine, void *areq)* To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ; }else if (rc) {
@@ -1572,7 +1572,7 @@ static int xts_paes_do_one_request(struct crypto_engine *engine, void *areq)* To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ; }else if (rc) {
arch/s390/crypto/phmac_s390.c +2 -2
@@ -895,7 +895,7 @@ static int phmac_do_one_request(struct crypto_engine *engine, void *areq)* tell scheduler to voluntarily give up the CPU here. */ pr_debug ("rescheduling request\n" ); -cond_resched (); +msleep (1 );return -ENOSPC ; }else if (rc) {hwh_advance (hwh, rc);
@@ -916,7 +916,7 @@ static int phmac_do_one_request(struct crypto_engine *engine, void *areq)* tell scheduler to voluntarily give up the CPU here. */ pr_debug ("rescheduling request\n" ); -cond_resched (); +msleep (1 );return -ENOSPC ; }break ;
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH v2 2/4 KVM: s390: Remove cond_resched() calls
In reply to Heiko CarstensSince [1] cond_resched() is a no-op on s390. Remove all calls.
[1] commit 7dadeaa6e851 ("sched: Further restrict the preemption modes")
--- arch/s390/include/asm/uv.h | 1 - arch/s390/kvm/gaccess.c | 8 ++------ arch/s390/kvm/gmap.c | 4 ---- arch/s390/kvm/kvm-s390.c | 1 - arch/s390/kvm/pv.c | 1 - arch/s390/kvm/vsie.c | 1 - arch/s390/mm/gmap_helpers.c | 1 - 7 files changed, 2 insertions(+), 15 deletions(-)
arch/s390/include/asm/uv.h +0 -1
@@ -461,7 +461,6 @@ static inline int uv_call_sched(unsigned long r1, unsigned long r2)do { cc =__uv_call (r1, r2); -cond_resched (); }while (cc >1 );return cc; }
arch/s390/kvm/gaccess.c +2 -6
@@ -151,10 +151,8 @@ static void ipte_lock_simple(struct kvm *kvm) ic = &kvm->arch.sca->ipte_control; old =READ_ONCE (*ic);do { -if (old.k) { -cond_resched (); +if (old.k) goto retry; - } new = old; new.k =1 ; }while (!try_cmpxchg (&ic->val, &old.val, new.val));
@@ -189,10 +187,8 @@ static void ipte_lock_siif(struct kvm *kvm) ic = &kvm->arch.sca->ipte_control; old =READ_ONCE (*ic); do { - if (old.kg) { - cond_resched(); + if (old.kg) goto retry; - } new = old; new.k = 1; new.kh++;
arch/s390/kvm/gmap.c +0 -4
@@ -941,7 +941,6 @@ void gmap_split_huge_pages(struct gmap *gmap)scoped_guard (read_lock, &gmap->kvm->mmu_lock) start = _dat_walk_gfn_range(start, asce_end(gmap->asce), gmap->asce, &ops,DAT_WALK_IGN_HOLES , gmap); -cond_resched (); }while (start); }
@@ -963,7 +962,6 @@ static int _gmap_enable_skeys(struct gmap *gmap)do {scoped_guard (write_lock, &gmap->kvm->mmu_lock) start = dat_reset_skeys(gmap->asce, start); -cond_resched (); }while (start);return 0 ; }
@@ -1019,7 +1017,6 @@ int gmap_pv_destroy_range(struct gmap *gmap, gfn_t start, gfn_t end, bool interr DAT_WALK_IGN_HOLES, NULL);if (interruptible &&fatal_signal_pending (current))return -EINTR ; -cond_resched (); }while (start && start < end);return 0 ; }
@@ -1138,7 +1135,6 @@ void _gmap_set_cmma_all(struct gmap *gmap, bool dirty) gfn =_dat_walk_gfn_range (gfn,asce_end (gmap->asce), gmap->asce, &ops,DAT_WALK_IGN_HOLES , &gmap->kvm->arch.cmma_dirty_pages); -cond_resched (); }while (gfn); }
arch/s390/kvm/kvm-s390.c +0 -1
@@ -1027,7 +1027,6 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *attdo {scoped_guard (read_lock, &kvm->mmu_lock) start_gfn = dat_reset_cmma(kvm->arch.gmap->asce, start_gfn); -cond_resched (); }while (start_gfn); ret =0 ;break ;
arch/s390/kvm/pv.c +0 -1
@@ -832,7 +832,6 @@ int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size,while (offset < size) { ret =unpack_one (kvm, addr, tweak, offset, rc, rrc);if (ret == -EAGAIN ) { -cond_resched ();if (fatal_signal_pending (current))break ;continue ;
arch/s390/kvm/vsie.c +0 -1
@@ -1434,7 +1434,6 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) }if (sg) sg =gmap_put (sg); -cond_resched (); }if (sg) sg =gmap_put (sg);
arch/s390/mm/gmap_helpers.c +0 -1
@@ -272,7 +272,6 @@ static int __gmap_helper_unshare_zeropages(struct mm_struct *mm)* truncation. In that case, the shared zeropage would be gone * and we can simply retry and make progress. */ -cond_resched (); goto retry; }
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH v2 4/4 s390/cio: Remove cond_resched() calls
In reply to Heiko CarstensSince [1] cond_resched() is a no-op on s390. Remove all calls.
[1] commit 7dadeaa6e851 ("sched: Further restrict the preemption modes")
--- drivers/s390/cio/css.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/s390/cio/css.c +0 -8
@@ -618,11 +618,6 @@ static int slow_eval_known_fn(struct subchannel *sch, void *data) rc =css_evaluate_known_subchannel (sch,1 );if (rc == -EAGAIN )css_schedule_eval (sch->schid); -/* -* The loop might take long time for platforms with lots of -* known devices. Allow scheduling here. -*/ -cond_resched (); }return 0 ; }
@@ -654,9 +649,6 @@ static int slow_eval_unknown_fn(struct subchannel_id schid, void *data)default : rc =0 ; } -/* Allow scheduling here since the containing loop might -* take a while. */ -cond_resched (); }return rc; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 1/4] s390/crypto: Replace cond_resched() with msleep(1)
In reply to Heiko CarstensSashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
With [1]
cond_resched()is always compiled away and becomes a no-op.The comments for all
cond_resched()calls in crypto code however indicate that the current process should be scheduled away to avoid instant re-invocation of a callback. This is not whatcond_resched()would do or did.
Quoted 7 lines
Instead of just removing the
cond_resched()calls, replace them withmsleep()calls, as suggested by Holger Dengler. This forces the current task to be scheduled away (sleeps) like originally intended.[1] commit
7dadeaa6e851("sched: Further restrict the preemption modes")Signed-off-by Heiko Carstens <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH v2 2/4] KVM: s390: Remove cond_resched() calls
In reply to Heiko CarstensSashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
Since [1]
cond_resched()is a no-op on s390. Remove all calls.[1] commit
7dadeaa6e851("sched: Further restrict the preemption modes")Signed-off-by Heiko Carstens <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH v2 3/4] s390: Remove cond_resched() calls
In reply to Heiko CarstensSashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
Since [1]
cond_resched()is a no-op on s390. Remove all calls.[1] commit
7dadeaa6e851("sched: Further restrict the preemption modes")Signed-off-by Heiko Carstens <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH v2 4/4] s390/cio: Remove cond_resched() calls
In reply to Heiko CarstensSashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines
Since [1]
cond_resched()is a no-op on s390. Remove all calls.[1] commit
7dadeaa6e851("sched: Further restrict the preemption modes")Reviewed-by Peter Oberparleiter <[email protected]>Signed-off-by Heiko Carstens <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v2 1/4] s390/crypto: Replace cond_resched() with msleep(1)
In reply to Heiko CarstensQuoted 7 lines · Heiko Carstens
With [1]
cond_resched()is always compiled away and becomes a no-op.The comments for all
cond_resched()calls in crypto code however indicate that the current process should be scheduled away to avoid instant re-invocation of a callback. This is not whatcond_resched()would do or did.
Quoted 7 lines
Instead of just removing the
cond_resched()calls, replace them withmsleep()calls, as suggested by Holger Dengler. This forces the current task to be scheduled away (sleeps) like originally intended.[1] commit
7dadeaa6e851("sched: Further restrict the preemption modes")Signed-off-by Heiko Carstens <[email protected]>
Signature · 2 lines
Mit freundlichen Grüßen / Kind regards Holger Dengler
Re: [PATCH v2 1/4] s390/crypto: Replace cond_resched() with msleep(1)
In reply to Heiko CarstensQuoted 86 lines · Heiko Carstens
With [1]
cond_resched()is always compiled away and becomes a no-op.The comments for all
cond_resched()calls in crypto code however indicate that the current process should be scheduled away to avoid instant re-invocation of a callback. This is not whatcond_resched()would do or did.Instead of just removing the
cond_resched()calls, replace them withmsleep()calls, as suggested by Holger Dengler. This forces the current task to be scheduled away (sleeps) like originally intended.[1] commit
7dadeaa6e851("sched: Further restrict the preemption modes")Signed-off-by Heiko Carstens <[email protected]>--- arch/s390/crypto/paes_s390.c | 8 ++++---- arch/s390/crypto/phmac_s390.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)arch/s390/crypto/paes_s390.c +1
-1@@ -555,7 +555,7 @@ static int ecb_paes_do_one_request(structcrypto_engine *engine, void *areq) * To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ;arch/s390/crypto/paes_s390.c +1
-1}else if (rc) {@@ -821,7 +821,7 @@ static int cbc_paes_do_one_request(structcrypto_engine *engine, void *areq) * To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ;arch/s390/crypto/paes_s390.c +1
-1}else if (rc) {@@ -1129,7 +1129,7 @@ static int ctr_paes_do_one_request(structcrypto_engine *engine, void *areq) * To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ;arch/s390/crypto/paes_s390.c +1
-1}else if (rc) {@@ -1572,7 +1572,7 @@ static int xts_paes_do_one_request(structcrypto_engine *engine, void *areq) * To avoid immediately re-invocation of this callback, * tell the scheduler to voluntarily give up the CPU here. */ -cond_resched (); +msleep (1 );pr_debug ("rescheduling request\n" );return -ENOSPC ;arch/s390/crypto/paes_s390.c +0
-0}else if (rc) {arch/s390/crypto/phmac_s390.c +1
-1@@ -895,7 +895,7 @@ static int phmac_do_one_request(structcrypto_engine *engine, void *areq) * tell scheduler to voluntarily give up the CPU here. */ pr_debug ("rescheduling request\n" ); -cond_resched (); +msleep (1 );return -ENOSPC ; }else if (rc) {arch/s390/crypto/phmac_s390.c +1
-1hwh_advance (hwh, rc);@@ -916,7 +916,7 @@ static int phmac_do_one_request(structcrypto_engine *engine, void *areq) * tell scheduler to voluntarily give up the CPU here. */ pr_debug ("rescheduling request\n" ); -cond_resched (); +msleep (1 );return -ENOSPC ; }
Quoted 1 line
break;