All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Thomas Falcon <tlfalcon@linux.ibm.com>
Cc: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org,
	dnbanerg@us.ibm.com, brking@linux.vnet.ibm.com,
	julietk@linux.vnet.ibm.com
Subject: Re: [PATCH net 3/4] ibmvnic: Bound waits for device queries
Date: Sat, 23 Nov 2019 17:46:53 -0800	[thread overview]
Message-ID: <20191123174653.19e37c30@cakuba.netronome.com> (raw)
In-Reply-To: <1574451706-19058-4-git-send-email-tlfalcon@linux.ibm.com>

On Fri, 22 Nov 2019 13:41:45 -0600, Thomas Falcon wrote:
> +static int ibmvnic_wait_for_completion(struct ibmvnic_adapter *adapter,
> +				       struct completion *comp_done,
> +				       unsigned long timeout)
> +{
> +	struct net_device *netdev = adapter->netdev;
> +	u8 retry = 5;
> +
> +restart_timer:
> +	if (!adapter->crq.active) {
> +		netdev_err(netdev, "Device down!\n");
> +		return -ENODEV;
> +	}
> +	/* periodically check that the device is up while waiting for
> +	 * a response
> +	 */
> +	if (!wait_for_completion_timeout(comp_done, timeout / retry)) {
> +		if (!adapter->crq.active) {
> +			netdev_err(netdev, "Device down!\n");
> +			return -ENODEV;
> +		} else {
> +			retry--;
> +			if (retry)
> +				goto restart_timer;
> +			netdev_err(netdev, "Operation timing out...\n");
> +			return -ETIMEDOUT;

Hm. This is not great. I don't see the need to open code a loop with
a goto:

while (true) {
	if (down())
		return E;

	if (retry--)
		break;

	if (wait())
		return 0
}

print(time out);
return E;

The wait_for_completion_timeout() will not be very precise, but I think
with 5 sleeps it shouldn't drift off too far from the desired 10sec.

> +		}
> +	}
> +
> +	return 0;
> +}

WARNING: multiple messages have this Message-ID (diff)
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Thomas Falcon <tlfalcon@linux.ibm.com>
Cc: brking@linux.vnet.ibm.com, netdev@vger.kernel.org,
	julietk@linux.vnet.ibm.com, dnbanerg@us.ibm.com,
	linuxppc-dev@ozlabs.org
Subject: Re: [PATCH net 3/4] ibmvnic: Bound waits for device queries
Date: Sat, 23 Nov 2019 17:46:53 -0800	[thread overview]
Message-ID: <20191123174653.19e37c30@cakuba.netronome.com> (raw)
In-Reply-To: <1574451706-19058-4-git-send-email-tlfalcon@linux.ibm.com>

On Fri, 22 Nov 2019 13:41:45 -0600, Thomas Falcon wrote:
> +static int ibmvnic_wait_for_completion(struct ibmvnic_adapter *adapter,
> +				       struct completion *comp_done,
> +				       unsigned long timeout)
> +{
> +	struct net_device *netdev = adapter->netdev;
> +	u8 retry = 5;
> +
> +restart_timer:
> +	if (!adapter->crq.active) {
> +		netdev_err(netdev, "Device down!\n");
> +		return -ENODEV;
> +	}
> +	/* periodically check that the device is up while waiting for
> +	 * a response
> +	 */
> +	if (!wait_for_completion_timeout(comp_done, timeout / retry)) {
> +		if (!adapter->crq.active) {
> +			netdev_err(netdev, "Device down!\n");
> +			return -ENODEV;
> +		} else {
> +			retry--;
> +			if (retry)
> +				goto restart_timer;
> +			netdev_err(netdev, "Operation timing out...\n");
> +			return -ETIMEDOUT;

Hm. This is not great. I don't see the need to open code a loop with
a goto:

while (true) {
	if (down())
		return E;

	if (retry--)
		break;

	if (wait())
		return 0
}

print(time out);
return E;

The wait_for_completion_timeout() will not be very precise, but I think
with 5 sleeps it shouldn't drift off too far from the desired 10sec.

> +		}
> +	}
> +
> +	return 0;
> +}

  reply	other threads:[~2019-11-24  1:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 19:41 [PATCH net 0/4] ibmvnic: Harden device commands and queries Thomas Falcon
2019-11-22 19:41 ` Thomas Falcon
2019-11-22 19:41 ` [PATCH net 1/4] ibmvnic: Fix completion structure initialization Thomas Falcon
2019-11-22 19:41   ` Thomas Falcon
2019-11-22 19:41 ` [PATCH net 2/4] ibmvnic: Terminate waiting device threads after loss of service Thomas Falcon
2019-11-22 19:41   ` Thomas Falcon
2019-11-22 19:41 ` [PATCH net 3/4] ibmvnic: Bound waits for device queries Thomas Falcon
2019-11-22 19:41   ` Thomas Falcon
2019-11-24  1:46   ` Jakub Kicinski [this message]
2019-11-24  1:46     ` Jakub Kicinski
2019-11-22 19:41 ` [PATCH net 4/4] ibmvnic: Serialize " Thomas Falcon
2019-11-22 19:41   ` Thomas Falcon
2019-11-24  1:47   ` Jakub Kicinski
2019-11-24  1:47     ` Jakub Kicinski
2019-11-24  1:49 ` [PATCH net 0/4] ibmvnic: Harden device commands and queries Jakub Kicinski
2019-11-24  1:49   ` Jakub Kicinski
2019-11-25 18:40   ` Thomas Falcon
2019-11-25 18:40     ` Thomas Falcon
2019-11-25 19:23     ` Jakub Kicinski
2019-11-25 19:23       ` Jakub Kicinski
2019-11-25 23:12       ` [PATCH net v2 " Thomas Falcon
2019-11-25 23:12         ` Thomas Falcon
2019-11-25 23:12         ` [PATCH net v2 1/4] ibmvnic: Fix completion structure initialization Thomas Falcon
2019-11-25 23:12           ` Thomas Falcon
2019-11-25 23:12         ` [PATCH net v2 2/4] ibmvnic: Terminate waiting device threads after loss of service Thomas Falcon
2019-11-25 23:12           ` Thomas Falcon
2019-11-25 23:12         ` [PATCH net v2 3/4] ibmvnic: Bound waits for device queries Thomas Falcon
2019-11-25 23:12           ` Thomas Falcon
2019-11-25 23:12         ` [PATCH net v2 4/4] ibmvnic: Serialize " Thomas Falcon
2019-11-25 23:12           ` Thomas Falcon
2019-11-26 21:19         ` [PATCH net v2 0/4] ibmvnic: Harden device commands and queries David Miller
2019-11-26 21:19           ` David Miller

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=20191123174653.19e37c30@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=dnbanerg@us.ibm.com \
    --cc=julietk@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=tlfalcon@linux.ibm.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 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.