Skip to contentSkip to conversation

Implementing NVMHCI...

DISCUSSION Jeff Garzik 8 participants 18 messages Apr 11, 2009 – Apr 12, 2009 libata

lore
Share & tools
lore
#0 lore raw

Has anybody looked into working on NVMHCI support? It is a new controller + new command set for direct interaction with non-volatile memory devices:

http://download.intel.com/standards/nvmhci/spec.pdf

Although NVMHCI is nice from a hardware design perspective, it is a bit problematic for Linux because

* NVMHCI might be implemented as part of an AHCI controller's register set, much like how Marvell's AHCI clones implement a PATA port: with wholly different per-port registers and DMA data structures, buried inside the standard AHCI per-port interrupt dispatch mechanism.

Or, NVMHCI might be implemented as its own PCI device, wholly independent from the AHCI PCI device.

The per-port registers and DMA data structure remain the same, whether or not it is embedded within AHCI or not.

* NVMHCI introduces a brand new command set, completely incompatible with ATA or SCSI. Presumably it is tuned specifically for non-volatile memory.

* The sector size can vary wildly from device to device. There is no 512-byte legacy to deal with, for a brand new command set. We should handle this OK, but...... who knows until you try.

The spec describes the sector size as
"512, 1k, 2k, 4k, 8k, etc." It will be interesting to reach
"etc" territory.

Here is my initial idea:

- Move 95% of ahci.c into libahci.c.

This will make implementation of AHCI-and-more devices like NVMHCI (AHCI 1.3) and Marvell much easier, while avoiding the cost of NVMHCI or Marvell support, for those users without such hardware.

- ahci.c becomes a tiny stub with a pci_device_id match table, calling functions in libahci.c.

- I can move my libata-dev.git#mv-ahci-pata work, recently refreshed, into mv-ahci.c.

- nvmhci.c implements the NVMHCI controller standard. Maybe referenced from ahci.c, or used standalone.

- nvmhci-blk.c implements a block device for NVMHCI-attached devices, using the new NVMHCI command set.

With a brand new command set, might as well avoid SCSI completely IMO, and create a brand new block device.

Open questions are...

1) When will we see hardware? This is a feature newly introduced in AHCI 1.3. AHCI 1.3 spec is public, but I have not seen any machines yet. http://download.intel.com/technology/serialata/pdf/rev1_3.pdf

My ICH10 box uses AHCI 1.2. dmesg | grep '^ahci'

Quoted 2 lines

ahci 0000:00:1f.2: AHCI 0001.0200 32 slots 6 ports 3 Gbps 0x3f impl SATA mode ahci 0000:00:1f.2: flags: 64bit ncq sntf pm led clo pio slum part ems

2) Has anyone else started working on this? All relevant specs are public on intel.com.

3) Are there major objections to doing this as a native block device (as opposed to faking SCSI, for example...) ?

Thanks,

Jeff (engaging in some light Saturday reading...)

#1 lore raw
Quoted 3 lines

The spec describes the sector size as
"512, 1k, 2k, 4k, 8k, etc." It will be interesting to reach
"etc" territory.

Over 4K will be fun.

Quoted 2 lines

- ahci.c becomes a tiny stub with a pci_device_id match table, calling functions in libahci.c.

It needs to a be a little bit bigger because of the folks wanting to do non PCI AHCI, so you need a little bit of PCI wrapping etc

Quoted 2 lines

With a brand new command set, might as well avoid SCSI completely IMO, and create a brand new block device.

Providing we allow for the (inevitable ;)) joys of NVHCI over SAS etc 8)

Alan

#2 lore raw
Quoted 11 lines · Alan Cox
Quoted 3 lines

The spec describes the sector size as
"512, 1k, 2k, 4k, 8k, etc." It will be interesting to reach
"etc" territory.

Over 4K will be fun.

Quoted 2 lines

- ahci.c becomes a tiny stub with a pci_device_id match table, calling functions in libahci.c.

It needs to a be a little bit bigger because of the folks wanting to do non PCI AHCI, so you need a little bit of PCI wrapping etc

True...

Quoted 4 lines
Quoted 2 lines

With a brand new command set, might as well avoid SCSI completely IMO, and create a brand new block device.

Providing we allow for the (inevitable ;)) joys of NVHCI over SAS etc 8)

Perhaps... from what I can tell, this is a direct, asynchronous NVM interface. It appears to lack any concept of bus or bus enumeration. No worries about link up/down, storage device hotplug, etc. (you still have PCI hotplug case, of course)

Jeff

#5 lore raw
In reply to Alan Cox
Quoted 6 lines · Alan Cox
Quoted 4 lines

The spec describes the sector size as
"512, 1k, 2k, 4k, 8k, etc." It will be interesting to reach
"etc" territory.

Over 4K will be fun.

And by "fun", you mean "irrelevant".

If anybody does that, they'll simply not work. And it's not worth it even trying to handle it.

That said, I'm pretty certain Windows has the same 4k issue, so we can hope nobody will ever do that kind of idiotically broken hardware. Of course, hardware people often do incredibly stupid things, so no guarantees.

Linus

#6 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 4 lines · Alan Cox
Quoted 3 lines

The spec describes the sector size as
"512, 1k, 2k, 4k, 8k, etc." It will be interesting to reach
"etc" territory.

Over 4K will be fun.

And by "fun", you mean "irrelevant".

If anybody does that, they'll simply not work. And it's not worth it even trying to handle it.

FSVO trying to handle...

At the driver level, it would be easy to clamp sector size to 4k, and point the scatterlist to a zero-filled region for the >4k portion of each sector. Inefficient, sure, but it is low-cost to the driver and gives the user something other than a brick.

if (too_large_sector_size)
nvmhci_fill_sg_clamped_interleave()
else
nvmhci_fill_sg()

Regards,

Jeff

#3 lore raw
In reply to Jeff Garzik
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jeff" == Jeff Garzik <[email protected]> writes:

Quoted 4 lines · Jeff> Alan Cox wrote:
Quoted 4 lines
Quoted 2 lines

With a brand new command set, might as well avoid SCSI completely IMO, and create a brand new block device.

Providing we allow for the (inevitable ;)) joys of NVHCI over SAS etc 8)

Jeff> Perhaps... from what I can tell, this is a direct, asynchronous Jeff> NVM interface. It appears to lack any concept of bus or bus Jeff> enumeration. No worries about link up/down, storage device Jeff> hotplug, etc. (you still have PCI hotplug case, of course)

Didn't we just spend years merging the old IDE PATA block devices into the libata/scsi block device setup to get a more unified userspace and to share common code?

I'm a total ignoramous here, but it would seem that it would be nice to keep the /dev/sd# stuff around for this, esp since it is supported through/with/around AHCI and libata stuff.

Honestly, I don't care as long as userspace isn't too affected and I can just format it using ext3. :] Which I realize would be silly since it's probably nothing like regular disk access, but more like the NVRAM used on Netapps for caching writes to disk so they can be acknowledged quicker to the clients. Or like the old PrestoServe NVRAM modules on DECsystems and Alphas.

John

#4 lore raw
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

"John" == John Stoffel <[email protected]> writes:

"Jeff" == Jeff Garzik <[email protected]> writes:

Quoted 4 lines · Jeff> Alan Cox wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

With a brand new command set, might as well avoid SCSI completely IMO, and create a brand new block device.

Providing we allow for the (inevitable ;)) joys of NVHCI over SAS etc 8)

Jeff> Perhaps... from what I can tell, this is a direct, asynchronous Jeff> NVM interface. It appears to lack any concept of bus or bus Jeff> enumeration. No worries about link up/down, storage device Jeff> hotplug, etc. (you still have PCI hotplug case, of course)

John> Didn't we just spend years merging the old IDE PATA block devices into John> the libata/scsi block device setup to get a more unified userspace and John> to share common code?

John> I'm a total ignoramous here, but it would seem that it would be nice John> to keep the /dev/sd# stuff around for this, esp since it is supported John> through/with/around AHCI and libata stuff.

John> Honestly, I don't care as long as userspace isn't too affected and I John> can just format it using ext3. :] Which I realize would be silly John> since it's probably nothing like regular disk access, but more like John> the NVRAM used on Netapps for caching writes to disk so they can be John> acknowledged quicker to the clients. Or like the old PrestoServe John> NVRAM modules on DECsystems and Alphas.

And actually spending some thought on this, I'm thinking that this will be like the MTD block device and such... seperate specialized block devices, but still usable. So maybe I'll just shutup now. :]

John

#7 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
Quoted 5 lines · Alan Cox
Quoted 4 lines

      The spec describes the sector size as
      "512, 1k, 2k, 4k, 8k, etc."   It will be interesting to reach "etc" territory.

Quoted 6 lines
Quoted 1 line

Over 4K will be fun.

And by "fun", you mean "irrelevant".

If anybody does that, they'll simply not work. And it's not worth it even trying to handle it.

Why does it matter what the sector size is?
I'm failing to see what the fuss is about.

We've abstract the DMA mapping/SG list handling enough that the block size should make no more difference than it does for the MTU size of a network.

And the linux VM does handle bigger than 4k pages (several architectures have implemented it) - even if x86 only supports 4k as base page size.

Block size just defines the granularity of the device's address space in the same way the VM base page size defines the Virtual address space.

Quoted 4 lines

That said, I'm pretty certain Windows has the same 4k issue, so we can hope nobody will ever do that kind of idiotically broken hardware. Of course, hardware people often do incredibly stupid things, so no guarantees.

That's just flame-bait. Not touching that.

thanks,
grant

Quoted 7 lines

               Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 7 lines · Grant Grundler

Why does it matter what the sector size is?
I'm failing to see what the fuss is about.

We've abstract the DMA mapping/SG list handling enough that the block size should make no more difference than it does for the MTU size of a network.

The VM is not ready or willing to do more than 4kB pages for any normal cacheing scheme.

Quoted 2 lines

And the linux VM does handle bigger than 4k pages (several architectures have implemented it) - even if x86 only supports 4k as base page size.

4k is not just the "supported" base page size, it's the only sane one. Bigger pages waste memory like mad on any normal load due to fragmentation. Only basically single-purpose servers are worth doing bigger pages for.

Quoted 2 lines

Block size just defines the granularity of the device's address space in the same way the VM base page size defines the Virtual address space.

.. and the point is, if you have granularity that is bigger than 4kB, you lose binary compatibility on x86, for example. The 4kB thing is encoded in mmap() semantics.

In other words, if you have sector size >4kB, your hardware is CRAP. It's unusable sh*t. No ifs, buts or maybe's about it.

Sure, we can work around it. We can work around it by doing things like read-modify-write cycles with bounce buffers (and where DMA remapping can be used to avoid the copy). Or we can work around it by saying that if you mmap files on such a a filesystem, your mmap's will have to have 8kB alignment semantics, and the hardware is only useful for servers.

Or we can just tell people what a total piece of shit the hardware is.

So if you're involved with any such hardware or know people who are, you might give people strong hints that sector sizes >4kB will not be taken seriously by a huge number of people. Maybe it's not too late to head the crap off at the pass.

Btw, this is not a new issue. Sandisk and some other totally clueless SSD manufacturers tried to convince people that 64kB access sizes were the RightThing(tm) to do. The reason? Their SSD's were crap, and couldn't do anything better, so they tried to blame software.

Then Intel came out with their controller, and now the same people who tried to sell their sh*t-for-brain SSD's are finally admittign that it was crap hardware.

Do you really want to go through that one more time?

Linus

#10 lore raw
In reply to Grant Grundler
Quoted 3 lines

We've abstract the DMA mapping/SG list handling enough that the block size should make no more difference than it does for the MTU size of a network.

You need to start managing groups of pages in the vm and keeping them together and writing them out together and paging them together even if one of them is dirty and the other isn't. You have to deal with cases where a process forks and the two pages are dirtied one in each but still have to be written together.

Alternatively you go for read-modify-write (nasty performance hit especially for RAID or a log structured fs).

Yes you can do it but it sure won't be pretty with a conventional fs. Some of the log structured file systems have no problems with this and some kinds of journalling can help but for a typical block file system it'll suck.

#11 lore raw
Quoted 4 lines · Alan Cox
Quoted 3 lines

We've abstract the DMA mapping/SG list handling enough that the block size should make no more difference than it does for the MTU size of a network.

Quoted 8 lines

You need to start managing groups of pages in the vm and keeping them together and writing them out together and paging them together even if one of them is dirty and the other isn't. You have to deal with cases where a process forks and the two pages are dirtied one in each but still have to be written together.

Alternatively you go for read-modify-write (nasty performance hit especially for RAID or a log structured fs).

Or just ignore the extra length, thereby excising the 'read-modify' step... Total storage is halved or worse, but you don't take as much of a performance hit.

Jeff

#12 lore raw
Quoted 4 lines · Jeff Garzik

Or just ignore the extra length, thereby excising the 'read-modify' step... Total storage is halved or worse, but you don't take as much of a performance hit.

Well, the people who want > 4kB sectors usually want _much_ bigger (ie 32kB sectors), and if you end up doing the "just use the first part" thing, you're wasting 7/8ths of the space.

Yes, it's doable, and yes, it obviously makes for a simple driver thing, but no, I don't think people will consider it acceptable to lose that much of their effective size of the disk.

I suspect people would scream even with a 8kB sector.

Treating all writes as read-modify-write cycles on a driver level (and then opportunistically avoiding the read part when you are lucky and see bigger contiguous writes) is likely more acceptable. But it _will_ suck dick from a performance angle, because no regular filesystem will care enough, so even with nicely behaved big writes, the two end-points will have a fairly high chance of requiring a rmw cycle.

Even the journaling ones that might have nice logging write behavior tend to have a non-logging part that then will behave badly. Rather few filesystems are _purely_ log-based, and the ones that are tend to have various limitations. Most commonly read performance just sucks.

We just merged nilfs2, and I _think_ that one is a pure logging filesystem with just linear writes (within a segment). But I think random read performance (think: loading executables off the disk) is bad.

And people tend to really dislike hardware that forces a particular filesystem on them. Guess how big the user base is going to be if you cannot format the device as NTFS, for example? Hint: if a piece of hardware only works well with special filesystems, that piece of hardware won't be a big seller.

Modern technology needs big volume to become cheap and relevant.

And maybe I'm wrong, and NTFS works fine as-is with sectors >4kB. But let me doubt that.

Linus

#14 lore raw
In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 3 lines

We've abstract the DMA mapping/SG list handling enough that the block size should make no more difference than it does for the MTU size of a network.

You need to start managing groups of pages in the vm and keeping them together and writing them out together and paging them together even if one of them is dirty and the other isn't. You have to deal with cases where a process forks and the two pages are dirtied one in each but still have to be written together.

gaining this sort of ability would not be a bad thing. with current hardware (SSDs and raid arrays) you can very easily be in a situation where it's much cheaper to deal with a group of related pages as one group rather than processing them individually. this is just an extention of the same issue.

David Lang

Quoted 13 lines

Alternatively you go for read-modify-write (nasty performance hit especially for RAID or a log structured fs).

Yes you can do it but it sure won't be pretty with a conventional fs. Some of the log structured file systems have no problems with this and some kinds of journalling can help but for a typical block file system it'll suck.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#13 lore raw
In reply to Linus Torvalds
Quoted 1 line · Linus Torvalds

And maybe I'm wrong, and NTFS works fine as-is with sectors >4kB. But let me doubt that.

FWIW... No clue about sector size, but NTFS cluster size (i.e. block size) goes up to 64k. Compression is disabled after 4k.

Jeff

#15 lore raw
In reply to [email protected]
Quoted 2 lines · On Sat, 11 Apr 2009, [email protected] wrote:

gaining this sort of ability would not be a bad thing.

.. and if my house was built of gold, that wouldn't be a bad thing either.

What's your point?

Are you going to create the magical patches that make that happen? Are you going to maintain the added complexity that comes from suddenly having multiple dirty bits per "page"? Are you going to create the mythical filesystems that magically start doing tail packing in order to not waste tons of disk-space with small files, even if they have a 32kB block-size?

In other words, your whole argument is built in "wouldn't it be nice".

And I'm just the grumpy old guy who tells you that there's this small thing called REALITY that comes and bites you in the *ss. And I'm sorry, but the very nature of "reality" is that it doesn't care one whit whether you believe me or not.

The fact is, >4kB sectors just aren't realistic right now, and I don't think you have any _clue_ about the pain of trying to make them so. You're just throwing pennies down a wishing well.

Linus

#9 lore raw
In reply to Linus Torvalds
Quoted 10 lines

So if you're involved with any such hardware or know people who are, you might give people strong hints that sector sizes >4kB will not be taken seriously by a huge number of people. Maybe it's not too late to head the crap off at the pass.

Btw, this is not a new issue. Sandisk and some other totally clueless SSD manufacturers tried to convince people that 64kB access sizes were the RightThing(tm) to do. The reason? Their SSD's were crap, and couldn't do anything better, so they tried to blame software.

Quoted 5 lines

Then Intel came out with their controller, and now the same people who tried to sell their sh*t-for-brain SSD's are finally admittign that it was crap hardware.

Do you really want to go through that one more time?

So with drive sizes soon to be at 10TB, and arrays soon to exceed 250 and perhaps even 1000TB, what's the long term solution? I'm far from being an expert, and you most certainly are an expert, so do you really feel a 4KB sector is the way to go for the indeterminate future? My mind reels at the thought of dealing with perhaps more than a trillion sectors on a drive system. Clearly it's possible a 64 bit file system may be a simpler proposition than a 64K sector, but still...

#16 lore raw
In reply to Alan Cox

Alan Cox wrote:
..

Quoted 2 lines

Alternatively you go for read-modify-write (nasty performance hit especially for RAID or a log structured fs).

..

Initially, at least, I'd guess that this NVM-HCI thing is all about built-in flash memory on motherboards, to hold the "instant-boot" software that hardware companies (eg. ASUS) are rapidly growing fond of.

At present, that means a mostly read-only Linux installation, though MS for sure are hoping for Moore's Law to kick in and provide sufficient space for a copy of Vista there or something.

The point being, it's probable *initial* intended use is for a run-time read-only filesystem, so having to do dirty R-M-W sequences for writes might not be a significant issue.

At present. And even if it were, it might not be much worse than
having the hardware itself do it internally, which is what would have to happen if it always only ever showed 4KB to us.

Longer term, as flash densities increase, we're going to end up with motherboards that have huge SSDs built-in, through an interface like this one, or over a virtual SATA link or something.

I wonder how long until "desktop/notebook" computers no longer have replaceable "hard disks" at all?

Cheers

#17 lore raw
Quoted 6 lines · Mark Lord

Alan Cox wrote:
..

Quoted 2 lines

Alternatively you go for read-modify-write (nasty performance hit especially for RAID or a log structured fs).

..

Quoted 7 lines

Initially, at least, I'd guess that this NVM-HCI thing is all about built-in flash memory on motherboards, to hold the "instant-boot" software that hardware companies (eg. ASUS) are rapidly growing fond of.

At present, that means a mostly read-only Linux installation, though MS for sure are hoping for Moore's Law to kick in and provide sufficient space for a copy of Vista there or something.

Yeah... instant boot, and "trusted boot" (booting a signed image), storage of useful details like boot drive layouts, etc.

I'm sure we can come up with other funs uses, too...

Jeff