LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-13-2018, 04:35 AM   #1
ComiXZonE
LQ Newbie
 
Registered: Aug 2018
Posts: 4

Rep: Reputation: Disabled
Where is the code that writes to SSD in Linux kernel?


Using Ubuntu 16.04 with kernel 4.16.7. Also, I have an Intel Optane 900P SSD mounted.

I am trying to find a code in the kernel that does writing to SSD in order to try to optimize it using DMA that is present on a target board running kernel 4.4.84.

I am aware of the NVME driver but was unable to find the code that actually does write to SSD. I would like to ask if I am looking in the right place and, if not, where I should be looking. Also, is any improvement even possible in the existing drivers or are they already optimized?

Thank you in advance.
 
Old 08-13-2018, 01:15 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,640

Rep: Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697
I think you may need to look in the kernel module code for that device.
 
1 members found this post helpful.
Old 08-15-2018, 08:05 AM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It's very much in the NVMe driver. The PCIe part is in drivers/nvme/host/pci.c and the little more generic part in drivers/nvme/host/core.c. The main "write" code is in nvme_queue_rq and consists of creating the command that is submitted to the disk. You won't find traditional DMA here because it's the disk DMA that does the work. All DMA-style parameters are in the SQE. You can also look at nvme_submit_io, it creates the command (SQE in the NVMe language).
 
1 members found this post helpful.
Old 08-15-2018, 09:08 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,129

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by ComiXZonE View Post
Also, is any improvement even possible in the existing drivers or are they already optimized?
All code can be improved. Whether you are competent, or can get your changes accepted is another matter.

The kernel is extremely fluid - and frustrating. Even if you have a valid patch, the underlying code may well change before you even get through testing your code. Then you need to start again. Maybe several times.

And you have to deal with the egos in the kernel dev community. Good luck.
Of course there is nothing stopping you maintaining your own out-of-tree patches.
 
1 members found this post helpful.
Old 08-15-2018, 09:19 AM   #5
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
NVMe is a very fast moving piece of code those days. The code is already pretty robust, but you can always find improvements, especially if you have a specific use-case in mind. And people developing it are very friendly while having high quality requirements.
 
1 members found this post helpful.
Old 08-16-2018, 03:25 AM   #6
ComiXZonE
LQ Newbie
 
Registered: Aug 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Hi everyone, thank you so much for your replies, I posted the same question on another forum and got no answers.

The thing is, we are connecting our custom board to SSD using Gen2 x2 PCIe and getting ~380MB/s which is about half the theoretical speed. But it may very well be the problem of the board itself whose CPU is already nearing 100% of load while writing to SSD. This is the reason why we are trying to optimize it with DMA.

Generally, we lack better understanding of the whole process. I suppose that when data arrives to NVMe driver it's too late for any DMA improvements. Only the part while the data is being sent to the NVMe driver for it to submit it with a command can be optimized with the board's DMA, am I right?

We are also trying to change the scheduler that is currently present in the NVMe driver, do you think it will yield some better results and, if you have some advice regarding that, it would be much appreciated.

Thank you again and looking forward to hearing from you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Install Linux in Toshiba u940 series with 32gb ssd and 750gb hdd I would like to have boot code in ssd only cvkchary Linux - Laptop and Netbook 4 08-31-2016 04:26 PM
LXer: Who writes the Linux kernel? LXer Syndicated Linux News 0 02-19-2015 06:45 PM
SSD Writes Heats Linux - Software 1 12-10-2013 07:30 PM
How to create a code that reads and writes my IP into a zone file NS-ME Linux - Server 3 10-17-2011 03:06 PM
Reducing writes to SSD: mounting /var (and others) on RAM disks (tmpfs). sysfce2 Slackware 7 08-26-2011 02:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration