linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] s390: Remove or replace cond_resched() calls
@ 2026-07-27 16:24 Heiko Carstens
  2026-07-27 16:24 ` [PATCH 1/4] s390/crypto: Replace cond_resched() with schedule() Heiko Carstens
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Heiko Carstens @ 2026-07-27 16:24 UTC (permalink / raw)
  To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
	Christian Borntraeger, Harald Freudenberger, Holger Dengler,
	Vineeth Vijayan, Peter Oberparleiter, Janosch Frank,
	Claudio Imbrenda, David Hildenbrand, Peter Zijlstra
  Cc: linux-s390, linux-kernel

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 schedule()
  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(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] s390/crypto: Replace cond_resched() with schedule()
  2026-07-27 16:24 [PATCH 0/4] s390: Remove or replace cond_resched() calls Heiko Carstens
@ 2026-07-27 16:24 ` Heiko Carstens
  2026-07-27 16:24 ` [PATCH 2/4] KVM: s390: Remove cond_resched() calls Heiko Carstens
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2026-07-27 16:24 UTC (permalink / raw)
  To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
	Christian Borntraeger, Harald Freudenberger, Holger Dengler,
	Vineeth Vijayan, Peter Oberparleiter, Janosch Frank,
	Claudio Imbrenda, David Hildenbrand, Peter Zijlstra
  Cc: linux-s390, linux-kernel

The comment for all cond_resched() calls in crypto code says that the
process should be scheduled away to avoid instant re-invocation of a
callback. This is not what cond_resched() would do or did.

Replace cond_resched() with a call to schedule() which comes closer, but
it looks more like this code wants an msleep() call.

Note that with [1] cond_resched() is always compiled away and becomes a
no-op.

[1] commit 7dadeaa6e851 ("sched: Further restrict the preemption modes")

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/crypto/paes_s390.c  | 8 ++++----
 arch/s390/crypto/phmac_s390.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
index 8cfe6166c193..d02de945f864 100644
--- a/arch/s390/crypto/paes_s390.c
+++ b/arch/s390/crypto/paes_s390.c
@@ -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();
+		schedule();
 		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();
+		schedule();
 		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();
+		schedule();
 		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();
+		schedule();
 		pr_debug("rescheduling request\n");
 		return -ENOSPC;
 	} else if (rc) {
diff --git a/arch/s390/crypto/phmac_s390.c b/arch/s390/crypto/phmac_s390.c
index 03ca33ffe6cc..bddfdcee6cb3 100644
--- a/arch/s390/crypto/phmac_s390.c
+++ b/arch/s390/crypto/phmac_s390.c
@@ -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();
+			schedule();
 			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();
+			schedule();
 			return -ENOSPC;
 		}
 		break;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] KVM: s390: Remove cond_resched() calls
  2026-07-27 16:24 [PATCH 0/4] s390: Remove or replace cond_resched() calls Heiko Carstens
  2026-07-27 16:24 ` [PATCH 1/4] s390/crypto: Replace cond_resched() with schedule() Heiko Carstens
@ 2026-07-27 16:24 ` Heiko Carstens
  2026-07-27 16:24 ` [PATCH 3/4] " Heiko Carstens
  2026-07-27 16:24 ` [PATCH 4/4] s390/cio: " Heiko Carstens
  3 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2026-07-27 16:24 UTC (permalink / raw)
  To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
	Christian Borntraeger, Harald Freudenberger, Holger Dengler,
	Vineeth Vijayan, Peter Oberparleiter, Janosch Frank,
	Claudio Imbrenda, David Hildenbrand, Peter Zijlstra
  Cc: linux-s390, linux-kernel

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 <hca@linux.ibm.com>
---
 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(-)

diff --git a/arch/s390/include/asm/uv.h b/arch/s390/include/asm/uv.h
index d919e69662f5..795da130342a 100644
--- a/arch/s390/include/asm/uv.h
+++ b/arch/s390/include/asm/uv.h
@@ -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;
 }
diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
index 36102b2727fb..0d389a302a70 100644
--- a/arch/s390/kvm/gaccess.c
+++ b/arch/s390/kvm/gaccess.c
@@ -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++;
diff --git a/arch/s390/kvm/gmap.c b/arch/s390/kvm/gmap.c
index 8abb4f55b306..3758e4009709 100644
--- a/arch/s390/kvm/gmap.c
+++ b/arch/s390/kvm/gmap.c
@@ -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);
 }
 
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 150b5dd2170e..2ede8f035a38 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1027,7 +1027,6 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
 		do {
 			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;
diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
index 1beacc841ca8..935fe308a050 100644
--- a/arch/s390/kvm/pv.c
+++ b/arch/s390/kvm/pv.c
@@ -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;
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index eea24562e7db..6dcd3b110c17 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -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);
diff --git a/arch/s390/mm/gmap_helpers.c b/arch/s390/mm/gmap_helpers.c
index 4bf7c9012feb..d564cdefb90f 100644
--- a/arch/s390/mm/gmap_helpers.c
+++ b/arch/s390/mm/gmap_helpers.c
@@ -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;
 	}
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] s390: Remove cond_resched() calls
  2026-07-27 16:24 [PATCH 0/4] s390: Remove or replace cond_resched() calls Heiko Carstens
  2026-07-27 16:24 ` [PATCH 1/4] s390/crypto: Replace cond_resched() with schedule() Heiko Carstens
  2026-07-27 16:24 ` [PATCH 2/4] KVM: s390: Remove cond_resched() calls Heiko Carstens
@ 2026-07-27 16:24 ` Heiko Carstens
  2026-07-27 16:24 ` [PATCH 4/4] s390/cio: " Heiko Carstens
  3 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2026-07-27 16:24 UTC (permalink / raw)
  To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
	Christian Borntraeger, Harald Freudenberger, Holger Dengler,
	Vineeth Vijayan, Peter Oberparleiter, Janosch Frank,
	Claudio Imbrenda, David Hildenbrand, Peter Zijlstra
  Cc: linux-s390, linux-kernel

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 <hca@linux.ibm.com>
---
 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(-)

diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
index 2076ac22e2c4..5f2596be6c1e 100644
--- a/arch/s390/kernel/perf_cpum_cf.c
+++ b/arch/s390/kernel/perf_cpum_cf.c
@@ -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))
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index eb7ef63fab1e..d342b68ee9be 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -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;
 }
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index e6f788696dd1..1e202e3d08e7 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -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;
 }
diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c
index 7ac44543e051..9610770fcf6d 100644
--- a/arch/s390/mm/pgalloc.c
+++ b/arch/s390/mm/pgalloc.c
@@ -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;
 }
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 39bd2adfc240..2dec238f3f12 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -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;
 }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] s390/cio: Remove cond_resched() calls
  2026-07-27 16:24 [PATCH 0/4] s390: Remove or replace cond_resched() calls Heiko Carstens
                   ` (2 preceding siblings ...)
  2026-07-27 16:24 ` [PATCH 3/4] " Heiko Carstens
@ 2026-07-27 16:24 ` Heiko Carstens
  3 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2026-07-27 16:24 UTC (permalink / raw)
  To: Alexander Gordeev, Sven Schnelle, Vasily Gorbik,
	Christian Borntraeger, Harald Freudenberger, Holger Dengler,
	Vineeth Vijayan, Peter Oberparleiter, Janosch Frank,
	Claudio Imbrenda, David Hildenbrand, Peter Zijlstra
  Cc: linux-s390, linux-kernel

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 <hca@linux.ibm.com>
---
 drivers/s390/cio/css.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index e5a0ec6b4e3e..54b8b8639694 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -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;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-27 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 16:24 [PATCH 0/4] s390: Remove or replace cond_resched() calls Heiko Carstens
2026-07-27 16:24 ` [PATCH 1/4] s390/crypto: Replace cond_resched() with schedule() Heiko Carstens
2026-07-27 16:24 ` [PATCH 2/4] KVM: s390: Remove cond_resched() calls Heiko Carstens
2026-07-27 16:24 ` [PATCH 3/4] " Heiko Carstens
2026-07-27 16:24 ` [PATCH 4/4] s390/cio: " Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).