Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH 2/4] KVM: s390: Remove cond_resched() calls
Date: Mon, 27 Jul 2026 16:57:40 +0000	[thread overview]
Message-ID: <20260727165740.B726F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727162430.1599396-3-hca@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Medium] Missing cpu_relax() in busy-wait loops in ipte_lock_simple and ipte_lock_siif.
--

--- Patch [2]: [PATCH 2/4] KVM: s390: Remove cond_resched() calls ---
commit 85d6ff7bc8ba9ff52b5d710af6d19c877a1f970f
Author: Heiko Carstens <hca@linux.ibm.com>

KVM: s390: Remove cond_resched() calls
    
Since [1] cond_resched() is a no-op on s390. Remove all calls.

[ ... ]

> diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
> index 36102b2727fbf..0d389a302a70e 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;
> -		}

[Severity: Medium]
This isn't a bug introduced by this patch, but removing cond_resched() makes
it clear that this becomes a tight read-spin loop when old.k evaluates to true.

Since cond_resched() is a no-op, this loop continuously re-reads memory without
yielding or pausing.

Should this include a cpu_relax() to prevent saturating memory bandwidth
and starving other SMT threads on the same core?

>  		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;
> -		}

[Severity: Medium]
This isn't a bug introduced by this patch, but similar to ipte_lock_simple(),
this creates a tight read-spin loop when old.kg evaluates to true.

Would adding cpu_relax() be appropriate here as well?

>  		new = old;
>  		new.k = 1;
>  		new.kh++;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727162430.1599396-1-hca@linux.ibm.com?part=2

  reply	other threads:[~2026-07-27 16:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 17:05   ` sashiko-bot
2026-07-27 16:24 ` [PATCH 2/4] KVM: s390: Remove cond_resched() calls Heiko Carstens
2026-07-27 16:57   ` sashiko-bot [this message]
2026-07-27 16:24 ` [PATCH 3/4] " Heiko Carstens
2026-07-27 16:54   ` sashiko-bot
2026-07-27 16:24 ` [PATCH 4/4] s390/cio: " Heiko Carstens
2026-07-27 16:54   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260727165740.B726F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox