Skip to contentSkip to conversation

mmc: Add CONFIG_MMC_BLOCK_MAX_SPEED

PATCH Mark Salyzyn 2 participants 5 messages Feb 4, 2016 – Feb 24, 2016 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

When CONFIG_MMC_BLOCK_MAX_SPEED is enabled, Expose max_read_speed, max_write_speed and cache_size controls to simulate a slow eMMC device. The boot default values for each respectively are CONFIG_MMC_BLOCK_MAX_READ_SPEED, CONFIG_MMC_BLOCK_MAX_WRITE_SPEED and CONFIG_MMC_BLOCK_CACHE_SIZE respectively; and if not defined are 0 (off), 0, (off) and 4 MB also respectively.

---
 drivers/mmc/card/Kconfig |  54 +++++++++
 drivers/mmc/card/block.c | 295 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/card/queue.h |   8 ++
 3 files changed, 357 insertions(+)
drivers/mmc/card/Kconfig +54 -0
index 5562308..70bf39c 100644
@@ -68,3 +68,57 @@ config MMC_TEST
 
 	  This driver is only of interest to those developing or
 	  testing a host driver. Most people should say N here.
+
+config MMC_BLOCK_MAX_SPEED
+	bool "Turn on maximum speed control per block device"
+	depends on MMC_BLOCK
+	help
+	  Say Y here to enable MMC device speed limiting. Used to test and
+	  simulate the behavior of the system when confronted with a slow MMC.
+
+	  Enables max_read_speed and max_write_speed attributes to control the
+	  write or read maximum KB/second speed.
+
+	  If unsure, say N here.
+
+config MMC_BLOCK_MAX_READ_SPEED
+	int "KB/second read speed limit per block device"
+	depends on MMC_BLOCK
+	depends on MMC_BLOCK_MAX_SPEED
+	default 0
+	help
+	  Number of KB/second reads allowed to the block device. Used to
+	  test and simulate the behavior of the system when confronted with
+	  a slow MMC.
+
+	  Value can be overridden at runtime with the max_read_speed attribute.
+
+	  If unsure, say 0 here (no speed limit)
+
+config MMC_BLOCK_MAX_WRITE_SPEED
+	int "KB/second write speed limit per block device"
+	depends on MMC_BLOCK
+	depends on MMC_BLOCK_MAX_SPEED
+	default 0
+	help
+	  Number of KB/second writes allowed to the block device. Used to
+	  test and simulate the behavior of the system when confronted with
+	  a slow MMC.
+
+	  Value can be overridden at runtime with the max_write_speed attribute.
+
+	  If unsure, say 0 here (no speed limit)
+
+config MMC_BLOCK_MAX_SPEED_CACHE_SIZE
+	int "MB of memory or SLC cache"
+	depends on MMC_BLOCK
+	depends on MMC_BLOCK_MAX_SPEED
+	default 4
+	help
+	  Number of MB of high speed memory or SLC cache expected on the
+	  eMMC device. Used to help simulate the write-back behavior more
+	  accurately.
+
+	  Value can be overridden at runtime with the cache_size attribute.
+
+	  If unsure, say 4 here
drivers/mmc/card/block.c +295 -0

337 lines not on this page · raw message

drivers/mmc/card/queue.h +8 -0
index 36cddab..fd7cef8 100644
@@ -58,6 +58,14 @@ struct mmc_queue {
 	struct mmc_queue_req	mqrq[2];
 	struct mmc_queue_req	*mqrq_cur;
 	struct mmc_queue_req	*mqrq_prev;
+#ifdef CONFIG_MMC_BLOCK_MAX_SPEED
+	atomic_t max_write_speed;
+	atomic_t max_read_speed;
+	atomic_t cache_size;
+	/* i/o tracking */
+	atomic_long_t cache_used;
+	unsigned long cache_jiffies;
+#endif
 };
 
 extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
Signature · 1 line
2.7.0.rc3.207.g0ac5344
#1 lore raw

Hi!

Quoted 6 lines · Mark Salyzyn

When CONFIG_MMC_BLOCK_MAX_SPEED is enabled, Expose max_read_speed, max_write_speed and cache_size controls to simulate a slow eMMC device. The boot default values for each respectively are CONFIG_MMC_BLOCK_MAX_READ_SPEED, CONFIG_MMC_BLOCK_MAX_WRITE_SPEED and CONFIG_MMC_BLOCK_CACHE_SIZE respectively; and if not defined are 0 (off), 0, (off) and 4 MB also respectively.

Extra , after 0.

Dunno. At minimum, I'd call the option something like "MMC_DEBUG_MAX_SPEED" and the speeds should be really controlled via /sys or something...

...and ... is there reason to limit it to mmc devices? Making harddrive slow would make it useful for testing, too...

...and you have the /sys interface. Drop the config options?

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 10 lines · Pavel Machek

Hi!

Quoted 6 lines · Mark Salyzyn

When CONFIG_MMC_BLOCK_MAX_SPEED is enabled, Expose max_read_speed, max_write_speed and cache_size controls to simulate a slow eMMC device. The boot default values for each respectively are CONFIG_MMC_BLOCK_MAX_READ_SPEED, CONFIG_MMC_BLOCK_MAX_WRITE_SPEED and CONFIG_MMC_BLOCK_CACHE_SIZE respectively; and if not defined are 0 (off), 0, (off) and 4 MB also respectively.

Extra , after 0.

Yes :-)

Quoted 3 lines

Dunno. At minimum, I'd call the option something like "MMC_DEBUG_MAX_SPEED" and the speeds should be really controlled via /sys or something...

Are controlled by sys. Concern over DEBUG_MAX_SPEED is the sys nodes changing name to debug_max_read_speed, etc, which would in turn result in a move to debugfs instead. Will have to think about all the side effects of such a move.

Quoted 2 lines

...and ... is there reason to limit it to mmc devices? Making harddrive slow would make it useful for testing, too...

The speed limit at this layer is not the same as in the block layer, the two methods would 'join' at the same value when one does sustained I/O most likely, but not at the random patterns we have experienced on the devices. We would like additional wiggle room to simulate eMMC stalls due to load leveling and other behaviors in the future. If we moved up a layer we would have to simulate head seek and rotational latency opening a can of worms we would feel best if left closed. View it as a political decision.

Quoted 2 lines

...and you have the /sys interface. Drop the config options?

I needed a start up default value for boot-time simulations. If just sys options, we would be applying the values far too late in the operation. I expect some other folks using this simulation would like to forgo an extended boot time, to have them set/reset under programmed control. I was covering two bases.

Quoted 2 lines

Best regards,
Pavel

Sincerely -- Mark Salyzyn

#3 lore raw

Decided to switch to CONFIG_MMC_SIMULATE_MAX_SPEED (and now the thread has a new title) so as not to disturb the debugfs gohds. Added some documentation to help the cause.

Outstanding will be whether to move this up to the block layer, or let it lay in the mmc driver where we can continue to refine the speed and behavior simulation model.

Sincerely -- Mark Salyzyn

Quoted 30 lines · Mark Salyzyn
Quoted 10 lines · Pavel Machek

Hi!

Quoted 6 lines · Mark Salyzyn

When CONFIG_MMC_BLOCK_MAX_SPEED is enabled, Expose max_read_speed, max_write_speed and cache_size controls to simulate a slow eMMC device. The boot default values for each respectively are CONFIG_MMC_BLOCK_MAX_READ_SPEED, CONFIG_MMC_BLOCK_MAX_WRITE_SPEED and CONFIG_MMC_BLOCK_CACHE_SIZE respectively; and if not defined are 0 (off), 0, (off) and 4 MB also respectively.

Extra , after 0.

Yes :-)

Quoted 3 lines

Dunno. At minimum, I'd call the option something like "MMC_DEBUG_MAX_SPEED" and the speeds should be really controlled via /sys or something...

Are controlled by sys. Concern over DEBUG_MAX_SPEED is the sys nodes changing name to debug_max_read_speed, etc, which would in turn result in a move to debugfs instead. Will have to think about all the side effects of such a move.

Quoted 2 lines

...and ... is there reason to limit it to mmc devices? Making harddrive slow would make it useful for testing, too...

The speed limit at this layer is not the same as in the block layer, the two methods would 'join' at the same value when one does sustained I/O most likely, but not at the random patterns we have experienced on the devices. We would like additional wiggle room to simulate eMMC stalls due to load leveling and other behaviors in the future. If we moved up a layer we would have to simulate head seek and rotational latency opening a can of worms we would feel best if left closed. View it as a political decision.

Quoted 2 lines

...and you have the /sys interface. Drop the config options?

I needed a start up default value for boot-time simulations. If just sys options, we would be applying the values far too late in the operation. I expect some other folks using this simulation would like to forgo an extended boot time, to have them set/reset under programmed control. I was covering two bases.

Quoted 2 lines

Best regards,
Pavel

Sincerely -- Mark Salyzyn

#4 lore raw
In reply to Mark Salyzyn

Hi!

Quoted 5 lines
Quoted 1 line

...and you have the /sys interface. Drop the config options?

I needed a start up default value for boot-time simulations. If just sys options, we would be applying the values far too late in the operation. I

Ok, use module parameters (aka kernel command line options), then...

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html