Unverified Commit 4047698b authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files
parents 16643782 510a62c7
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -358,8 +358,12 @@ What: /sys/block/<disk>/queue/iostats
Date:		January 2009
Contact:	linux-block@vger.kernel.org
Description:
		[RW] This file is used to control (on/off) the iostats
		accounting of the disk.
		[RW] This file is used to control the iostats accounting of the
		disk. If this value is 0, iostats accounting is disabled; If
		this value is 1, iostats accounting is enabled, but io_ticks is
		accounted by sampling and the result is not accurate; If this
		value is 2, iostats accounting is enabled and io_ticks is
		accounted precisely, but there will be slightly more overhead.


What:		/sys/block/<disk>/queue/logical_block_size
+24 −3
Original line number Diff line number Diff line
@@ -71,6 +71,21 @@ static struct kmem_cache *blk_requestq_cachep;
 */
static struct workqueue_struct *kblockd_workqueue;

static bool precise_iostat;

static int __init precise_iostat_setup(char *str)
{
	bool precise;

	if (!kstrtobool(str, &precise)) {
		precise_iostat = precise;
		pr_info("precise iostat %d\n", precise_iostat);
	}

	return 1;
}
__setup("precise_iostat=", precise_iostat_setup);

/**
 * blk_queue_flag_set - atomically set a queue flag
 * @flag: flag to be set
@@ -441,6 +456,8 @@ struct request_queue *blk_alloc_queue(int node_id)

	blk_set_default_limits(&q->limits);
	q->nr_requests = BLKDEV_DEFAULT_RQ;
	if (precise_iostat)
		blk_queue_flag_set(QUEUE_FLAG_PRECISE_IO_STAT, q);

	return q;

@@ -938,11 +955,15 @@ EXPORT_SYMBOL_GPL(iocb_bio_iopoll);
void update_io_ticks(struct block_device *part, unsigned long now, bool end)
{
	unsigned long stamp;
	bool precise = blk_queue_precise_io_stat(part->bd_queue);
again:
	stamp = READ_ONCE(part->bd_stamp);
	if (unlikely(time_after(now, stamp))) {
		if (likely(try_cmpxchg(&part->bd_stamp, &stamp, now)))
			__part_stat_add(part, io_ticks, end ? now - stamp : 1);
	if (unlikely(time_after(now, stamp)) &&
	    likely(try_cmpxchg(&part->bd_stamp, &stamp, now))) {
		if (end || (precise && part_in_flight(part)))
			__part_stat_add(part, io_ticks, now - stamp);
		else if (!precise)
			__part_stat_add(part, io_ticks, 1);
	}
	if (part->bd_partno) {
		part = bdev_whole(part);
+3 −0
Original line number Diff line number Diff line
@@ -783,6 +783,9 @@ static void blk_account_io_merge_request(struct request *req)
	if (blk_do_io_stat(req)) {
		part_stat_lock();
		part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
		if (req->rq_flags & RQF_PRECISE_IO_STAT)
			part_stat_local_dec(req->part,
					in_flight[op_is_write(req_op(req))]);
		part_stat_unlock();
	}
}
+2 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ static const char *const blk_queue_flag_name[] = {
	QUEUE_FLAG_NAME(FAIL_IO),
	QUEUE_FLAG_NAME(NONROT),
	QUEUE_FLAG_NAME(IO_STAT),
	QUEUE_FLAG_NAME(PRECISE_IO_STAT),
	QUEUE_FLAG_NAME(NOXMERGES),
	QUEUE_FLAG_NAME(ADD_RANDOM),
	QUEUE_FLAG_NAME(SYNCHRONOUS),
@@ -254,6 +255,7 @@ static const char *const rqf_name[] = {
	RQF_NAME(FAILED),
	RQF_NAME(QUIET),
	RQF_NAME(IO_STAT),
	RQF_NAME(PRECISE_IO_STAT),
	RQF_NAME(PM),
	RQF_NAME(HASHED),
	RQF_NAME(STATS),
+10 −1
Original line number Diff line number Diff line
@@ -360,8 +360,11 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,

	if (data->flags & BLK_MQ_REQ_PM)
		data->rq_flags |= RQF_PM;
	if (blk_queue_io_stat(q))
	if (blk_queue_io_stat(q)) {
		data->rq_flags |= RQF_IO_STAT;
		if (blk_queue_precise_io_stat(q))
			data->rq_flags |= RQF_PRECISE_IO_STAT;
	}
	rq->rq_flags = data->rq_flags;

	if (data->rq_flags & RQF_SCHED_TAGS) {
@@ -994,6 +997,9 @@ static inline void blk_account_io_done(struct request *req, u64 now)
		update_io_ticks(req->part, jiffies, true);
		part_stat_inc(req->part, ios[sgrp]);
		part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns);
		if (req->rq_flags & RQF_PRECISE_IO_STAT)
			part_stat_local_dec(req->part,
					in_flight[op_is_write(req_op(req))]);
		part_stat_unlock();
	}
}
@@ -1016,6 +1022,9 @@ static inline void blk_account_io_start(struct request *req)

		part_stat_lock();
		update_io_ticks(req->part, jiffies, false);
		if (req->rq_flags & RQF_PRECISE_IO_STAT)
			part_stat_local_inc(req->part,
					in_flight[op_is_write(req_op(req))]);
		part_stat_unlock();
	}
}
Loading