mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Swen Schillig <swen@vnet.ibm.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>,
	Christof Schmitt <christof.schmitt@de.ibm.com>,
	linux-scsi@vger.kernel.org,
	Linux on 390 Port <LINUX-390@vm.marist.edu>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] zfcp: add some internal zfcp adapter statistics
Date: Sat, 3 Nov 2007 10:17:22 +0100	[thread overview]
Message-ID: <20071103091722.GA7807@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <200710311133.52090.swen@vnet.ibm.com>

> +static void zfcp_fsf_req_latency(struct zfcp_fsf_req *fsf_req)
> +{
> +	struct fsf_qual_latency_info *lat_inf;
> +	struct zfcp_unit *unit;
> +
> +	lat_inf = &fsf_req->qtcb->prefix.prot_status_qual.latency_info;
> +	unit = fsf_req->unit;
> +
> +	switch (fsf_req->qtcb->bottom.io.data_direction) {
> +	case FSF_DATADIR_READ:
> +		unit->latencies.read.channel += lat_inf->channel_lat;
> +		unit->latencies.read.fabric += lat_inf->fabric_lat;
> +		unit->latencies.read.counter++;
> +		break;
> +	case FSF_DATADIR_WRITE:
> +		unit->latencies.write.channel += lat_inf->channel_lat;
> +		unit->latencies.write.fabric += lat_inf->fabric_lat;
> +		unit->latencies.write.counter++;
> +		break;
> +	case FSF_DATADIR_CMND:
> +		unit->latencies.cmd.channel += lat_inf->channel_lat;
> +		unit->latencies.cmd.fabric += lat_inf->fabric_lat;
> +		unit->latencies.cmd.counter++;
> +		break;
> +	}
> +}

These statistics are concurrently updated from several cpus without
any locking. That looks like a bug.

> +zfcp_sysfs_unit_##_name##_latency_show(struct device *dev,		\
> +				       struct device_attribute *attr,	\
> +				       char *buf) {			\
> +	struct scsi_device *sdev = to_scsi_device(dev);			\
> +	struct zfcp_unit *unit = sdev->hostdata;			\
> +	struct zfcp_latencies *lat = &unit->latencies;			\
> +	struct zfcp_adapter *adapter = unit->port->adapter;		\
> +									\
> +	return sprintf(buf, "%u %u %u\n",				\
> +		       lat->_name.fabric * adapter->timer_ticks / 1000, \
> +		       lat->_name.channel * adapter->timer_ticks / 1000,\
> +		       lat->_name.counter);				\

In addition they can be read concurrently from userspace without any
locking... Since you put several values together in the output I assume
this is supposed to be some sort of snapshot, which it currently isn't.

> +static int
> +zfcp_sysfs_adapter_ex_config(struct class_device *cdev,
> +			     struct fsf_qtcb_bottom_config **qtcb_config)
> +{
> +	struct Scsi_Host *scsi_host = class_to_shost(cdev);
> +	struct zfcp_adapter *adapter = (struct zfcp_adapter *)
> +						scsi_host->hostdata[0];
> +
> +	if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA)) {
> +		ZFCP_LOG_NORMAL("error: Enhanced measurement feature not "
> +				"supported");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	*qtcb_config = kzalloc(sizeof(struct fsf_qtcb_bottom_config),
> +			       GFP_KERNEL);
> +	if (!*qtcb_config)
> +		return -ENOMEM;
> +
> +	return zfcp_fsf_exchange_config_data_sync(adapter, *qtcb_config);
> +}
> +
> +static ssize_t
> +zfcp_sysfs_adapter_request_show(struct class_device *cdev, char *buf)
> +{
> +	struct fsf_qtcb_bottom_config *qtcb_config;
> +	int retval;
> +
> +	retval = zfcp_sysfs_adapter_ex_config(cdev, &qtcb_config);
> +
> +	if (!retval)
> +		retval = sprintf(buf, "%lu %lu %lu\n",
> +				 qtcb_config->stat_info.input_req,
> +				 qtcb_config->stat_info.output_req,
> +				 qtcb_config->stat_info.control_req);
> +
> +	kfree(qtcb_config);
> +	return retval;
> +}

You're going to call kfree with some random value if the adapter doesn't
support the measurement data feature.

  reply	other threads:[~2007-11-03  9:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31 10:33 Swen Schillig
2007-11-03  9:17 ` Heiko Carstens [this message]
2007-11-03  9:40   ` Heiko Carstens
2007-11-05 11:35     ` Swen Schillig
2007-11-05 15:12   ` Swen Schillig
2007-11-25 11:16 ` James Bottomley
2007-11-26 10:23   ` Swen Schillig
2007-12-06  9:40     ` Swen Schillig

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=20071103091722.GA7807@osiris.boeblingen.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=LINUX-390@vm.marist.edu \
    --cc=christof.schmitt@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=swen@vnet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome