From: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
To: Ruben Safir <ruben@mrbrklyn.com>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: New text
Date: Wed, 19 Feb 2020 16:36:10 -0500 [thread overview]
Message-ID: <228783.1582148170@turing-police> (raw)
In-Reply-To: <20200219155410.GA25523@www2.mrbrklyn.com>
[-- Attachment #1.1: Type: text/plain, Size: 2816 bytes --]
On Wed, 19 Feb 2020 10:54:10 -0500, Ruben Safir said:
> is there currently a rfecommended text to learn kernel development from?
The first thing to remember is that the kernel has no obligation to be easy for
new programmers. It's more like a Formula 1 race car than a Ford Escort -
there's an expectation that you *really* know what you're doing when you put
your hands on the steering wheel.
As a result, the authoritative source on that is, of course:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Seriously - the kernel is a work in progress, and it's in motion all the time.
There's no way to write a text that's up to date - by the time you finish, the
source tree has moved by 3 or 4 million lines.
Currently, the best is probably Linux Device Drivers, Third Edition (just
google for LDD3 and you'll get a pointer to the PDF).
However - keep in mind that it discusses *concepts* like locking and variable
lifetimes and so on. It's now somewhere over 15 million lines out of date, and
it's expected that if you can't figure out for yourself what concepts mean, or
what the *current* API is, then you probably shouldn't be writing large chunks
of kernel code that requires undertanding the current APIs.
Note that many bugs are fixable without knowing all that - it's often a
"somebody added A and B, when it should have been A - B" or a stupid null
pointer mistake, or similar. And drivers/staging is just *full* of stuff that
is in drastic need of help.
Protip: if you've been handed a device dqriver for a 4.7 kernel, and been told to make
it work under a 5.5 kernel, and you have *no* idea how to fix all the compile errors,
the way to proceed is usually:
0) Kernel API changes are *supposed* to break a compile - if you used to pass
an integer as the third parameter, and now it's a pointer to a structure, the
build will break. Anybody who makes a kernel API change where the third
parameter used to be an integer that meant one thing, and changes it to an
integer that means something else, so it will compile but not work correctly,
will probably get smacked around with a large trout or something. (A common
work around for this is changing a function from (struct *A, struct *B, oldint)
to (struct A*, newint, struct *B) so the compiler will whine).
1) Start wading through the git log until you find the commit that changed the
API. In either that commit, or a commit in the same series, whoever changed the
API also changed all the in-tree users of the API.
2) Look at that commit, and see what got changed in all the in-tree users.
3) Do the same thing to your out-of-tree code.
And here you thought it was difficult, :)
(Of course, if you're trying to get a 2.6.12 driver working on 5.6... you may decide
that it's time to start drinking heavily :)
[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next prev parent reply other threads:[~2020-02-19 21:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 15:54 New text Ruben Safir
2020-02-19 21:36 ` Valdis Klētnieks [this message]
2020-02-19 23:17 ` Ruben Safir
2020-02-20 20:12 ` Valdis Klētnieks
2020-02-20 21:06 ` Ruben Safir
2020-02-19 23:43 ` Robert P. J. Day
2020-02-20 1:55 ` Ruben Safir
2020-02-23 3:51 ` Aruna Hewapathirane
2020-03-15 11:10 ` Rishi Agrawal
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=228783.1582148170@turing-police \
--to=valdis.kletnieks@vt.edu \
--cc=kernelnewbies@kernelnewbies.org \
--cc=ruben@mrbrklyn.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.