From: Ciunas Bennett <ciunas@linux.ibm.com>
To: linux-s390@vger.kernel.org
Cc: Ciunas Bennett <ciunas@linux.ibm.com>
Subject: [PATCH 1/2] s390/kvm: Refactor __diag_time_slice_end_directed for single exit point
Date: Fri, 19 Jun 2026 12:13:48 +0200 [thread overview]
Message-ID: <20260619101349.162430-2-ciunas@linux.ibm.com> (raw)
In-Reply-To: <20260619101349.162430-1-ciunas@linux.ibm.com>
Refactor the DIAG 9c (directed yield) handler to use a unified exit path,
improving code maintainability and reducing duplication.
Changes:
- Consolidate all exit paths to use a single 'out' label
- Replace multiple VCPU_EVENT logging calls with one unified call
- Introduce 'result' string variable to track operation outcome
- Initialize tcpu_cpu to -1 for safe handling across all code paths
- Ensure statistics updates occur before the common exit point
This refactoring maintains identical functionality while making the control
flow clearer and easier to maintain. All three possible outcomes (yield
forwarded, done, ignored) now converge at a single logging point
Signed-off-by: Ciunas Bennett <ciunas@linux.ibm.com>
---
arch/s390/kvm/diag.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index d89d1c381522..85c84421b510 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -186,7 +186,8 @@ static int diag9c_forwarding_overrun(void)
static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
{
struct kvm_vcpu *tcpu;
- int tcpu_cpu;
+ const char *result;
+ int tcpu_cpu = -1;
int tid;
tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
@@ -211,21 +212,22 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
if (!vcpu_is_preempted(tcpu_cpu))
goto no_yield;
smp_yield_cpu(tcpu_cpu);
- VCPU_EVENT(vcpu, 5,
- "diag time slice end directed to %d: yield forwarded",
- tid);
vcpu->stat.diag_9c_forward++;
- return 0;
+ result = "yield forwarded";
+ goto out;
}
if (kvm_vcpu_yield_to(tcpu) <= 0)
goto no_yield;
- VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: done", tid);
- return 0;
+ result = "done";
+ goto out;
no_yield:
- VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: ignored", tid);
vcpu->stat.diag_9c_ignored++;
+ result = "ignored";
+out:
+ VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: %s", tid,
+ result);
return 0;
}
--
2.54.0
next prev parent reply other threads:[~2026-06-19 10:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-19 10:13 [PATCH 0/2] Improve DIAG 9c observability Ciunas Bennett
2026-06-19 10:13 ` Ciunas Bennett [this message]
2026-06-19 10:27 ` [PATCH 1/2] s390/kvm: Refactor __diag_time_slice_end_directed for single exit point Christian Borntraeger
2026-06-19 10:52 ` Ciunas Bennett
2026-06-19 13:49 ` Heiko Carstens
2026-06-19 10:13 ` [PATCH 2/2] s390/kvm: Add tracepoint for DIAG 9c directed yield operations Ciunas Bennett
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=20260619101349.162430-2-ciunas@linux.ibm.com \
--to=ciunas@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.