mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Bojun Zhu <zhubojun.zbj@antgroup.com>,
	linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org,
	jarkko@kernel.org, dave.hansen@linux.intel.com
Cc: reinette.chatre@intel.com, "刘双(轩屹)" <ls123674@antgroup.com>
Subject: Re: [RFC PATCH v2 1/1] x86/sgx: Explicitly give up the CPU in EDMM's ioctl() to avoid softlockup
Date: Fri, 26 Apr 2024 10:06:56 -0700	[thread overview]
Message-ID: <30415ed3-a05a-454d-9077-c8674617f291@intel.com> (raw)
In-Reply-To: <20240426141823.112366-2-zhubojun.zbj@antgroup.com>

On 4/26/24 07:18, Bojun Zhu wrote:
>  	for (c = 0 ; c < modp->length; c += PAGE_SIZE) {
> +		if (sgx_check_signal_and_resched()) {
> +			if (!c)
> +				ret = -ERESTARTSYS;
> +
> +			goto out;
> +		}

This construct is rather fugly.  Let's not perpetuate it, please.  Why
not do:

	int ret = -ERESTARTSYS;

	...
	for (c = 0 ; c < modp->length; c += PAGE_SIZE) {
		if (sgx_check_signal_and_resched())
			goto out;

Then, voila, when c==0 on the first run through the loop, you'll get a
ret=-ERESTARTSYS.

But honestly, it seems kinda silly to annotate all these loops with
explicit cond_resched()s.  I'd much rather do this once and, for
instance, just wrap the enclave locks:

-	  mutex_lock(&encl->lock);
+	  sgx_lock_enclave(encl);

and then have the lock function do the rescheds.  I assume that
mutex_lock() isn't doing this generically for performance reasons.  But
we don't care in SGX land and can just resched to our heart's content.


  reply	other threads:[~2024-04-26 17:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 14:18 [RFC PATCH v2 0/1] " Bojun Zhu
2024-04-26 14:18 ` [RFC PATCH v2 1/1] " Bojun Zhu
2024-04-26 17:06   ` Dave Hansen [this message]
2024-04-29  2:23     ` Bojun Zhu
2024-04-28 22:04   ` Jarkko Sakkinen

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=30415ed3-a05a-454d-9077-c8674617f291@intel.com \
    --to=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jarkko@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=ls123674@antgroup.com \
    --cc=reinette.chatre@intel.com \
    --cc=zhubojun.zbj@antgroup.com \
    /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

all inboxes | Powered by JetHome®