Thread (11 messages) flat view 11 messages, 6 authors, 2015-07-28

Re: [PATCH RFC 0/1] Document how to add a new syscall

From: David Drysdale <hidden>
Date: 2015-07-28 16:02:29
Also in: lkml

On Tue, Jul 28, 2015 at 3:19 PM, Peter Zijlstra [off-list ref] wrote:
On Tue, Jul 28, 2015 at 07:59:16AM -0600, Shuah Khan wrote:
quoted
On 07/28/2015 05:41 AM, David Drysdale wrote:
quoted
Given that I've gotten some of the details wrong in the past (and I've
seen others do likewise), I thought it might be helpful to collate the
best practices for adding a new system call to the kernel.

Apologies for the wide circulation -- I've tried to include folk who've
recently added or proposed a system call, as they're most likely to
have opinions on:
 - whether this a useful addition to Documentation/
 - whether the details of the advice are correct and complete.

Shuah, is there anything more that should be added for the Testing
section in particular?
David,

Looks good. You could add a one liner on in some cases, it might be
necessary to install headers before test compiles. Other than that,
the information looks good.
For perf we still use the syscall() wrapper and we have hardcoded
(fallback) syscall numbers in there in case they've not yet reached
unistd.h.

People update their kernels far more often than their userspace headers.
How about:
diff --git a/Documentation/adding-syscalls.txt
b/Documentation/adding-syscalls.txt
index 5f52edda8951..b274c3d01edb 100644
--- a/Documentation/adding-syscalls.txt
+++ b/Documentation/adding-syscalls.txt
@@ -389,6 +389,11 @@ reviewers with a demonstration of how user space
programs will use the system
 call.  A good way to combine these aims is to include a simple self-test
 program in a new directory under tools/testing/selftests/.

+For a new system call, there will obviously be no libc wrapper function and so
+the test will need to invoke it using syscall(); also, if the system call
+involves a new userspace-visible structure, the corresponding header will need
+to be installed to compile the test.
+
 Make sure the selftest runs successfully on all supported architectures.  For
 example, check that it works when compiled as an x86_64 (-m64), x86_32 (-m32)
 and x32 (-mx32) ABI program.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help